A document is more than a string of words. Pages, columns, headings, tables, captions, footnotes, boxes and whitespace tell a reader how the text is organised. Document layout tokenisation is the process of turning that spatial organisation into model-ready structure instead of flattening everything into one undifferentiated sequence.
This matters because a document can contain every correct word and still be represented incorrectly if the reading order, table relationships or section hierarchy are lost.
This article continues the eduKateSingapore Representation and Tokenisation series.
The Document Representation Route
PHYSICAL / DIGITAL DOCUMENT → PAGE IMAGE OR PDF OBJECTS → OCR / TEXT EXTRACTION → WORD / LINE / BLOCK BOXES → READING ORDER → HEADING / TABLE / LIST / CAPTION STRUCTURE → LAYOUT TOKENS + TEXT TOKENS → DOCUMENT MODEL → RETRIEVAL / EXTRACTION / QUESTION ANSWERING → SOURCE PAGE RETURN
1. Pages Are Spatial Containers
A page gives text a two-dimensional coordinate system. The same sentence placed in a title, footnote or side note can play different roles even if the words are identical.
Page position is therefore semantic metadata.
2. OCR Produces Text, Not Full Document Meaning
Optical character recognition can recover characters and words from scanned images. That is only one layer of the document.
A complete document representation also needs where those words appeared and how they were grouped.
3. Bounding Boxes Turn Text Into Spatial Tokens
OCR systems often attach a rectangle to each word, line or block. The box records where the text appeared on the page.
Text + bounding box is a richer token than text alone.
4. LayoutLM Made Text + Layout Joint Modelling Explicit
LayoutLM showed how text and two-dimensional layout can be learned together for document image understanding. Later work such as LayoutLMv2 added stronger interaction among text, layout and visual features.
The central representation idea is durable: document words are more useful when the model knows where they live.
5. Reading Order Is an Inference Problem
Single-column prose often reads top to bottom. Multi-column papers, invoices, brochures and magazines do not.
A system must infer which block comes next.
6. Wrong Reading Order Creates False Sentences
If two newspaper columns are interleaved line by line, every word may be correct while the reconstructed article becomes nonsense.
Ordering is part of fidelity.
7. Headings Define Scope
A paragraph under “Exceptions” should not be interpreted as the main rule. A paragraph under “Methods” belongs to a different discourse role from one under “Results”.
Heading hierarchy preserves scope.
8. Heading Levels Are Hierarchical Tokens
Title, section, subsection and sub-subsection form a tree over the document.
The text sequence becomes more faithful when those hierarchical relationships remain attached.
9. Font Size Is Evidence, Not Truth
Large bold text often indicates a heading, but decorative design can use the same style for emphasis or marketing.
Layout classification should combine typography, position and textual context.
10. Whitespace Can Be Structural
Blank space separates columns, sections, cards and table groups. Removing whitespace before layout analysis can collapse distinct blocks.
Absence can be part of document grammar.
11. Lines Are Intermediate Units
Characters form words; words form lines; lines form blocks. The correct unit for a task can be word, line or paragraph.
Document tokenisation is naturally hierarchical.
12. Text Blocks Are Operational Chunks
A text box or paragraph block can be used as a retrieval unit. This keeps nearby words together and often preserves local meaning better than fixed-length token chunks.
Layout-aware chunking can therefore improve retrieval quality.
13. Tables Are Not Flat Text
A table stores relationships among headers, rows and columns. Reading cells sequentially can detach values from their labels.
Table structure should survive extraction.
14. Row and Column Headers Are Context Tokens
The value 82 means little until the system knows which row and column it belongs to.
Cell meaning emerges from value + coordinates + headers.
15. Merged Cells Create Hierarchy
A header spanning several columns applies to multiple child columns. Flattening merged cells can erase that parent-child relationship.
Complex tables need structural parsing, not OCR alone.
16. Lists Encode Order and Membership
Bullets indicate membership. Numbered lists can indicate order, sequence or priority.
List markers should not be treated as disposable punctuation if the structure matters.
17. Nested Lists Encode Parent–Child Relationships
Indentation and numbering levels can create a hierarchy of claims or steps.
Flattening nested lists changes their logic.
18. Forms Contain Label–Value Relationships
A form field can contain a label on the left and an entered value on the right. Their spatial relation tells the system that they belong together.
Form understanding is a relation-extraction problem over layout tokens.
19. Checkboxes Are Visual State Tokens
A checked box, empty box or radio button carries meaning that may not appear in OCR text.
Visual document understanding needs non-text tokens too.
20. Signatures Are Layout-Bound Evidence
A signature’s position can determine which declaration it belongs to.
Moving the signature image without its surrounding layout can destroy evidential context.
21. Captions Bind Text to Figures
A caption explains an image, chart or table. Its physical proximity and numbering connect it to a visual object.
Caption extraction should preserve the attachment relation.
22. Footnotes Have Different Authority From Main Text
Footnotes can qualify, cite or contradict the main sentence.
A flat extraction that inserts footnote text into the middle of a paragraph can produce false reading order.
23. Page Headers and Footers Are Repeating Noise or Useful Metadata
Page numbers and running headers can be removed for semantic retrieval, while legal notices or document IDs may need preservation.
Boilerplate classification is task-relative.
24. Repetition Can Help Detect Boilerplate
A phrase appearing in the same page position across every page is likely a header or footer.
Cross-page context helps classify layout roles.
25. Page Numbers Are Navigation Tokens
They may not matter to semantic content, but they are essential for citation and world return.
Source-page identity should survive even when page numbers are excluded from model prose.
26. Multi-Page Tables Need Continuation Logic
A table can begin on one page and continue on the next with repeated or omitted headers.
Page boundaries should not automatically terminate table identity.
27. Hyphenation Across Line Breaks Needs Repair
Printed documents can split one word across lines with a hyphen. OCR may preserve the hyphen literally.
Dehyphenation is useful when the hyphen is typographic and harmful when it belongs to the word.
28. Reading Order Can Be a Graph
Complex layouts are better represented by relations such as above, below, left_of, contains and next rather than one fixed sequence.
This connects document layout to Graph Tokenisation.
29. Layout Coordinates Need Normalisation
Documents come in different page sizes and resolutions. Bounding boxes can be normalized to a common coordinate range so models can compare positions.
The normalization should preserve relative geometry.
30. Rotation Changes Coordinate Interpretation
Scanned pages can be rotated or skewed. A text box at the “top” of a rotated page may be physically elsewhere in raw image coordinates.
Orientation correction belongs before reliable layout tokenisation.
31. Handwriting Introduces Another Recognition Layer
Forms, notebooks and exams can mix printed text with handwriting.
Handwriting recognition has different error patterns and should preserve confidence separately from printed OCR.
32. OCR Confidence Is Part of Provenance
A word recognized with 99% confidence and one recognized with 55% should not be treated as equally certain evidence.
Confidence can guide human review and retrieval weighting.
33. OCR Errors Can Masquerade as Factual Errors
If 1 is read as I or 0 as O, downstream language reasoning can be perfectly coherent around a false source string.
Diagnose the earliest failing layer.
34. Document Chunking Should Respect Layout
Fixed 500-token chunks can split a table from its heading, a definition from its exception or a figure from its caption.
Layout-aware chunking preserves document structure before applying token budgets.
35. Retrieval Should Carry Page and Box Provenance
When a model retrieves a paragraph, it should know which document, page and region produced it.
This enables exact source return and visual verification.
36. Visual Verification Is Stronger Than Extracted Text Alone
For high-stakes tables, contracts or scanned evidence, returning to the page image can reveal layout meaning that extraction missed.
World return should reach the document, not stop at an intermediate OCR string.
37. Digital PDFs Can Contain Hidden Text Layers
A PDF can display one visual page while storing text objects in another order. Copy–paste order may therefore disagree with visual reading order.
Document parsing should compare object structure with rendered layout.
38. Accessibility Structure Can Be Valuable Metadata
Tagged PDFs and semantic HTML can encode headings, lists and table roles explicitly.
When reliable, semantic tags can reduce the need to infer layout from pixels.
39. But Tags Can Be Wrong
Generated or poorly authored documents can contain incorrect accessibility tags.
Explicit structure is evidence, not infallible truth.
40. The Document Layout Tokenisation Audit
- Is the source scanned, digital-born or mixed?
- What OCR engine and confidence data are available?
- Are word, line and block bounding boxes preserved?
- How is reading order inferred?
- Are headings and section levels represented?
- Are tables preserved as row–column structures?
- Are lists and nesting retained?
- Are forms represented as label–value relations?
- Are figures connected to captions?
- How are headers, footers and footnotes treated?
- Do page numbers remain available for citation?
- Are rotation and skew corrected?
- Does chunking respect layout boundaries?
- Can every extracted token return to page and box coordinates?
- Can high-stakes claims be verified against the rendered source?
41. What Students Should Remember
- Documents are spatial as well as textual.
- OCR recovers words but not full layout meaning.
- Bounding boxes make position part of the token.
- Reading order must be reconstructed.
- Headings, tables, lists and forms carry hierarchy.
- Fixed text chunks can destroy document relationships.
- Provenance should include page and region.
- World return should reach the original document view.
42. The Deep Principle
A document says things through words and through placement. Flattening layout into text throws away one of the languages the document uses.
Document intelligence begins when the system can answer not only “what words are here?” but also “where are they, what owns them, what follows them and what visual structure makes them mean this?”
Continue the Representation & Tokenisation Series
- Spatial Tokenisation | How Coordinates, Grids, Regions and Places Become Model-Ready Units
- Biological Sequence Tokenisation | How DNA, RNA and Proteins Become Model-Ready Units
- Workflow Tokenisation | How Processes Become Steps, Actions, States and Decisions
- Canonical owner: World Representation & Cognitive Tools