RAG & Retrieval·Question 13 of 100Basic

How would you detect that a parser silently corrupted documents, at scale, without reading every page?

Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.

Model answer: the part to lead with

You cannot eyeball millions of pages, so the job is to make silent failure loud: automatic parse-quality signals that flag suspect documents into a review-or-reprocess queue, backed by a small hand-checked reference set per document type. Silent parse corruption is the worst class of RAG bug because nothing errors - a mangled table or interleaved columns flow into chunking, embedding and generation, and the model answers confidently from soup while the pipeline reports success at every stage.

Full worked answer

You cannot eyeball millions of pages, so the job is to make silent failure loud: automatic parse-quality signals that flag suspect documents into a review-or-reprocess queue, backed by a small hand-checked reference set per document type. Silent parse corruption is the worst class of RAG bug because nothing errors - a mangled table or interleaved columns flow into chunking, embedding and generation, and the model answers confidently from soup while the pipeline reports success at every stage.

Cheap automatic signals, computed at ingest per page:

  • Extraction ratio: near-empty text from a large or image-heavy file means a missing text layer or a failed OCR pass.
  • Gibberish detection: fraction of tokens that are not real words, long runs of single characters, absurd mean word length - catches encoding breakage and column interleaving.
  • Structure ratios: a page that comes out as one unbroken block, or as mostly whitespace, is suspect.
  • Table sanity: detected table regions whose extracted form has no consistent column count.
  • Header/footer repetition: the same line on nearly every page usually means chrome leaked into the body.
  • OCR confidence and language-detection failures, where the parser exposes them.

Corroboration on a sample: run a cheap second parser and diff the two outputs, since large disagreement isolates the hard pages, or use an LLM to judge whether the extracted text reads as coherent prose for its type.

Process around the signals: sample stratified by document type and source, because failures cluster by template; diff parsed output against the rendered page; and track a parse-quality score per document type over time, so a parser upgrade that regresses one template fails a check instead of shipping silently. Route flagged pages to the expensive path (a VLM) rather than indexing them broken.

The misconception is that parse quality is a property you inherit from a library. It is a per-corpus metric you have to instrument.

What a good answer covers

  • You cannot eyeball millions of pages, so the job is to make silent failure loud
  • Silent parse corruption is the worst class of RAG bug because nothing errors - a mangled table or…
  • Extraction ratio: near-empty text from a large or image-heavy file means a missing text layer or a…
  • Gibberish detection: fraction of tokens that are not real words, long runs of single characters, absurd…
  • Structure ratios: a page that comes out as one unbroken block, or as mostly whitespace, is suspect

Key terms: Extraction ratio · Gibberish detection · Structure ratios · Table sanity · Header/footer repetition · OCR confidence and language-detection failures

Interviewer follow-ups to expect

  1. Which single automatic signal catches the most parse failures per unit of effort?

  2. When is a flagged page worth re-parsing with a VLM versus dropping it from the corpus?

Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep