caveman-ai/trim-1
trim-1: a 1.2 MB model that keeps the lines of a context an AI agent needs
About caveman-ai/trim-1
caveman-ai/trim-1 is an open-source project on GitHub, mainly written in Go. trim-1: a 1.2 MB model that keeps the lines of a context an AI agent needs It currently holds 136 stars and 14 forks with 0 open issues, and was last pushed on an unknown date (repository created unknown).
Project Overview
AI Homed tracks it on the Today's Trending board, currently at rank #90 with 0 new stars today.
GitHub Repository Details
README
trim-1
trim-1 is a small model that decides which lines of a context an AI agent needs for its current ask, and drops the rest.
Give it a context (a tool result, a file, a log, a long chat) and the current query. It returns the context's own lines, in their original order, with a short marker wherever lines were removed. It never rewrites or summarizes a line, so identifiers, paths and error text come through exactly as they were.
- 1.2 MB. 712 gradient-boosted trees, not a neural network.
- Milliseconds on one CPU core. No GPU, no network call.
- Deterministic. No sampling and no randomness: the same context and query
- No dependencies. Pure Go, standard library only. The model is embedded.
Install
Needs Go 1.23 or newer.
go install github.com/caveman-ai/trim-1/cmd/trim@latest
Use
From the command line:
trim --query "why does the build fail" build.log > build.trimmed.log
cat long-document.md | trim --query "what is the refund policy" --point balanced
The trimmed context goes to stdout. A one-line summary goes to stderr:
trim: kept 246 lines, removed 189, 47831 -> 36344 bytes
From Go:
import trim "github.com/caveman-ai/trim-1"
res := trim.Compress(context, query, trim.Options{Point: "balanced"})
fmt.Print(res.Output)
trim.Score(context, query) returns every line with its keep probability, if
you want to make the selection yourself.
Which setting to use
--point decides how hard trim-1 cuts: conservative, balanced (the
default) or aggressive. Cutting harder costs quality, because every removed
line is one the model can no longer read.
- Long-document retrieval is what trim-1 is for. Use
balanced. - Coding-agent tool outputs are short and dense. Stay at
balancedor
conservative and expect small savings.
The model card has the numbers behind this.
When it does nothing
trim-1 fails closed. It returns the context unchanged, and says why on stderr, when:
- the query is blank,
- the context is under 2,000 bytes,
- the context is over 8 MiB or 200,000 lines,
- the context already has a removal marker line, such as trim-1's own output,
- the cut would remove less than 10% of the bytes.
trim command exits with status 2 on a missing --query or an unknown
--point. Flags go before the file name.
Test
go test ./...
TestPredictionParity checks the Go tree evaluation against the training
library's own predictions, bit for bit. TestGolden pins the full output on a
sample log.
License
Apache-2.0. model.go includes a copy of Go's math.Exp, under the BSD license
in LICENSE-go. trim-1 is the model inside
Caveman.
