Repository navigation
test(memory): a recall benchmark with a lexical baseline - #299
Merged
Merged
Conversation
B3 shipped semantic recall and said its quality was unmeasured. This is the instrument: 24 fixed facts, 20 queries in three groups (10 sharing a word with their fact, 6 paraphrases that share none, 4 cross-lingual), ranked at depth 10 and reported as hit@1/3/5 and MRR per group. What makes it a gate rather than a report: - the corpus's hygiene is asserted: a paraphrase or cross-lingual query that shares a token with its target would let the lexical ranker answer it, and the column would stop meaning what it says; - the local ranker's floor is asserted: every lexical query finds its fact in the top three — deterministic, so it cannot flake; - the metrics are unit-tested on rankings with a known answer, so a wrong hit@k cannot look like a result; - the counts the page quotes (24 facts, 20 queries, 10/6/4) are asserted, so docs/memory-bench.md cannot drift from the corpus. The measured half is gated behind TINYCODE_MEMORY_BENCH_URL/_MODEL and `make memory-bench`: it embeds the corpus against a real endpoint, refuses to report if any fact failed to embed (a silent fallback would print lexical numbers under a semantic heading), and prints the same table for both rankers. CI has no model, so the page records the semantic numbers as not measured yet rather than pretending; the deterministic baseline is 1.00/0.00/0.00 at hit@1. Verified: go test ./... -count=1 and -race, 16 packages ok; go vet and gofmt clean; the hygiene gate mutation-checked (a paraphrase query given a shared word fails it, and passes when restored); `make memory-bench` without an endpoint skips with its reason and exits 0. Refs #297, #168
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
agent/testdata/memory-bench.json(new): 24 fixed facts and 20 queries in three groups — 10 thatshare a distinctive word with their fact, 6 English paraphrases that share none, 4 Chinese queries
against English facts.
agent/memory_bench_test.go(new): the harness. Ranks at depth 10, reports hit@1/3/5 and MRR pergroup, and asserts what can be asserted deterministically — corpus hygiene (a paraphrase query must
share no token with its target, or the lexical ranker could answer it), the local ranker's top-3
floor, the metric arithmetic, and the counts the page quotes.
TestMemoryBenchRealEndpoint: gated onTINYCODE_MEMORY_BENCH_URL/_MODEL; embeds the corpusagainst a real endpoint, refuses to report if any fact failed to embed, and prints the same table for
the semantic and lexical rankers.
make memory-benchwithMEMORY_BENCH_*pass-through, documented in the target's comment.docs/memory-bench.md(new): the corpus, the columns, the deterministic baseline, how to run, how toread (compare within a model; the cross-lingual column is a model property), and the explicit note
that no semantic number is recorded yet.
Why
B3's PR said, in its own honest-scope section, that recall quality was unmeasured. "Semantic beats
lexical" is a claim; the next decision in this area — consolidation, quantisation, a cross-encoder, a
different model — should be made against a number. The benchmark is also the reason the claim stays
honest: the page carries the lexical baseline (deterministic, reproduced by CI) and an empty cell where
a model's numbers would go, rather than a sentence that implies one.
Verification
go test ./... -count=1and-race: 16 packagesok;go vetandgofmt -lclean.MEMBENCH ranker=lexical kind=lexical n=10 hit1=1.00 hit3=1.00 hit5=1.00 mrr=1.00,kind=paraphrase n=6 hit1=0.00 …,kind=crosslingual n=4 hit1=0.00 ….how do I cut a versionchanged tohow do I cut a release version→TestMemoryBenchCorpusIsWellFormedfails withshares [release]; restored, it passes.make memory-benchwith no endpoint →--- SKIP: TestMemoryBenchRealEndpointand exit 0, so anordinary run never needs a model.
git log --format='%h %G? %s'→G.Honest scope
in the section where the numbers would go.
regression instrument, not a model evaluation.
lexical floor.
Follow-ups
Refs #297, #168