End-to-End Document Parsing: Visual Compression and Semantic Ordering Explained
A practical guide to end-to-end document parsing, covering why character accuracy alone is insufficient, how visual token compression and semantic ordering shape parsing quality, and how to design trustworthy evaluations and production-ready pipelines.
1. Evaluating Document Parsing Models Requires More Than Character Accuracy
Document parsing involves far more than “transcribing text from an image.” A single page may contain headings, body text, tables, footnotes, formulas, and illustrations, arranged in double columns, spanning columns, or partially rotated. A model must not only recognize characters but also understand which region each piece of content belongs to, how regions relate to each other, and in what order the output should be produced.
Therefore, evaluating end-to-end document parsing should answer at least four questions:
- Can small text, symbols, and characters over complex backgrounds be recognized accurately?
- Can heading hierarchies, table relationships, and paragraph boundaries be correctly recovered?
- Under a limited visual token budget, does the key content remain complete?
- On real-world business documents, is the output stable, verifiable, and maintainable?
A visual token can be understood as a unit in the feature sequence produced by encoding an image—it is not equivalent to a text token. A single visual token may carry information about a patch of the image, and its information density depends on factors such as image resolution, encoding method, and compression strength.
From a technical evolution perspective, two directions deserve attention: one is improving the compression efficiency of visual representations; the other is making the organization of visual information closer to the semantic structure of the document. The first addresses “how to use fewer input resources,” while the second addresses “how to make the input easier for the model to understand.”
2. How End-to-End Architectures Organize Document Information
A typical end-to-end document parsing system can be abstracted as:
Page image → visual feature extraction → feature compression and fusion → cross-modal alignment → text or structured output generation.
The vision encoder converts pixels into features, and the language decoder generates results based on those features and task requirements. In some architectures, a projection module sits between the two, mapping visual features into the representation space the decoder can accept.
Compared with pipelines that separately run text detection, text recognition, layout analysis, and structure recovery, end-to-end approaches can reduce information fragmentation between modules through joint training. For example, the model can use table semantics to help determine cell contents instead of relying entirely on text boxes fixed in an earlier stage.
However, end-to-end does not mean errors disappear naturally. On the contrary, error sources can be harder to localize: a missing table cell might result from lost details during image encoding, an incorrect reading-order inference, or an omission during generation. In engineering practice, observability must therefore be preserved—monitoring only whether the final text reads fluently is not enough.
3. Visual Compression: See Clearly First, Then Reduce Tokens
3.1 The Computational Cost of High Resolution
Text in documents is usually much smaller than the subjects in natural images. Recognizing footnotes, superscripts and subscripts, and dense tables typically requires relatively high input resolution.
Suppose the input image is 1024×1024 pixels and is split into 16×16-pixel patches. The initial grid is:
64×64 = 4096 visual positions.
If all of these positions participate in standard global self-attention, the number of attention relations grows quadratically with sequence length. Note that this describes the scale of the relevant computation in standard attention; it does not mean the total model latency scales strictly in the same proportion.
Therefore, a sensible design usually does not keep all high-resolution features engaged in expensive global interactions throughout. Instead, it preserves local details at the front and progressively shortens the sequence.
3.2 Dividing Work Between Local Perception and Global Understanding
A common design is to use window attention to extract local features first, then perform global modeling on the compressed features.
The local stage focuses on fine details such as character strokes, neighboring text, table lines, and image edges. Window attention restricts the interaction range, controlling the computational cost of high-resolution input.
The global stage focuses on cross-region relationships—for example, the association between body text and footnotes, the reading relationship between left and right columns, and the constraint a multi-row table header places on the data below it.
The essence of this division is placing expensive global computation where the sequence is shorter. However, window partitions can cut through locally continuous structures, so practical designs must also handle information exchange across windows and boundary handling.
3.3 How 2D Downsampling Reduces Sequence Length
Take two convolutional layers, each with a stride of 2. Each layer roughly halves the width and height of the feature map. After two layers, width and height each become one quarter of the original, and the total number of spatial positions drops to one sixteenth.
For a 64×64 feature grid, the transformation looks like:
64×64 → 32×32 → 16×16.
The corresponding sequence lengths are:
4096 → 1024 → 256.
The “16× compression” here refers to the reduction in the number of spatial positions. It does not imply a 16× improvement in file size, memory usage, or inference time. Convolutions themselves require computation, feature channel counts may change, and the system still incurs other costs such as decoding and data transfer.
3.4 The Boundary of Compression Efficiency Is Information Fidelity
Compressed features aggregate information over larger regions, but there is no guarantee that all details are fully preserved.
Decimal points in dense tables, superscripts and subscripts in formulas, and subtle differences between similar characters may all be damaged by overly aggressive compression. Even if the language decoder can generate fluent text, it may not be able to recover visual evidence that has already been lost.
Therefore, the reasonable goal is not “the fewer visual tokens, the better,” but finding a balance among accuracy, structural completeness, latency, and resource consumption. For pages with highly variable text density, options such as multi-scale inputs, local cropping, or adaptive visual budget allocation can be considered, though these strategies add implementation complexity.
4. Semantic Ordering: Making 2D Pages Suitable for Sequential Generation
4.1 Raster Order Is Not Reading Order
Images are typically organized as a 2D grid, while generative decoders produce output token by token. There is an inherent mismatch between the two.
Consider a double-column document: simply scanning row by row from left to right may interleave content from the two columns. Headings spanning columns, side notes, and page-bottom footnotes add further difficulty.
This shows that even when textual features are preserved well enough, an unreasonable sequence organization forces the decoder to spend extra capacity recovering logical relationships.
4.2 What Problem Should Semantic Ordering Solve?
The goal of semantic ordering is to combine page content, region relationships, and positional information so that related visual representations form an organization more favorable for parsing. For example, keeping content within the same paragraph coherent, associating table headers before processing the corresponding data, or linking footnotes to their reference positions.
However, “dynamic reordering” should not be simplistically understood as applying a single fixed sort to all visual tokens. Concrete implementations may involve explicit permutations, hierarchical region organization, learnable queries, or attention constraints—different mechanisms altogether. Without clear architectural evidence, one cannot infer which implementation a model uses merely from a concept’s name.
4.3 Causality and Visual Understanding
Causal language decoding typically means: when generating the current position, the model can only access previously generated text and cannot see future output. Whether the vision encoder can observe the entire page at once is a separate question.
A system can perfectly well use global visual information to understand the page first, then generate text in a causal manner. So when discussing “causal flow of vision,” it is necessary to clarify whether the causal constraint applies to visual representations, the query sequence, or the text decoding process. Mechanisms at different levels should not be conflated.
From an engineering evaluation standpoint, the more important question is whether this organization reduces cross-column serialization, duplicated paragraphs, and table misalignment—not whether the name itself sounds novel.
5. Why Compression and Ordering Need Co-Design
Visual compression mainly addresses resource efficiency; semantic ordering mainly addresses structural organization. Neither replaces the other.
If compression is applied too aggressively first, local characters and region boundaries become blurry, making it difficult for subsequent ordering to determine which contents belong to the same paragraph. Conversely, even if layout relationships are judged correctly, retaining too many redundant features still leaves the decoder with a heavy input cost.
A more reasonable approach considers three levels jointly:
- Local level: preserve fine-grained evidence such as characters and symbols.
- Region level: represent the structure of paragraphs, tables, images, and headings.
- Page level: establish cross-region reading order and semantic links.
At the same time, the compressed sequence should retain sufficient positional cues. Otherwise, the model may know “what content exists” but cannot reliably answer “where the content is located” or “how the pieces relate to each other.”
6. Designing Trustworthy Evaluations
6.1 Evaluate Content Accuracy and Structural Accuracy Separately
Character error rate measures insertions, deletions, and substitutions, but it cannot fully reflect whether table structure is correct. Two outputs may contain identical text yet carry entirely different business meanings because their cell relationships differ.
Evaluations therefore need to cover text accuracy, paragraph completeness, reading order, table row-column relationships, formula representation, and field associations simultaneously.
6.2 Performance Figures Must State Their Conditions
“Fewer input tokens” cannot be directly translated into “fastest end to end.” Total time also includes image preprocessing, visual encoding, result generation, and post-processing. Long documents produce more output text, and the decoding stage may become the main bottleneck.
A fair comparison requires at least unifying or clearly documenting:
- Input resolution and cropping strategy;
- Hardware environment and numerical precision;
- Batch size and concurrency;
- Output format and generation length;
- Whether preprocessing, retries, and post-processing time are counted.
Reporting only average latency is also insufficient. High-percentile latency and the retry cost of failed samples should be examined as well.
6.3 Test Capability Boundaries with Hard Samples
Test sets should include low-quality scans, tilted pages, dense tables, multi-column layouts, mixed languages, and unusual symbols, with results reported separately by document type.
Pay special attention to outputs that “look plausible but are unfaithful to the original image”—for example, hallucinating unclear digits, dropping repeated rows, or merging footnotes into body text. Such errors are often harder to detect than explicit parsing failures.
7. Practical Recommendations for Production Environments
First, establish input quality checks. When pages are severely blurred, incompletely cropped, or abnormally oriented, they should be corrected or flagged for recapture first, rather than handing irrecoverable information loss to the model.
Second, allocate resources according to document density. Simple single-column pages can use a lighter processing path, while pages with dense tables or tiny text may require higher resolution or supplementary local recognition.
Third, apply structural and business validation to outputs. Structured results should be checked for field types, required fields, and format validity; financial documents can additionally be checked for consistency between line items and totals. Note that rules can only catch some contradictions—they cannot replace verification against the original image.
For high-risk fields such as amounts, dates, and reference numbers, retain the corresponding page and region information, and perform secondary recognition or human review when necessary. Model-generated explanations should not be treated as reliable evidence; the verifiable original image is the basis for traceability.
Finally, establish a continuous regression process. Every time resolution, compression ratio, prompt templates, or model versions are adjusted, re-check accuracy, structural completeness, latency, and resource consumption on a fixed sample set, so that local optimization does not damage performance on other document types.
8. Conclusion: Shift Evaluation Focus from Model Names to Capability Loops
The key advance of end-to-end document parsing is not merely reading more text with fewer visual tokens. It is preserving visual evidence more completely under limited resources, organizing page semantics more coherently, and producing results that business systems can validate.
Visual compression determines whether a system can handle high-resolution inputs economically; semantic ordering determines whether 2D content can be smoothly converted into linear expression; and engineering validation determines whether the results are trustworthy.
A truly valuable solution must be accurate, stable, efficient, and traceable at the same time—judgments should never rest on a single compression ratio, one benchmark ranking, or a handful of demo examples.
