RAGcore
Document parsing
Turning PDFs, slides, HTML and scans into clean text with structure — the step most RAG quality is lost in.
What it is and why it exists
Retrieval can only find what parsing extracted. PDFs hide reading order, tables become word soup, headers and footers repeat on every page, scans need OCR. Good parsing keeps headings, lists and tables as structure and attaches metadata (source, page, section, permissions, dates).
Quick prototype
pypdf text extraction, ignore tables.
In production, at scale
Route by document type: native text for digital PDFs and HTML, layout-aware parsers for complex layouts and tables, OCR or vision models for scans; strip boilerplate; store page and section anchors for citations; spot-check extraction quality per source.
Vendors and tools
| Unstructured / Docling / LlamaParse | Layout-aware parsing to elements |
|---|---|
| Azure Document Intelligence / Google Document AI | OCR, layout and forms |
| Vision models | Page images → structured text for hard layouts |
On AWS: Amazon Textract (OCR, tables, forms); Bedrock Data Automation; Bedrock Knowledge Bases can use foundation-model parsing.
How it fails
- Two-column PDFs read across columns
- Tables flattened so values lose their headers
- Repeated footers dominating every chunk
What the interviewer asks next
Retrieval misses answers that are in a table. Why?
Parsing flattened the table so the value and its header ended up far apart or in different chunks. Keep tables intact (or as row-wise text with headers repeated) and chunk around them.
What metadata do you attach at parse time?
Source ID and URL, title, section path, page, last-modified date, version, language and the access-control list — everything you will filter, cite or freshness-check on later.