caveman-ai / trim-1
git clone https://github.com/caveman-ai/trim-1.git
v0.1.0 · 6d ago
trim-1: a 1.2 MB model that keeps the lines of a context an AI agent needs
—
stars, 24h
+174
stars, 7 days · #321
+174
stars, 30 days · #1,438
174
★ total · +174% this week
17
forks · 3 open issues
Star history starts 2026-10-20; the chart appears after the second daily snapshot.
LanguageGo
LicenseApache-2.0
Created2026-10-14 (6d ago)
Last push6d ago
Watchers2
OwnerOrganization
Links
README excerpt
# 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 give the same output. - **No dependencies.** Pure Go, standard library only. The model is embedded. The model card, with benchmark results and limits, is on Hugging Face: caveman-so/trim-1. ## Install Needs Go 1.23 or newer. [code] ## Use From the command line: [code] [code] The trimmed context goes to stdout. A one-line summary goes to stderr: [code] From Go: [code] `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 `balanced` or `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. The `trim` command exits with status 2 on a missing `--query` or an unknown `--point`. Flags go before the file name. ## Test [code] `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.