Retrieval and RAGQuery understanding and retrieval designStaff
How should RAG select an exact plan limit from nested and repeated table headers?
By Amit Kumar3 min readWorked answer includedReviewed 28 Sept 2026
The question
Interview question
A hypothetical table has Enterprise above Standard and Premium columns, with daily limits 50 and 100. Another section has Personal above its own Standard column, with a weekly limit 10. Assume extraction preserves the cells and merged-header hierarchy. A user asks for Enterprise Standard’s daily limit. Design query disambiguation, cell selection and evidence validation, then handle a query that says only Standard.
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 faithful table representation is necessary, but it does not by itself choose the cell the user meant. The query “Enterprise Standard daily limit” identifies a path through a header hierarchy, not just a cell containing the word Standard. The answer must bind the product family, plan, measure and time unit to the same qualified cell.
In the hypothetical table, the requested path is Enterprise, then Standard, then the requests-per-day row. Its value is 50 requests per day. The Premium value 100 belongs to another column. The Personal Standard value 10 belongs to a different family and a different unit. A broad match on Standard can retrieve all three neighboring concepts while still failing the exact lookup. Converting 10 per week to a daily average would answer a different question and cannot replace the source’s allowance rule.
Preserve the structural evidence. Amazon Textract’s table documentation represents cells, merged cells, headers and row/column positions. An application can retain the resulting header path, row measure, value, unit, footnote links, source revision and source coordinates in a cell record. These vendor structures are an example input, not a guarantee that an extractor correctly interprets every document. Missing merged spans or uncertain footnotes still need review.
Separate candidate discovery from exact resolution. Search can locate the relevant table using surrounding prose and product terms. A resolver then matches the requested family and plan against qualified header paths, selects the measure and checks unit and applicable version. It should return the selected cell together with its path and qualifiers. The generator explains that result instead of guessing a relationship from a flattened line containing several labels and numbers.
When the user says only Standard, the family is ambiguous. Use trusted conversational context if it already establishes Enterprise or Personal, otherwise ask which family is meant or present the two conditional limits with their different units. Do not resolve ambiguity through whichever Standard cell happens to rank first. A taxonomy alias can help only when its mapping is authoritative and scoped to the source version. Marketing names reused across products should not collapse into one global plan ID.
Footnotes can refine a selected cell without applying to its neighbors. Keep the attachment to the correct header or value rather than copying every table note into every answer. If a blank cell appears, preserve whether the document defines it as inherited, unavailable or not applicable. Absence of a number is not automatically zero or the value from the previous column. If the qualifier cannot be resolved, explain which exact limit remains uncertain.
The supporting citation should identify the source revision, selected cell and header/footnote evidence. A validator can compare the returned value and unit with that record and reject a mismatch before generation is used for a decision. It can also detect a missing requested dimension. It cannot establish that a PDF’s policy is authoritative merely because the parse is consistent, so source authority and effective time remain separate prerequisites.
Test repeated Standard labels, swapped column order, a merged family header, a footnote changing one plan and a query missing the product family. Maintain separate failure labels for extraction, query disambiguation, cell resolution and explanation. Preserving cells and footnotes during ingestion teaches diagnosing lost relationships before evidence assembly. Here the parser can be correct and the answer can still fail because query terms were joined to the wrong qualified header path.
Related questions
Keep practising retrieval and rag
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