Skip to content

A BEIR harness measures knowledge.search on public passage-retrieval sets - #236

Merged
zlareb1 merged 8 commits into
mainfrom
bench/beir-knowledge
Nov 3, 2026
Merged

zlareb1 merged 8 commits into
mainfrom
bench/beir-knowledge

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Related: #193

Changelog category (leave one):

  • Build/Testing/Packaging Improvement

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.py measures knowledge.search on BEIR passage-retrieval datasets (nDCG@10, recall@10/100, MRR@10 against the graded judgements); --fetch downloads one of the small datasets.

Why

bench/knowledge_retrieval.py (#193) measures knowledge.search on 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 in SMALL, which also fixes the revision the numbers are measured on), and writes only corpus.jsonl, queries.jsonl and qrels/test.tsv under bench/datasets/beir/<dataset> (git-ignored; --data-dir to 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.
  • Each passage is one document (beir:<doc id>, its title, its text, or its title when the text is empty); ingest goes through knowledge.bulk_add in 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_add never 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.
  • Each test query with a judgement is searched at the wire bound (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 reports depth, the documents they held: recall@100 is BEIR's only where depth is 100.
  • The run discipline is knowledge_retrieval.py's, reusing its helpers (run_namespace and check_corpus now take the prefix and the tag, digest and check_reranked are shared): a named namespace must start with beir- (a run's own beir-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=VALUE sets any search field but the depth (MAX_SEARCH_TOP_K), scope, filters and collapse_sections (refused); an ignored_args answer 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 sends rerank="none", so a deployment default cannot rerank the baseline; check_reranked fails 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's params are the arm as sent (rerank included), 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 with str.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, for bench.bootstrap.paired_bootstrap.

Scope and risk

bench/, two docs tables and the third-party-datasets paragraph of docs/benchmarks/running.md. knowledge_retrieval.py shares its helpers and gains the same two checks: its corpus check refuses a document without chunks, and its arms pin rerank="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, which docs/benchmarks/running.md now says beside LoCoMo and PerLTQA.

Compatibility, rollout and rollback

  • Wire: none. Operator steps: none.
  • Rollback: revert; nothing is stored.

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, depth and counts, a baseline pinning rerank="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_sections refused; 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 pinning rerank="none" and failing when reranked, its corpus check refusing a document without chunks.
  • make format-check lint typecheck and ruff check bench/ (make lint does not cover bench/); the full unit suite on the head; --fetch scifact and --fetch nfcorpus against 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 typecheck and make test-unit pass; the integration suite passes if server behaviour changed.
  • Generated files are regenerated in this PR, not by hand: the SDK op tables, docs/reference/configuration.md and the docs/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 under docs/ describe the system as it now is, and this description names any operator steps and wire changes.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers; the history goes in this description (tests/unit/test_public_copy.py).
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.

🤖 Generated with Claude Code

@zlareb1
zlareb1 force-pushed the bench/beir-knowledge branch from 3bf073b to 9bfd9fc Compare November 3, 2026 21:38
zlareb1 and others added 4 commits November 3, 2026 21:44
…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
zlareb1 force-pushed the bench/beir-knowledge branch from b9aa121 to 6dd6125 Compare November 3, 2026 21:44
zlareb1 and others added 4 commits November 3, 2026 21:50
…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]>
@zlareb1
zlareb1 merged commit f977cfd into main Nov 3, 2026
18 checks passed
@zlareb1
zlareb1 deleted the bench/beir-knowledge branch November 3, 2026 22:50
@pufit pufit mentioned this pull request Nov 4, 2026
9 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant