00-START-HERE · 01-READING-ROUTES · 13_chunking_and_granularity · 15_approximate_nearest_neighbor_search This chapter explains why table cells and document blocks lose meaning when they are flattened, how table and layout encoders restore structure, and which costs, invariance limits, metrics, and layout priors matter in a Retrieval-Augmented Generation (RAG) interview.
TL;DR
- A table stores meaning in the triple of row key, column header, and cell value. A fixed text cut can separate those parts while leaving a chunk that looks healthy.
- Detect tables before splitting. Keep a fitting table atomic. For an oversized table, split only between rows and repeat the header in every fragment.
- TAPAS repairs row-major flattening with additive column, row, and rank lookups. Its absolute row and column fields also make equivalent renderings look different.
- TableFormer removes global, row, and column position IDs. It keeps within-cell order and adds 13 structural relation biases to attention.
- Accuracy alone can hide order sensitivity. Variation percentage (VP) counts paired answer flips and stays visible when correct-to-wrong and wrong-to-correct flips cancel.
- Clean extraction is not correct reading order. Sorting blocks instead of lines raises the coherent span in the worked two-column page from 11 tokens to 495.
- Layout rules are corpus assumptions. Reading direction, full-height gutters, relative type size, emphasis rarity, and the rendered table’s key column must be tested on each domain.
The story
Imagine a warehouse that receives crates of financial reports, manuals, forms, and tables. The search system is the shipping desk. It must find the right package and send enough contents to an answer station. A prose paragraph arrives as one labeled crate. Its words carry most of its meaning. A table arrives differently. The header is the crate manifest, the first column is the pallet label, and each numeric cell is one loose item. If a clerk cuts the shipment after a fixed number of tokens, the manifest can stay upstairs while most pallets move downstairs. The downstairs pallets still look orderly. Every row has aligned numbers and a region code. Yet the number no longer says whether it is revenue, gross margin, operating expense, or net income. The shipping desk matches the query words to the upstairs manifest and sends the labeled crate without the requested row. The first repair is operational. The receiving clerk marks each table before the cutting line. Small tables stay whole. Tall tables split only between rows, and every pallet receives a copied manifest. This costs more labels and more packages, but every number remains self-describing. The warehouse then installs a table scanner. TAPAS reads each item with token, sequence position, segment, column, row, and numeric rank fields. The scanner understands the grid, but it also stamps absolute aisle and shelf numbers onto the items. Moving an unchanged pallet to another aisle changes its representation. TableFormer changes the stamps. It removes global aisle and shelf numbers. It records relations such as same row, same column, and header-to-cell. A harmless pallet swap leaves those relations unchanged. The warehouse now measures paired answer flips, because aggregate accuracy can stay flat while many individual shipments change. Documents create a second kind of warehouse error. A two-column page is two vertical racks. A line-level clerk alternates one shelf from the left rack and one from the right. Every word remains legible, yet each outgoing box mixes unrelated specifications. A block-level clerk empties one rack before moving to the next. For long documents, the warehouse uses two floors of supervision. A lower encoder reads inside each block. A higher encoder reads block summaries, block types, order, adjacency, and image slots. The hierarchy makes block structure representable and reduces the attention pairs in the worked example by times. The final lesson is that warehouse geometry is not universal. English reports, Arabic contracts, vertical Japanese manuals, journals, slide decks, and spanning figures require different routing rules. A good system writes those priors down, tests them on held-out domains, and keeps relational invariance in the encoder while keeping rendering conventions in the parser.
Decoder table
| Technical term | Plain-English meaning | Why it matters |
|---|---|---|
| Retrieval-Augmented Generation (RAG) | A system that retrieves source material before a model answers | Ingestion decides whether the needed structure survives long enough to be retrieved |
| Semi-structured data | Prose and tables interleaved in one source | Meaning can live in position even when the extracted text looks normal |
| Structured data | Rows or triples governed by an explicit schema | Exact predicates, joins, and aggregation are available without similarity ranking |
| Unstructured data | Prose, transcripts, or tickets whose meaning lives mainly in tokens | Standard chunkers and embedding models are designed around this case |
| Large Language Model (LLM)-generated data | Synthetic questions, summaries, or propositions written for retrieval | It provides query-like wording but moves provenance responsibility to the system owner |
| Asia-Pacific (APAC), Americas (AMER), and Europe, Middle East, and Africa (EMEA) | The three region labels printed in the worked table | They identify rows but do not identify the meaning of each numeric cell |
| Third quarter 2025 (Q3-25) | The period label used in the worked table | It is query vocabulary that can remain with the header while a value is cut away |
| Gross margin (), operating expense (Opex), and net income (NI) | Abbreviated metric headers in the worked table | They give the numeric cells their column meaning |
| Table region | A two-dimensional page area identified as a table before linearization | It must be protected before a generic text splitter runs |
| Row key | The cell that identifies a row, usually in the first rendered column | A value needs its row key and column header to be interpretable |
| Column header | The label that names an attribute | Numeric cell text is weak retrieval material without this label |
| Row-major serialization | Printing the header, then every row from left to right | It places same-column cells far apart in the token sequence |
| Orphan row | A row separated from the header that gives its values meaning | Orphan rows can be fluent, retrievable, and semantically unusable |
| Atomic table | A table kept as one retrieval unit | It avoids header severance when the table fits the budget |
| Header repetition | Copying column labels into every row group or row serialization | It makes each table fragment self-describing |
| Retrieval surrogate | A short row-level or table-level description used for search | It decouples what the system embeds from the larger payload it injects |
| Table payload | The original table region returned after a surrogate matches | It preserves full context for comparison questions at a prefill cost |
| Lookup question | A query that names one row and one column | A header-repeated row can answer it |
| Aggregation question | A query comparing or combining rows, such as a maximum, total or count | One isolated ordinary row cannot generally establish a global aggregate; use enough evidence or an executor |
| Structured Query Language (SQL) | A language for exact operations over structured tables | It is the route for compound selection and aggregation when a schema is worth maintaining |
| Best Matching 25 (BM25) | A sparse term-matching ranker | It can rank the header chunk first because the query vocabulary occurs there |
| Dense Passage Retrieval (DPR) | A method label printed in the TAPAS illustration | It is one cell value in the exact source figure, not a new architecture introduced by this chapter |
| WordPiece | The subword token unit used in the stated table-encoder examples | Cell length in WordPiece tokens determines the row budget |
| Bidirectional Encoder Representations from Transformers (BERT) | The base encoder architecture used by TAPAS | Its learned position table has rows in the stated base configuration |
| TAPAS | A table model that keeps the BERT transformer unchanged and adds table fields at input | It restores grid coordinates and numeric order with little parameter cost |
| Token identifier (ID) | The lookup key for a token’s lexical identity | It stays unchanged under a row permutation |
| Position ID | The token’s absolute place in the flattened sequence | It changes when the printed row or column order changes |
| Segment ID | The field separating query tokens from table tokens | TAPAS uses segment for the query and the other segment for the table |
| Column ID | The absolute printed column assigned to a table token | It restores coordinates but introduces column-order sensitivity |
| Row ID | The absolute printed row assigned to a table token | It changes every token vector in swapped rows |
| Rank ID | Value-derived rank within a numeric or date column | Stable under row permutations only if parsing and tie handling do not depend on printed order |
| Additive input embedding | A sum of learned lookup vectors before the first transformer layer | TAPAS changes representation rather than transformer capacity |
| Silent truncation | Dropping tokens beyond the encoder window without making the remaining sequence invalid | A maximum can be computed over visible rows when the source had |
| Verbalization | Rewriting cells as prose such as header is value | It avoids a custom encoder but repeats structure as costly content |
| Weak supervision | Training from final answers instead of explicit logical forms | TAPAS learns cell selection and one aggregation operator from answer-level signals |
| Cell-selection head | The output that chooses a set of cells | It does not express an arbitrary multi-step query plan |
| Sequential Question Answering (SQA), TabFact, and | A table question-answering benchmark, a table fact-verification benchmark, and the metric-column label in one source example | SQA provides the to comparison, while SQA and TabFact receive permutation tests |
| Relational invariance | The requirement that equivalent row or non-key column permutations preserve the answer | It separates data meaning from rendering order |
| Permutation orbit | All row and column orders that denote the same relation | Its factorial size makes finite augmentation a weak guarantee |
| TableFormer | A table encoder using relation-aware attention | Architectural equivariance needs compatible retained inputs and masks; an invariant readout preserves answers |
| Within-cell position | Token order that resets at each cell boundary | It preserves real word order such as Palo Alto |
| Structural relation | A pair type such as same cell, same row, same column, or header-to-cell | It survives harmless row and column permutations |
| Attention bias | A learned scalar added to an attention logit for a relation type | It encodes structure with very few parameters |
| Variation percentage (VP) | The share of paired queries whose answer flips after a label-preserving perturbation | It exposes instability that aggregate accuracy cancels |
| Marginal accuracy | Accuracy measured separately on original and perturbed sets | Equal totals do not imply the same questions were answered correctly |
| Conditional invariance | A symmetry guarantee conditional on the full retained representation and computation | Same-cell inclusion is necessary but not the only condition; truncation can break it |
| Optical character recognition (OCR) | Conversion of a scanned page into text | High character confidence does not validate reading order |
| Raster order | Sorting page lines by vertical position and then horizontal position | It interleaves two columns with overlapping line heights |
| Reading order | The sequence in which document blocks should be consumed | Correct tokens in the wrong order produce useless chunks |
| Layout block | A typed page region such as header, paragraph, list, table, figure, or image | Block identity gives a representation level for document structure |
| Bounding box | The coordinates surrounding a page block | It supports ordering, citation, and layout features |
| Block adjacency | The relation between neighboring blocks independent of their token lengths | A flat sequence makes this relation drift with block size |
| Layout-Aware Multimodal Pre-training (LAMPreT) | A two-level document encoder with text and image blocks | It models semantics inside blocks and relations among blocks |
| Convolutional neural network (CNN) encoder | The image encoder feeding image blocks into the upper sequence | It gives non-text blocks a slot beside text blocks |
| Masked language modeling | Predicting hidden tokens from their context | Alone, it can ignore the upper layout level and solve each block locally |
| Image-text matching | Detecting an image swapped from another document | It is one of the two low-level LAMPreT objectives |
| Block-ordering prediction | Detecting whether two block summaries were swapped | It directly punishes layout blindness |
| Image fitting | Selecting the correct candidate for a masked image block | It tests cross-modal block association |
| Block filling | Selecting the correct candidate for a masked text block | It tests document-level text block association |
| Mean reciprocal rank (MRR) | A rank metric that rewards an earlier correct result | The stated LAMPreT evaluation uses it for block-level tasks |
| and | Whether the correct item appears among the first or results | The source uses for block evaluation and for layout transfer |
| LayoutLM | A flat encoder that adds normalized two-dimensional box coordinates | It fits single-page geometry but does not create a block sequence |
| Two-level hierarchy | Content attention inside blocks plus attention across summaries | Compare attention pairs, not a guaranteed whole-model speedup; all block lengths must fit the lower stage |
| Layout prior | An assumed map from geometry or typography to meaning | Every linearizer supplies one in code or learned weights |
| Manhattan layout | Axis-aligned blocks separated by coherent whitespace | Recursive X-Y cut works when its full-height valleys exist |
| Recursive X-Y cut | Alternating projection cuts at the widest zero-ink valley | It discovers columns before ordering their blocks |
| Full-height gutter | A vertical whitespace band with zero ink across all lines in a region | It separates columns when ordinary word spaces disappear under projection |
| Non-Manhattan layout | A page with spanning elements or geometry that breaks full-height valleys | X-Y cut can fail and force a bad fallback order |
| Page-relative type ratio | A block’s size divided by the character-weighted modal size on the page | It transfers across journals, slides, and contracts better than an absolute point threshold |
| Emphasis rarity gate | Treating bold as meaningful only while bold text is rare | Bold cannot mark a useful minority when most of the page is bold |
| Leftmost-key prior | The convention that the first rendered column identifies each row | It belongs in linearization and chunk metadata, not relational index embeddings |
| Script-aware sort | Choosing block order from writing direction | Left-to-right, right-to-left, and vertical scripts require different order functions |
| Held-out domain | A document category absent from parser training or rule tuning | It reveals learned or coded layout priors that do not transfer |
| Table symbols , , , , and | The table, row count, column count, column- header, and cell at row and column | They define the row-key, header, and value triple, while counts equivalent row and column permutations |
| Overloaded symbols , , , , and | is chunk size, cell length, or layer count where locally defined. The others are overlap, tokens per cell, row or sequence count, and header distance | They expose fit, orphaning, and compute only when their local definitions stay explicit |
| TAPAS symbols , , , , , , , and | Query length, window, vector width, sequence position, row ID, column ID, rank ID, and maximum fitting rows | They price fit and separate content-derived fields from printed-order fields. In retrieval cost, instead counts returned chunks |
| , , , , , and | Learned token, position, segment, column, row, and rank lookup tables | Their sum is the complete stated TAPAS input intervention |
| , , , , , , and | Query and key projections, head width, an attention logit, a structural pair type, its learned bias, and a row permutation | They show how TableFormer moves table structure from token vectors into permutation-stable attention |
| and | Correct-to-wrong and wrong-to-correct fractions | Accuracy change is , correctness flips ; answer VP also counts other changed outputs |
| , , and in the hierarchy | Block count, average tokens per block, and total tokens | They compare flat attention with hierarchical attention |
| and | A component loss and its weight | Reduction conventions and gradient scales matter; equal ranges are not sufficient for balanced optimization |
| , , , , , and | Block sort coordinates and bounding-box corners | They encode page geometry but do not by themselves define reading order |
| , , and in typography | A block’s type size, the page’s character-weighted modal size, and the bold-token fraction | They make heading and emphasis rules relative to the page |
Core mechanics
Mathematical conventions
Storage uses decimal bytes; fp32 has per coordinate. Count chunks per page or document when boundaries must be preserved. Constant cell lengths, two special tokens, uniform block lengths and equal-cost hardware seconds are scenario assumptions, not properties of all tokenizers or systems. The symbol is locally a chunk cap, cell token length or layer count; definitions do not transfer between examples. Attention-pair counts and describe the quadratic attention term, not full-transformer time. Parameter-work proxies and stated sustained FLOP rates omit memory, scheduling, parsing, masks, lookup traffic and I/O. For permutation tests, separate correctness-label flips from any answer-value change. Exact equivariance requires the same retained cells, permutation-compatible inputs and masks, deterministic inference and an equivariant head or invariant readout. Report rounded results with , not exact equality; empirical study results remain reported inputs rather than causal deductions from these counts.
14.1 Semi-structured data and why splitting a table corrupts it
A cell needs three coordinates
- What: A value is interpreted with its row key, column header, and cell value.
- Why: Only the cell value is adjacent to itself in row-major text.
- Failure without it: A retrieved value can be assigned the wrong column label.
- Cost and complexity: Preserving the triple requires table detection, row-aware splitting, and repeated labels. Let a table have columns, data rows, headers , and value in one-based data row and column . Under the simplifying convention that each serialized cell occupies exactly tokens, the row-key/header/value unit is . Comparing corresponding cell starts in a header-first row-major stream gives distance:
The distance grows linearly with . It is unbounded as the table becomes taller.
Fixed splitting creates orphan rows
- What: Split a header-first stream with chunk cap and overlap .
- Why: The header is printed once. In the stated case, only the first window contains it.
- Failure without it: Later row fragments can lose their metric labels despite retaining row keys and period values.
- Cost and complexity: Local overlap is not a substitute for explicit header propagation; whether any later window retains a particular header cell depends on the actual stride and alignment. The rows sharing the first chunk with the header number:
The fully labeled-row fraction in the first window is for . At , a row costs tokens: the header and full rows occupy tokens. Thus of rows are complete and self-described in that window; rows are not. The header ends at token , the second window starts at token , and overlap tokens are about row-equivalents, not a repeated header. A few cells of row can still appear beside labels; “orphan” here means a row not wholly available with the header.
Retrieval fails before generation
- What: The metric phrase, such as gross margin, is a column label; row key and period may occur in later rows.
- Why: Separating the metric label from those values weakens or corrupts the searchable evidence.
- Failure without it: BM25 may retrieve a label-only chunk or a bare row; it does not necessarily share only the row key, since period values can also match.
- Cost and complexity: A larger embedding model cannot certify the meaning of labels that were discarded. Recovering the header from parent metadata is a possible repair. The opening prose assigns to APAC, while Figure assigns APAC and EMEA . Preserve this as a reported source inconsistency rather than silently inventing a reconciliation. A whole-table vector can locate a table but does not itself select a row. A -position encoder needs an explicit inclusion policy; silent truncation is an implementation failure to reject, not an inevitable model behavior. A longer encoder shifts rather than eliminates context and precision costs. Similar-looking rows need not produce a reliable semantic-breakpoint dip.
Parse before splitting
- What: Detect table regions while the document is still two-dimensional.
- Why: A downstream token stream no longer carries the region boundary.
- Failure without it: The table can be cut before the system knows it is a table.
- Cost and complexity: Header repetition raises tokens and vector count. Keep a fitting table atomic. For an oversized table, split between complete rows and repeat the header in each fragment. Header-to-value distance then depends on the local row number and is bounded by the fragment length, not generally by when many rows share a header. Repeating labels inside each row gives an local row span. Here, groups of at most rows plus a -token header would need fragments and embedded tokens; the row-by-row alternative below uses a different serialization.
Worked table configurations
The table has , , and . One row costs 30 tokens. The header plus data costs tokens.
| Configuration | What happens | Cost and limit |
|---|---|---|
| Recursive character split | , stride gives minimally covering windows | unpadded embedded tokens; only of rows are fully present with the header |
| Header repeated per row | Assume labels add tokens per cell: per row, whole rows per -token chunk, chunks without overlap | tokens: more than the unique original serialization, but more than its overlapped embedding bill; vectors increase . No row is cut or unlabeled |
| -token table surrogate plus payload | One vector indexes a summary and the -token payload remains attached | A plan returning tables injects tokens; another returning labeled rows injects . Ratio compares these text budgets, not equivalent workloads or measured latency |
The larger payload can support cross-row comparisons that one isolated row cannot establish. At a rough characters per token, tokens imply characters. The source’s separate approximately -character estimate differs by about relative to ; this is a rough consistency check, not a verified tokenization conversion. The table has times the stated window. Table-native encoders still need an ingestion and cell-inclusion policy.
Operating decisions
- Detect tables before the text splitter. Measure pipe, tab, and decimal-alignment density on a sample before assuming the corpus has almost no tables.
- Repeat headers in oversized row groups. Price the actual serialization: the example’s per-row labels add about versus unique text, while per-group repetition has a different cost.
- Index row surrogates for lookup traffic.
- Index table surrogates for comparison traffic and return the table payload.
- Route highest, total, year-over-year, and count questions to SQL when recurring shapes justify a maintained schema.
- Leave heterogeneous one-off layouts in retrieval when schema induction costs more than it returns.
- Stratify retrieval evaluation by whether the gold answer lives in a table.
14.2 Table encoding: TAPAS and its positional assumptions
The one-dimensional input problem
- What: A table has rows and columns, while a transformer receives one token sequence.
- Why: Row-major flattening creates misleading token distances.
- Failure without it: Same-row but unrelated cells look near. Same-column cells look far.
- Cost and complexity: A structural encoder adds input lookups and a parser that supplies their IDs. For token at position and segment , BERT uses:
Each lookup returns coordinates in the stated base configuration. The learned position table has entries; extensions require a specified method. In this local formula let mean tokens per cell, let and index data cells, and use zero-based sequence positions. A serializer with query tokens, two prefix special tokens and one -token header row starts the cell at:
For one-based data indices, replace with . Adjacent cell starts are tokens apart, while consecutive same-column row starts are apart. At , these distances are and tokens. They are sequence distances, not attention-hop counts.
TAPAS adds table fields at the input
- What: A simplified TAPAS-style input sums column, row and numeric-rank lookups with the base fields.
- Why: The added fields expose grid membership and numeric order.
- Failure without it: Flattened sequence distance alone is a poor representation of attribute identity.
- Cost and complexity: Three additional tables would add parameters in this budget exercise. This is not a claim to enumerate every field of every released TAPAS checkpoint.
In this simplified schema, query tokens use segment and zeros in the table fields. Headers use row ID , data row IDs are one-based, and numeric/date ranks are content-derived after parsing. Ties must be handled independently of printed order to preserve rank stability. A comparison such as versus can be connected by full attention in one layer; being separated by many sequence positions does not require that many attention hops.
Positional assumptions
- What: Token, segment, and rank fields are content-derived or content-stable. Position, column, and row fields depend on rendering.
- Why: A relation can remain unchanged when rows or non-key columns move.
- Failure without it: Equivalent tables can produce different first-layer vectors and answers.
- Cost and complexity: Canonicalization can reduce parser churn but does not make the encoder invariant. A label-preserving row permutation leaves lexical identity, segment and correctly parsed value-rank attached to the same cell, while changing absolute position and row IDs. Column permutations change column IDs. This permits order sensitivity; it does not force every logit or every prediction to change. Key roles and order-bearing queries must be specified separately from arbitrary printed position.
Window and verbalization arithmetic
Take . With exactly two budgeted special tokens, structural length is . The complete-row budget is
Add any extra special tokens required by the actual tokenizer before computing this bound. The opening anecdote about segments with visible is separate; it does not follow from this -row example. For verbalization, explicitly budget a repeated -token row-key prefix plus cells of header, “is,” value and comma token: tokens per row. Then rows use table tokens and total; only complete rows fit. Table-text inflation is . If both full sequences could be run, the quadratic attention-term ratio would be , not a measured whole-model latency ratio; neither full sequence fits this unmodified window.
Parameter and result accounting
Three tables add:
The three-table increment is one matrix and approximately of million parameters. The reported SQA comparison is a -percentage-point gain, but the parameter count alone does not causally isolate structure from training and pipeline changes. For distinct rows and movable non-key columns, serializations exist. Identical rows or columns can reduce the distinct orbit; finite augmentation does not by itself enforce invariance.
TAPAS claim limits
TAPAS is not a general query engine: the stated head chooses cells and at most one aggregation operator from none, count, sum or average. It does not expose an arbitrary SQL execution plan, even if a model sometimes answers a compound question correctly. Prefer an exact executor for reliable compound numerical reasoning. Numeric ranks also depend on implementation and parsing. The source describes a parser where an invalid entry can disable a column’s rank feature; do not generalize that behavior to every TAPAS parser. Test missing values such as n/a and formatted values such as 1,204 under the actual locale, and monitor parse rates.
Operating decisions
- Compute the row budget before selecting the encoder.
- Reject rather than silently truncate.
- Shard by row group only with the header replicated.
- Route cross-shard comparisons and aggregates elsewhere.
- Prefer verbalization for few small tables when maintaining a serializer is cheaper than maintaining a model. The source calls it the right choice on a 5-row table and for open-ended reasoning with a long-context instruction-tuned model.
- Prefer structural encoding above roughly 10 rows in the stated cost comparison.
- Freeze canonical column order and parser version beside the index.
- Run row permutation tests on label-preserving tables.
- Do not permute chronological ledgers, ranked leaderboards, or other order-bearing tables.
14.3 Row and column order bias and TableFormer’s fix
Put exact symmetries in the architecture
- What: For order-free data, a relation is a set of tuples over named attributes.
- Why: Up to row/column renderings can denote it when rows and attributes are distinct and all permutations preserve the query label.
- Failure without it: A model can learn incidental order rather than the requested relation.
- Cost and complexity: Architecture can impose exact equivariance; augmentation samples an orbit but offers no exhaustive guarantee. Order-bearing tables and fixed key roles restrict the allowed permutation group. A -row, -column table with distinct rows and columns has renderings. Five distinct row permutations cover of the row orbit. Repeated samples cover less, and this coverage fraction is not a generalization probability. Training on five times as many examples gives roughly five times the example-processing work only under the same per-example and epoch assumptions.
Why TAPAS changes after a swap
- What: Row and column embeddings enter token representations.
- Why: Attention logits depend on those representations.
- Failure without it: A row swap can perturb logits involving moved cells; a nonzero change is not mathematically inevitable for every pair.
- Cost and complexity: Subsequent layers may amplify or suppress the perturbation. No exact invariance follows merely from using the same BERT weights.
Changing a row ID changes the selected lookup vector when those entries differ. Its projections can alter logits, but cancellations or learned invariance can leave some unchanged. The architecture supplies no general rule requiring all such changes to vanish.
TableFormer moves structure into attention
- What: TableFormer deletes global position, row, and column IDs.
- Why: Absolute IDs encode rendering order as meaning.
- Failure without it: A harmless permutation rewrites token vectors.
- Cost and complexity: It adds one learned relation scalar to each attention logit. Position resets inside each cell. Word order within a cell remains real. The structural pair function maps each token pair to 1 of 13 relations. The source names same cell, same row, same column, cell-to-header, header-to-cell, mirrored question-table relations, and a residual class.
For a label-preserving cell-token permutation represented by matrix (query tokens fixed), require the pair relation and every attention mask to permute consistently. Relation invariance is:
These equations describe attention and token-output equivariance when all retained inputs, within-cell positions and masks obey the permutation, dropout is disabled or coupled appropriately, and no other order-dependent features enter. An invariant aggregation/readout then preserves the answer; cell-selection outputs must be mapped back to original cells. Keeping within-cell order means Palo Alto is not permuted into Alto Palo.
Parameter and compute cost
The row/column lookup subset has parameters. Relation biases use scalars if shared across layers or otherwise; the latter is of that removed subset. This comparison excludes other input embeddings, including whatever within-cell positions replace global positions. At , adding one bias per head and token pair requires additions. The quadratic attention arithmetic proxy is FLOPs, so the additions are of that term. They are about of the parameter-work proxy FLOPs; that proxy is not a complete BERT forward-pass measurement. Relation lookup, materialization, masking, softmax and memory traffic also cost time. The stated T5 scale check is learned bucket scalars.
Variation percentage sees canceled flips
- What: Let be correct-to-wrong and wrong-to-correct fractions on paired examples; let be changed predictions among examples wrong both times.
- Why: Accuracy change is . Correctness-label flip rate is . With a unique correct answer, answer-value VP is .
- Failure without it: Opposite correctness flips cancel, and wrong-to-different-wrong changes are invisible to correctness alone. Multiple acceptable correct outputs require another change category or a canonicalization policy.
- Cost and complexity: Compute VP from actual paired outputs under label-preserving perturbations, not just their aggregate correctness counts. The source reports permutation evaluations on SQA and TabFact and TableFormer VP below in its settings. As a separate bound, if original and perturbed accuracies are both , correctness down/up fractions can satisfy , so correctness-label flips can reach with zero accuracy delta. Under a unique-gold-answer convention, at least are correct both times, so answer-value VP is also at most ; without that convention, answer-value changes need separate accounting.
Worked regression
For questions, original correct and paired counts down, up imply correct after permutation, a -percentage-point drop. They prove correctness-label flips and stable correctness labels. Answer-value VP is at least and equals it only if there are no additional wrong-to-different-wrong or acceptable-answer changes; the counts alone do not prove unchanged answers. A strictly sub- VP on exactly examples permits at most changed outputs, not a guaranteed transfer of the study’s rate.
Invariance claim limit
Exact architectural equivariance assumes the same cells survive and the full input, masks and output handling satisfy the symmetry. Truncation can change cell inclusion after permutation and break that guarantee. It is one possible source of residual empirical VP, not the unique explanation proved by a sub- number; parsing, nondeterminism, masks or head details can also matter. Meaningful order, multirow headers and within-cell token order must remain intact. Oversized tables still need ingestion and sharding policies.
Operating decisions
- Canonicalize row and column order in the parser before changing the encoder. Sorting rows by the key and pinning columns removes parser churn for the cost of a comparator.
- Keep order when order is data, including chronology and ranking.
- Report VP beside accuracy on structured-input evaluations. One label-preserving perturbation per example doubles evaluated inputs without new gold labels, but requires additional inference and validation that the label truly remains valid.
- Permute within order-free groups for partially ordered tables.
- Use architecture for exact symmetries and augmentation for formatting, whitespace, and casing changes.
- Repeat the header in every row block. A 60-row table that truncates becomes order-sensitive again.
- Route aggregates that cross row blocks to SQL.
- Read a table paper for its perturbation result as well as its headline accuracy.
14.4 Document layout: blocks, reading order, and hierarchical pre-training
Extraction and order are separate
- What: OCR or a parser can return every character correctly and still linearize the page wrongly. The opening parser reports confidence across the page.
- Why: Two-column lines share vertical bands.
- Failure without it: Sorting each line by vertical then horizontal position alternates unrelated columns.
- Cost and complexity: Sorting blocks changes one key but requires trustworthy block boundaries. The worked page has 2 columns, 45 lines per column, and 11 tokens per line. It contains tokens. Line sorting produces one coherent line at a time, or 11 tokens. Block sorting produces one 45-line column, or 495 coherent tokens. That is a improvement without model training.
What the parser must preserve
- What: Each block carries a bounding box, type, content, text properties, and image status.
- Why: Header, paragraph, list, table, figure, and image roles are different.
- Failure without it: The same words cannot reveal whether they govern later content.
- Cost and complexity: Block IDs, types, page numbers, boxes, and text properties add metadata and parser work.
Correct order is necessary but not sufficient. A flat token stream cannot express block membership and block type directly. The source contrasts
Discontinued modelsas a header governing 300 tokens with the same words as a table cell governing nothing. It also measures block adjacency in tokens. Blocks 3 and 4 remain neighbors whether block 3 contains 12 or 800 tokens. The flat distance changes with block length anyway. For scans, the source uses Optical Character Recognition (OCR). For born-digital Portable Document Format (PDF) and HyperText Markup Language (HTML), it uses a structure parser. Each block can carry font size, bold, italic, and underline properties, plus image status.
LAMPreT uses two encoder levels
- What: A lower transformer reads within blocks. A higher transformer reads block summaries.
- Why: Block order, type, adjacency, and image position need their own sequence.
- Failure without it: Long documents overrun the flat window and non-text blocks lack explicit slots.
- Cost and complexity: The system needs block parsing, two encoders, image encoding, and five objectives. Each lower-level block receives its specified text, type, modality and formatting features; a CLS summary represents the block. The upper sequence receives block summaries in layout order, including encoded image blocks. This can represent document relations absent from a flat text-only baseline. For the following pair-count toy, assume exactly text blocks of tokens, with equal widths and comparable attention accounting. Then .
The hierarchy uses:
The pair counts are versus , a ratio of . This is not a -fold whole-transformer speedup or an equivalence of the two functions: projections, feed-forward layers, extra summaries, image encoding and different depths remain. For fixed and equal block lengths, the continuous pair-count optimum solves , giving . Real blocks are semantic units, not an arbitrary compute knob. In this equal-length toy, lower length and upper length fit positions, while does not. A mean length alone would not bound the longest block; variable lengths use before padding.
Five pre-training objectives
- What: Two objectives operate within content and three operate on the block sequence.
- Why: Layout is learned only when a layout-blind model is punished.
- Failure without it: Masked language modeling can solve one block at a time and ignore the upper encoder.
- Cost and complexity: Five component losses require normalization, hypotheses, weights, and ablations. The stated five objectives are masked language modeling, image-text matching, block-order prediction, image fitting and text-block filling. They encourage within-block and document-level learning, but a within-block-only model is not automatically at chance: it may exploit lexical, type or candidate-distribution shortcuts. Chance rates depend on class balance and candidate construction. Ablate access to cross-block context to test what the objectives actually teach. The weighted total is:
Weights are tunable. Their numerical values are not comparable without the loss definitions, reduction convention and gradient scales. As a hypothetical magnitude example, times a loss as large as can outweigh times one as large as ; actual cross-entropy losses are not generally bounded by those ranges. Normalize per-token/per-block reductions or measure gradients, then sweep and ablate; equal loss ranges alone do not guarantee balanced training.
LayoutLM trade-off and claim limit
- What: LayoutLM adds normalized box coordinates to a flat token input.
- Why: Absolute page geometry is useful for fitting single-page forms and receipts.
- Failure without it: Coordinates do not create an explicit block order or image slot.
- Cost and complexity: Flat two-dimensional positions are simpler for fitting pages. Hierarchy is more complex but supports blocks and images across longer documents. For a fitting single-page form, flat box-aware representations can be a strong baseline. The simplified text-plus-box comparison here does not describe every LayoutLM variant; multimodal variants can include image features. A hierarchy explicitly exposes block order and non-text slots but is not mathematically guaranteed to outperform all flat models on long documents. The reported LAMPreT evidence concerns comparable text-block tasks and stronger image association under its evaluation, not universal superiority or better text infilling.
Datasheet cost example
The corpus has pages of tokens, total. Preserving page boundaries with unpadded -token windows gives chunks and of -dimensional fp32 payload. Pooling unrelated pages into one stream would instead give chunks; that is a different segmentation policy. For a separately stated serving budget of five full -token chunks, take distractor text under raster extraction as an assumption: of tokens. At and , their incremental prefill proxy is . On the ideal two-column page, choosing the chunk corresponding to the relevant column after block ordering can leave at most foreign tokens in a full -token chunk: over five chunks, or . Their proxy is , a difference of . This is conditional on relevant-column selection and the stated geometry, not a bound for arbitrary layouts or total latency. Parsing at CPU-core-seconds per page costs core-seconds, core-hours, or elapsed seconds on perfectly parallel workers. CPU seconds and GPU seconds are different priced resources. With rates per core-second and per GPU-second, an idealized financial break-even is
The approximately queries or hours of traffic at QPS apply only to an equal-price-per-second illustration. No actual monetary payback follows without prices, utilization and incremental parser cost. Benchmark the parser and serving path.
Operating decisions
- Sort blocks, not lines or tokens.
- Preserve the parser’s internal order inside each block.
- Prepend the governing header chain to a chunk before buying a layout-aware model.
- Use the hierarchy when text must bind to images or multi-page block relations.
- Persist block ID, block type, page number, and bounding box beside each chunk. This costs a few dozen bytes per chunk beside of vector payload in this page-preserving example; retaining reusable metadata can avoid repeating the parser work.
- Inspect objective reductions, magnitudes and gradient scales before selecting weights; normalization is one aid, not a guarantee. A source hypothesis can weight masked language modeling low for image-dominated pages and high for text-dense filings.
- Evaluate layout with answer flips after block perturbation, not accuracy delta alone. When no stable order exists, such as on loose forms or slide decks, perturb block type labels instead.
- Use flat box positions for fitting single-page documents.
- Use hierarchy above 512 tokens or when cross-modal block association matters.
14.5 Layout priors you should be able to name
A sort key is a bundle of assumptions
- What: Sorting blocks by means downward first and rightward within a band. The opening transfer case moves from on Securities and Exchange Commission filings to on Osaka maintenance manuals while OCR, bounding boxes, and embedding weights remain unchanged.
- Why: It matches one common left-to-right Manhattan layout.
- Failure without it: It interleaves columns or reverses scripts whose reading direction differs.
- Cost and complexity: The system must classify columns, script, and region structure before sorting. The naive sort asserts four priors.
- Reading moves downward.
- Reading moves rightward within a band.
- Blocks are rectangular.
- One global order exists. With five blocks in each of two columns, the correct order has nine adjacent pairs. The alternating sort preserves zero of nine.
Recursive X-Y cut
- What: Project ink onto one axis, cut at the widest zero valley, then recurse with the axis swapped.
- Why: A full-height gutter remains empty when ordinary word spaces fill under projection.
- Failure without it: A spanning element erases the valley and the fallback can interleave columns.
- Cost and complexity: One projection per region plus thresholds tied to body size. A US Letter page is points. One-inch (-point) margins give points of text area. An -point gutter gives points per column; -point leading permits line slots under this simple layout. A -point body em is smaller than the gutter, while approximate -point word spaces occur at varying horizontal positions. A full-height blank gutter is one useful cut signal. A spanning figure can erase that valley in the current region, but recursive horizontal cuts may isolate it and restore gutters above or below. Failure is conditional on the available whitespace and fallback, not inevitable for every spanning figure.
Reading order depends on script and genre
Sort keys are local conventions, not complete page-reading algorithms. After region and column detection, a left-to-right horizontal band may use ; a right-to-left band may use , with increasing downward. Column-major text needs column order before within-column , not a global line-level sort. Traditional vertical Japanese or Chinese may use right-to-left columns with top-to-bottom flow, schematically . Mixed scripts, newspapers and irregular blocks require a region-specific partial order or learned reading-order policy.
Typography must be relative
- What: Size and weight mean something only against the rest of the page.
- Why: Journals, slides, and contracts use different absolute point sizes.
- Failure without it: A 14-point threshold misses contract headings and labels every token in a 24-point slide body.
- Cost and complexity: A character-weighted size histogram and emphasis-rate calculation are required per page. Let be the character-weighted modal type size. A candidate heading rule can be
The bold rule is an alternative to the size rule, not an extra condition every heading must pass. The reported detector transfer from to is an anecdote, not proved by the threshold arithmetic alone. Separately, if exactly of tokens are true heading tokens, selecting all bold tokens at has precision at most . Selecting at has precision at most . These are token-level ceilings; rarity alone does not guarantee relevance or correctness.
Worked mixed corpus
The corpus has documents. Journals are . They use 10-point body, 12-point subheads, 14-point section heads, and 18-point titles. Slides are . They use 24-point body and 32-point headings. Contracts are . They use 11-point body and 11-point bold headings.
| Rule | Journals | Slides | Contracts | Weighted result |
|---|---|---|---|---|
| Absolute points | Under the constructed template, detects of heading blocks: recall | Detects all blocks, including one title among seven: recall , block precision | Recall for -point headings | Document-mixture macro recall , not pooled heading-level recall |
| Relative size OR bold with | All assumed heading size ratios pass | passes; body ratio fails | Same-size bold headings pass the alternative rarity branch if the assumed bold tokens among are exactly the heading tokens | Recall only under this constructed template and correct mode/bold assumptions |
Assume additionally pages per document and character records per page. The histogram scan processes records; at an assumed increments per second, the arithmetic timing proxy is , excluding extraction and other work. The source’s modular type-scale examples are , , and . A rule deliberately excludes , but small size differences can still mark real headings when other features support them. Modal size need not be body size on every page. A larger threshold such as is a domain heuristic under OCR uncertainty, not a guaranteed robust cutoff.
Rendering priors and encoder invariance coexist
- What: The rendered leftmost column often acts as the key, while the underlying relation remains column-order invariant.
- Why: Rendering and relation are different objects.
- Failure without it: Putting the leftmost-key rule into the encoder confuses typography with data semantics.
- Cost and complexity: The parser keeps the key in each chunk. The encoder keeps role relations without absolute index embeddings. TableFormer drops row and column indices but keeps header-to-cell and same-column roles. The linearizer keeps the key cell and required header rows in every fragment. Arabic or other right-to-left rendering can invert the rendered-key convention without requiring an encoder change.
Learned priors also have domains
LayoutLM was pre-trained on scanned English business documents from the Illinois Institute of Technology Complex Document Information Processing (IIT-CDIP) corpus. PubLayNet was built by matching Portable Document Format (PDF) text against PubMed Central Extensible Markup Language (XML). It covers scientific articles. DocLayNet was created because single-domain layout corpora do not transfer. Its authors annotated 11 layout classes across 6 document categories. A coded prior can fail loudly on a held-out domain. A learned prior can fail silently when the training domain is hidden from system tests.
Operating decisions
- Use page-relative size ratios instead of absolute point thresholds.
- Detect columns before applying a block sort.
- Audit a parser-provided reading-order field on 50 held-out pages. The source says most commercial parsers already emit one.
- Record script at ingest and select the order function from it.
- Carry the key cell and every required header row into table fragments.
- Preserve both header rows when the header spans two rows.
- Treat multi-column spanning cells as genuinely ambiguous unless structure is retained.
- Gate emphasis rules on the page’s own emphasis rate. In single-weight documents, fall back to numbering patterns such as 1. or Article 3.
- Re-test every prior on a document category absent from development.
- Use the optometrist test as a diagnostic. Features visible when words are unreadable are layout signals that plain text extraction discards.
Diagrams
Table 14.1
| Type | Example | Retrieval gets free | What it costs |
|---|---|---|---|
| Structured | SQL rows, knowledge graph triples | Exact predicates, joins, aggregation. Similarity ranking is not needed for an exact keyed predicate, though other queries can still require ranking | The schema is yours to design and migrate forever |
| Semi-structured | Filings, wikis, manuals with prose interleaved with tables | Coverage without imposing one global relational schema | Cell meaning is positional, so splitting corrupts it and cell text is weak similarity-search material |
| Unstructured | Prose, transcripts, tickets | Everything a chunker assumes, including sentences, redundancy, and distributional signal | Exact predicates require additional extraction or structure rather than appearing automatically in raw prose |
| LLM-generated | Synthetic question and answer pairs, summaries, propositions | A retrieval surface written in the query’s own vocabulary | Provenance becomes yours to defend, and the errors are fluent |
Table : These categories suggest different ingestion and query strategies; they are not an exclusive partition of failure modes. Prose also carries meaning in word order, structured rows depend on schema, and synthetic text can lose qualifiers. Semi-structured tables make the dependence on row/header roles especially explicit.
Figure 14.1
A. Row-major serialization, cut every tokens
| Seg | Qtr | Rev | Opex | NI | |
|---|---|---|---|---|---|
| header | header | header | header | header | header |
| … | … | … | … | … | … |
| cut | cut | cut | cut | cut | cut |
| EMEA | Q3-25 |
The first chunk contains the header and complete rows, about of the data rows. Query terms such as period values may also occur in later rows. The remaining rows are not wholly present with that original header. In this constant-cell toy, header-to-cell start distance is ; the later stream can retain row keys and period values while losing metric labels.
B. Row-wise serialization, header repeated
| Self-describing row | Position relative to cut |
|---|---|
| Seg:APAC Qtr:Q3-25 : … | above |
| Seg:EMEA Qtr:Q3-25 : … | above |
| cut | cut |
| Seg:AMER Qtr:Q3-25 : … | below |
With labels inside each complete row, header-to-value distance is local to that row, of order . The safety also requires cuts only between rows. This serialization has more unique tokens; its embedding bill is above the overlapping baseline, not above it. Figure : A header-first serialization leaves only complete data rows with the header in the first window under the stated geometry. Repeating labels per row and cutting between rows makes the modeled fragments self-describing. Label repetition alone does not prevent a blind cut inside a row.
Figure 14.2
A. Rendered table
| Method | Year | MRR |
|---|---|---|
| BM25 | ||
| DPR |
This figure treats every cell as exactly one token and shows local positions only. Adjacent cell-start distance is and consecutive same-column distance is ; real strings such as BM25 may tokenize into more than one WordPiece.
B. Row-major input fields
| Field | Method | Year | MRR | BM25 | DPR | ||||
|---|---|---|---|---|---|---|---|---|---|
| position ID | |||||||||
| column ID | |||||||||
| row ID | |||||||||
| rank ID |
Position, column, and row IDs come from printed order. Rank IDs come from sorted values. Figure : The simplified one-token-per-cell illustration separates lexical content and numeric rank from printed position, row and column IDs. The local position IDs omit the query offset. Adding grid fields makes the structure explicit but also permits order sensitivity; it does not guarantee that a row permutation changes the answer.
Figure 14.3
A. TAPAS before and after a row swap
| Method | Recall | Latency | |
| BM25 | |||
| ColBERT |
| after swap | |||
|---|---|---|---|
| Method | Recall | Latency | |
| ColBERT | |||
| BM25 |
The moved row changes row and absolute-position lookup IDs. Its token representation can change if those embeddings differ; this does not imply every projected attention logit or final answer must change.
B. TableFormer relations
Diagram description and source
flowchart LR
h["Recall header"] -->|"column header to cell"| b["BM25 0.71"]
h -->|"column header to cell"| c["ColBERT 0.86"]
b ---|"same column"| c
bm["BM25"] -.-|"same row"| b
cm["ColBERT"] -.-|"same row"| c
note["13 relation types in all"]
The relation edges survive the swap. Attention is permuted with the table. Figure : Absolute row IDs permit a moved cell’s representation to change. Relation-aware attention can instead be permutation-equivariant under compatible inputs, masks, retained cells and output handling. The attention matrix permutes; an invariant answer requires the stated readout conditions.
Figure 14.4
Diagram description and source
flowchart TB
subgraph lines["A. Sort lines by vertical then horizontal position"]
direction LR
l1["left line 1"] --> r1["right line 1"] --> l2["left line 2"] --> r2["right line 2"] --> more["continue alternating"]
more --> run11["longest coherent run: 11 tokens"]
end
subgraph blocks["B. Sort blocks by vertical then horizontal position"]
direction LR
b1["block 1: full left column"] --> b2["block 2: full right column"]
b2 --> run495["longest coherent run: 495 tokens"]
end
subgraph hierarchy["C. Two encoder levels"]
direction TB
c1["content encoder block 1"] --> cls1["CLS 1"]
c2["content encoder block 2"] --> cls2["CLS 2"]
c3["content encoder block 3"] --> cls3["CLS 3"]
c4["content encoder block 4"] --> cls4["CLS 4"]
cls1 --> layout["layout encoder over block sequence"]
cls2 --> layout
cls3 --> layout
cls4 --> layout
cls2 <-.->|"block-ordering prediction swaps 2 and 3"| cls3
end
run11 ~~~ b1 ~~~ c1
Token embedding equals WordPiece plus block index, block type, modality, and text features. Figure : Reading order is decided at the block level, not the token level: sorting lines rather than blocks cuts the longest coherent span on a two-column page from 495 tokens to 11, while a two-level encoder gives block order, block type, and block adjacency a representation level at which they can be predicted.
Figure 14.5
Diagram description and source
flowchart LR
subgraph manhattan["A. Manhattan layout"]
direction TB
m1["1 full-width header"] --> split1["horizontal cut below block 1"]
split1 --> gutter["18-point gutter has zero ink on all 54 lines"]
gutter --> m2["2 left column"]
gutter --> m4["4 right column"]
m2 --> m3["3 left column"]
m4 --> m5["5 right column"]
m3 --> m6["6 spanning footer"]
m5 --> m6
m6 --> ok["cut succeeds, order correct"]
end
subgraph nonmanhattan["B. Non-Manhattan layout"]
direction TB
ntop["full-width top block"] --> n1["1 upper left"]
ntop --> n2["2 upper right"]
n1 --> span["spanning figure crosses gutter"]
n2 --> span
span --> n4["4 lower left"]
span --> n5["5 lower right"]
n4 --> fail["if no isolating horizontal cut restores a gutter, vertical cut fails"]
n5 --> fail
fail --> fallback["vertical then horizontal fallback interleaves columns"]
fallback --> zero["zero correct adjacencies in the stated alternating fallback"]
end
m1 ~~~ n1
Figure : A full-height gutter is a strong cut signal within a region. A spanning element may erase it, but an earlier horizontal split can sometimes isolate that element. Only when suitable region cuts fail and the implementation falls back to alternating column blocks does the illustrated zero-adjacency error follow.
Whiteboard pack
What to draw
- Draw a table with one header row and many data rows.
- Draw a fixed cut below the header. Circle one orphan value.
- Connect that value to its row key and column header. Label the path .
- Redraw the rows with labels repeated. Use row-atomic cuts and mark orphan rate in this toy. Label unique-token inflation versus extra embedding tokens relative to the overlapping baseline.
- Draw TAPAS as six input fields. Circle position, row, and column as order-dependent.
- Draw a row swap. Replace absolute IDs with TableFormer’s same-row, same-column, and header-to-cell edges.
- Write accuracy change , correctness-flip rate , and answer-value VP under a unique-correct-answer convention.
- Draw two page columns. Show line sorting as an alternating stripe and block sorting as two solid spans.
- Stack a content encoder below a layout encoder. Add the five pre-training objectives.
- Finish with a full-height gutter, a spanning figure, and script-dependent sort keys.
Spoken script
Tables and pages are not plain token streams. I detect table and block structure before splitting. For a tall table, I split only between rows and repeat the header, so every value keeps its row key and column label. TAPAS adds row, column, and rank fields, but absolute indices create order bias. TableFormer moves structure into relation-aware attention, which survives harmless permutations. For documents, I sort blocks, not lines, and use hierarchy when block relations or images matter. I test reading-order, truncation, and permutation failures explicitly, because clean extracted text can still be structurally wrong.
Interview traps
1. Why does a good text pipeline fail on table numbers?
The likely failure is table splitting, because query words stay in the header while the answer row lands elsewhere. Inspect one retrieved chunk, then detect tables before splitting, cut only between rows, and repeat the header if labels and values are separated. For a 200-page filing with 60 tables, index prose normally, keep fitting tables atomic, use row-atomic fallback for large tables, and restore headers on continuation pages.
2. Does adding row and column embeddings solve table structure?
Grid embeddings restore coordinates but permit printed-order bias. For a -row, -column table with tokens per cell, and two specials, the complete-row budget is , not rows. Repeat headers for sharding and route reliable cross-shard aggregates to an executor.
3. A row permutation moves accuracy from 60.0% to 59.8%. Is the model robust?
No. The down and up flips prove correctness instability despite only a -point accuracy drop. Full answer-value VP may be higher. With unique correct outputs and accuracy both times, up to may change. Temperature zero does not enforce invariance to changed inputs. Five row augmentations cover only about of a distinct -row orbit and add processing cost; neither that tiny fraction nor deterministic decoding proves robustness.
4. Should I choose LayoutLM or a two-level layout encoder?
Use flat box coordinates for a fitting single-page form where absolute geometry is the signal, and use hierarchy above 512 tokens or when block adjacency and image slots matter. The stated LAMPreT result is comparable text block filling and better image association, not better text infilling. In the 40,000-page-per-day, 10 QPS, 300-millisecond scenario, combine page-image retrieval with block extraction and rank fusion because the image leg bypasses reading order but gives up lexical exact match on part numbers and error codes plus span citation.
5. Why not hard-code geometry and typography?
Global line sorting by can interleave columns, and an absolute -point heading rule can fail across type scales. The alternating five-block-per-column toy preserves zero of nine directed adjacencies. Detect regions, columns and scripts first, then validate relative-size and rarity-gated bold rules on held-out domains. Those rules are heuristics, not a proof of perfect transfer.
Key numbers
| Topic | Value or model estimate | Meaning or limit |
|---|---|---|
| Table geometry and retention | ; | Complete rows with the header in the first aligned window; for fractions |
| Opening split | , , , , tokens | of rows retain labels, retained, orphaned, orphan rate |
| Overlap and original size | unique tokens; windows, unpadded embedded tokens at stride | overlap tokens do not carry the header from tokens – to the second start at |
| Header repetition | tokens per labeled row, whole rows/chunk, chunks, tokens | serialization inflation but extra versus overlapped embedding; more vectors |
| Surrogate and payload | table tokens versus row tokens, ratio | Different text-return budgets, not equal-workload latency; character checks are rough approximations |
| BERT and flattening | Zero-based data cell starts | Adjacent cells differ by , same-column rows by ; table fields and tokenizer details remain implementation-specific |
| TAPAS window | gives tokens and complete fitting rows | At with the same query budget, only full rows fit; the opening -versus- anecdote is separate |
| Verbalization | Explicit prefix-plus-cell template: tokens/row, table tokens, total; rows fit | Table-token ratio ; hypothetical full-sequence attention-term ratio , not a whole-model timing result |
| TAPAS scale and result | Three hypothetical tables: parameters, of M | Reported SQA gain points is not a controlled causal consequence of this count; distinct-order upper scenario |
| Numeric parse gate | Test literal missing/locale-formatted values under the actual parser | One invalid value disabling an entire rank field is implementation-specific, not a theorem about all TAPAS systems |
| Permutation orbit | for distinct rows/columns; | Orbit coverage is not generalization probability; duplicates reduce distinct permutations |
| TableFormer parameters | row/column lookup parameters versus shared or per-layer bias scalars | The latter is of that subset, not a complete net model-parameter accounting |
| TableFormer compute | bias additions; quadratic attention proxy FLOPs | of attention arithmetic; of , with lookup, memory and runtime overhead omitted |
| VP limit and report | Equal accuracies permit correctness-label flips; unique-gold answer VP has the same upper bound | Reported sub- TableFormer VP is study-scoped; truncation is one possible residual cause |
| Worked regression | correct, down and up flips among | correctness flips; answer VP is at least that. correctness labels stay stable, not necessarily answers |
| Reading order | tokens, coherent span versus | Block sorting improves coherent span |
| Hierarchy | : flat pairs versus hierarchical, ratio | Equal-length pair-count optimum ; not a whole-transformer speedup |
| Objectives and loss | stated objectives; hypothetical weighted magnitudes versus | Inspect reductions and gradients; actual cross-entropy need not lie in those bounded ranges |
| Datasheet corpus | pages, tokens/page, page-preserving chunks, fp32 payload | Pooling the pages into one stream instead gives chunks; those policies are not interchangeable |
| Block-sort economics | Conditional serving toy: distractors , prefill proxy | CPU-core-seconds parse work; financial break-even queries, not a hardware-seconds identity |
| Page-image trade-off | pages per day, QPS, -millisecond budget | Image retrieval bypasses reading order but gives up lexical exact match and span citation unless a block leg remains |
| Layout assumptions | priors, of adjacencies preserved with five blocks per column | The priors are down, right, rectangles, and one global order |
| X-Y geometry | points, text , -point gutter, -point columns, line slots | A spanning element can remove a regional gutter, but horizontal recursion may isolate it; failure is conditional |
| Typography and emphasis | true heading tokens among : bold-selection precision at most for selected or for | Token-level ceilings, not a claim that rarity alone makes bold a correct heading signal |
| Mixed corpus result | Document shares : absolute-rule mixture macro recall | Relative-size OR rare-bold rule attains only under the constructed templates; not pooled recall or a transfer guarantee |
| Mixed corpus detail | Journal heading-block recall ; slide block precision ; contract bold-token share | pages/document and character records/page give increments, at the assumed rate |
| Type and transfer checks | Type-scale ratios , , , ; the rule excludes | Size and emphasis cutoffs are domain heuristics. DocLayNet’s reported classes and categories motivate held-out-domain testing |
00-START-HERE · 01-READING-ROUTES · 13_chunking_and_granularity · 15_approximate_nearest_neighbor_search