Skip to content

The parsing bench measures what a parse does downstream: search hits cited to their page, and decision quotes found in the file - #300

Merged
zlareb1 merged 11 commits into
mainfrom
dp-downstream
Nov 6, 2026
Merged

zlareb1 merged 11 commits into
mainfrom
dp-downstream

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Related: #289

Changelog category (leave one):

  • Not for changelog

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):

The document-parsing bench measures what a parse does downstream: knowledge.search recall with the hit cited by its page, and how often decision extraction finds its quotes in the parsed text.

Why

The parsing bench (#289) scores a parse against gold labels. What Loom needs from a parse is what it does after ingest: whether a search hit holds the answer and cites the page it is on, and whether decision extraction can ground its quotes in the text. Two parses with the same text recall can differ there (one block over many pages cites nothing; a table flattened into words loses its rows).

Design

  • python -m bench.docparse run --artifacts DIR writes each file's artifact beside the normalized parse; artifacts PARSES.jsonl --out DIR turns another parser's normalized parses into contract artifacts (blocks with their pages and section paths, tables as typed tables), so any parser can be compared.
  • downstream NAME=DIR ... serves each system's artifacts from a stub extractor (the contract's GET /v1/capabilities and POST /v1/extract, by file name) to a running Loom whose LOOM_DOCUMENT_EXTRACTOR_URL points at it, ingests the corpus into one namespace per system through knowledge.upload and knowledge.ingest (partial files too), and asks the same queries of each.
  • Queries: per file, up to three paragraphs (eight words from each) and two table rows (the row's name and a value), each searched within its own document (uri_prefix), since a parse decides what its chunks hold and cite, not how documents rank against each other. Found at k: a top-k hit holds 70% of the answer's words; cited: that hit's locator holds the answer's page and spans no more than the answer does plus one page (a table row: within the table's pages, a page or two). The report is recall at 1 and 5, found and cited, per category and overall, each system paired with the first with a 95% bootstrap interval (files resampled).
  • The Loom runs with auth off on the same host (the stub binds 127.0.0.1). A file still ingesting at the half-hour deadline stops the run, as the stub would serve it the next system's artifact; run --artifacts and artifacts --out refuse a directory that already holds artifacts, so a failed parse leaves none from an earlier run; a query of a file whose ingest this run did not finish is not found, so an earlier run's revision still serving it scores nothing; a token the stub refuses stops the run at the next status poll; either stop cancels the system's open jobs, so none reaches the stub once it serves another system.
  • --decisions N mines N PDF documents with decision_extract.extract_document in a dry run, in this process, counting at the point extraction grounds a claim's quotes in the parsed text: the share of claims kept is the quote-match rate, and the share of kept quotes that are a run of the gold text says how often the parse's text is the document's. It needs the server's settings and a real LLM, so it runs only when asked.

Scope and risk

bench/docparse/ (downstream.py, run.py, __main__.py), bench/test_docparse.py, bench/README.md. Bench only; nothing under server/ changes. The stub binds 127.0.0.1, answers only the token the server sends, and serves only a corpus file's name from its directory. --decisions spends LLM tokens (about $1 for 12 documents and three systems).

Compatibility, rollout and rollback

  • Wire: none.
  • Operator steps: none.
  • Rollback: revert.

Tests

pytest bench/test_docparse.py: a normalized parse becomes an artifact that passes parse_artifact, with its headings opening sections, its table blocks and typed tables, and an incomplete parse's failed units; the stub refuses a missing or wrong token on either route and a name with a path, and serves a system's artifact by file name; run --artifacts and artifacts --out refuse a directory that already holds artifacts; ingest stops on a refused token or at its deadline after polling, and cancels only its open jobs; downstream refuses two systems that share a namespace, an empty token and more decision documents than it has; the query set holds paragraphs and table rows with their pages; a hit is found when it holds the answer and cited only on the right page, a table row within its table's pages, and another system's copy of the document is not a hit; decision counts come from where extraction grounds a claim's quotes, the rejected options' quotes included, and a document this run did not ingest is not mined (unread); the report pairs each system with the first.

One run end to end against a local Loom (fake embedder, no LLM), 212 queries, the reference extractor before and after the PDF layout and OCR changes and a layout-model baseline:

Previous New Baseline
Cited at 1 0.792 0.825 0.858
Cited at 5 0.887 0.943 0.948
Found at 5 0.920 0.976 1.000
Files ingested (of 54) 49 54 53

Each search is scoped to its document and to its system's own namespace (namespace_scope: this), and a hit from another namespace does not count. Scanned pages go from 0 to 1.00 cited at 5. Table rows over many pages cite less often than a page's flattened text did (0.80 against 1.00 at 5): knowledge.search folds the row blocks of one section, so a row deep in a long table can fall out of the top five. That is the search's, not the parse's.

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 ran the harness end to end against a local server and checked the judge against hand-picked hits.

  • 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).
  • A new migration is additive and numbered after the latest on main; no merged migration is edited.
  • A behaviour change to any file a plugin ships (hooks/, lib/, bin/, skills/, .mcp.json, the Codex plugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.
  • The frontend builds (npm --prefix frontend run build) and its tests pass, if frontend/ changed.
  • 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 and others added 11 commits November 6, 2026 19:36
…cited to their page, and decision quotes found in the file

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…is never served, and a stalled ingest stops the run

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…the run, and run --artifacts takes only an empty directory

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…directory itself, and the judge always checks the namespace

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…e check guards an artifacts directory

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…asons read in order

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
… a second httpx import

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
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