Data and Knowledge SystemsKnowledge representation and evidenceStaff
How should a RAG pipeline preserve table cells, headers and footnotes for accurate numerical answers?
By Amit Kumar4 min readWorked answer includedReviewed 26 Sept 2026
The question
Interview question
In a hypothetical benefits PDF, the family cap is 5,000 USD, the individual cap is 2,000 USD and a footnote limits plan X to 1,500 USD. The assistant retrieves and cites the correct page but reports 5,000 USD for an individual on plan X. Trace extraction and evidence assembly, design a cell-level representation and validation, and explain how to handle missing headers or changed footnotes.
Draft your approach first
Take a few minutes before you read the answer. Name the constraint that matters most, the failure you are designing for and how you would know it worked.
Reveal the worked answerWorked answer
A numerical answer needs the relationships among a table’s row, column, plan and footnote. Retrieving the right page establishes its location without establishing those relationships. A text extractor that emits Individual Family $2,000 $5,000 as one line may give the model all the tokens and still lose which number belongs to which header. A chunker may detach the footnote or carry a merged “annual cap” heading to only the first row. This is a parsing and evidence-assembly problem before it is a model reasoning problem.
I would inspect the original page next to the extracted representation and the exact model context. Did the parser preserve cells, row and column headers, merged-cell spans, units, footnote markers, and page coordinates? Does the plan qualifier sit in a caption outside the table? Did OCR read $1,500 as $7,500? It is easy to blame generation when the model was never given a faithful table. Google's Document AI layout parser is one example of layout-aware processing. Its output still needs validation on the actual PDFs and table types.
For indexing, I would keep a structured table object alongside the original page. A cell has its value, row key, column key, parent headers, units, footnote references, page and bounding box, source revision, and extraction confidence when available. Search can use lexical terms for exact plan names and numbers and a table-level representation for semantic discovery. Once a table is retrieved, assemble the relevant row and its headers plus the footnote into the context. Do not ask an embedding to encode the entire two-dimensional relationship in one flat sentence.
The assistant's claim should resolve to a particular cell and its qualifier. For “individual, plan X,” find the individual column's $2,000 cell, then apply the plan X footnote that lowers it to $1,500. The answer is $1,500 for that plan, with a citation that can highlight the cell and the footnote, assuming no other governing rule. For an unspecified plan, asking a clarifying question or stating the conditional values may be better than choosing $1,500 for everyone. The arithmetic here is a minimum cap, not a sum of two dollar amounts. If the footnote describes an entirely different condition, the answer changes. The parser must preserve the link so a reviewer can tell.
At the generation boundary I would require the proposed number, currency, population, time period, and supporting cell/qualifier IDs as structured evidence. A deterministic check can verify that the cited cell contains the number or that an explicit calculation links cited inputs to the output. It cannot decide every policy exception, so sampled human review should inspect difficult tables and disagreement cases. Evaluate cell selection, qualifier application, and final claim support separately. A page-level citation correctness metric would mark this wrong answer as right.
Remove the table header from an OCR scan and the choice gets harder. I would not infer “individual” solely from left-to-right position if the scan can have rotated pages or split columns. Reprocess the page with a better extractor, use a source-native spreadsheet when available, or abstain from the exact amount and route the document for repair. The system should make incomplete extraction visible rather than convert missing layout into confident policy.
Then the footnote changes but the table image does not. Treat the page or table plus footnote as one versioned evidence dependency. Reindex affected table representations and invalidate answers that depended on the old qualifier. A parser confidence score can prioritize review, but the visible failure is a wrong claim with a correct page citation, so the release test has to check the claim against the right cell and condition.
The representation should let a reviewer follow one claim without reconstructing the entire PDF. For this hypothetical answer, the evidence record names the individual-cap cell, its population header and the plan X footnote. An extraction test can check that those three nodes remain connected after OCR, chunking and context serialization. A generation test can then check that the assistant applies the stated 1,500 USD cap rather than copying the more visually prominent 5,000 USD amount.
Keep those tests separate. If the graph already assigns 5,000 USD to the individual column, the fault is upstream of retrieval. If the graph is correct but the chunk omits the footnote, repair assembly. If the complete graph reaches the model and it still selects the family amount, inspect selection and reasoning. This diagnostic split makes parser upgrades reviewable: compare the affected relationships and claims on the same pages, rather than accepting a larger total word count as evidence that the new extractor is better.
Related questions
- How should an assistant resolve conflicting policy sources when the authoritative source is unavailable?Staff
- When should a retrieval system embed individual sentences instead of larger passages?Staff
- How would you build an evidence-backed impact graph for consumers of a changing event schema?Principal
Keep practising data and knowledge systems
Follow another question in this area, or search the complete library.
Get my essays on AI engineering and distributed systems by email. Subscribe to ArchCrux