# Document Ingestion and Parsing

> Real-world data is PDFs, HTML, slides and spreadsheets; clean extraction and a repeatable, incremental pipeline decide RAG quality. Free notes, key concepts,...

Canonical: https://www.internhack.in/roadmaps/tracks/ai-engineer/document-ingestion
Last updated: 2026-11-28

Real-world data is PDFs, HTML, slides and spreadsheets; clean extraction and a repeatable, incremental pipeline decide RAG quality.

Intermediate · about 5 hours · difficulty 3/5

Learn first: [RAG Fundamentals](https://www.internhack.in/roadmaps/tracks/ai-engineer/rag-basics)

Garbage in, garbage retrieved. Ingestion is unglamorous but it is where many RAG projects are won or lost.

### Extracting text

- **PDFs** are layouts, not documents. Text extractors can scramble columns, headers and tables. Try a few parsers; for complex layouts use layout-aware tools or send page images to a vision-capable model.
- **HTML**: strip navigation, footers and scripts; keep headings for structure.
- **Office files, Markdown, code, email, chat exports**: each needs its own loader.
- **Tables**: keep them intact, convert to Markdown, or also store a natural-language summary.
- **Scanned documents** need OCR.

### The pipeline around it

- **Normalize**: fix whitespace, encoding and boilerplate; remove duplicates.
- **Capture metadata**: source URL, title, author, dates, permissions.
- **Incremental updates**: hash content so unchanged documents are skipped and edited ones are re-chunked and re-embedded. Handle deletions so stale chunks disappear.
- **Idempotence and logs**: rerunning ingestion must not create duplicates; log failures per file.

### Pitfalls

Never trust extraction blindly. Spot-check a sample of parsed documents by eye, especially tables and multi-column pages. Also remember that ingested documents may contain hidden instructions (prompt injection) or sensitive data (PII).

### Good enough to move on

You have an ingestion job that handles at least three file types, skips unchanged files, removes deleted ones, and logs failures.

## Key concepts

- **PDF text extraction**
- **HTML cleaning**
- **Tables and structured content**
- **OCR and vision-based parsing**
- **Content hashing and incremental updates**
- **Handling deletions**
- **Parsing libraries (Unstructured, Docling)**

## Mini project

Write an ingestion job that watches a folder of PDFs, HTML and Markdown files, parses and chunks them, and on rerun only processes changed files and removes chunks for deleted files.

## Check yourself

A policy PDF was updated but users still get answers from the old version. What part of your ingestion pipeline failed?

## Free resources

- [Docling documentation](https://docling-project.github.io/docling/) (Docling)
- [Unstructured open source docs](https://docs.unstructured.io/open-source/introduction/overview) (Unstructured)

Previous: [RAG Fundamentals](https://www.internhack.in/roadmaps/tracks/ai-engineer/rag-basics) · Next: [Hybrid Search: Keywords Plus Vectors](https://www.internhack.in/roadmaps/tracks/ai-engineer/hybrid-search)

## More in Retrieval-Augmented Generation

- [RAG Fundamentals](https://www.internhack.in/roadmaps/tracks/ai-engineer/rag-basics)
- [Document Ingestion and Parsing](https://www.internhack.in/roadmaps/tracks/ai-engineer/document-ingestion)
- [Hybrid Search: Keywords Plus Vectors](https://www.internhack.in/roadmaps/tracks/ai-engineer/hybrid-search)
- [Reranking Retrieved Results](https://www.internhack.in/roadmaps/tracks/ai-engineer/reranking)
- [Citations and Grounded Answers](https://www.internhack.in/roadmaps/tracks/ai-engineer/citations-grounding)
- [Evaluating Retrieval Quality](https://www.internhack.in/roadmaps/tracks/ai-engineer/retrieval-evaluation)
- [Advanced RAG Patterns](https://www.internhack.in/roadmaps/tracks/ai-engineer/advanced-rag)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [AI Engineer Roadmap](https://www.internhack.in/roadmaps/tracks/ai-engineer)
