DeepSeek-OCR: Contexts Optical Compression
- Publication
- Publication venue not yet verified
- First submitted to arXiv
- arXiv:2510.18234
Cite this paper · BibTeX
The citation identifies the linked source version. It cites the original paper and its authors.
@misc{deepseekdeepseekocr2025,
title = {{DeepSeek-OCR: Contexts Optical Compression}},
author = {Haoran Wei and Yaofeng Sun and Yukun Li},
year = {2025},
eprint = {2510.18234},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2510.18234}
}
Judging by the name, this is an OCR model. Read the abstract, though, and you find that the authors are really asking something else.
When an LLM processes long text, the cost of attention grows with the square of the length. If a page of a document comes to a thousand text tokens, could you take a picture of it, give it to the model as a hundred, or even sixty-four, vision tokens, and have the model read the original text back?
If so, images become a way to compress text. The authors call this idea contexts optical compression, and OCR is the testing ground where they check it. The input is an image, the answer is the original text, and a simple comparison tells you whether it's right.
This is a technical report that DeepSeek-AI uploaded to arXiv on October 21, 2025, with the weights and code open-sourced at the same time.
Defining the Problem
In the related-work section, the authors ask directly how many vision tokens, at minimum, a thousand-word document needs in order to be decoded back.
Answering that requires an encoder whose number of vision tokens can be adjusted. The authors survey three common approaches in the open-source VLMs of the time, each with drawbacks:
- Dual-tower, as in Vary: an extra SAM encoder runs in parallel to handle high resolution. Parameters and memory stay reasonably under control, but images need two separate preprocessing paths, and pipeline parallelism is hard to apply during training.
- Tile-based, as in InternVL2.0: a large image is cut into small tiles that are encoded separately. It can handle extremely high resolutions, but the native resolution is usually below 512×512, so a large image gets chopped into many fragments and the number of vision tokens shoots up.
- Adaptive resolution, as in Qwen2-VL: patches are cut directly from the original image. It's flexible, but activation memory for large images is very high, and once the vision-token sequence gets long, both prefill and generation slow down.
The authors wanted an encoder that handles high resolution, keeps memory from blowing up at high resolution, produces few vision tokens, supports multiple resolutions, and still has a moderate parameter count. No existing option met all of these, so they built their own, called DeepEncoder.
Solving the Problem
Overall Architecture

Let's go through it once from left to right:
- SAM (80 million parameters, ViTDet architecture) handles perception, mainly with local window attention.
- Conv 16x is two convolutional layers that cut the number of tokens to one sixteenth.
- CLIP (ViT, 300 million parameters) handles global attention. Its original patch embedding layer is removed, since its input is already the tokens output by the previous stage.
- DeepSeek-3B is the decoder, a 3-billion-parameter MoE that activates about 570 million parameters per inference.
DeepEncoder as a whole has about 380 million parameters. The stages are ordered this way to do only cheap local attention while there are many tokens, and save the expensive global attention for after compression.
Walking One 1024×1024 Page Through
We'll use the paper's own example, a 1024×1024 page in Base mode:
- SAM works in 16×16-pixel patches, giving 1024/16 × 1024/16 = 64×64 = 4,096 patch tokens. This stage relies mainly on window attention and has only 80 million parameters, so memory holds up.
- The convolution module is two layers with kernel 3, stride 2, and padding 1, raising the channels from 256 to 1024. Each layer halves both height and width, going 64×64 → 32×32 → 16×16 and leaving 4,096 / 16 = 256 tokens.
- These 256 tokens go into CLIP for global attention. Pairwise attention over 256 tokens, compared with 4,096, means a score table 256 times smaller.
- The decoder receives these 256 vision tokens along with the prompt and outputs text autoregressively.
So “how many tokens a page becomes” is determined entirely by the input resolution:
| Mode | Resolution | Vision tokens | Processing |
|---|---|---|---|
| Tiny | 512×512 | 64 | Direct resize |
| Small | 640×640 | 100 | Direct resize |
| Base | 1024×1024 | 256 | Aspect ratio kept, padded |
| Large | 1280×1280 | 400 | Aspect ratio kept, padded |
| Gundam | n local 640×640 tiles + 1024×1024 global view | n×100 + 256 | Tiled, n from 2 to 9 |
The Decoder: Recovering Text from a Compressed Representation
The authors describe the decoder's job as a mapping that reconstructs the representation of text tokens from compressed vision tokens .
The decoder is DeepSeekMoE, which at inference activates 6 of its 64 routed experts plus 2 shared experts. The authors say it has the expressive power of a 3-billion-parameter model at an inference cost close to that of a small 500-million-parameter one.
When is more than ten times , the decoder can't get by on “translating” each vision token one at a time. It has to use the language knowledge it has learned to expand the compressed information into full sentences. That is why the method works, and it is also what later research would question; we'll come back to it in the discussion.
Data and Training
Document data is the centerpiece. The authors collected about 30 million PDF pages from the web, covering about 100 languages, roughly 25 million of them in Chinese and English. The annotations come in two kinds:
- Coarse annotations: text extracted directly from the PDFs with fitz, mainly to teach the model to recognize characters in many languages.
- Fine annotations: 2 million pages each of Chinese and English, labeled with interleaved “coordinates + category + text” using layout models such as PP-DocLayout and OCR models such as MinerU and GOT-OCR2.0. For minority languages, they used fitz to generate small images, trained a GOT-OCR2.0 on them, and then used it to annotate, producing 600,000 samples.
There are also 3 million Word documents, 10 million scene-text samples each in Chinese and English labeled with PaddleOCR, and what the authors call “OCR 2.0” data, including 10 million charts (labeled as HTML tables), 5 million chemical formulas (SMILES), and 1 million plane-geometry samples.
The overall mix is 70% OCR data, 20% general vision data, and 10% text-only data.
Training has two stages. First, DeepEncoder is trained on its own with a small language model and a next-token prediction objective; then SAM and the compressor are frozen, and the whole model is trained together with the decoder. The main training run used 20 nodes with eight A100-40G GPUs each, processing about 70 billion tokens of multimodal data per day.
Discussion
Compression Experiments: 100 Pages from Fox

Start with the left plot. The horizontal axis is the number of text tokens in each page's ground truth; the purple bars are 64 vision tokens (Tiny), the blue bars 100 (Small), and the dashed lines the corresponding compression ratios.
The authors selected every English page in the Fox benchmark with between 600 and 1,300 text tokens, which came to exactly 100 pages, and tested them with “Free OCR,” a prompt that doesn't ask for layout. A few rows from Table 2:
| Text tokens | 64 vision tokens | 100 vision tokens | Pages |
|---|---|---|---|
| 600–700 | 96.5% (10.5×) | 98.5% (6.7×) | 7 |
| 800–900 | 83.8% (13.2×) | 96.8% (8.5×) | 28 |
| 1000–1100 | 79.3% (16.5×) | 91.5% (10.6×) | 11 |
| 1200–1300 | 59.1% (19.7×) | 87.1% (12.6×) | 4 |
Two things to keep in mind when reading this table:
- The page counts are uneven. The abstract's “about 60% at 20× compression” comes from the last row, which has only 4 pages; the ranges in the middle, from 700 to 900, have 28 pages each.
- Format differences pull the scores down. The model's output format doesn't fully match Fox's ground truth, and the authors say actual performance should be somewhat higher than the table shows.
The authors think the decline beyond 10× compression may come from the more complex layouts of longer documents and from long text already being blurry at 512×512 and 640×640. The latter, they suggest, could be treated as a kind of “forgetting mechanism.”
Real Documents: OmniDocBench
The right plot and Table 3 switch to OmniDocBench, a real-world document parsing benchmark. The paper doesn't state the version; the table scores English and Chinese separately, consistent with the format before v1.5. Every metric is an edit distance, so lower is better. The authors' emphasis is token efficiency:
- Small mode uses only 100 vision tokens and reaches an overall English edit distance of 0.221, lower than GOT-OCR2.0 with 256 tokens (0.287).
- Gundam mode averages 795 tokens and scores 0.127 in English and 0.181 in Chinese, both better than MinerU2.0, which averages 6,790 tokens (0.133 and 0.238).
Table 4 breaks the results down by document type, showing how many tokens each kind of document needs. Slides already reach an edit distance of just 0.116 in Tiny mode; books and reports already do well in Small mode. Newspapers are another matter entirely, at 0.94 in Tiny and falling to 0.122 only in Gundam. The authors explain that a newspaper page has four to five thousand text tokens, far beyond the roughly 10× compression range of the other modes.
Optical Compression and Forgetting
In the discussion section, the authors imagine rendering earlier content in a multi-turn conversation as images to compress it; the older the conversation, the smaller the image, with fewer tokens and blurrier text, like human memory slowly fading.
The authors themselves call this a very preliminary exploration. The conclusion also states that OCR alone is not enough to fully validate true contexts optical compression; future work includes pretraining on interleaved digital and optical text, needle-in-a-haystack tests, and other evaluations.
Discussion After Release
The paper drew plenty of discussion after it came out. In a post on October 20, 2025, Andrej Karpathy said it was a good OCR model, but he was more interested in whether pixels might make better LLM inputs than text. His reasons included information compression, keeping formatting such as bold and color, and getting rid of the tokenizer. Karpathy, 2025-10-20
Another line of response was to check how much of those high scores actually came from the image. In January 2026, “Visual Merit or Linguistic Crutch?” replaced Fox's paragraphs with random letters: Tiny mode fell from 88% to about 20%, while on the same data PaddleOCR-v5, which recognizes text line by line, dropped only from 94% to 90%.
Back to that mapping. When each vision token has to account for a dozen or more text tokens on average, the decoder's language knowledge has to fill in a great deal. With normal English, that knowledge is what makes the compression work; when the content follows no pattern, it can't fill the gaps back in.
Conclusion
DeepSeek-OCR turns “how many vision tokens does a page need?” into a measurable question and gives a practical answer:
- DeepEncoder's arrangement works. Local attention first, then compression, then global attention lets a 1024×1024 page produce only 256 vision tokens while keeping memory in check.
- At about 10× compression, English pages can mostly be read back. On Fox, precision is about 97% within 10×; at higher compression ratios it starts to drop, and the figures around 20× rest on only a handful of pages.
- As an OCR tool, its token efficiency is excellent. Small mode already beats GOT-OCR2.0, and Gundam mode beats MinerU2.0 with less than an eighth of the tokens. The authors also say a single A100-40G can produce more than 200,000 pages of training data a day.
As for “compressing an LLM's long context with images,” the paper takes only the first step. The OCR scores show that the decoder can recover the text, but they don't tell us how much of the recovered text came from the image. Three months later, someone took up that question.