You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(tableformer): pixel-exact preprocessing — live OTSL now byte-exact vs docling
Reproduces docling's TableFormer preprocessing pipeline exactly, so the live Rust
inference now emits the SAME OTSL token sequence docling does (verified on
2305v1-pg9: 54 tokens, 6×8, identical; and all 5 tables of 2206.01062: matching
token counts). The model is hyper-sensitive to input pixels; four things had to
match byte-for-byte:
- Render: docling renders at 1.5× the target scale and downsamples (pypdfium2 →
PIL BICUBIC). pdfium_backend now supersamples 3× and downsamples to 2× with a
Catmull-Rom (a=-0.5) cubic — the same kernel. Cuts page-bitmap diff vs docling
from 8.7% of pixels (max 185) to 2.0% (max 12).
- Page→1024px: cv2.INTER_AREA. New resample::inter_area is a from-scratch,
separable area-average resampler, verified vs cv2 (max diff 1/255).
- Crop→448: cv2.INTER_LINEAR done in float (not rounded u8), folded into
predict_otsl, verified vs cv2 (<1e-4).
- Tensor layout: docling transposes (2,1,0) → the model wants (C, W, H), not
C,H,W. This transpose alone was scrambling rows/cols.
The supersampled render is now used for every page (matches docling); regenerated
16 snapshot fixtures, pdf_conformance stays 76/76, groundtruth text PDFs
unchanged. Adds the dump_stages example for render-parity debugging. Next:
OTSL→grid with spans, cell-text matching, serialization, pipeline wiring.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0 commit comments