Donut, short for Document Understanding Transformer, is an OCR-free document AI model that reads a document image directly and generates structured output, such as key-value pairs in JSON form, without first running optical character recognition. Introduced by researchers at NAVER Clova in 2022, it became a reference architecture for end-to-end document understanding in Document AI.
Earlier pipelines chained an OCR engine, a layout model and an extraction model, so errors from the first stage propagated through the rest. Donut replaces that chain with a single image-to-sequence transformer trained to map pixels to the desired output, which simplifies deployment and removes OCR errors and costs from the pipeline. Not to be confused with unrelated uses of the same name outside document AI.
How the Donut architecture works
Donut consists of a visual encoder and a text decoder connected by cross-attention. The encoder is a Swin Transformer that splits the page image into patches and produces a grid of visual embeddings; the decoder, initialized from a multilingual BART-style language model, generates output tokens one at a time while attending to those embeddings.
The task is controlled by a task prompt token given to the decoder at the start, for example a token that means receipt parsing or question answering. The decoder then emits a token sequence with special field tags, such as an opening and closing tag around a total amount, which a simple converter turns into JSON output.
The table summarizes the main components and their roles.
| Component | Role | Notable detail |
|---|---|---|
| Swin Transformer encoder | Turns the page image into visual features | Handles high input resolution efficiently |
| BART-style decoder | Generates the output token sequence | Multilingual vocabulary |
| Task prompt | Selects the task at inference time | One model can serve several tasks |
| Structured tokens | Mark fields and nesting in the output | Converted to JSON after decoding |
Because Donut reads text from pixels, it needs high input resolution. Typical configurations use page images of roughly 2,560 by 1,920 pixels for full documents, and lower resolution visibly degrades recognition of small print.
Pre-training and fine-tuning
Donut learns to read through a pseudo-OCR pre-training task: given a document image, the model must output all of its text in reading order. This objective teaches the decoder both character recognition and reading order without any separate OCR model.
Real annotated documents are scarce, so the authors also released SynthDoG, a synthetic document generator that renders text from corpora onto varied backgrounds and layouts in several languages. Synthetic pages make it practical to pre-train for new languages and scripts at low cost.
After pre-training, the model is fine-tuned on a downstream task with a few hundred to a few thousand labeled examples, where each label is the target JSON for one image. The following table lists typical tasks and the public datasets often used to evaluate them.
| Task | Typical output | Example dataset |
|---|---|---|
| Document classification | A single class label | RVL-CDIP |
| Receipt parsing | Nested fields and line items | CORD |
| Key information extraction | Named fields such as date and total | SROIE, Train Ticket |
| Document question answering | A short answer to a question | DocVQA |
Donut compared with other document models
Donut belongs to the class of OCR-free document understanding models, in contrast with layout-aware language models that consume OCR text plus bounding boxes. Each approach has clear strengths, and the right choice depends on document type and accuracy requirements.
| Approach | Input | Main trade-off |
|---|---|---|
| Donut | Page image only | Simple pipeline; weaker on dense small text |
| LayoutLM family | Image, OCR text and boxes | Strong accuracy; depends on OCR quality |
| Pix2Struct | Screenshot or page image | Broader pre-training on web pages |
| Nougat | Scientific page images | Specialized for papers and formulas |
| Vision-language LLMs | Image plus instruction | Flexible; larger and costlier to run |
On structured receipts and forms, Donut reached accuracy comparable to OCR-based pipelines while running faster, because it skips the OCR stage. On text-heavy question answering such as DocVQA, OCR-based models and later large vision-language models generally score higher, since answers often depend on small text that Donut reads less reliably.
Strengths, limitations and practical use
Donut is most useful for semi-structured, repetitive documents such as receipts, tickets, simple invoices and forms, where the output schema is fixed and a modest labeled dataset is available. It is also attractive in environments where licensing or running a commercial OCR engine is impractical.
| Issue | Cause | Mitigation |
|---|---|---|
| Hallucinated values | Decoder generates plausible but absent text | Validate fields with rules and checksums |
| Missed small print | Insufficient input resolution | Increase resolution or crop regions |
| Slow inference on long pages | Autoregressive decoding of long outputs | Limit schema to required fields |
| No confidence per field | Output is a generated sequence | Use token probabilities as a proxy score |
| Poor multi-page handling | Model processes one image at a time | Split documents and merge results |
The most important warning concerns generative errors: unlike OCR, which fails visibly, Donut can output a well-formed but incorrect value. Production systems therefore add validation rules, extraction confidence scores derived from token probabilities and human review for low-confidence fields.
Teams adopting Donut should also plan for schema changes. Adding a new field requires new labels and another fine-tuning run, whereas instruction-following vision-language models can often extract a new field from a prompt alone. In exchange, a fine-tuned Donut model is small enough to run on a single modest GPU and gives predictable latency, which matters for high-volume batch processing and for deployments that must keep documents on premises.
In plain words
Most document software works in two steps. First it turns the picture of a page into text. Then it tries to find the useful parts. Donut does both steps at once.
It looks at the image of a receipt or form and writes out the answer directly, such as the date, the shop and the total. This is simpler and often faster. The catch is that it can sometimes write a value that looks right but is wrong, so important results still need checking.
A real-world example
An expense management team receives about 30,000 photographed receipts each month from employees in several countries. The existing pipeline uses a commercial OCR service plus custom rules, which is costly and breaks on crumpled or low-contrast images.
The team fine-tunes a pre-trained Donut model on 2,000 labeled receipts with fields for merchant, date, currency, tax and total. In testing, the model extracts the total correctly on most receipts and removes the per-page OCR fee. Rules then check that line items add up to the total and route mismatches, roughly one receipt in twenty, to a human reviewer. The result is lower processing cost with controlled accuracy.