Supervised fine-tuning
Document parsing pipelines
How do I fine-tune a model to parse messy PDFs and scans consistently?
Train on your own extracted text paired with the corrected output. The value is handling your specific layout failures — split tables, running headers, footnote reflow — which a general model has no reason to have learned.
| Objective | Supervised fine-tuning |
|---|---|
| Dataset shape | Raw extracted text in, cleaned and structured output out, including the badly extracted cases. |
| Metric that decides it | Field-level accuracy on documents from each layout family you actually receive. |
| Cheapest starting point | Mistral Nemo 12B on RTX 4000 Ada$0.09 per GPU-hour |
Document pipelines break on layout, not language. A table split across a page boundary, a header repeated mid-paragraph, a footnote reflowed into the body: text extraction produces something almost right, and the almost is what costs a person an hour a day.
Your correction history is the dataset. Wherever someone has fixed a parsed document, that is a labelled pair of what extraction produced and what it should have produced.
Long context matters more than parameter count. A 12B model with a 128K window handles a whole report in one pass; a stronger model with a short window forces a chunking layer whose seams create new errors.
The mistake to avoid
Training only on clean documents because they were easier to assemble. The model never sees the layouts that motivated the project.
Models to start from
In order. Start at the top and move down the list only if the evaluation gate says you have to — the smallest model that clears your bar is the one you pay for on every request forever.
Before you deploy it
Whatever the metric above says in isolation, the deployment decision is comparative: is this better than what is running today? Gate the candidate against the incumbent, blinded, on held-out cases from your own traffic. A fail is a cheap answer to an expensive question.
Frequently asked questions
Does this replace my OCR step?
No. It cleans up after it. Text extraction stays; the fine-tune fixes the structural damage extraction leaves behind.
How do I handle new layouts?
Track accuracy per layout family. A new supplier or template is a new family, and it needs its own examples before you should trust the output.
Start with Mistral Nemo 12B
Upload your dataset, read the validation report, and forecast the run before anything is leased.