Optical compression in DeepSeek-OCR is a technique that converts a full document image into a compact set of vision tokens while preserving the essential information needed to reconstruct the text and layout. Instead of analyzing each character or word individually like traditional OCR engines, DeepSeek-OCR’s optical compression treats the entire page as a visual signal. It uses a neural encoder, called the DeepEncoder, to identify meaningful visual regions—such as paragraphs, tables, or figures—and compress them into a much smaller token representation. These tokens act like condensed “snapshots” of the document’s content and structure, allowing the model to represent pages with as few as one-tenth the number of tokens compared to conventional methods.
The process works in three main stages: render, compress, and reconstruct. First, DeepSeek-OCR renders the input document into a high-resolution visual format (such as a page image). The DeepEncoder then analyzes this image to extract key spatial and textual patterns. This stage performs what’s called “optical compression,” meaning it reduces the image into a compact sequence of visual embeddings—roughly 10× to 20× smaller than the original tokenized text representation. Finally, the Mixture-of-Experts (MoE) Decoder reconstructs the original text, layout, and structural metadata from these tokens. The decoder learns to map the compressed vision tokens back into readable text and structured formats like Markdown, HTML, or JSON, depending on the output mode. This approach enables high accuracy while significantly reducing computational cost.
For developers, optical compression is valuable because it solves a key bottleneck: processing long or complex documents efficiently. For example, when integrating DeepSeek-OCR into retrieval-augmented generation (RAG) or long-context workflows, the compressed token sequence allows large language models to handle entire PDFs or research papers without hitting token limits. It also speeds up inference, reduces GPU memory consumption, and lowers cost. In essence, optical compression lets DeepSeek-OCR act like a visual “zip file” for documents—capturing every essential feature while stripping away redundant visual information—making it practical for large-scale, high-volume document understanding tasks.
Resources: