Skip to content

A document-parsing bench scores the reference extractor on a labelled corpus of Loom's document shapes - #289

Merged
zlareb1 merged 34 commits into
mainfrom
dp-corpus
Nov 6, 2026
Merged

zlareb1 merged 34 commits into
mainfrom
dp-corpus

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

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

A document-parsing bench (python -m bench.docparse) scores the reference extractor on a labelled corpus of design docs, specs, runbooks and decks as PDF, DOCX and PPTX: text, reading order, headings, tables, page locators and silent loss.

Why

The reference extractor's PDF reader takes the text layer only, and nothing measured what that costs on the documents Loom ingests. A parser change needs a fixed corpus with gold labels and a scorer before it is built, so that a gain is measured and a regression is caught, on a held-out split it was not tuned on.

Scope and risk

Bench code, a committed corpus and docs; no server or extractor change.

  • bench/docparse/corpus/: 54 files with gold.jsonl, split dev and held-out within each category: browser-printed design docs, office-suite PDF exports, typeset PDFs with no outline, two-column pages, rotated pages, borderless tables, tables over several pages with a repeated header, slide decks and their PDF exports, scanned pages and a whiteboard photo, DOCX and PPTX. Six are public-domain PEPs printed from their HTML; the rest are synthetic. Gold labels are the document specs the files were rendered from (specs.py); each gold item's pages come from the rendered file through poppler, a parser the bench does not score, found in the document's order through one stream of its words (the synthetic text repeats its phrases). An office or deck export and a scan take their source's split, so no held-out text is tuned on.
  • corpus.py rebuilds the corpus in a tools container (Dockerfile.tools: Chromium, LibreOffice, poppler); run.py parses each file with the extractor in a child process of its own and writes normalized parses; score.py scores any parse of that shape, so another parser is compared by writing it.
  • Metrics per file, category and overall: text recall and precision, reading order, heading F1 and level accuracy (levels by rank over the matched headings, a leading section number aside; headings or tables where the file has none score 0), table cell F1 and detection F1, page and slide locators (a block found in the order of the document and cited right only when its pages hold the gold page and span no more pages than it does), notes membership, lost blocks and silent loss (reported complete while a block, a page's text or a tenth of the words is missing), errors (a failed or timed-out parse scores 0 on every metric its gold defines but level accuracy, which it has none of), seconds and peak memory. Each system after the first gets its paired difference with a 95% bootstrap interval (bench.bootstrap.paired_bootstrap).
  • The corpus is 3.8 MB, most of it the scanned pages.

Compatibility, rollout and rollback

  • Wire: none.
  • Operator steps: none.
  • Rollback: reverting removes the bench and its corpus.

Tests

pytest bench/test_docparse.py: every gold file is in the corpus and every category in both splits, and an export or a scan is in its source's; every gold page span is ordered and every PDF and PPTX item has its page; a block cited over every page scores near 0 and invented tables score 0; a failed parse scores 0 and counts as an error in the report; a timed-out parse, a child that dies leaving undecodable bytes, and one whose last line is no JSON object are each that file's error and the run goes on; a container call returns its output, and a failed one names its program, its input file and the end of its stderr (no colon when there is none); a heading is cited whether the parse keeps its number or not; the corpus build refuses a missing PEP page, a directory that is no corpus and a missing parent before making or removing anything, leaves a directory as found when the tools container cannot see it (or there is no docker program), and once it can, empties the directory with what marks it a corpus removed last; a perfect parse scores full marks on every file; a dropped block in a complete parse is a silent loss and is not one when the parse says it is incomplete; a block whose lines are reordered is not lost; a heading matches without its number and levels compare by rank; a table split over pages with its header repeated scores whole and one with its columns swapped scores 0; reading order follows a repeated text to its next occurrence.

The current extractor on the whole corpus (python -m bench.docparse run --out main.jsonl, then score main=main.jsonl):

Category Text recall Heading F1 Table cell F1 Locators Silent loss
All PDFs (42) 0.877 0.165 0.000 0.842 2
PDF exports (10) 1.000 0.378 0.000 0.965 0
Scanned PDFs (5) 0.000 0.000 0.000 0.000 0
DOCX (6) 1.000 1.000 1.000 0
PPTX (6) 0.969 1.000 1.000 0.933 3

A PDF's tables and, without an outline, its headings are not read; scanned pages fail as needing OCR, so they are not silent; a picture on a slide that holds text is lost while the file reads complete. About 0.06 s and 36 MB a file.

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 checked the gold labels against rendered pages, the scorer against hand-built parses, and the scorer's fairness on another parser's output (a parser that drops section numbers or reorders a code block's lines is not charged a lost block).

  • 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 28 commits November 6, 2026 17:59
… corpus of Loom's document shapes

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ations, invented tables and failed parses

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…atches probes on whole words

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
… parses out of time and memory, and checks its container mount

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…and can rerun after a refusal

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
… of their own that CI tests

A missing PEP page, a directory that is no corpus and a container that cannot
see it are refused first; a stopped build's directory can be built again, its
scratch emptied with the rest.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…nd leaves a refused directory as found

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…nd says why a render failed; its preflight tests are one case each

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…an, from text or bytes, and refuses an --out that is a file

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
… its source is tested through it

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…sts model what docker() raises and returns

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…a failure with no stderr ends without a colon

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
… its file's error

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…tderr only when there is some

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ed before it is cut

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…o caller sets

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
… manual states the reading-order unit

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]>
…wn number

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…he stream holds it

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…he one way

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…e is its own test

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
zlareb1 and others added 6 commits November 6, 2026 17:59
…line reads as one on its own lines

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]>
…ock case

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]>
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