Repository navigation
A labelled document fixture measures knowledge.search retrieval - #193
Merged
Merged
Conversation
This was referenced Nov 3, 2026
bench/knowledge_retrieval.py ingests a small synthetic corpus and scores knowledge.search per query kind: recall@1/5/10, MRR, nDCG@10, all-gold recall, and the top-hit score on unanswerable queries. Labels are (source_uri, answer text) pairs, so they survive a chunker change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…skew its numbers A default run ingests into its own salted namespace, so two arms never erase each other's. A search over an empty namespace, a top_k override and a cross-mode score average are refused or replaced (top-hit similarity). One chunk holding two gold passages credits both. Fixture: grammatical sentences, labels that name the fix, more freshness and multi-document queries. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Only the fresh namespace a run makes up is erased; --param refuses every field that defines the measurement; nDCG and all-gold read the one depth constant. Fixture: the handbook sections no longer name the product outside the opening section, two queries gain the second document that answers them, and three template sentences read correctly. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…' namespaces alone A search whose response names ignored_args fails the run; the harness ingests into a named namespace only when it is unregistered or a bench namespace, and --phase ingest/search need one. Runbook codes accept the Symptom section, and the handbook queries that need the title are labelled context. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ery answer Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…that is not the fixture --param accepts knowledge.search fields alone (identity and transport keys are dropped by the server without a word); a named namespace whose documents differ from the fixture's fails the run. Two paraphrase queries no longer repeat their answer's words; the JSONL carries its provenance header; the fixture is listed in the in-house fixtures table. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…es another version Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…her documents Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…and guards named namespaces nDCG's ideal ranking uses the same gains (a hit holding two passages gains 2), so nothing is capped; a hybrid or lexical arm whose lexical leg never fired fails; the similarity means count only queries with a hit; a named bench namespace is written only when all its documents are fixture ingests. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… write Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ecords its instrument A named namespace must start with knowledge-retrieval-, which replaces the owner and listing checks: the harness never registers, fills or prints an erase command for another namespace. Each report carries the server's embedding model and build, and a fake embedder is refused. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…of the corpus Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…unt the queries the lexical leg scored Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…says how to pair two arms Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…s the fixture it scored Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…and clusters queries by question Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…uses a valueless param Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…e chunks Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…chunker Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…d as a partition Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…tests chunk as ingest does Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ommitted fixture Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
zlareb1
force-pushed
the
bench/knowledge-retrieval-fixture
branch
from
November 3, 2026 15:55
bb3e29c to
c2462d0
Compare
6 tasks done
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.
Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
bench/knowledge_retrieval.pymeasuresknowledge.searchon a small labelled document corpus: recall@k, MRR and nDCG@10 per query kind.Why
No bench scores the knowledge plane's document retrieval on its own (NarrativeQA measures answers end to end). Ranking changes to
knowledge.search(the lexical leg, fusion, reranking, chunking) need a cheap, repeatable before/after number.The fixture is synthetic, so it carries no licence or confidentiality question: handbooks of four fictional products that share one heading layout (the product name is in the title, the first heading and its opening paragraph; the other sections never name it), runbooks keyed by error code (the code is in the title and the Symptom section, never in the Resolution), an old and a current version of one policy, other policies, design notes and meeting notes. 21 documents (97 chunks at the default chunk size), 76 answerable queries in five kinds and 5 unanswerable ones:
contextparaphraseidentifiermultifreshnessTwo arms compare per query: the docstring says how to pair two
--outreports throughbench.bootstrap.paired_bootstrap, clustered by the fixture'sclusterfield, which groups the queries whose results move together: one question asked of each product, and every set of queries that share a gold chunk, merged transitively into 36 clusters over the 76 answerable queries (a unit test rebuilds that partition from the chunker and checks the labels equal it). A label is a (source_uri, answer text) pair, so a hit is relevant when it comes from that document and holds that text; the labels survive a chunker change that keeps each answer inside one chunk (a unit test checks they lie inside one chunk at the default size). Themultiandfreshnessfigures rest on five and three queries and are coarse.First result on
main, text-embedding-3-large, default chunking, measured with this head's fixture:hybrid(default)semanticlexicalMRR and nDCG@10 differ per query (a single passage at rank 2 scores 0.5 and 0.63; finding one of two passages leaves nDCG below 1) and only average out close together here.
The default hybrid mode ranks below its own vector leg, most on
contextqueries: the lexical leg scores chunk text only, so a section whose subject is named only in its document's title or heading path is invisible to BM25 (the vector leg embeds the title and breadcrumb with the text), and fusion weights that leg's ranks like the vector leg's. A follow-up changes the lexical leg; this PR only adds the measurement.Scope and risk
Bench only: a harness, its fixture (the JSONL opens with its provenance header), a README entry and a row in its when-to-run table, a row in the in-house fixtures table of
docs/benchmarks/running.mdand a unit test. No server code. A default run ingests into a fresh namespace (knowledge-retrieval-run-<random>), registered as a bench namespace and erased when the run ends, so concurrent arms never share one.--phase ingestand--phase searchneed a--namespace, which is never erased (ingest once, search per arm) and must start withknowledge-retrieval-, the prefix of every namespace the harness writes, so it never registers, fills or prints an erase command for anyone else's namespace (a run's own freshknowledge-retrieval-run-…namespace cannot be named, so no named run writes into a concurrent one); the ingest prints theloom namespaces-gccommand that erases it before anything else. Each report records the server's embedding model, dimension and build, digests of the corpus and the queries, and the namespace's chunk count (instrument), so two reports pair only over one corpus, query set and chunking; an unknown or fake embedder is refused.--paramtakes onlyknowledge.searchfields and refuses the ones the harness sets (top_k, the metrics are @10;org,namespace,namespaces,namespace_scope,query) and the filters that would score a subset of the corpus as the whole (tags,uri_prefix,since_seconds,session_ids,source_classes), so an identity or transport key the server would drop silently (session_id,explain,traffic_class) is refused too; a field the server still names inignored_args, a search that finds nothing, a hybrid or lexical arm whose lexical leg never fired (a cold corpus runs the vector leg alone;lexical_firedcounts the queries it scored, so a partly degraded arm shows), or a named namespace whose documents are not exactly this fixture's fails the run instead of reporting the default arm, zeros or a stale corpus: each ingested document carries afixture:<digest>tag of the corpus it came from, and the search phase checks every document's tag and the URI set.Compatibility, rollout and rollback
--namespacestays until erased withloom namespaces-gc.Tests
pytest tests/unit/test_bench_knowledge_retrieval.py: a fresh ingest erased when the run ends; the embedder and namespace refusals; scoring (a hit counts only from its document and with its text, each gold passage once, one chunk holding two passages, nDCG, misses), parameter parsing and the refused fields, which namespace a run erases, the prefix a named one needs, a kept ingest registering as kept and tagging every upsert, the failed-run checks (nothing found, an ignored field, a namespace holding other documents), the top-hit similarity on answerable and unanswerable queries (over queries with a hit, the rest counted per answerability) and the per-kind means, passage-level nDCG (a hit holding two passages credits both at its rank, capped at 1, so finding them apart and lower never outscores finding them together), and that every gold passage occurs exactly once in its document and inside one chunk at the default size (97 chunks), each passage of a query in a chunk of its own.PYTHONPATH=$PWD .venv/bin/python bench/knowledge_retrieval.py --base-url http://localhost:<port> --namespace knowledge-retrieval-main13 --phase ingest, then--namespace knowledge-retrieval-main13 --phase search --param search_mode=<mode>per arm, against a server from source with text-embedding-3-large: the table above. Two ingests of one fixture version gave identical numbers; a default run's fresh namespace had 0 live chunks after it ended.make format lint,tests/unit/test_public_copy.py,tests/unit/test_doc_links.py.AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated (an agent wrote most of the diff): Claude Code; the fixture labels are checked by the unit test and the numbers come from runs against a local server.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make format-check,make lint,make typecheckandmake test-unitpass; the integration suite passes if server behaviour changed.docs/describe the system as it now is, and this description names any operator steps and wire changes.tests/unit/test_public_copy.py).git commit -s), as CONTRIBUTING.md asks.🤖 Generated with Claude Code