Donut · document AI

Also known as: Document Understanding Transformer

On this page 6

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.

ComponentRoleNotable detail
Swin Transformer encoderTurns the page image into visual featuresHandles high input resolution efficiently
BART-style decoderGenerates the output token sequenceMultilingual vocabulary
Task promptSelects the task at inference timeOne model can serve several tasks
Structured tokensMark fields and nesting in the outputConverted to JSON after decoding
Components of the Donut model

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.

TaskTypical outputExample dataset
Document classificationA single class labelRVL-CDIP
Receipt parsingNested fields and line itemsCORD
Key information extractionNamed fields such as date and totalSROIE, Train Ticket
Document question answeringA short answer to a questionDocVQA
Downstream tasks commonly used with Donut

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.

ApproachInputMain trade-off
DonutPage image onlySimple pipeline; weaker on dense small text
LayoutLM familyImage, OCR text and boxesStrong accuracy; depends on OCR quality
Pix2StructScreenshot or page imageBroader pre-training on web pages
NougatScientific page imagesSpecialized for papers and formulas
Vision-language LLMsImage plus instructionFlexible; larger and costlier to run
Donut and related approaches

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.

IssueCauseMitigation
Hallucinated valuesDecoder generates plausible but absent textValidate fields with rules and checksums
Missed small printInsufficient input resolutionIncrease resolution or crop regions
Slow inference on long pagesAutoregressive decoding of long outputsLimit schema to required fields
No confidence per fieldOutput is a generated sequenceUse token probabilities as a proxy score
Poor multi-page handlingModel processes one image at a timeSplit documents and merge results
Typical issues when deploying Donut

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.