DeepSeek-OCR 2: Visual Causal Flow
Stop reading images in raster order. Let learnable queries attend over the whole page and hand the language model a semantically reordered sequence instead of a top-left-to-bottom-right scan.
arXiv:2601.20552Where this sits
The second step in the optical compression line. The first model asked how many vision tokens a page needs; this one asks in what order those tokens should arrive. It is a small, focused change with a clear claim: the rigid raster scan that every vision-language model inherits from image grids is the wrong interface for documents.
- Replaces DeepEncoder's CLIP component with DeepEncoder V2, an LLM-style encoder whose learnable causal flow queries reorder visual tokens by semantics before the decoder reads them.
- Keeps visual tokens under bidirectional attention for global modeling while queries run causal attention, combining both in one customized attention mask.
- Preserves the token budget: queries have the same cardinality as visual tokens, so only query outputs are forwarded and the sequence stays at 256 to 1120 tokens, at or below the previous model's 1156.
- Raises OmniDocBench v1.5 to 91.09 percent, a 3.73 point gain over DeepSeek-OCR, and cuts reading-order edit distance from 0.085 to 0.057.
- Improves production robustness: repetition rate falls from 6.25 to 4.17 percent on online user-log images and from 3.69 to 2.88 percent on PDF data production.
What it is
DeepSeek-OCR 2 keeps the optical compression idea of the first model and replaces its encoder's CLIP block with DeepEncoder V2, an LLM-style module that reorders visual tokens before the decoder sees them. Visual tokens keep bidirectional attention so global context is preserved, while a set of learnable causal flow queries, appended after them, attend to all visual tokens and to one another in causal order. Because the queries have the same cardinality as the visual tokens, only their outputs are passed to the language decoder, and the total sequence does not grow: 256 tokens for the global view plus 144 per local crop, capped at 1120. The paper describes the result as two cascaded one-dimensional causal reasoners - the encoder chooses a reading order, the decoder reasons over it - and reports 91.09 percent on OmniDocBench v1.5, a 3.73 point gain over DeepSeek-OCR, with reading-order edit distance falling from 0.085 to 0.057 and production repetition rates dropping from 6.25 to 4.17 percent on user-log images.
1Theory from first principles
The raster scan is an assumption, not a law
Vision-language models flatten an image grid in a fixed order, usually left to right, top to bottom, and encode position with a fixed positional scheme. Language models, meanwhile, read causal sequences. For a photograph the order hardly matters; for a page it matters a great deal, because a document has a logical reading order that a raster scan does not follow. Multi-column layouts, sidebars, figures with captions, and tables all break the assumption, and the model pays for it in the reading-order mistakes that show up downstream as garbled output. The paper's premise is that the order should be decided from the image's semantics rather than imposed by the grid.
DeepEncoder V2: bidirectional seeing, causal ordering
The encoder keeps DeepSeek-OCR's window-attention perception stage and the 16x compressor, and swaps the CLIP block for a small LLM-style stack with a custom mask. Visual tokens are processed bidirectionally, exactly as a vision encoder would, so each token sees the whole page and global modeling is not lost. Appended after them is a set of learnable query tokens - the causal flow queries - that run causal attention: each query attends to every visual token and to the queries before it. The queries therefore form a sequence that progressively summarizes the page in a chosen order, and because there are as many queries as visual tokens, the outputs can replace the visual sequence one for one. Only the query outputs are handed to the language decoder, which then reasons over an already-ordered sequence with its ordinary causal attention.
The dual-stream attention mask
M = [ [ 1, 0 ],
[ 1, LowerTri(Q) ] ]
visual tokens: bidirectional block (top-left all ones)
queries: causal block (bottom-right lower triangular)The mask is the mechanism. The top-left block lets every visual token attend to every other visual token, preserving the global view. The bottom-left block lets every query attend to all visual tokens, so ordering decisions see the whole page. The bottom-right block is causal, so query i only sees queries before it and the ordering process is itself autoregressive. The top-right zeros keep visual tokens from peeking at the queries, so the visual representation is not contaminated by the ordering that is being derived from it.
def dual_mask(n_visual, n_query):
"""True means 'may attend'. Visual block bidirectional, query block causal."""
size = n_visual + n_query
mask = [[False] * size for _ in range(size)]
for i in range(n_visual): # visual -> visual
for j in range(n_visual):
mask[i][j] = True
for i in range(n_visual, size): # query -> all visual
for j in range(n_visual):
mask[i][j] = True
for j in range(n_visual, i + 1): # query -> earlier queries
mask[i][j] = True
return mask
# 144 local queries per crop, 256 global queries; query outputs alone are fed
# to the LLM decoder, so the token count the decoder sees does not grow.- Equal cardinality is the trick that keeps the token budget flat: the queries do not add tokens, they replace the visual tokens in the decoder's input.
- The global view uses 256 queries and each local crop 144, so the sequence ranges from 256 to 1120 tokens - lower than the previous model's 1156 and matching Gemini-3-Pro's stated maximum visual token budget.
- Because only query outputs are forwarded, the decoder never sees the raw visual tokens; it sees a causally ordered summary of them.
Two cascaded one-dimensional reasoners
The paper's conceptual framing is worth taking seriously: a two-dimensional image is being understood by two one-dimensional causal processes in series. The encoder's queries perform reading-logic reasoning, deciding an order; the decoder performs task reasoning over the sequence that order produced. Neither stage has to model two dimensions at once, which is precisely why the arrangement is efficient - each is a standard causal sequence model doing what it is good at. The paper calls the decomposition a possible route toward genuine 2D reasoning and is careful to say it is a long journey: multi-hop re-examination of a page would need longer causal flow sequences than the visual tokens they replace.
Results, production behavior, and limits
On OmniDocBench v1.5 the model reaches 91.09 percent, up 3.73 points from DeepSeek-OCR under similar training data, while reading-order edit distance falls from 0.085 to 0.057 - the metric that most directly reflects the reordering claim. In production, where ground truth is unavailable, the reported signal is repetition rate: 6.25 to 4.17 percent on online user-log images and 3.69 to 2.88 percent on PDF data generation, which matters because repetition is the failure mode that ruins batch document processing. The limits are the flip side of the design: the method is validated on OCR and document understanding rather than general visual reasoning; the query count is fixed equal to the visual token count, so the reordering is single-pass rather than iterative; and the paper states that genuine 2D reasoning needs longer causal flow sequences and remains future work. The token budget claim is comparative rather than absolute: it is at or below the previous model and matches one frontier system's stated maximum, not a new low.
2Inside the paper
Problem the paper sets out to solve
Every vision-language model feeds image tokens to the language model in a fixed raster order with fixed positional encoding, which contradicts how documents are actually read. The paper asks whether the encoder can choose a semantic reading order before the decoder begins.
Key idea to look for while reading
The attention mask and the equal-cardinality query design. Section 2 describes DeepEncoder V2 and the mask; Section 4 reports OmniDocBench and the reading-order metric; Section 5 adds production measurements. Read the reading-order edit distance as the direct test of the central claim, since overall OCR accuracy can improve for unrelated reasons.
Evidence the paper musters
OmniDocBench v1.5: 91.09 percent, +3.73 over DeepSeek-OCR under similar training data. Reading-order edit distance: 0.085 to 0.057. Production repetition rate: 6.25 to 4.17 percent on online user-log images and 3.69 to 2.88 percent on PDF production. Token budget: 256 to 1120 reordered tokens (256 global plus 144 per local crop), versus DeepSeek-OCR's 1156 maximum.
Limits the authors admit
The scope is OCR and document understanding; general visual reasoning is not evaluated. The reordering is single-pass because queries equal visual tokens in count, and the paper says multi-hop reordering needs longer flow sequences. Comparisons are against the authors' previous model and a small set of systems, and the production numbers are repetition rates rather than accuracy because labels do not exist in production.
Practitioner takeaway
The order in which you feed a model its input is part of the architecture, not a preprocessing detail. When a fixed scan order conflicts with the data's structure, a small learned module that chooses the order can pay off without changing the token budget - the trick is making the chooser produce exactly as many outputs as the tokens it replaces. And evaluate the property you changed: reading-order distance, not just aggregate OCR score.
3Implementation check
0 of 5 questions answered
1.What is the central change from DeepSeek-OCR to DeepSeek-OCR 2?
2.Why can the reordering happen without increasing the token count?
3.In the dual-stream mask, what is the purpose of the bottom-left block?
4.Which metric most directly supports the claim that the encoder learned a better reading order?
5.How does the paper frame the architecture's significance?
4Build it yourself
Reorder a two-column page and decode it causally
Advanced4-6 hoursA two-column page is stored as six blocks of two words each. Raster order reads across columns and breaks the bigram context; fit a positional scorer that sorts blocks into true reading order, decode both orderings with a causal bigram-greedy decoder, and compare word accuracy and Kendall order distance.
Milestones
- Fill build_page: sample a 12-word bigram chain and place the words into blocks in column-major reading order.
- Fill decode: for each block in the given order, pick the candidate word with the best BETA-weighted bigram log-prob given the previously decoded word.
- Fill fit_order: run the perceptron over the ordered block pairs until sorting by w[0]*col + w[1]*row reproduces the reading order.
- Run raster and flow orderings over 200 pages and report word accuracy and Kendall distance for each.
- Confirm the flow order reaches distance 0.0 and beats raster word accuracy by at least 0.2.
- Compare BETA 1 and BETA 3 and report how much the causal context is worth.
Success criteria
- The flow ordering reaches normalized order distance 0.0 while raster stays at 0.2.
- Flow word accuracy is at least 0.7 while raster stays below 0.35 at the fixed seed.
- Both orderings run 200 pages in under 2 seconds with the standard library.
Stretch goals
- Add a third column and check whether the learned positional score still recovers the reading order.
- Replace the greedy decoder with a beam of size 3 and report the accuracy change.
- Add symbol noise to the vision tokens and find the level where the ordering advantage disappears.