Concept guide · RAG foundations
How do you handle PDFs, scans, tables, and images in RAG?
A slower explanation for when the short interview answer is not enough. Start with the intuition, then connect it to the technical idea and the way an interviewer expects you to reason about it.
ML area
Generative AI → Document ingestion for RAG
Interview format
Core · Scenario
Question
GENAI-053
Start with the idea
In simple terms
PDFs, scans, tables, and images need format-aware extraction. A text parser may handle a digital PDF well but produce nonsense for a scan or destroy the relationship between a table header and its values.
Make it concrete
For an invoice, preserve the vendor, invoice number, table headers, line items, totals, page, and source file instead of indexing a flat stream of disconnected numbers.
Build the answer
How to approach it
- 1Classify files and choose extraction based on their actual structure.
- 2Preserve layout, headings, tables, pages, and source identifiers.
- 3Create extraction quality checks before embedding the output.
Go one level deeper
The technical explanation
Ingestion is data engineering, not a one-time upload. Detect document type, choose OCR or vision when required, preserve layout and reading order, attach page and section metadata, and validate extracted samples against originals. Keep raw artefacts and parser versions so a better extractor can reprocess the corpus without losing provenance.
Say this in the interview
Use format-aware parsing, OCR or vision for scans, and preserve page, heading, table, and source metadata. Keep table headers with values and validate extraction on representative pages. Route complex documents through more expensive processing rather than assuming plain text extraction is correct.
Keep preparing