Repository navigation
A BEIR harness measures knowledge.search on public passage-retrieval sets - #236
Merged
Merged
Conversation
zlareb1
force-pushed
the
bench/beir-knowledge
branch
from
November 3, 2026 21:38
3bf073b to
9bfd9fc
Compare
…sets Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…s and checks each arm ran Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…s; the baseline pins no reranker Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…the reranker ran Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
zlareb1
force-pushed
the
bench/beir-knowledge
branch
from
November 3, 2026 21:44
b9aa121 to
6dd6125
Compare
…re it registers; batches of 50 Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…in the ignored-field refusal Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… their reason Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ested Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
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.
Related: #193
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/beir_knowledge.pymeasuresknowledge.searchon BEIR passage-retrieval datasets (nDCG@10, recall@10/100, MRR@10 against the graded judgements);--fetchdownloads one of the small datasets.Why
bench/knowledge_retrieval.py(#193) measuresknowledge.searchon a synthetic fixture written with the feature, which is enough to compare two arms but not to place document retrieval against published numbers. BEIR's small datasets (SciFact, NFCorpus, ArguAna, SCIDOCS, FiQA-2018) are the standard zero-shot passage-retrieval sets, judged by humans, with no LLM judge needed. This PR adds the harness only: no run is reported here, and nothing in the server changes.Design
--fetch <dataset>downloads one release archive, refuses it unless its MD5 is the one the BEIR release publishes (pinned per dataset inSMALL, which also fixes the revision the numbers are measured on), and writes onlycorpus.jsonl,queries.jsonlandqrels/test.tsvunderbench/datasets/beir/<dataset>(git-ignored;--data-dirto change). Members are read by name and written by the harness, never extracted as paths. Checked against the real SciFact and NFCorpus archives (both MD5s match); SciFact loads as 5,183 passages, 300 test queries and 339 judgements, as the dataset states. TREC-COVID (171K passages) is left out of the small set.beir:<doc id>, its title, its text, or its title when the text is empty); ingest goes throughknowledge.bulk_addin batches of 50 (each document is embedded by its own call, so a batch finishes well inside the client timeout), every document tagged with a digest of the corpus and the server's embedding model: a search reads only chunks of the current model, so a namespace ingested under another would otherwise score as empty, or lexical only, without failing.bulk_addnever supersedes a document's chunks (a resent passage would have its chunks indexed twice), so the ingest first lists the namespace: it refuses one holding any document of another corpus, version or model before registering or writing anything, and sends only the passages not there with their chunks, so a failed ingest is resumed by running it again (a document an interrupted write left without chunks is sent again: its row is replaced and its chunks are added once). A batch is sent once: no resend after a 5xx, which could have written it; after a client timeout the docstring says to rerun only once the server has finished the batch.top_k=100,collapse_sections=false); the hits are scored by document, a passage's chunks counted once at the first one's rank, and a hit on the query's own id dropped (ArguAna's queries are corpus passages; BEIR's evaluation drops them the same way). nDCG@10 uses the graded judgement as the gain (the convention the published BEIR numbers use); recall@10/@100 count documents judged > 0; MRR@10. The 100 hits are chunks, so each query also reportsdepth, the documents they held: recall@100 is BEIR's only wheredepthis 100.knowledge_retrieval.py's, reusing its helpers (run_namespaceandcheck_corpusnow take the prefix and the tag,digestandcheck_rerankedare shared): a named namespace must start withbeir-(a run's ownbeir-run-…cannot be named) and is kept for later arms; a fresh one is erased at the end; a search over a namespace that does not hold exactly this corpus under this model (documents, tag, and a chunk for each) fails, and so do a dataset with no judged query and an arm in which no query found anything;--param KEY=VALUEsets any search field but the depth (MAX_SEARCH_TOP_K), scope, filters andcollapse_sections(refused); anignored_argsanswer fails the arm; a fake embedder is refused; a hybrid or lexical arm whose lexical leg never fired fails. An arm that names no reranker sendsrerank="none", so a deployment default cannot rerank the baseline;check_rerankedfails a baseline any answer of which names a reranker, and a rerank arm none of whose answers does (a reranker that keeps the fused order names none, so not every answer must). A report'sparamsare the arm as sent (rerankincluded), in both harnesses. The instrument records digests of the corpus and model, the queries and the judgements, so only reports over the same inputs pair. The JSONL files are read line by line, never withstr.splitlines, which would also break a record on U+2028 inside a string (none in the SciFact or NFCorpus files). Per-query rows carry an id, forbench.bootstrap.paired_bootstrap.Scope and risk
bench/, two docs tables and the third-party-datasets paragraph ofdocs/benchmarks/running.md.knowledge_retrieval.pyshares its helpers and gains the same two checks: its corpus check refuses a document without chunks, and its arms pinrerank="none"unless they name a reranker (check_reranked), so a deployment's rerank default cannot reach its baseline. Licences are upstream's and differ per dataset; SciFact's is non-commercial, whichdocs/benchmarks/running.mdnow says beside LoCoMo and PerLTQA.Compatibility, rollout and rollback
Tests
tests/unit/test_bench_beir_knowledge.py: loading a dataset (an unjudged query and an empty passage left out, a title-only passage indexed by its title, a dataset with no judged query refused); a document's chunks counted once and the query's own id dropped; nDCG with graded gains, a judgement of 0 not relevant, recall@10 against @100; the namespace prefix rules; a fetch refusing an archive with the wrong MD5 (writing nothing) and writing only the kept members of one that also holds a traversal path; the search loop's fixed fields, metrics,depthand counts, a baseline pinningrerank="none"; a hybrid arm whose lexical leg never fired, a rerank arm with no reranked answer, a reranked baseline and an arm that found nothing failing, a semantic arm passing;--param collapse_sectionsrefused; an ignored field failing the arm; a namespace of another corpus, version or embedding model refused by the search and by the ingest before it registers or writes; a resumed ingest sending only the missing and chunkless passages, in tagged batches.tests/unit/test_bench_knowledge_retrieval.py:check_reranked(four cases), the fixture harness's baseline pinningrerank="none"and failing when reranked, its corpus check refusing a document without chunks.make format-check lint typecheckandruff check bench/(make lintdoes not coverbench/); the full unit suite on the head;--fetch scifactand--fetch nfcorpusagainst the real archives (downloads only; nothing ingested).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.
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/reference/configuration.mdand thedocs/reference/tables (python scripts/codegen/docs_reference.py), the reach manifest,schemas/schema.sql(make schema-dump) and the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py).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