Skip to content

Commit 98f5326

Browse files
authored
Merge pull request #59 from artiz/claude/issue-58-docs-cleanup
docs: refresh MIGRATION/conformance docs; drop PDF_PARSER_NOTES (#58)
2 parents 7d10d9a + e1a3c87 commit 98f5326

4 files changed

Lines changed: 75 additions & 258 deletions

File tree

COMPARING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,14 @@ case — see the divergence table below.
182182
| **PPTX** | **7 / 7**| 7 / 7 |
183183
| **DOCX** | **25 / 26** | 25 / 26 |
184184
| **HTML** | **31 / 32**| 31 / 32 |
185-
| **PDF** | **6 / 14**| 7 / 14 |
185+
| **PDF** | **6 / 16**| 7 / 16 |
186186

187187
> † The pure-parse backends above are scored against **live** docling. **PDF** is a
188188
> discriminative ML reconstruction pipeline (not a deterministic parse), so it is
189189
> scored against a committed groundtruth corpus (`tests/data/pdf/groundtruth`) that
190190
> is **regenerated from live docling** and therefore matches `scripts/conformance/conformance.sh
191191
> pdf` (padded GitHub tables, current docling text). The PDF score is reported two
192-
> ways: **6 / 14 strict** byte-for-byte, and **7 / 14 whitespace-normalized** — the
192+
> ways: **6 / 16 strict** byte-for-byte, and **7 / 16 whitespace-normalized** — the
193193
> 7th (`amt_handbook_sample`) differs only by docling's spurious double space in a
194194
> `1⁄4` fraction, where the Rust output's single space is the more faithful
195195
> rendering.

MIGRATION.md

Lines changed: 52 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ phased plan is kept at the end as history.)
1414
> against *live* docling; the PDF/image/METS ML path lives in `docling-pdf`
1515
> (a pure-Rust PDF text parser + pdfium rasterization + ONNX
1616
> layout/TableFormer/OCR + a port of docling-parse's line sanitizer) and is also
17-
> measured byte-for-byte against live docling — **6 / 14 PDF fixtures exact, 7 / 14
17+
> measured byte-for-byte against live docling — **6 / 16 PDF fixtures exact, 7 / 16
1818
> whitespace-normalized** (see `PDF_CONFORMANCE.md`), with a snapshot baseline
1919
> guarding against regressions. `cargo test` is green (unit tests + a 133-source
2020
> output-regression suite).
@@ -24,11 +24,11 @@ phased plan is kept at the end as history.)
2424
| | |
2525
|---|---|
2626
| **What** | A Rust port of docling's converter, backends, and discriminative PDF/ASR pipelines; same `convert → DoclingDocument → export_to_markdown()/json()` shape, single static binary, no Python/torch at runtime |
27-
| **Conformance** | Declarative formats byte-for-byte vs *live* PyPI docling (most 100%, see §2); PDF ML path 6/14 fixtures byte-exact, rest close; every optimization is gated on this not regressing |
27+
| **Conformance** | Declarative formats byte-for-byte vs *live* PyPI docling (most 100%, see §2); `.dclx` DocLang output ≈91% mean vs docling's own `.dclx` (§2); PDF ML path 6/16 fixtures byte-exact, rest close; every optimization is gated on this not regressing |
2828
| **Performance** | PDF ML pipeline **4.3× faster warm / 4.7× end-to-end** than Python docling at 2.3–2.6× less peak RAM (INT8 + SIMD, conformance-validated); declarative formats 20–60× warm, ~60× less RAM; details + methodology in [`PDF_PERFORMANCE.md`](./PDF_PERFORMANCE.md) |
2929
| **Models** | docling's own checkpoints (layout heron, TableFormer, PP-OCRv3, Whisper tiny), format-converted to ONNX by `scripts/export_*.py` — no retraining; INT8 variants are calibrated post-training quantizations (`scripts/install/quantize_models.py`) |
3030
| **Tracking upstream** | See [§9](#9-keeping-up-with-upstream-docling): conformance is measured against the *latest published* docling on demand, so an upstream release that changes output surfaces as a concrete per-fixture diff |
31-
| **Not ported (by design)** | VLM pipelines, enrichment models, DocTags input, the legacy APS-text patent dump (§5); inline formatting is baked into text rather than structured fields (§4) |
31+
| **Not ported (by design)** | VLM pipelines, enrichment models, DocTags/DocLang *input* backends (§5); inline formatting is baked into text rather than structured fields (§4) |
3232

3333
---
3434

@@ -106,7 +106,7 @@ content-type resolution, and image extraction — reused by DOCX/PPTX/XLSX/EPUB.
106106

107107
These run docling's *discriminative* PDF pipeline ported to ONNX. They are now
108108
measured **byte-for-byte against live docling** (the committed PDF groundtruth is
109-
regenerated from it): **6 / 14 exact (7 / 14 whitespace-normalized)**, the rest
109+
regenerated from it): **6 / 16 exact (7 / 16 whitespace-normalized)**, the rest
110110
close — see `PDF_CONFORMANCE.md`. A deterministic snapshot baseline
111111
(`scripts/conformance/pdf_conformance.sh`) still guards against regressions.
112112

@@ -117,6 +117,27 @@ close — see `PDF_CONFORMANCE.md`. A deterministic snapshot baseline
117117
| METS / Google Books | `.tar.gz` of per-page hOCR + TIFF → cells from hOCR → the same layout+assembly path (no OCR needed) |
118118
| Audio (wav/mp3/flac/ogg/aac/m4a + mp4/mov audio tracks) | `docling-asr`: **symphonia** decode (no ffmpeg) → 16 kHz mono → ported log-mel front-end → **Whisper tiny** encoder/decoder (ONNX, greedy with OpenAI's timestamp rules — docling's ASR defaults) → `[time: start-end] text` paragraphs. AVI is the one container symphonia can't demux. |
119119

120+
### DocLang (`.dclx`) coverage
121+
122+
The `.dclx` DocLang output (§3) is scored against docling's own `.dclx` archives
123+
with `scripts/conformance/dclx_conformance.sh` — the extracted `document.xml`
124+
line-diffed, similarity `= 100·(1 − difflines / max_lines)`. **≈91% mean over the
125+
134-fixture non-PDF corpus** (issue #32 target: ≥90%), per source format:
126+
127+
| Format | `.dclx` similarity | Format | `.dclx` similarity |
128+
|---|---|---|---|
129+
| CSV / AsciiDoc / Email | **100%** | Markdown | 92% |
130+
| USPTO | 98% | ODF / LaTeX | 91% |
131+
| DOCX / PPTX | 96% | XLSX | 87% |
132+
| JATS | 95% | HTML | 84% |
133+
| | | WebVTT | 81% |
134+
135+
The remaining format gaps are tracked under
136+
[issue #32](https://github.com/docling-project/docling.rs/issues/32); its children
137+
(#38#41, #44) landed the ODF, USPTO legacy-entity, elife XML, wiki_duck and
138+
APS-plain-text work — `pftaps` is now byte-exact (§5). PDF `.dclx` is byte-exact
139+
on the one fixture with a groundtruth archive.
140+
120141
---
121142

122143
## 3. Output formats
@@ -134,10 +155,11 @@ close — see `PDF_CONFORMANCE.md`. A deterministic snapshot baseline
134155
`<strikethrough>`/`<sub|superscript>`), lists with enumeration `<marker>`s, OTSL
135156
tables (`<ched>`/`<fcel>`/`<lcel>`…) with per-cell `<location>`, code, formulas,
136157
pictures and furniture. Conformance is scored against docling's own `.dclx`
137-
archives (`scripts/conformance/dclx_conformance.sh`): **≈83% mean similarity over
138-
the 134-fixture non-PDF corpus** and climbing — csv/asciidoc/email/json exact,
139-
html/docx/jats/md/latex/xlsx/webvtt/uspto in the 80s–90s, with the format-by-format
140-
gaps tracked as [issue #32](https://github.com/docling-project/docling.rs/issues/32) and its
158+
archives (`scripts/conformance/dclx_conformance.sh`): **≈91% mean similarity over
159+
the 134-fixture non-PDF corpus** (issue #32's ≥90% target) — csv/asciidoc/email
160+
exact, uspto/docx/pptx/jats in the mid-to-high 90s, md/odf/latex low 90s,
161+
xlsx/html/webvtt in the 80s (full table in §2). The format-by-format gaps are
162+
tracked as [issue #32](https://github.com/docling-project/docling.rs/issues/32) and its
141163
children (#38#41, #44). This is an **output** format; a DocLang *input* backend is
142164
still out of scope (§5).
143165

@@ -203,11 +225,21 @@ These are deliberate or unavoidable divergences, not bugs.
203225
ligature recomposition, loose-box geometry. Plus docling's markdown escaping,
204226
typographic-punctuation normalization, wrap dehyphenation,
205227
paragraph-continuation merging, band-aware two-column reading order, and
206-
false-picture / page-number layout fixes.
228+
false-picture / page-number layout fixes. The parser is now the **sole** text
229+
source — pdfium does only page rasterisation + link annotations. Its per-word
230+
cells reproduce docling-parse's `word_cells` byte-for-byte (377/377 on
231+
`2305-pg9`), which is what TableFormer matches against; a char-frequency
232+
validator (`scripts/test/parser_completeness.py`) confirms nothing is silently
233+
dropped (Form-XObject text and glyph-name-only fonts were the two classes it
234+
surfaced and fixed).
207235
- Output is measured **byte-for-byte against live docling** (PDF_CONFORMANCE.md):
208-
**6 / 14 exact, 7 / 14 whitespace-normalized**, the rest close. The remaining
236+
**6 / 16 exact, 7 / 16 whitespace-normalized**, the rest close. The remaining
209237
gaps are model-level (TableFormer structure on complex tables, layout
210-
classification) plus `amt`'s fraction spacing (a docling quirk).
238+
classification, title-page reading order) plus `amt`'s fraction spacing — a
239+
docling quirk from its embedded-font OS/2 metrics that our single-spaced output
240+
renders more faithfully; matching it exactly needs a font-metrics layer that
241+
entangles with the RTL box geometry. The full per-fixture breakdown and the
242+
model-level blockers live in `PDF_CONFORMANCE.md`.
211243

212244
6. **Extracted image bytes are real but not byte-identical.** Cropped/embedded
213245
pixels are correct, but the PNG re-encoding differs from docling's, so the
@@ -240,13 +272,15 @@ deliberate scope boundary or a cosmetic, single-fixture polish gap.
240272
- **XML DocLang / DocTags *input* backend** — DocLang is supported as an
241273
**output** format (§3), but reading `.dclx`/DocTags *back in* is not: no such
242274
sources in the corpus to verify against, and not in the requested scope.
243-
- **Legacy APS-text patents.** USPTO now covers the modern `v4x` XML **and** the
244-
2001-era `pap-v15` applications (`pa`) and `PATDOC`/ST.32 grants (`pg`),
245-
including their CALS tables. The one remaining format is the legacy **APS
246-
plain text** (`pftaps`): docling doesn't parse it either — it dumps the raw
247-
file into a single DocLang `<text>` — so matching that reference is a
248-
serialization detail tracked in
249-
[issue #44](https://github.com/docling-project/docling.rs/issues/44), not a parsing gap.
275+
276+
**Now migrated (previously listed here):**
277+
278+
- **Legacy APS-text patents.** USPTO covers the modern `v4x` XML, the 2001-era
279+
`pap-v15` applications (`pa`) and `PATDOC`/ST.32 grants (`pg`) with their CALS
280+
tables, **and** the legacy **APS plain text** (`pftaps`): docling routes it to
281+
its plain-text backend (one DocLang `<text>` dump), and docling.rs reproduces
282+
that serialization byte-exactly — the `.dclx` is a perfect match
283+
([issue #44](https://github.com/docling-project/docling.rs/issues/44), done).
250284

251285
**Minor known gaps (cosmetic, tracked per-fixture):**
252286

PDF_CONFORMANCE.md

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ The heavy table docs improved with the docling-parse **word-cell** grouping now
4444
feeding TableFormer (2305.03393v1 93→32, 2203.01017v2 209→183, 2206.01062
4545
198→164, redp5110 226→173): the parser's per-word cells reproduce docling-parse's
4646
`word_cells` byte-for-byte, so cell-to-grid matching tracks docling more closely.
47-
See "Text reconstruction" below and `PDF_PARSER_NOTES.md` item 6.
47+
See "Text reconstruction" below.
4848

4949
## How the pipeline works
5050

@@ -133,22 +133,28 @@ suppression** (empty low-confidence margin boxes on text pages), and
133133
## Remaining blockers (model-level)
134134

135135
These yield smaller or uncertain gains than the text-layer work already shipped.
136-
137-
1. **TableFormer structure on complex tables.** Multi-row headers / spans on the
138-
big papers (2206, 2203) differ from docling's OTSL prediction; one cell-
139-
structure diff cascades through the padded columns into many row diffs
140-
(2206's ~92 table-row diffs trace to ~4 structure diffs).
141-
2. **Layout classification.** The layout ONNX classifies redp5110's
142-
table-of-contents as a *picture* (docling renders it as a table) and
143-
table_mislabeled's survey as *tables* (docling renders lists/text) — opposite
144-
classifications, not a text problem.
145-
3. **Complex title-page reading order.** Author-block / abstract interleaving on
146-
the academic papers (band reading-order handles the full-width title; the
147-
in-column author/abstract order is still off).
148-
4. **amt fraction double space (text-layer, strict-only).** docling boxes glyphs
136+
Each is tracked as its own issue:
137+
138+
1. **TableFormer structure on complex tables**
139+
([#60](https://github.com/docling-project/docling.rs/issues/60)). Multi-row
140+
headers / spans on the big papers (2206, 2203) differ from docling's OTSL
141+
prediction; one cell-structure diff cascades through the padded columns into
142+
many row diffs (2206's ~92 table-row diffs trace to ~4 structure diffs).
143+
2. **Layout classification**
144+
([#61](https://github.com/docling-project/docling.rs/issues/61)). The layout
145+
ONNX classifies redp5110's table-of-contents as a *picture* (docling renders
146+
it as a table) and table_mislabeled's survey as *tables* (docling renders
147+
lists/text) — opposite classifications, not a text problem.
148+
3. **Complex title-page reading order**
149+
([#62](https://github.com/docling-project/docling.rs/issues/62)). Author-block
150+
/ abstract interleaving on the academic papers (band reading-order handles the
151+
full-width title; the in-column author/abstract order is still off).
152+
4. **amt fraction double space (text-layer, strict-only)**
153+
([#63](https://github.com/docling-project/docling.rs/issues/63)). docling boxes glyphs
149154
with the embedded font's OS/2 typographic metrics, not the PDF descriptor's;
150155
that ~0.3 pt difference makes its justified line insert a *second* space before
151156
the `1⁄4` numerator. Our single-spaced output is the more faithful rendering
152157
(the whitespace-normalized metric credits it); reproducing docling's exact
153158
spacing needs an embedded-font metrics layer, which globally entangles with RTL
154-
geometry. See `PDF_PARSER_NOTES.md`.
159+
box geometry (a trial that fixed one `¼` regressed `right_to_left_01`). See
160+
`MIGRATION.md` §4.

0 commit comments

Comments
 (0)