caveman-ai/trim-1
Tentang
trim-1: a 1.2 MB model that keeps the lines of a context an AI agent needs
AI dan pembelajaran mesinPertumbuhan bintang terukur
- dalam 24 jam
- +2
- dalam 7 hari
- +6
- dalam 15 hari
- +7
- dalam 1 bulan
- Mengumpulkan riwayat
Perubahan bersih pada periode yang tumpang tindih, bukan total harian. Pengukuran yang belum tersedia dibiarkan kosong. Bintang menunjukkan perhatian, bukan kualitas.
README.md
Aslitrim-2
trim-2 is a small two-stage 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.
- 3.57 MB. Two-stage contextual gradient-boosted trees (701 stage-1 trees
over 134 lexical, sub-identifier, structural, and query features + 641 DAgger
stage-2 trees adding 40 sequence, template, and 2-hop anchor-propagation
features = 174 total features), paired with exact O(N) Viterbi DP
token-knapsack line selection and payload-shape calibration (
code,diff,log,grep,structured,prose). Not a neural network. - CPU only. About 13 ms for a 2k-token log and about 250 ms for a
50k-token log on one Apple M5 Max core (
go test -bench Compress -cpu 1). 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.
trim-2 replaces trim-1 in this repository. The trim-1 model card, with its
benchmark results and limits, stays on Hugging Face:
caveman-so/trim-1. To keep trim-1,
pin the last trim-1 commit in go.mod.
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-2 cuts: conservative, balanced (the
default), aggressive, max, or smart_max. Cutting harder costs quality,
because every removed line is one the model can no longer read.
balancedis the default for coding-agent tool outputs and documents.conservativekeeps more context when missing a single line is costly.aggressiveandmaxcut harder on verbose logs and traces.smart_maxusesbalancedon source code and diffs andmaxon everything else (logs, search results, prose, dumps). It picks by the shape of the context, not the query.
From Go, Options{AnnotateOmitted: true} adds a short checked summary to each
removal marker, such as an omitted run's error and warning count on a log, the
symbols it covered in code, or the files it covered in a diff.
When it does nothing
trim-2 fails closed. It returns the context unchanged, and says why on stderr, when:
- the query is blank, too vague (no informative terms or identifiers), or asks for the whole context (review the whole file, list every item),
- the context is under 512 bytes (source code under 900 bytes at
balancedandsmart_max, under 1,200 bytes atconservative), - the context is over 8 MiB or 200,000 lines,
- the context already has a removal marker line, such as trim-2's own output,
- the cut would remove less than 5% 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
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-2 is the model inside
Caveman.
Jelajahi proyek terkait
Memuat…
