一、前言

仅供参考,未经实验验证。

二、DeepSeek-OCR 2

论文标题: DeepSeek-OCR 2: Visual Causal Flow(DeepSeek-OCR 2:视觉因果流)
(DeepSeekMath-V2:迈向自我验证的数学推理)
作者: Haoran Wei, Yaofeng Sun, Yukun Li
机构: DeepSeek-AI
发表时间: 2026年1月28日
GitHub: https://github.com/deepseek-ai/DeepSeek-OCR-2
论文地址: https://arxiv.org/pdf/2601.20552

2. 相关工作

2.1. 解码器中的并行查询

DETR [10] pioneered the integration of transformer architecture into object detection, fundamentally breaking away from traditional detection paradigms [38, 40]. To overcome the efficiency limitations of serial decoding in transformer blocks, DETR introduced preset parallelized learnable queries—a set of 100 object queries that encode object priors such as shape and position through training.
DETR [10] 开创性地将 Transformer 架构集成到目标检测任务中,从根本上打破了传统检测范式 [38, 40]。为了克服 Transformer 模块中串行解码的效率限制,DETR 引入了预设的可学习并行查询,即一组 100 个目标查询,它们通过训练来编码目标的先验信息,如形状和位置。

These queries interact with feature maps [18] via cross-attention mechanisms, while simultaneously engaging in bidirectional information exchange among themselves through self-attention. DETR established a foundational paradigm that enables transformers to handle parallelized tokens. The object query design has since become the de facto standard architectural component in subsequent transformer-based detection methods [29, 56].
这些查询通过交叉注意力机制与特征图 [18] 进行交互,同时通过自注意力机制在它们之间进行双向信息交换。DETR 建立了一个基础范式,使 Transformer 能够处理并行化的 token。此后,object query 设计已成为后续基于 Transformer 的检测方法 [29, 56] 中事实上的标准架构组件。

2.2. Projector中的并行查询

In recent years, vision-language models [7, 9, 22, 50] have developed rapidly, with architectures converging toward the encoder-projector-LLM paradigm. The projector aligns visual tokens with the LLM’s embedding space, serving as a critical bridge that enables LLMs to understand visual content.
近年来,视觉语言模型[7, 9, 22, 50]发展迅速,其架构逐渐收敛为**"编码器-投影器-LLM"范式**。投影器将视觉 token 与 LLM 的嵌入空间进行对齐,充当关键桥梁,使 LLM 能够理解视觉内容。

Q-former, introduced in BLIP-2 [22], exemplifies an effective projector design that employs learnable queries for visual token compression. Adopting a BERT-like [15] architecture and drawing inspiration from DETR’s object queries [10], Q-former utilizes 32 learnable queries that interact with hundreds of CLIP [37] visual tokens through cross-attention.
Q-former,在 BLIP-2 [22] 中提出,是采用可学习查询来压缩视觉令牌的有效投影仪设计的典范。Q-former 采用类似 BERT [15] 的架构,并借鉴了 DETR 的对象查询 [10],通过交叉注意力与数百个 CLIP [37] 视觉令牌进行交互,使用了 32 个可学习查询。

These compressed query representations are subsequently fed into the LLM, achieving effective mapping from visual to language space. The success of Q-former demonstrates that parallelized learnable queries are effective not only for feature decoding in detection tasks but also for token compression in multimodal alignment.
这些压缩的查询表示随后被馈送到LLM,从而实现了从视觉空间到语言空间的有效映射。Q-former的成功表明,并行化的可学习查询不仅在检测任务中的特征解码方面是有效的,而且在多模态对齐中的令牌压缩方面也是有效的。

2.3. 基于LLM的多模态初始化

LLMs trained on large-scale internet data have proven effective as initialization for multimodal models. Pang et al. [35] demonstrated that frozen LLM transformer layers enhance visual discriminative tasks. Moreover, encoder-free or lightweight-encoder models such as Fuyu [5] and Chameleon [43] in vision, as well as VALL-E [47] in speech, further validate the potential of LLM pretrained weights for multimodal initialization.
在大型互联网数据上训练的LLM已被证明可以有效地作为多模态模型的初始化。Pang等人[35]证明了冻结的LLM Transformer层可以增强视觉判别任务。此外,视觉领域的无编码器或轻量级编码器模型,如Fuyu [5]和Chameleon [43],以及语音领域的VALL-E [47],进一步验证了LLM预训练权重在多模态初始化方面的潜力。

3. 方法论

3.1. 架构

在这里插入图片描述
Figure 3 | DeepSeek-OCR 2 adopts the visual token compression mechanism from DeepEncoder, employing an 80M-parameter image compressor that reduces visual tokens by a factor of 16. DeepEncoder V2 differs by replacing DeepEncoder’s CLIP module with a compact language model architecture. Through customized attention masks, this LM-style vision encoder acquires CLIP’s knowledge compression capabilities while initiating causal modeling of visual sequences.
图 3 | DeepSeek-OCR 2 采用了 DeepEncoder 中的视觉 token 压缩机制,使用了一个 80M 参数的图像压缩器,将视觉 token 减少了 16 倍。DeepEncoder V2 的不同之处在于,它用一个紧凑的语言模型架构取代了 DeepEncoder 的 CLIP 模块。通过定制的注意力掩码,这种 LM 风格的视觉编码器获得了 CLIP 的知识压缩能力,同时启动了视觉序列的因果建模。

As shown in Figure 3, DeepSeek-OCR 2 inherits the overall architecture of DeepSeek-OCR, which consists of an encoder and a decoder. The encoder discretizes images into visual tokens, while the decoder generates outputs conditioned on these visual tokens and text prompts.
如图 3 所示,DeepSeek-OCR 2 继承了 DeepSeek-OCR 的整体架构,该架构由编码器和解码器组成。编码器将图像离散化为视觉标记,而解码器则根据这些视觉标记和文本提示生成输出。

The key distinction lies in the encoder: we upgrade DeepEncoder to DeepEncoder V2, which retains all capabilities of its predecessor while introducing causal reasoning through a novel architectural design. We elaborate on the details of DeepSeek-OCR 2 in the following sections.
关键区别在于编码器:我们将DeepEncoder升级为DeepEncoder V2,它保留了其前代的所有功能,并通过新颖的架构设计引入了因果推理。我们在以下各节中详细阐述DeepSeek-OCR 2的细节。

3.2. DeepEncoder V2

The vanilla encoder serves as an important component that extracts and compresses image features through attention mechanisms, where each token attends to all others, achieving fullimage receptive fields analogous to human foveal and peripheral vision. However, flattening 2D image patches into a 1D sequence imposes a rigid ordering bias through text-oriented positional encodings (e.g., RoPE [42]).
标准的编码器通过注意力机制提取和压缩图像特征,其中每个 token 都关注所有其他 token,从而实现与人类中央凹和周边视觉相似的全图像感受野。然而,将二维图像块展平成一维序列会通过面向文本的位置编码(例如 RoPE [42])施加僵化的顺序偏差。

This contradicts natural visual reading patterns, especially nonlinear layouts in optical texts, forms and tables.
这与自然的视觉阅读模式相矛盾,尤其是在光学文本、表格和表单中的非线性布局。

3.2.1. 视觉标记器( Vision tokenizer)

The first component of DeepEncoder V2 is a vision tokenizer. Following DeepEncoder, we employ an architecture combining an 80M-parameter SAM-base [21] along with two convolutional layers [50]. The output dimension of the final convolutional layer is reduced from 1024 in DeepEncoder to 896 to align with the subsequent pipeline.
DeepEncoder V2 的第一个组件是视觉分词器。在 DeepEncoder 之后,我们采用了结合一个 8000 万参数的 SAM-base [21] 和两个卷积层的架构 [50]。最后一个卷积层的输出维度从 DeepEncoder 中的 1024 降低到 896,以匹配后续的流水线。

Note that this compression-based tokenizer is not mandatory and can be replaced with simple patch embedding. We retain it because it achieves 16× token compression [19, 46, 51, 52] through window attention with minimal parameters, significantly reducing both computational cost and activation memory for the subsequent global attention module.
请注意,这种基于压缩的tokenizer并非强制要求,可以用简单的patch embedding替代。我们保留它是因为它通过窗口注意力实现了16倍的token压缩[19, 46, 51, 52],并且参数量极少,显著降低了后续全局注意力模块的计算成本和激活内存。

Moreover, its parameter count ( 80M) remains comparable to the typical 100M parameters used for text input embeddings in LLMs.
此外,其参数量(80M)与大型语言模型中用于文本输入嵌入的典型100M参数量相当。
在这里插入图片描述
Figure 4 | Token count calculation in DeepEncoder V2. DeepEncoder V2 outputs 256−1120 tokens per image using a multi-crop strategy with 0−6 local views. With 0 local views, only the global view produces 256 tokens; with 6 local views, the count reaches 1120 (6×144+256).
图 4 | DeepEncoder V2 中的 Token 计数计算。DeepEncoder V2 使用多裁剪策略,通过 0-6 个局部视图,为每张图像输出 256-1120 个 token。当局部视图为 0 时,只有全局视图产生 256 个 token;当局部视图为 6 时,计数达到 1120 (6×144+256)。

3.2.2. 将语言模型作为视觉编码器

In DeepEncoder, a CLIP ViT follows the vision tokenizer to compress visual knowledge. DeepEncoder V2 redesigns this component into an LLM-style architecture with a dual-stream attention mechanism. Visual tokens utilize bidirectional attention to preserve CLIP’s global modeling capability, while newly introduced causal flow queries employ causal attention.
在DeepEncoder中,CLIP ViT在视觉分词器之后用于压缩视觉知识。DeepEncoder V2将此组件重新设计为具有双流注意力机制的LLM风格架构。视觉令牌利用双向注意力来保留CLIP的全局建模能力,而新引入的因果流查询则采用因果注意力。

These learnable queries are appended after visual tokens as a suffix, where each query attends to all visual tokens and preceding queries. By maintaining equal cardinality between queries and visual tokens, this design imposes semantic ordering and distilling on visual features without altering token count.
这些可学习的查询被附加在视觉标记之后作为后缀,其中每个查询都关注所有视觉标记和先前的查询。通过保持查询和视觉标记之间的相等基数,该设计在不改变标记计数的情况下,对视觉特征施加了语义排序和蒸馏。

Finally, only the causal query outputs are fed to the LLM decoder.
最后,仅将因果查询输出馈送至LLM解码器。

We instantiate this architecture using Qwen2-0.5B [48], whose 500M parameters are comparable to CLIP ViT (300M) without introducing excessive computational overhead. The decoderonly architecture with prefix-concatenation of visual tokens proves crucial: extra experiments with cross-attention in an mBART-style [30] encoder-decoder structure fail to converge.
我们使用 Qwen2-0.5B [48] 来实例化该架构,其 5 亿个参数与 CLIP ViT(3 亿个参数)相当,且不会引入过度的计算开销。Decoder-only 架构通过前缀拼接视觉 token 被证明是至关重要的:使用 mBART 风格 [30] 编码器-解码器结构的交叉注意力进行的额外实验未能收敛。

We hypothesize this failure stems from insufficient visual token interaction when isolated in a separate encoder. In contrast, the prefix design keeps visual tokens active throughout all layers, fostering effective visual information exchange with causal queries.
我们假设这种失败源于在单独的编码器中隔离时视觉令牌的交互不足。相比之下,前缀设计在所有层中保持视觉令牌的活跃状态,促进了与因果查询的有效视觉信息交换。

This architecture actually establishes two-stage cascade causal reasoning: the encoder semantically reorders visual tokens through learnable queries, while the LLM decoder performs autoregressive reasoning over the ordered sequence. Unlike vanilla encoders that impose rigid spatial ordering through positional encodings, our causally-ordered queries adapt to smooth visual semantics while naturally aligning with the LLM’s unidirectional attention pattern.
该架构实际上建立了双阶段的级联因果推理:编码器通过可学习的查询在语义上重新排序视觉标记,而语言模型解码器则对排序后的序列执行自回归推理。与强制通过位置编码施加刚性空间顺序的普通编码器不同,我们的因果排序查询能够适应平滑的视觉语义,同时自然地与语言模型的单向注意力模式对齐。

This design may bridge the gap between 2D spatial structure and 1D causal language modeling.
该设计可能弥合二维空间结构与一维因果语言建模之间的差距。

3.2.3. 因果流查询(Causal flow query)

As aforementioned, the number of causal query tokens equals the number of visual tokens, computed as W × H 16 2 × 16 \frac{W \times H}{16^2 \times 16} 162×16W×H , where W W W and H H H denote the width and height of the image input to the encoder. To avoid maintaining multiple query sets for different resolutions, we adopt a multi-crop strategy with fixed query configurations at predefined resolutions.
如前所述,因果查询token的数量等于视觉token的数量,计算公式为 W × H 16 2 × 16 \frac{W \times H}{16^2 \times 16} 162×16W×H,其中 W W W H H H 表示输入编码器的图像的宽度和高度。为了避免为不同分辨率维护多组查询,我们采用了一种多裁剪策略,在预定义分辨率上使用固定的查询配置。

Specifically, the global view uses a resolution of 1024 × 1024 1024 \times 1024 1024×1024 , corresponding to 256 query embeddings denoted as query global \text{query}_{\text{global}} queryglobal . Local crops adopt a resolution of 768 × 768 768 \times 768 768×768 , with the number of crops k k k ranging from 0 to 6 (no cropping is applied when both image dimensions are smaller than 768). All local views share a unified set of 144 query embeddings, denoted as query local \text{query}_{\text{local}} querylocal . Therefore, the total number of reordered visual tokens fed to the LLM is k × 144 + 256 k \times 144 + 256 k×144+256 , ranging from [256, 1120]. This maximum token count (1120) is lower than DeepSeek-OCR’s 1156 (Gundam mode) and matches Gemini-3-Pro’s maximum visual token budget.
具体而言,全局视图使用 1024 × 1024 1024 \times 1024 1024×1024 的分辨率,对应256个查询嵌入,记为 query global \text{query}_{\text{global}} queryglobal。局部裁剪采用 768 × 768 768 \times 768 768×768 的分辨率,裁剪数量 k k k 的范围为0到6(当图像的两个维度均小于768时,不应用裁剪)。所有局部视图共享一组统一的144个查询嵌入,记为 query local \text{query}_{\text{local}} querylocal。因此,输入到LLM的重排视觉token的总数为 k × 144 + 256 k \times 144 + 256 k×144+256,范围在 [256, 1120] 之间。这一最大token数(1120)低于DeepSeek-OCR的1156(Gundam模式),并与Gemini-3-Pro的最大视觉token预算相匹配。

3.2.4. 注意力掩码

在这里插入图片描述
Figure 5 | Attention mask architecture of DeepEncoder V2. Concatenation of bidirectional mask (vision tokens, ViT-like) and causal triangular mask (flow tokens, LLM decoder-style).
图 5 | DeepEncoder V2 的注意力掩码架构。双向掩码(视觉 tokens,类似 ViT)和因果三角掩码(流 tokens,LLM 解码器风格)的串联。

To better illustrate the attention mechanism of DeepEncoder V2, we visualize the attention mask in Figure 5. The attention mask is composed of two distinct regions. The left region applies bidirectional attention (similar to ViT) to original visual tokens, allowing full token-to-token visibility. The right region employs causal attention (triangular mask, identical to decoder-only LLMs) for causal flow tokens, where each token attends only to previous tokens. These two components are concatenated along the sequence dimension to construct DeepEncoder V2’s attention mask ( M \mathbf{M} M ), as follows:
为了更好地说明 DeepEncoder V2 的注意力机制,我们在图 5 中对注意力掩码进行了可视化。该注意力掩码由两个不同的区域组成:左侧区域对原始视觉 token 应用双向注意力(类似于 ViT),允许所有 token 之间完全互相可见;右侧区域则对因果流 token 采用因果注意力(三角掩码,与仅解码器 LLM 相同),其中每个 token 只能关注到其之前的 token。这两个组件沿序列维度拼接,构成了 DeepEncoder V2 的注意力掩码( M \mathbf{M} M),具体如下:
M = [ 1 m × m 0 m × n 1 n × m LowerTri ( n ) ] , where  n = m ( 1 ) \mathbf{M} = \begin{bmatrix} \mathbf{1}_{m \times m} & \mathbf{0}_{m \times n} \\ \mathbf{1}_{n \times m} & \text{LowerTri}(n) \end{bmatrix}, \quad \text{where } n = m \quad (1) M=[1m×m1n×m0m×nLowerTri(n)],where n=m(1)

where n n n is the number of causal query tokens, m m m represents vanilla visual tokens number, and LowerTri denotes a lower triangular matrix (with ones on and below the diagonal, zeros above).
其中, n n n 为因果查询 token 的数量, m m m 为普通视觉 token 的数量,LowerTri 表示下三角矩阵(对角线及其下方元素为 1,上方元素为 0)。

3.3. DeepSeek-MoE解码器

Since DeepSeek-OCR 2 primarily focuses on encoder improvements, we do not upgrade the decoder component. Following this design principle, we retain DeepSeek-OCR’s decoder – a 3B-parameter MoE structure with about 500M active parameters. The core forward pass of DeepSeek-OCR 2 can be formulated as:
由于 DeepSeek-OCR 2 主要专注于编码器的改进,我们不对解码器组件进行升级。遵循这一设计原则,我们保留了 DeepSeek-OCR 的解码器——一个 30 亿参数(3B)的 MoE(混合专家)结构,其中约有 5 亿(500M)活跃参数。DeepSeek-OCR 2 的核心前向传播过程可以形式化表示为:
O = D ( π Q ( T L ( E ( I ) ⊕ Q 0 ; M ) ) ) ( 2 ) \mathbf{O} = \mathcal{D}(\pi_Q(\mathcal{T}^L(\mathcal{E}(\mathbf{I}) \oplus \mathbf{Q}_0; \mathbf{M}))) \quad (2) O=D(πQ(TL(E(I)Q0;M)))(2)

where I ∈ R H × W × 3 \mathbf{I} \in \mathbb{R}^{H \times W \times 3} IRH×W×3 is the input image, E \mathcal{E} E is the vision tokenizer mapping images to m m m visual tokens V ∈ R m × d \mathbf{V} \in \mathbb{R}^{m \times d} VRm×d , Q 0 ∈ R n × d \mathbf{Q}_0 \in \mathbb{R}^{n \times d} Q0Rn×d are learnable causal query embeddings, ⊕ \oplus denotes sequence concatenation, T L \mathcal{T}^L TL represents an L L L -layer Transformer with masked attention, M ∈ { 0 , 1 } 2 n × 2 n \mathbf{M} \in \{0, 1\}^{2n \times 2n} M{0,1}2n×2n is the block causal attention mask defined in Equation 1, π Q \pi_Q πQ is the projection operator that extracts the last n n n tokens (i.e., Z = X m + 1 : m + n \mathbf{Z} = \mathbf{X}_{m+1:m+n} Z=Xm+1:m+n ), D \mathcal{D} D is the language decoder, and O ∈ R n × ∣ V ∣ \mathbf{O} \in \mathbb{R}^{n \times |\mathcal{V}|} ORn×V is the output logits over LLM vocabulary.
其中, I ∈ R H × W × 3 \mathbf{I} \in \mathbb{R}^{H \times W \times 3} IRH×W×3 为输入图像; E \mathcal{E} E 为视觉分词器,负责将图像映射为 m m m 个视觉 token V ∈ R m × d \mathbf{V} \in \mathbb{R}^{m \times d} VRm×d Q 0 ∈ R n × d \mathbf{Q}_0 \in \mathbb{R}^{n \times d} Q0Rn×d 为可学习的因果查询嵌入; ⊕ \oplus 表示序列拼接; T L \mathcal{T}^L TL 表示带有掩码注意力的 L L L 层 Transformer; M ∈ { 0 , 1 } 2 n × 2 n \mathbf{M} \in \{0, 1\}^{2n \times 2n} M{0,1}2n×2n 为公式 (1) 中定义的块因果注意力掩码; π Q \pi_Q πQ 为投影算子,负责提取后 n n n 个 token(即 Z = X m + 1 : m + n \mathbf{Z} = \mathbf{X}_{m+1:m+n} Z=Xm+1:m+n); D \mathcal{D} D 为语言解码器; O ∈ R n × ∣ V ∣ \mathbf{O} \in \mathbb{R}^{n \times |\mathcal{V}|} ORn×V 为 LLM 词表上的输出 logits。
M = [ 1 m × m 0 m × n 1 n × m LowerTri ( n ) ] , where  n = m ( 1 ) \mathbf{M} = \begin{bmatrix} \mathbf{1}_{m \times m} & \mathbf{0}_{m \times n} \\ \mathbf{1}_{n \times m} & \text{LowerTri}(n) \end{bmatrix}, \quad \text{where } n = m \quad (1) M=[1m×m1n×m0m×nLowerTri(n)],where n=m(1)

4. Experimental Settings

4.1. 数据引擎

DeepSeek-OCR 2 employs the same data sources as DeepSeek-OCR, comprising OCR 1.0, OCR 2.0 [11, 27, 53], and general vision data [54], with OCR data constituting 80% of the training mixture. We also introduce two modifications: (1) a more balanced sampling strategy for OCR 1.0 data, partitioning pages by content type (text, formulas, tables) with a 3:1:1 ratio, and (2) label refinement for layout detection by merging semantically similar categories (e.g., unifying “figure caption” and “figure title”). Given these minimal differences, we consider DeepSeek-OCR a valid baseline for comparison.
DeepSeek-OCR 2 采用与 DeepSeek-OCR 相同的数据源,包括 OCR 1.0、OCR 2.0 [11, 27, 53] 以及通用视觉数据 [54],其中 OCR 数据占训练混合数据的 80%。我们还引入了两项修改:(1) 对 OCR 1.0 数据采用更均衡的采样策略,按内容类型(文本、公式、表格)划分页面,比例为 3:1:1;(2) 对布局检测的标签进行精细化处理,合并语义相近的类别(例如,将"figure caption"和"figure title"统一)。鉴于这些差异较小,我们认为 DeepSeek-OCR 是一个有效的对比基线。

4.2. 训练流程(Training Pipelines)

We train DeepSeek-OCR 2 in three stages: (1) encoder pretraining, (2) query enhancement, and (3) decoder specialization. The stage-1 enables the vision tokenizer and LLM-style encoder to acquire fundamental capabilities in feature extraction, token compression, and token reordering capabilities. The stage-2 further strengthens the token reordering capability of the encoder while enhancing visual knowledge compression. The stage-3 freezes the encoder parameters and optimizes only the decoder, enabling higher data throughput under the same FLOPs.
我们以三个阶段训练 DeepSeek-OCR 2:(1) 编码器预训练,(2) 查询增强,以及 (3) 解码器专门化。第一阶段使视觉分词器和类 LLM 编码器获得特征提取、token 压缩和 token 重排序的基本能力。第二阶段进一步增强编码器的 token 重排序能力,同时提升视觉知识压缩效果。第三阶段冻结编码器参数,仅优化解码器,在相同 FLOPs 下实现更高的数据吞吐量。

4.2.1. 训练 DeepEncoder V2

Following DeepSeek-OCR and Vary [50], we train DeepEncoder V2 using a language modeling objective, coupling the encoder with a lightweight decoder [20] for joint optimization via next token prediction. We employ two dataloaders at resolutions of 768 × 768 768 \times 768 768×768 and 1024 × 1024 1024 \times 1024 1024×1024 . The vision tokenizer is initialized from DeepEncoder, and the LLM-like encoder from Qwen2-0.5B-base [48]. After pretraining, only the encoder parameters are retained for subsequent stages. We use the AdamW [32] optimizer with cosine learning rate decay from 1 e − 4 1e-4 1e4 to 1 e − 6 1e-6 1e6 , training on 160 A100 GPUs (20 nodes × \times × 8 GPUs) with batch size 640 for 40k iterations (with sequence packing at 8K length, about 100M image-text pair samples).
遵循 DeepSeek-OCR 和 Vary [50] 的做法,我们使用语言建模目标训练 DeepEncoder V2,将编码器与轻量级解码器 [20] 耦合,通过 next token prediction 进行联合优化。我们使用两个分辨率分别为 768 × 768 768 \times 768 768×768 1024 × 1024 1024 \times 1024 1024×1024 的数据加载器。视觉分词器从 DeepEncoder 初始化,类 LLM 编码器从 Qwen2-0.5B-base [48] 初始化。预训练后,仅保留编码器参数用于后续阶段。我们使用 AdamW [32] 优化器,学习率从 1 e − 4 1e-4 1e4 1 e − 6 1e-6 1e6 进行余弦衰减,在 160 张 A100 GPU(20 个节点 × \times × 8 张 GPU)上训练,batch size 为 640,共 40k 个迭代(序列打包长度为 8K,约 1 亿图像-文本对样本)。

4.2.2. 查询增强

After DeepEncoder V2 pretraining, we integrate it with DeepSeek-3B-A500M [24, 25] as our final pipeline. We freeze the visual tokenizer (SAM-conv structure) while jointly optimizing the LLM encoder and LLM decoder to enhance query representations. At this stage, we unify the two resolutions into a single dataloader via multi-crop strategy. We adopt 4-stage pipeline parallelism: vision tokenizer (PP0), LLM-style encoder (PP1), and DeepSeek-LLM layers (6 layers per stage on PP2-3). With 160 GPUs (40GB/per-GPU), we configure 40 data parallel replicas (4 GPUs per replica) and train with global batch size 1280 using the same optimizer and learning rate decay from 5 e − 5 5e-5 5e5 to 1 e − 6 1e-6 1e6 over 15k iterations.
在 DeepEncoder V2 预训练完成后,我们将其与 DeepSeek-3B-A500M [24, 25] 集成作为最终流程。我们冻结视觉分词器(SAM-conv 结构),同时联合优化 LLM 编码器和 LLM 解码器以增强查询表征。在此阶段,我们通过多裁剪策略将两种分辨率统一为单个数据加载器。我们采用 4 阶段流水线并行:视觉分词器(PP0)、类 LLM 编码器(PP1),以及 DeepSeek-LLM 层(PP2-3 每个阶段 6 层)。使用 160 张 GPU(每张 40GB),我们配置 40 个数据并行副本(每个副本 4 张 GPU),以全局 batch size 1280 进行训练,使用相同的优化器,学习率从 5 e − 5 5e-5 5e5 1 e − 6 1e-6 1e6 衰减,共 15k 个迭代。

4.2.3. 继续训练 LLM(Continue-training LLM)

To rapidly consume training data, we freeze all DeepEncoder V2 parameters in this stage and only update the DeepSeek-LLM parameters. This stage accelerates training (more than doubles the training speed under the same global batch size) while helping the LLM better understand DeepEncoder V2’s reordered visual tokens. Continuing from stage-2, we perform another learning rate decay from 1 e − 6 1e-6 1e6 to 5 e − 8 5e-8 5e8 training for 20k iterations in this stage.
为了快速消耗训练数据,我们在这一阶段冻结所有 DeepEncoder V2 的参数,仅更新 DeepSeek-LLM 的参数。该阶段加速了训练(在相同全局 batch size 下,训练速度提升一倍以上),同时帮助 LLM 更好地理解 DeepEncoder V2 重排序后的视觉 token。从第二阶段继续,我们在这一阶段进行另外一轮学习率衰减,从 1 e − 6 1e-6 1e6 降至 5 e − 8 5e-8 5e8,训练 20k 个迭代。

Table 1 | Comprehensive evaluation of document reading on OmniDocBench v1.5. V-tokenmax represents the maximum number of visual tokens used per page in this benchmark. R-order denotes reading order. Except for DeepSeek OCR and DeepSeek OCR 2, all other model results in this table are sourced from the OmniDocBench repository.
表 1 | 在 OmniDocBench v1.5 上的文档阅读综合评估。V-tokenmax 表示该基准测试中每页使用的最大视觉 token 数量。R-order 表示阅读顺序。除 DeepSeek OCR 和 DeepSeek OCR 2 外,本表中所有其他模型结果均来自 OmniDocBench 仓库。
在这里插入图片描述

5. 评估

We select OmniDocBench v1.5 [34] as our primary benchmark for evaluation. This benchmark comprises 1,355 document pages spanning 9 major categories (including magazines, academic papers, research reports, and so on) in both Chinese and English. With its diverse test samples and robust evaluation criteria, OmniDocBench provides an effective framework for validating the performance of DeepSeek-OCR 2, particularly the effectiveness of DeepEncoder V2.
我们选用 OmniDocBench v1.5 [34] 作为主要评估基准。该基准测试包含 1,355 页文档,涵盖 9 个主要类别(包括杂志、学术论文、研究报告等),涉及中英文两种语言。凭借其多样化的测试样本和稳健的评估标准,OmniDocBench 为验证 DeepSeek-OCR 2 的性能,特别是 DeepEncoder V2 的有效性,提供了一个有效的框架。

5.1. 主要结果

As shown in Table 1, DeepSeek-OCR 2 achieves advanced performance of 91.09% while using the smallest upper limit of visual tokens (V-tokenmax). Compared to the DeepSeek-OCR baseline, it demonstrates a 3.73% improvement under similar train data sources, validating the effectiveness of our newly designed architecture. Beyond the overall improvement, the Edit Distance (ED) for reading order (R-order) has also significantly decreased (from 0.085 to 0.057), indicating that the new DeepEncoder V2 can effectively select and arrange initial visual tokens based on image information. As illustrated in Table 2, DeepSeek-OCR 2 (0.100) achieves lower ED in document parsing compared to Gemini-3 Pro (0.115) under a similar visual token budget (1120), further demonstrating that our new model maintains high compression rates of visual tokens while ensuring superior performance, with exceptionally high potential.
如表 1 所示,DeepSeek-OCR 2 在使用最小视觉 token 上限(V-tokenmax)的情况下,取得了 91.09% 的先进性能。与 DeepSeek-OCR 基线相比,在相似的训练数据来源下,它实现了 3.73% 的提升,验证了我们新设计架构的有效性。除了整体性能提升外,阅读顺序(R-order)的编辑距离(ED)也显著下降(从 0.085 降至 0.057),表明新的 DeepEncoder V2 能够基于图像信息有效地选择和排列初始视觉 token。如表 2 所示,在相似的视觉 token 预算(1120)下,DeepSeek-OCR 2(0.100)在文档解析中的编辑距离低于 Gemini-3 Pro(0.115),进一步证明我们的新模型在确保卓越性能的同时,保持了视觉 token 的高压缩率,具有极高的潜力。

Table 2 | Edit Distances for different categories of document-elements in OmniDocBench v1.5. V-tokenmax denotes the lowest maximum number of visual tokens.
表 2 | OmniDocBench v1.5 中不同文档元素类别的编辑距离。V-tokenmax 表示最低的最大视觉 token 数量。在这里插入图片描述

5.2. 改进空间(Improvement Headroom)

We conduct a detailed performance comparison between DeepSeek-OCR and DeepSeek-OCR 2 across 9 document types and found that DeepSeek-OCR 2 still has considerable room for improvement, as shown in Table 3. For text recognition Edit Distance (ED), DeepSeek-OCR 2 outperforms DeepSeek-OCR in most cases, but there are also notable weaknesses, such as newspapers, where it performs > 0.13 ED. We believe there are two main reasons: (1) the lower upper limit of visual tokens may affect the recognition of text-super-rich newspapers, which can be simply addressed in the future by increasing the number of local crops; (2) insufficient newspaper data – our training data contains only 250k relevant samples, which is inadequate for training DeepEncoder V2 for this class. Of course, for the reading order (R-order) metric, DeepSeek-OCR 2 consistently outperforms DeepSeek-OCR across the board, further validating the effectiveness of our visual causal flow encoder design.
我们对 DeepSeek-OCR 和 DeepSeek-OCR 2 在 9 种文档类型上进行了详细的性能比较,发现 DeepSeek-OCR 2 仍有相当大的改进空间,如表 3 所示。在文本识别的编辑距离(ED)方面,DeepSeek-OCR 2 在大多数情况下优于 DeepSeek-OCR,但也存在明显的薄弱环节,例如在处理报纸时,其编辑距离超过 0.13。我们认为主要有两个原因:(1) 视觉 token 的上限较低可能会影响对文本极度丰富的报纸的识别,这一问题未来可以通过增加局部裁剪的数量来简单解决;(2) 报纸数据不足——我们的训练数据仅包含 25 万个相关样本,不足以训练 DeepEncoder V2 处理该类文档。当然,在阅读顺序(R-order)指标上,DeepSeek-OCR 2 在所有类别上均全面优于 DeepSeek-OCR,进一步验证了我们视觉因果流编码器设计的有效性。

Table 3 | Detailed comparison between DeepSeek-OCR 2 and DeepSeek-OCR across 9 document types. R-order denotes reading order. All metrics are Edit Distances, where lower is better.
表 3 | DeepSeek-OCR 2 与 DeepSeek-OCR 在 9 种文档类型上的详细对比。R-order 表示阅读顺序。所有指标均为编辑距离,越低越好。
在这里插入图片描述

5.3. 实际就绪度(Practical Readiness)

DeepSeek-OCR serves two primary production use cases: an online OCR service that reads image/documents for DeepSeek-LLMs, and a pretraining data pipeline that performs batch PDF processing. We compare the production performance between DeepSeek-OCR 2 and DeepSeek-OCR. Since ground truth is unavailable in production environments, we focus primarily on repetition rate as our key metric.
DeepSeek-OCR 服务于两个主要生产用例:一是为 DeepSeek-LLM 提供图像/文档读取的在线 OCR 服务,二是执行批量 PDF 处理的预训练数据流水线。我们对比了 DeepSeek-OCR 2 与 DeepSeek-OCR 的生产性能。由于生产环境中无法获取真实标注(ground truth),我们主要将重复率作为关键指标。

As shown in Table 4, DeepSeek-OCR 2 demonstrates markedly improved practical readiness compared to its predecessor (DeepSeek-OCR), reducing the repetition rate from 6.25% to 4.17% for online user-log images, and from 3.69% to 2.88% for PDF data production. These results further validate the effectiveness of the DeepSeek-OCR 2 architecture, particularly its logical visual comprehension capabilities.
如表 4 所示,与其前代模型(DeepSeek-OCR)相比,DeepSeek-OCR 2 展现出显著改善的实际就绪度:针对在线用户日志图像,重复率从 6.25% 降至 4.17%;针对 PDF 数据生产,重复率从 3.69% 降至 2.88%。这些结果进一步验证了 DeepSeek-OCR 2 架构的有效性,尤其是其逻辑视觉理解能力。

Table 4 | Production performance comparison between DeepSeek-OCR and DeepSeek-OCR 2. For OCR models serving LLM pipelines, ground truth is not accessible in production environments. Therefore, Repetition rate constitutes the primary observable quality metric.
表 4 | DeepSeek-OCR 与 DeepSeek-OCR 2 的生产性能对比。对于服务于 LLM 流水线的 OCR 模型,生产环境中无法获取真实标注。因此,重复率构成了主要可观测的质量指标。
在这里插入图片描述

6. 讨论与未来工作

6.1. 迈向真正的二维推理(Towards Genuine 2D Reasoning)

DeepSeek-OCR 2 presents a novel architectural paradigm with an LLM-style encoder cascaded with an LLM decoder. This cascade of two 1D causal reasoners holds promise for genuine 2D reasoning: the encoder performs reading logic reasoning (causally reordering visual information through query tokens), while the decoder executes visual task reasoning over these causally-ordered representations. Decomposing 2D understanding into two complementary/orthogonal 1D causal reasoning subtasks may represent a breakthrough toward genuine 2D reasoning. Of course, achieving this goal remains a long journey. For instance, to enable multiple re-examinations and multi-hop reordering of visual content, we may need substantially longer causal flow tokens than the original visual token sequence. We will continue to refine this architecture and explore its effectiveness on general visual reasoning tasks in future work.
DeepSeek-OCR 2 提出了一种新颖的架构范式,将类 LLM 编码器与 LLM 解码器级联。这种两个一维因果推理器的级联为真正的二维推理带来了希望:编码器执行阅读逻辑推理(通过查询 token 因果性地重排序视觉信息),而解码器则在这些因果排序的表征上执行视觉任务推理。将二维理解分解为两个互补/正交的一维因果推理子任务,可能是迈向真正二维推理的突破。当然,实现这一目标仍是一段漫长的旅程。例如,为了实现视觉内容的多次复查和多跳重排序,我们可能需要比原始视觉 token 序列长得多的因果流 token。我们将在未来的工作中继续完善这一架构,并探索其在通用视觉推理任务上的有效性。

6.2. 迈向原生多模态(Towards Native Multimodality)

DeepEncoder V2 provides initial validation of the LLM-style encoder’s viability for visual tasks. More importantly, this architecture enjoys the potential to evolve into a unified omni-modal encoder: a single encoder with shared W k , W v W_k, W_v Wk,Wv projections, attention mechanisms, and FFNs can process multiple modalities through modality-specific learnable query embeddings. Such an encoder could compress text, extract speech features, and reorganize visual content within the same parameter space, differing only in the learned weights of their query embeddings. DeepSeek-OCR’s optical compression represents an initial exploration toward native multimodality, while we believe DeepSeek-OCR 2’s LLM-style encoder architecture marks our further step in this direction. We will also continue exploring the integration of additional modalities through this shared encoder framework in the future.
DeepEncoder V2 为类 LLM 编码器在视觉任务上的可行性提供了初步验证。更重要的是,该架构具有演化为统一全模态编码器的潜力:一个具有共享的 W k W_k Wk W v W_v Wv 投影、注意力机制和 FFN 的单一编码器,可以通过模态特定的可学习查询嵌入来处理多种模态。这样的编码器可以在同一参数空间内压缩文本、提取语音特征和重组视觉内容,仅在其查询嵌入的学习权重上有所不同。DeepSeek-OCR 的光学压缩代表了迈向原生多模态的初步探索,而我们相信 DeepSeek-OCR 2 的类 LLM 编码器架构标志着我们朝这一方向迈出的更进一步。未来,我们也将继续探索通过这一共享编码器框架集成更多模态。

7. 结论

In this technical report, we present DeepSeek-OCR 2, a significant upgrade to DeepSeek-OCR, that maintains high visual token compression while achieving meaningfully performance improvements. This advancement is powered by the newly proposed DeepEncoder V2, which implicitly distills causal understanding of the visual world through the integration of both bidirectional and causal attention mechanisms, leading to causal reasoning capabilities in the vision encoder and, consequently, marked lifts in visual reading logic.
在本技术报告中,我们介绍了 DeepSeek-OCR 2,这是对 DeepSeek-OCR 的重大升级,它在保持高视觉 token 压缩率的同时,实现了有意义的性能提升。这一进步得益于新提出的 DeepEncoder V2,它通过整合双向和因果注意力机制,隐式地提炼出对视觉世界的因果理解,从而在视觉编码器中引入了因果推理能力,并因此显著提升了视觉阅读逻辑。

While optical text reading, particularly document parsing, represents one of the most practical vision tasks in the LLM era, it constitutes only a small part of the broader visual understanding landscape. Looking ahead, we will refine and adapt this architecture to more diverse scenarios, seeking deeper toward a more comprehensive vision of multimodal intelligence.
虽然光学文本阅读,特别是文档解析,是 LLM 时代最实用的视觉任务之一,但它只是更广泛视觉理解图景中的一小部分。展望未来,我们将进一步完善并适配这一架构到更多样化的场景中,朝着更全面的多模态智能愿景深入探索。

更多推荐