DeepSeek-OCR: Optical Context Compression, Setup and Limits
DeepSeek-OCR is a 3B open OCR model that explores compressing long text contexts into vision tokens. This guide explains DeepEncoder, the measured compression-accuracy tradeoff, all five supported resolution modes, prompt recipes, working vLLM and Transformers code, and the limits DeepSeek states.
View 2 referencesAllow the functional cookie to save your likes. Privacy details
What is DeepSeek-OCR?
DeepSeek-OCR is an open-source OCR and document-understanding model released by DeepSeek on October 20, 2025. It investigates whether a document image can encode long textual context more cheaply than the equivalent digital text, using vision tokens as a compression medium.
The model has two parts: DeepEncoder, which processes high-resolution images with low activation and produces a manageable number of vision tokens, and DeepSeek3B-MoE-A570M, a mixture-of-experts decoder that converts those tokens back to text. The repository carries an MIT license. DeepSeek added upstream vLLM support on October 23, 2025, and announced DeepSeek-OCR2 on January 27, 2026. Official repository
How does DeepSeek-OCR compress text into vision tokens?
DeepSeek-OCR maps a page of text into a small grid of vision tokens, then asks the decoder to reconstruct the text from them. Because attention cost grows with the square of sequence length, fewer tokens mean cheaper long-context handling. DeepEncoder keeps activations low at high resolution while emitting few tokens.
The key design constraint is DeepEncoder: it must keep activations low at high resolution while emitting few enough tokens to be useful. DeepSeek frames the work as an initial feasibility study of optical 2D mapping, not as a general replacement for text context. The paper is titled "DeepSeek-OCR: Contexts Optical Compression" and is listed as arXiv:2510.18234, with Haoran Wei, Yaofeng Sun and Yukun Li as authors. Paper
How accurate is DeepSeek-OCR at high compression ratios?
DeepSeek reports roughly 97% decoding accuracy when text tokens stay within ten times the vision-token count, and about 60% at a 20x compression ratio. The ten-times boundary is where the method remains practical. Fox benchmark results show accuracy falling sharply as pages get denser and the token budget stays fixed.
On the Fox benchmark, the paper's own table shows accuracy falling as documents get denser: for pages with 600–700 text tokens, 64 vision tokens give 96.5% and 100 vision tokens give 98.5%; for 1,200–1,300 text tokens, the same settings give 59.1% and 87.1%. On OmniDocBench, DeepSeek reports state-of-the-art results among end-to-end models while using the fewest vision tokens, including beating GOT-OCR2.0 with 100 tokens per page against 256. These measurements come from DeepSeek's paper and should be reproduced on your own document mix before you design around them. Compression results
Which resolution modes does DeepSeek-OCR support?
The model supports four native-resolution modes and one dynamic mode, each trading detail for a fixed token count. Tiny uses 64 vision tokens at 512 pixels, Small 100 at 640, Base 256 at 1024, Large 400 at 1280, and Gundam combines small crops with one base view.
| Mode | Input size | Vision tokens |
|---|---|---|
| Tiny | 512 x 512 | 64 |
| Small | 640 x 640 | 100 |
| Base | 1024 x 1024 | 256 |
| Large | 1280 x 1280 | 400 |
| Gundam (dynamic) | n x 640 x 640 + 1 x 1024 x 1024 | variable |
Small, at 100 vision tokens, is the interesting default for dense documents because it was the setting used in the OmniDocBench comparison. Gundam combines many small crops with one base-resolution view, which suits pages with mixed-size content. Supported modes
How do you run DeepSeek-OCR?
You can run DeepSeek-OCR through vLLM for throughput or Transformers for flexibility. The repository documents both, plus batch evaluation and a PDF path measured at roughly 2,500 tokens per second on an A100-40G. The documented environment is CUDA 11.8 with PyTorch 2.6.0 and Python 3.12.9.
The documented environment is CUDA 11.8 with PyTorch 2.6.0 and Python 3.12.9. For a Transformers inference:
from transformers import AutoModel, AutoTokenizer
import torch, os
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
model_name = "deepseek-ai/DeepSeek-OCR"
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
model = AutoModel.from_pretrained(
model_name, _attn_implementation="flash_attention_2",
trust_remote_code=True, use_safetensors=True,
).eval().cuda().to(torch.bfloat16)
prompt = "<image>\n<|grounding|>Convert the document to markdown."
res = model.infer(
tokenizer, prompt=prompt, image_file="your_image.jpg",
output_path="your/output/dir", base_size=1024, image_size=640,
crop_mode=True, save_results=True, test_compress=True,
)
For vLLM, the upstream path uses uv pip install -U vllm --pre --extra-index-url https://wheels.vllm.ai/nightly and an LLM instance with NGramPerReqLogitsProcessor, prefix caching disabled and a 30-token n-gram window. The repository's own scripts under DeepSeek-OCR-master provide ready-made image, PDF and batch-evaluation entry points. Install and inference
Which prompts should you use with DeepSeek-OCR?
Prompt prefixes switch tasks, so choosing the right one matters as much as resolution. The repository documents conversion to markdown, general OCR, plain text without layout, figure parsing, detailed description, and referring-expression grounding. The test_compress flag reports compression information during inference.
<|grounding|>Convert the document to markdown.for structured document conversion.<|grounding|>OCR this image.for general text in images.Free OCR.when you do not want layout information.Parse the figure.for charts and figures embedded in documents.Describe this image in detail.for general vision understanding.Locate <|ref|>xxxx<|/ref|> in the image.for referring-expression grounding.
The test_compress=True flag in the inference call reports compression information, which is useful if you are evaluating the optical-compression idea itself rather than just extracting text.
What are the limits of DeepSeek-OCR?
DeepSeek-OCR is a feasibility study, not a general long-context solution. Accuracy depends on how many text tokens a page contains relative to the vision budget; at 64 tokens and 1,200 to 1,300 text tokens, reported Fox accuracy falls to 59.1%. It also needs CUDA, flash-attention and trust_remote_code.
Three limitations follow from the published results. Densely typeset pages are the weak case: at 64 vision tokens and 1,200–1,300 text tokens, reported Fox accuracy drops to 59.1%. The 20x compression figure of about 60% accuracy is interesting for research but too low for high-stakes transcription. And DeepSeek-OCR2 was announced in January 2026, so check whether the newer release supersedes the version you are evaluating.
The model also requires a CUDA environment, flash-attention and trust_remote_code=True, which is a meaningful deployment constraint in regulated settings. Finally, the reported OmniDocBench comparison is against specific baselines under specific settings; it does not imply superiority over every modern OCR system.
Frequently asked questions about DeepSeek-OCR
These questions address what practitioners verify first: model size, license, PDF support, the Gundam dynamic mode, and whether a newer version exists. Answers come from the official repository and paper, and each points to the source needed for a deeper check.
Is DeepSeek-OCR really only 3B parameters?
The decoder is described as DeepSeek3B-MoE-A570M: about 3B total parameters with roughly 570M active per token. The venue reporting the release called it a 3B model, consistent with that architecture.
What license does DeepSeek-OCR use?
The GitHub repository includes an MIT license. Check the model card on Hugging Face for any additional model-specific terms before commercial use.
Can DeepSeek-OCR process PDFs?
Yes. The repository ships a PDF script and reports concurrency around 2,500 tokens per second on a single A100-40G in its documented setup.
What is Gundam mode?
Gundam is the dynamic-resolution mode: many 640 x 640 crops plus one 1024 x 1024 view. It is designed for pages whose content varies in scale.
Is there a newer version?
DeepSeek announced DeepSeek-OCR2 on January 27, 2026 in the same repository. Evaluate both if compression quality matters to your use case.
Bottom line
DeepSeek-OCR is worth running if you handle large document volumes and want to trade vision tokens for cheaper context, especially at the 100-token Small setting. It is not yet a drop-in answer to long-context cost: dense pages degrade sharply at low token budgets, and the accuracy numbers are DeepSeek's own. Treat it as a strong research artifact with a clear operating envelope.