---
title: Design a pipeline that turns 50 million PDFs (born-digital reports, scanned forms, papers with tables and equations)…
url: https://gurkanozkan.ai/learn/questions/recent-a-datapipe-01/
markdown: https://gurkanozkan.ai/learn/questions/recent-a-datapipe-01.md
kind: question
role: Applied LLM
stage: System design
difficulty: Hard
json: https://gurkanozkan.ai/api/learn/questions/recent-a-datapipe-01.json
robots: noindex
---

# Design a pipeline that turns 50 million PDFs (born-digital reports, scanned forms, papers with tables and equations) into clean text for pretraining and retrieval. Choose between heuristic extractors and a vision-language OCR model, estimate the cost, and explain how you would measure quality.

Applied LLM · System design · Hard

## Answer

*Model answer, written in a candidate's voice*

### In short

- Route with a cheap classifier: born-digital pages with a good text layer go to a fast extractor; scanned pages and complex layouts (tables, formulas, multi-column) go to a VLM-based OCR model.
- Estimate cost with stated assumptions: 50M PDFs x 10 pages = 500M pages; self-hosted olmOCR-style inference at roughly $176 per million pages is about $88k, versus >$6,000 per million pages for a frontier API (~$3M), so hybrid routing is the main lever.
- Measure quality with unit-test-style checks on a labelled sample per document type: required text present, reading order, table cells, formula rendering, plus downstream retrieval and perplexity checks.
- Post-process: exact and near-duplicate removal, language identification, PII redaction, boilerplate removal, and provenance/licence metadata stored with each document.
- Engineer sharded, idempotent jobs with retries and a dead-letter queue for corrupt files, versioned extractors for reprocessing, and lineage from output back to source.

### In full

I would not run one extractor over everything; I would put a cheap classifier in front and route born-digital pages with a usable text layer to a fast text extractor, while sending scanned pages and complex layouts (tables, equations, multi-column) to a VLM-based OCR model. With stated assumptions of 50M PDFs at about 10 pages each (500M pages), self-hosted olmOCR-style inference at roughly $176 per million pages is about $88k, versus more than $6,000 per million pages for a frontier API (~$3M), so the classifier and the split between fast and VLM paths are where the cost is won. Quality would be measured with unit-test-style checks on a labelled sample per document type — required text present, reading order, table cells, formula rendering — plus downstream retrieval and perplexity checks rather than trusting raw OCR confidence. After extraction I would run exact and near-duplicate removal, language identification, PII redaction, boilerplate removal, and store provenance and licence metadata with each document so downstream consumers know what is usable and under what terms. Operationally I would shard the work, make jobs idempotent with retries and a dead-letter queue for corrupt files, version the extractors so documents can be reprocessed when a better model lands, and keep lineage from every output back to its source PDF.

*Checked against sources by an independent AI reviewer.*

## What a strong answer covers

- Routes documents: born-digital pages with good text layers go to a fast extractor; scanned pages and complex layouts (tables, formulas, multi-column) go to a VLM-based OCR model; a cheap classifier decides
- Estimates cost with stated assumptions, e.g. 50M PDFs × 10 pages = 500M pages; at the roughly $176 per million pages olmOCR reported for self-hosted inference that is about $88k, versus about $3M at the >$6,000 per million pages it estimated for a frontier API
- Measures quality with unit-test-style checks (required text present, reading order, table cells, formula rendering) on a labelled sample per document type, plus downstream retrieval or perplexity checks
- Post-processing: exact and near-duplicate removal, language identification, PII redaction, boilerplate removal, and provenance and licence metadata stored with each document
- Engineering: sharded, idempotent jobs with retries and a dead-letter queue for corrupt files, versioned extractors so documents can be reprocessed, and lineage from output back to source

## Common mistakes

- Sending every page to an expensive frontier API
- Judging extraction quality by eyeballing a handful of documents

## Follow-ups

- A downstream team finds tables are silently flattened. How do you detect and backfill?

## Topic guides

- [Data pipelines for ML and LLM systems](https://gurkanozkan.ai/learn/topics/data-pipeline.md)
- [Data quality, leakage and drift](https://gurkanozkan.ai/learn/topics/data-quality.md)
- [LLM cost and unit economics](https://gurkanozkan.ai/learn/topics/cost.md)
---

*Study material compiled with AI: drafted by a local model (Inkling 2 Mini) from public sources, then checked against those sources by independent AI reviewers (Claude) in November 2026. Not reviewed line by line by a person.*
