INDUSTRY USE CASES

Page Stream Segmentation: Separating Mixed Scanned Documents

By Sygnet Research, checked before publication

Key takeaways

  • Page stream segmentation (PSS) is a binary decision per page ("new document" vs "same document"), and treating it as anything else usually overcomplicates the pipeline.
  • The naive baseline of one page per document already yields a boundary recall of 1.0 and a precision of .63 on the OpenPSS data, so report precision/recall separately and never trust raw accuracy.
  • Fine-tuned small decoder LLMs on previous-page + current-page OCR reach page F1 of 0.987 and document-level F1 of 0.967 (Mistral-7B-FT), while the same model zero-shot collapses to page F1 0.575.
  • Split first, classify second, extract third: a single-pass "extract everything from the folder" prompt destroys the document-level provenance your auditors and your retrieval layer both need.

What exactly is the problem when a scanned folder contains mixed documents?

The task is called page stream segmentation: retrieving the boundaries that separate source documents given a consecutive stream of pages (for example, sequentially scanned PDF files). A 40-page KYC folder with an invoice, a Kbis extract, a signed contract and three proofs of address is not one document; it is four to six documents concatenated by a scanner that had no idea what it was feeding. If you send that straight to an extraction model, every downstream field becomes ambiguous: whose SIREN, which invoice total, which signature date.

The research framing has been stable for a decade. PSS is the task of automatically separating a stream of scanned images into coherent multi-page documents, and two families of approaches exist: rule-based versus machine learning-based. Rule-based systems rely on hand-crafted features from "descriptors" to decide whether a page continues the predecessor sequence or starts a new document. They still have a place (separator sheets, barcode pages, Factur-X XML attachments), but in real French back-office folders the separators are missing far more often than they are present.

A 40-page KYC folder is not one document; it is four to six documents concatenated by a scanner that had no idea what it was feeding.

How should the pipeline be staged?

Four stages, in this order: normalize, segment, classify, extract. Normalization means rasterizing at a fixed DPI, deskewing, binarizing and running OCR once, then caching the result. OCR is the expensive part and you will reuse the same text for segmentation, classification and extraction, so pay for it a single time. The 2017 CNN pipeline did exactly that: pages are OCRed, images OTSU-binarized and resized to 224×224, text tokenized and stemmed with digits replaced by #, then text-CNN and image-CNN representations feed an MLP that decides whether each page begins a new document.

Segmentation comes before classification for a practical reason: a page-type classifier applied page by page will happily label page 3 of a contract as "annex" and fragment the document. Once boundaries exist, classify the segment, not the page, by voting over its pages or by reading only the first page (which carries the logo, header and reference numbers). Then route each segment to the right extraction schema. If you also constrain the extraction output, constrained decoding keeps the JSON valid per document type instead of one bloated union schema.

Which model should do the boundary detection?

Start with a text + layout model over a two-page window, and only reach for a VLM if your scans are visually distinctive and OCR-poor. The evidence on modality fusion is genuinely mixed. Wiedemann and Heyer found accuracy and kappa improve significantly when image and text features are combined in one MLP, reaching circa 93% on the German dataset and more than 91% on the English data. But the 2024 benchmark pushes back: DiT, a vision-only encoder, is strongest among the encoders, with LayoutLMv3 and LiLT underperforming it and LiLT underperforming RoBERTa, leading the authors to state that added modalities are not a guaranteed win unless architecture and training regimes are aligned.

Context window matters more than modality for most folders. The 2017 method copies predecessor features and concatenates a three-page text window; the 2024 LLM system uses previous page plus current page. A BERT baseline trained on Tobacco800 shows the gain plainly: single-page accuracy 0.9266 / kappa 0.8506 versus prev-page 0.9344 / kappa 0.8667.

ApproachReported resultContext usedPractical cost
One page = one document (baseline)recall 1.0, precision .63 (OpenPSS)nonezero
Multimodal CNN (text + image)up to 95% in-house, up to 93% public3-page text windowtraining + 2 CNNs
BERT, previous-page inputacc 0.9344, kappa 0.86672 pagesfine-tune, CPU-servable
Fine-tuned Mistral-7B (TABME++)page F1 0.987, doc F1 0.9672 pages OCRsingle H100, LoRA + 4-bit
Zero-shot LLMpage F1 0.575 (Mistral-7B-ZS), 0.859 (GPT-4o-ZS)2 pages OCRAPI only

The zero-shot row is the one to internalize. Prompting a frontier model to "tell me where the documents start" is a demo, not a pipeline.

How do you measure segmentation quality properly?

Measure page-level precision and recall for the boundary class, plus a document-level metric that only credits perfectly reconstructed documents. Accuracy alone is misleading because boundaries are rare: in WooIR, on average only 28% of each stream consists of transitions. Kappa was introduced in this literature precisely for that reason, since it reflects the uneven same-document / new-document class distribution.

Document-level scoring is where systems separate. On TABME++, the gap between page and document F1 for the strongest model is roughly two points (0.987 page vs 0.967 document) and widens sharply for weaker ones: Phi-3-mini-FT reaches page F1 0.973 but document F1 0.933. One missed boundary ruins two documents.

Also budget for label noise in your own gold set. Wiedemann and Heyer report that some false positives carry genuine textual and visual characteristics of document beginnings, hinting at annotation errors in the gold standard, while others involve complex layouts, and that attachments are sometimes treated as part of the main document and sometimes as single-page documents in their own right. Write that rule down before annotating, not after. Our extraction accuracy evaluation checklist covers the same discipline one layer down.

What breaks in production, and how do you contain it?

Three recurring failures: blank and separator pages, duplicate scans, and documents interleaved rather than concatenated. Blank-page removal before segmentation is cheap and removes a whole class of false boundaries. Duplicates (the same Kbis scanned twice) should be caught by perceptual hash plus text hash, otherwise your segment classifier emits two "valid" Kbis and your reviewer arbitrates.

Interleaving is the nasty one. Sequence models assume contiguity, and clustering approaches exist partly for that reason: the hypothesis is that pages from one document are similar to each other and different from pages in other documents, something difficult to incorporate in classification-style approaches. In practice, run agglomerative clustering as a second-opinion signal and flag disagreements for human review rather than silently overriding the sequential model.

Finally, keep provenance. For each extracted field, store the source document id, the page range inside the original PDF, and the boundary confidence. Without it you cannot explain an extraction to an auditor, and your retrieval layer will mix clauses from a contract with lines from an invoice, the exact failure mode described in our analysis of why 95% OCR accuracy still fails RAG. Sygnet runs splitting, classification and extraction as separate, individually auditable stages for this reason.

One missed boundary ruins two documents, which is why page-level F1 flatters systems that document-level F1 exposes.

FAQ

Should I fine-tune or use a zero-shot LLM for document splitting?

Fine-tune. The TABME++ results are unambiguous: fine-tuned decoders reach page F1 0.987 while Mistral-7B zero-shot sits at 0.575 and GPT-4o zero-shot at 0.859 on a 10% test subset. Cost is not prohibitive either, since a single H100 suffices for fine-tuning 4–7B decoders with LoRA and 4-bit quantization. If you have no labels, start with the previous-page BERT baseline and label the 500 hardest boundaries.

How much training data do I actually need?

Less than people assume, if your document mix is narrow. The 2024 LLM pipeline reports strong validation metrics after approximately 5,000 updates with early stopping around 20,000, and the classic archival experiment trained on 80 binders containing 17,376 pages, testing on 20 binders with 5,095 pages. For a French back-office mix (invoices, Kbis, contracts, proofs of address), a few hundred annotated streams typically gets you past the baseline. Whether to train at all is the subject of our build vs buy analysis.

Can I skip splitting and just ask the model to extract everything?

Only if folders are short and homogeneous. Beyond roughly ten pages you lose per-document provenance, you cannot apply a type-specific schema, and duplicate entities (two addresses, three dates) get merged without any trace of which document they came from. Segment-then-extract also lets you apply different review thresholds per document type, which is how fraud checks on Kbis extracts stay separable from invoice validation.

One email when we publish something worth your time.