Skip to content

A fast, helpful, and open-source document parser

docs: record round 5 of the table/TEDS work

Logan Markewich54aed20fc288
diff --git a/TABLE_TEDS_PROGRESS.md b/TABLE_TEDS_PROGRESS.md
index e5e79eb..c160f75 100644
--- a/TABLE_TEDS_PROGRESS.md
+++ b/TABLE_TEDS_PROGRESS.md
@@ -5,22 +5,23 @@ Goal: close the table-fidelity (TEDS) gap against **pdf-inspector** (firecrawl)
## Standing
-| metric | baseline (2.10.1) | r1 (`093ddba`) | r2 (`520413d`) | r3 (`08225ac`) | r4 | Δ total | pdf-inspector |
-|---|---|---|---|---|---|---|---|
-| **overall** | 0.8732 | 0.8757 | 0.8783 | 0.8786 | **0.8816** | +0.0084 | 0.8753 |
-| TEDS | 0.6929 | 0.7128 | 0.7441 | 0.7471 | **0.7817** | **+0.0888** | 0.8141 |
-| MHS | 0.8114 | 0.8175 | 0.8179 | 0.8179 | **0.8203** | +0.0089 | 0.7879 |
-| NID | 0.9127 | 0.9129 | 0.9136 | 0.9136 | **0.9143** | +0.0016 | 0.9147 |
+| metric | baseline (2.10.1) | r1 (`093ddba`) | r2 (`520413d`) | r3 (`08225ac`) | r4 (`8aad56b`) | r5 (`09c9080`) | Δ total | pdf-inspector |
+|---|---|---|---|---|---|---|---|---|
+| **overall** | 0.8732 | 0.8757 | 0.8783 | 0.8786 | 0.8816 | **0.8855** | +0.0123 | 0.8753 |
+| TEDS | 0.6929 | 0.7128 | 0.7441 | 0.7471 | 0.7817 | **0.8134** | **+0.1205** | 0.8141 |
+| MHS | 0.8114 | 0.8175 | 0.8179 | 0.8179 | 0.8203 | **0.8210** | +0.0096 | 0.7879 |
+| NID | 0.9127 | 0.9129 | 0.9136 | 0.9136 | 0.9143 | **0.9169** | +0.0042 | 0.9147 |
ParseBench table composite (the mandatory cross-check): 0.4034 → 0.4063 (r3) →
-**0.4074** (r4), so every round so far is positive-or-flat on *both* benchmarks.
+0.4074 (r4) → **0.4171** (r5), so every round so far is positive-or-flat on
+*both* benchmarks.
-We lead on overall + MHS, trail on TEDS by **0.032** (was 0.101) and NID by
-0.0004. **TEDS is scored on only 42 of the 200 docs**, so one doc = 0.024 of the
-mean.
+**After round 5 we lead on every metric.** The TEDS gap is **−0.0007** (was
+0.032, and 0.101 before r4) — parity within noise. **TEDS is scored on only 42
+of the 200 docs**, so one doc = 0.024 of the mean.
-Round 4 is three commits (`87d54ef`, `46e95b4`, `8aad56b`), ~300 lines in
-`tables.rs` plus one line in `classify.rs`. 308 lib tests pass.
+Round 5 is three commits (`bd96364`, `6e1557b`, `09c9080`), ~230 lines in
+`tables.rs`, no other file touched. 314 lib tests pass.
## What shipped
@@ -175,6 +176,98 @@ Round 4 is three commits (`87d54ef`, `46e95b4`, `8aad56b`), ~300 lines in
the paragraph below the band. Further gates: band lines contiguous, ≥3 of
them, seed line reads as exactly 2 pieces.
+## What shipped — round 5 (the three things nobody was reading off the page)
+
+Every round-5 change has the same shape: the geometry already answered the
+question and no code was looking at it.
+
+9. **`RULED_VLINE_MIN_COVERAGE` — vertical rules too short to be columns**
+ (`bd96364`; +0.0040 odl TEDS, ParseBench flat; doc 200 0.276 → 0.445).
+
+ A slide deck draws a table as one stroked rect *per cell*, so a 21.6×9.4pt
+ highlight box behind a phrase **inside** a cell contributes a pair of
+ vertical edges that split that column for the whole table — doc 200's 210pt
+ `Explanation` column became three, taking a 4-column grid to 6.
+ `collapse_gutter_columns` cannot fuse the sliver back, because text centres
+ genuinely do land in it. The mirror of `RULED_HLINE_MIN_COVERAGE`: a vertical
+ must span 20% of the component's row extent.
+
+ **Applying the filter directly is what does not work, and this is the
+ general lesson: dropping evidence can flip a grid from rejected to
+ accepted.** Three documents found that one at a time — a bar chart lost its
+ last column and released its gridlines as thematic breaks (doc 71, MHS
+ 0.98 → 0.62); a pie chart's callout rules were dropped and a grid the density
+ gate had rejected became a junk 2-column table (doc 70, NID −0.10); and
+ ParseBench `FBLB-134215544_page88` turned a rejected component into an
+ 11-column table that swallowed the page (0.66 → 0.03) after dropping **one
+ 4%-coverage stub out of 20**. Raising the fallback threshold patched each in
+ turn and kept finding new ones. What kills the class is structural: the
+ unfiltered build runs first and gatekeeps, so the filtered grid can only
+ ever *replace* a table that would have been produced anyway.
+
+ It must also *earn* the replacement. `CellGrid` now carries `straddle_frac`,
+ and the refined grid is taken only if the straddle census drops by ≥0.05 —
+ doc 200 goes 0.33 → 0.03, whereas a stub sitting on a real column edge (very
+ common in dense financial tables) leaves it flat and merely costs a column
+ (ParseBench `corp-q1-2025_page10`, 0.73 → 0.33 without this).
+
+10. **Unruled outer rows and columns, recovered from the perpendicular rules**
+ (`6e1557b`; +0.0123 odl TEDS, **+0.0070 ParseBench** — the largest
+ single-change ParseBench gain so far; doc 182 0.247 → 0.762).
+
+ A table with interior dividers but no outer frame gives `xs` that stop at
+ the first and last vertical rule, so its outermost columns are *missing*.
+ Doc 182's 4×4 table came out as the 2×2 grid its rules literally describe
+ and all 31 lines tripped the overhang guard before the component collapsed.
+ The horizontals already know how wide the table is and the verticals how
+ tall; nothing read them. Extend each axis to the **median** extent of the
+ perpendicular rules.
+
+ Three guards, each load-bearing:
+ - **median, not min/max** — one overshooting stroke must not widen the grid;
+ - **the new band must hold a span centre**, the `collapse_gutter_columns`
+ idiom, or a pen-cap overshoot manufactures an empty outer column;
+ - **the band must be at least as tall as the shortest existing row.**
+ Verticals routinely overrun the last horizontal by a few points; doc 45
+ turned a 15.5pt tail on 26pt rows into a phantom row, which was enough for
+ the ruled grid to outrank a better borderless table and merge five rows
+ into one (−0.50). The *column* axis takes no such floor — an unruled label
+ column is common and legitimately much narrower than its data columns
+ (doc 182's is 94pt against 259pt).
+
+ On ParseBench four pages of one insurance filing go from 0.09–0.42 to ~0.99.
+
+11. **Split a grid component at row bands no vertical rule spans**
+ (`09c9080`; +0.0154 odl TEDS, +0.0027 ParseBench; docs 82/84 → 1.000,
+ 83 → 0.995, 81 → 0.935).
+
+ This closes followup 8, and the mechanism was **not** the one recorded
+ there. `cluster_v_segments` merges same-x verticals by taking the *union* of
+ their y-ranges **with no gap check**. Two tables stacked in one column, each
+ drawing its own short strokes at the same left edge, therefore fuse into one
+ component across 113pt of blank page. Each is then scored with the other's
+ rows empty and dies on the empty-cell fraction — and where the two layouts
+ differ their column sets are unioned too. Doc 81's `Number | of clauses`
+ split across two columns, filed in the negative results as a
+ detector-priority problem, is that union and needs no priority plumbing.
+
+ The cut signal needs no emptiness threshold: a band between consecutive
+ horizontals that **no raw, pre-cluster `VSeg` spans**. That is strictly
+ stronger than "a big gap", and unlike a gap rule it cannot fire on a
+ rowspan, where the vertical does continue through the boundary. Each band's
+ verticals are then **clipped to the band**, or the shared spine carries the
+ neighbour's height straight back in through items 9 and 10.
+
+ Guards: median row pitch ≥ 8pt (vector-drawn maths glyphs make components
+ with a 3–4pt pitch), gap ≥ max(2.5 × pitch, 30pt), and every band must keep
+ ≥2 rows or the split is abandoned whole. Docs 127/130/165/188 — the ones the
+ round-4 trim experiment broke — are untouched, because a post-hoc row trim
+ keeps the unioned *columns* and splitting the component does not.
+
+ **Requiring 3 rows per band instead of 2 was measured and is worse**
+ (−0.0004 ParseBench: it loses `FBLB-134215544_page6` and recovers neither of
+ the two docs it was aimed at). Left at 2.
+
## Cross-benchmark check is mandatory for table work
**opendataloader-bench alone is not enough.** Round 2 looked perfect on it — four
@@ -240,12 +333,20 @@ that report in place**, so copy it aside before running a variant.
scores are already committed at `opendataloader-bench/prediction/pdf-inspector/`.
Re-evaluate with `uv run src/evaluator.py --engine pdf-inspector`.
-## Where the remaining 0.032 sits
+## Where the remaining −0.0007 sits
+
+We are at parity on the mean, so from here the question is no longer "close the
+gap" but "which docs are still individually behind". Top per-doc gaps after
+round 5 (perdoc index, ours vs pdf-inspector):
+199 −0.346, 118 −0.276, 196 −0.211, 120 −0.173, 45 −0.156, 189 −0.127,
+145 −0.126, 169 −0.122, 115 −0.108, 165 −0.107, 187 −0.083, 80 −0.065.
+
+Note the index shift: these are `perdoc.py` indices (doc id = index + 1). The
+old "doc 200 / 83 / 81" labels in the sections above are ids; 199/82/80 are the
+same documents.
-Top per-doc gaps after round 4 (`perdoc.py`-style, ours vs pdf-inspector):
-200 −0.515, 83 −0.327, 119 −0.276, 197 −0.211, 182 −0.206, 121 −0.173,
-81 −0.162, 46 −0.156, 84 −0.154, 190 −0.127, 146 −0.126, 170 −0.122.
-Docs 81/83/84 are the same source family (item 8 in the old ranking, below).
+Docs we *lead* on offset all of this, which is why the mean is level — but
+every entry above is still a real defect.
## Where the 0.101 sat before round 4
@@ -270,19 +371,29 @@ So the dominant problem is **misfiling**, not dropping, text.
column *is* populated. Worth trying next, but the empty-first-cell rule is what makes
the current version regression-free — relax it only behind an A/B.
-3. **Doc 200 is still the biggest single item (0.276 vs 0.791, ~+0.012).** The
- table now reaches the output (item 7), so `flatten_header_band` is finally on a
- live path. Two problems remain, and the *first* is the real one:
- - **Column over-segmentation**: `xs` has 6 columns where GT has 4.
- `336.9/358.5` is a padding-pair sliver that `collapse_gutter_columns` keeps
- only because a *title* span centre lands in it, and `347.7` is a spurious
- split inside the `Explanation` column. This also causes the second problem,
- by pushing the real header row below `TABLE_ROW_MIN_FILL`.
- - The flatten's anchor then lands on the first *data* row and eats it along
- with the two title rows above. Relaxing the anchor to accept a half-filled
- row of short, column-distinct labels wins +0.009 TEDS here and **costs
- −0.0043 on ParseBench** — measured, not guessed. Do not ship it without
- fixing the columns first.
+3. **Doc 200 / index 199 — the columns are fixed, the rows are not**
+ (0.445 vs 0.791, ~+0.008 available). Item 9 fixed the column
+ over-segmentation this slot used to describe; `xs` is now GT's 4. Two things
+ remain, and they are one mechanism:
+ - The page is **not a ruled grid at all — it is 44 independent per-cell
+ rects** (4 distinct x/width pairs × 11 rows; see `dump_rects_raw`). The
+ columns' rects are not y-aligned (each cell's rect hugs its own text), so
+ unioning every top and bottom yields 24 row boundaries for 11 rows. Tall
+ cells then get cut by a neighbouring column's boundaries and their text
+ splits across rows (`2. Data labeling and` / `fine-tuning`).
+ - `flatten_header_band` still folds the two full-width *title* banners into
+ the header row.
+ The right model for this class is to cluster the cell rects directly —
+ columns by near-identical (x, width), rows by **y-interval overlap** (rows
+ overlap ~100%, adjacent rows 0%, which is unambiguous where no y threshold
+ is). That is a new detector, not a tweak, and it needs priority plumbing
+ against the ruled path.
+ A cheaper partial: `rowspan_mask` already marks these cells correctly (it is
+ how the density gate survives), but `spanned` is only *counted*, never used
+ to merge cell text. Making a spanned cell fold into the cell above is
+ contained and reuses round-4 machinery.
+ Do **not** relax the `flatten_header_band` anchor — measured at −0.0043 on
+ ParseBench, see negative results.
4. ~~**Doc 165 worksheet**~~ — **DONE in round 4** (item 8), 0.000 → 1.000. The
"bordered worksheet / `TABLE_MAX_EMPTY_CELL_FRACTION`" diagnosis in this slot
@@ -315,10 +426,41 @@ So the dominant problem is **misfiling**, not dropping, text.
past the 6pt `TABLE_TRACK_TOLERANCE_PT`. Needs track *ranges* rather than
points; touch with care, that tolerance gates several paths.
-8. **Docs 81/83/84 (same source family, −0.64 summed).** One grid component
- spans two stacked tables, so each is evaluated with the other's rows empty
- and both die on `empty-frac 0.60`. See the trim experiment in negative
- results for what does *not* work.
+8. ~~**Docs 81/83/84 (same source family)**~~ — **DONE in round 5** (item 11).
+ The diagnosis in this slot was right about the symptom and wrong about the
+ cause: the component does span two stacked tables, but because
+ `cluster_v_segments` unions y-ranges across a 113pt gap, not because of
+ anything about the rows. Splitting the component (not trimming rows) fixes
+ all four and leaves the trim experiment's casualties alone.
+
+9. **Doc 119 / index 118 (0.724 vs 1.000, ~+0.007).** Diagnosed, not built. Two
+ independent defects:
+ - **9 phantom rows.** The PDF draws a background fill rect per *text line*
+ inside each cell, and `RULED_HLINE_MIN_COVERAGE` is **Global-pass only** —
+ the per-region pass (which is what emits this table) keeps every
+ horizontal. Coverage over the column extent is perfectly bimodal: 7
+ boundaries at ≥0.998 (exactly GT's 6 rows) against 9 phantoms at 0.661 and
+ 0.336. Note the existing 0.5 threshold would *not* fix it even if promoted;
+ it needs a strict tier (~0.9) gated on the full-width frame being real.
+ **Blast radius is measured and large**: over the 200-doc corpus, 24 docs
+ lose boundaries under a 0.9 filter, including 165, 150, 199, 200 and 141.
+ This needs its own attribution run and a hand check of 165.
+ - **A wrong column split.** `bucket_words_into_columns` returns `None` when
+ every word centre lands in one column — the doc comment says the caller's
+ "whole-span fallbacks" are then the honest answer, but the actual next
+ fallback is `split_span_at_anchors`, which *interpolates* a split from a
+ character index and cuts `(begins` off into the previous column. Word
+ geometry had the right answer and it was discarded precisely because it was
+ unanimous. Small, independent, and worth doing first.
+
+10. **Doc 197 / index 196 (0.789 vs 1.000) — do not chase this to 1.0.**
+ Measured by patching the markdown and re-scoring: the *faithful* structural
+ reading of the missing table (1 column × 11 rows) scores **0.447**, i.e.
+ −0.34. GT's 1.000 requires reproducing an idiosyncrasy (a header cell and a
+ merged body cell side by side in one row). A 1-column header + single merged
+ body cell gets 0.850 (+0.061 on one doc = +0.0015 mean) and would require a
+ new 1-column-table producer in `two_col_band_pass`. Low priority, and the
+ ceiling is an artefact rather than a defect.
## Negative results — do not retry blind
@@ -352,6 +494,21 @@ So the dominant problem is **misfiling**, not dropping, text.
(`Number | of clauses` split across two columns) over a correct borderless
table. Fixing this class needs either detector-priority plumbing or splitting
the *component* — not a post-hoc row trim. Reverted; not in the shipped diff.
+ **Round 5 settled this**: splitting the component (item 11) was the answer,
+ and the extra column was the two tables' x-sets being unioned, so no
+ detector-priority plumbing was needed after all.
+- **Filtering short vertical rules before the grid is built** (round 5, item 9).
+ Three separate documents turned a *rejected* grid into an accepted junk table
+ because the filter removed the evidence the gates were rejecting it on.
+ Raising the fallback threshold (2 → 3 → 4 surviving rules) patched them one at
+ a time and kept finding new ones. Never let a cleanup pass run before the
+ gatekeeper.
+- **Requiring 3 rows per band in the component split** (round 5, item 11):
+ −0.0004 ParseBench, loses `FBLB-134215544_page6`, recovers neither doc it was
+ aimed at. Left at 2.
+- **Tagged-`/Table` and sub-word tracks** — see items 5 and 6 above; both were
+ measured inert *before* being built out, which is the cheapest thing in this
+ whole document. Do that first.
- **Relaxing the `flatten_header_band` anchor** to accept a half-filled row of
short (≤40 char), column-distinct labels when column over-segmentation pushes
the real header below `TABLE_ROW_MIN_FILL`. Doc 200 +0.009 TEDS / +0.020 NID