← 返回 2026-08-17

SimpleOPD:面向长上下文推理的简单分词器无关在线蒸馏 SimpleOPD: Simple Tokenizer-Agnostic On-Policy Distillation for Long-Context Reasoning

Haonan He, Haodi Lei, Yun Luo, Haoran Zhang, Shunkai Zhang, Yizhuo Li, Shengji Tang, Zhilin Wang, Runzhe Zhan, Lei Bai, Ganqu Cui, Fangchen Yu, Yafu Li, Peng Ye, Ning Ding, Yu Cheng 📅 2026-08-14 👍 33 2026-08-22 18:30
LLM后训练 在线蒸馏 数学证明 知识蒸馏 跨分词器 长上下文推理

共享文本空间对齐加稳定化技巧,实现跨分词器的长上下文推理在线蒸馏

前置知识

在线蒸馏

与离线蒸馏直接在教师生成的固定数据集上做监督训练不同,在线蒸馏让学生模型自己采样生成回答轨迹,再由教师模型对学生轨迹上的每个 token 逐点给出 log-probability 作为监督信号,从而在学生自身的策略分布上提供稠密的 token 级反馈。它优化师生分布间的反向 KL 散度,比离线方案遗忘更少、泛化更好,已被 GLM-5、DeepSeek-V4、Qwen3.5 等旗舰模型采用。

本文全部技术贡献都建立在 OPD 框架内:跨分词器对齐解决的核心问题就是'教师如何在学生自己采样的轨迹上打分',不理解 OPD 的采样-评分-更新循环就无法理解对齐为何必要。

反向 KL 散度

衡量学生分布 $\pi_\theta$ 相对教师分布 $\pi_\phi$ 差异的量,形式为 $D_{\mathrm{KL}}(\pi_\theta\|\pi_\phi)=\mathbb{E}_{y\sim\pi_\theta}[\log(\pi_\theta/\pi_\phi)]$。与正向 KL 不同,反向 KL 在学生自己的分布下取期望,是'mode-seeking'的:学生倾向于集中到教师高概率区域,配合 on-policy 采样天然避免了在教师分布上做重要性采样。

SimpleOPD 的蒸馏目标就是反向 KL 的 token 对齐替身,论文证明了当分词器完全一致时目标严格退化为反向 KL,这是方法正确性的关键论据。

PPO 截断策略损失

强化学习中常用的策略梯度目标:定义新旧策略的概率比 $r_t=\pi_\theta(y_t|\cdot)/\pi_{\theta_{old}}(y_t|\cdot)$,以 $\min(r_t \tilde{A}_t, \mathrm{clip}(r_t,1-\epsilon,1+\epsilon)\tilde{A}_t)$ 为损失,$\epsilon$ 通常取 0.2。截断防止单次更新偏离采样策略太远,使同一批 rollout 数据可以复用多次更新。

SimpleOPD 把教师 log-prob 与学生旧策略 log-prob 之差当作固定优势 $\tilde{A}_t$,再用 PPO clip 做多次更新,训练细节(clip 0.2、每批更新 4 次)直接来自这套机制。

分词器(BPE 与 SentencePiece)

分词器把文本切分为 token 序列,不同模型家族的词表和切分策略不同:Qwen 系用 byte-level BPE,GLM-4.7 也用 BPE 但词表不同,Gemma 用 SentencePiece,同一段文本会被切成完全不同的 token 序列。因此两个模型对同一字符串的 token 级概率分布定义在不同的随机变量空间上,不能逐位置比较。

这正是本文要解决的问题根源:教师和学生的 log-prob 无法直接对齐,论文用'共享文本空间+文本跨度一致才对齐'的方案绕开了它。

参考 KL 正则

在训练目标中加入当前策略与某个固定参考策略(此处是学生自己的初始策略)之间的 KL 散度惩罚项,约束策略不要漂移过远:$\mathcal{L}=\mathcal{L}_{\mathrm{Distill}}+\beta\,D_{\mathrm{KL}}(\pi_\theta\|\pi_{\theta_{init}})$,$\beta$ 是需要调节的系数,太大限制学习、太小失去约束。

它是本文两大稳定化技巧之一,论文消融显示系数取值因模型而异(Qwen/Intern 取 0.5,GLM 最优 1.0),是理解训练稳定性设计的关键。

研究动机

此前 OPD 研究几乎都假设教师和学生共享同一模型家族与词表。当把长上下文推理教师(如 SU-01,可对奥赛难题持续输出 10 万 token 以上推理)蒸馏给短上下文学生时,会同时出现四类问题。其一,师生分词器不同(Qwen 用 byte-level BPE,GLM 的 BPE 词表不同,Gemma 用 SentencePiece),token 级分布无法逐位置对齐。其二,容量与上下文长度差异造成师生分布错配,教师偏好的回答经常超出学生的上下文预算。其三,论文实测直接 OPD 会让 Intern-S2-Preview 和 Qwen3.5-35B-A3B 的平均回答长度在 100 个训练步内急剧增长,截断率与重复率持续攀升,Qwen3.5-35B-A3B 的 AnswerBench 从 0.78 一路跌到 0.60 附近,输出质量与任务分数出现背离。其四,教师监督会系统性抑制 、<|im_end|> 等终止 token,学生逐渐丧失正常结束回答的能力,案例研究中甚至出现答对后把自检重复 972 次或推理塌缩成单 token 死循环的现象。

本文的目标是本文的目标是设计一套简单、稳定、完全不依赖共享词表的在线蒸馏方法,把 IMO 金牌级别的长上下文数学证明模型 SU-01(30B-A3B,基于 Qwen3-30B-A3B,ProofBench 上与 DeepSeek-V3.2-Speciale 同档)的证明推理能力迁移到一批短上下文学生模型,覆盖同族的 Qwen3-4B 与 Qwen3-30B-A3B,以及跨族的 Qwen3.5-4B、Qwen3.5-35B-A3B、Intern-S2-Preview、GLM-4.7-Flash、Gemma-4-26B-A4B 共 7 个学生。方法要同时满足三点:不在教师轨迹上做监督微调(SFT),不人工构造不兼容分词之间的对应关系,并把蒸馏过程稳定在学生的上下文预算内,消除长度爆炸与截断,最终在 ProofBench、AnswerBench、AIME25、AMOBench 上取得一致提升。

与已有工作不同的是,独特的切入角度是把整个蒸馏搬到'共享文本空间'中:学生用自己的分词器生成并解码出表面字符串 $s$,教师用原生分词器和聊天模板对同一段文本重新编码,然后只对'累计前缀相同且当前 token 文本跨度完全一致'的 token 对建立对齐,其余位置回退到学生自身 log-prob。这与已有跨分词器方案的本质区别在于不做任何 logit 投影、概率合并或词表映射这类有损近似。在此之上,论文第一次系统刻画了'长上下文教师蒸馏给短上下文学生'特有的长度爆炸、截断与终止失败病理,并用终止 token 优势掩码和学生参考 KL 两个极简技巧将其解决,把一个此前被忽视的异构蒸馏场景真正做通。

核心方法

方法回答的核心问题是“教师怎么给学生的 rollout 打分”:既然两边分词不同,就让双方在同一段文本上工作。学生先用聊天模板 $C_\theta$ 构造上下文 $c_\theta$,采样回答 $y_{1:n}$ 并解码成字符串 $s$;教师用模板 $C_\phi$ 构造 $c_\phi$ 后拼接同一段 $s$,用教师分词器编码为 $z_{1:m}$。随后做线性双指针扫描,找出文本跨度完全一致的对齐对集合 $\mathcal{M}$,构造学生长度的教师目标:对齐位置继承教师 $\log\pi_\phi(z_i|c_\phi,z_{<i})$,未对齐位置回退为学生自身 log-prob。在此目标上定义优势并用 PPO 截断损失(clip 0.2)更新,叠加终止 token 掩码与参考 KL 两个稳定化手段。训练基于 Slime 框架,共 100 个 rollout 迭代,学习率 1e-6,批 64,每 prompt 采 4 条回答。

核心创新有二。第一是跨分词器对齐规则:$\mathcal{M}=\{(i,t): P_\phi(i)=P_\theta(t) \wedge \tau_\phi(z_i)=\tau_\theta(y_t)\}$,其中 $P_\theta(t)$、$P_\phi(i)$ 是该位置之前的累计响应文本,$\tau$ 是 token 贡献的文本跨度。只有前缀和跨度都相同才对齐,构成部分一对一映射;部分重叠的 token 一律不对齐,因为一个教师 token 的 log-prob 无法唯一分摊给多个学生 token。这个设计有一个漂亮的理论性质:当分词器完全一致时每个位置都对齐,目标严格退化为反向 KL $D_{\mathrm{KL}}(\pi_\theta\|\pi_\phi)$,说明它是精确目标的合法替身而非粗糙近似。第二是首次把 OPD 的长度爆炸当作可测量、可修复的病理:掩掉 与 <|im_end|> 的优势以阻止教师监督抑制终止,再加对初始策略的参考 KL 约束策略漂移,把截断率从持续上升压到接近 0。

方法步骤详情

流程分五步。(1) 采样:学生输入 $c_\theta=C_\theta(x)$,rollout 引擎采出 $y_{1:n}$,解码得回答文本 $s=D_\theta(y_{1:n})$。(2) 教师编码:构造 $c_\phi=C_\phi(x)$,把 $c_\phi\oplus s$ 交给教师,得 $E_\phi(s|c_\phi)=(z_1,\dots,z_m)$。(3) 对齐:计算累计前缀 $P_\theta(t)$、$P_\phi(i)$,双指针扫描——前缀与跨度均一致则对齐并双双前进,否则文本消耗少的一侧前进追赶,得到对齐指示 $a_t=\mathbb{1}[\exists i,(i,t)\in\mathcal{M}]$ 与词法重叠率 $\rho=|\mathcal{M}|/n$(实测开局即超 0.9)。(4) 目标与优势:对齐位置取教师 log-prob、未对齐位置回退学生自身得目标 $\tilde{\ell}^{\phi}_t$;定义固定优势 $\tilde{A}_t=\tilde{\ell}^{\phi}_t-\log\pi_{\theta_{old}}(y_t)$,终止 token 优势置零。(5) 更新:PPO 截断损失(clip 0.2)加参考 KL(Qwen/Intern 0.5,GLM/Gemma 1.0),每批更新 4 次,Qwen 系长度 32K、GLM/Gemma 6K,共 100 个迭代。

技术新颖性

与已有工作的本质区别有三点。其一,自 MiniLLM/GKD 以来的 OPD 工作都默认共享词表,跨分词器时要么做 logit 投影要么放弃 token 级蒸馏;本文证明'共享表面文本+跨度一致才对齐'即可保留绝大部分监督信号(词法重叠率全程 0.9 以上),完全不触碰词表结构,且同分词器情形无损退化为标准 OPD。其二,与 EOPD(在教师高熵位置补前向 KL)和 G-OPD(灵活参考模型加奖励缩放)这类修改目标函数的方案不同,SimpleOPD 的两个稳定化技巧作用于训练动态而非目标形式,实现极简且与前者正交,实验中在 ProofBench、AnswerBench、AMOBench 三项上大幅超越这两个基线。其三,本文首次把'长上下文教师→短上下文学生'场景下的长度爆炸、截断、终止失败作为系统性病理来研究,给出从现象(Figure 3/4)、单因素修复(Figure 5)到组合修复(Figure 6)的完整消融链,并发现参考 KL 强度需随师生差距与分词差异调节,这为后续异构蒸馏工作提供了方法论模板。

Overview of SimpleOPD. The student generates responses under its own tokenizer, while the teacher evaluates the same response under its native tokenizer. We align tokens with identical text spans, use teacher supervision for matched tokens, and stabilize training with KL regularization and termination-token masking.
Figure 2: Overview of SimpleOPD. The student generates responses under its own tokenizer, while the teacher evaluates the same response under its native tokenizer. We align tokens with identical text spans, use teacher supervision for matched tokens, and stabilize training with KL regularization and termination-token masking.
Intern-S2-Preview OPD training dynamics when masking the special tokens such as </think> and <|im_end|>. The special-token masking alone helps mitigate length-related instability but cannot resolve the length expansion problem.
Figure 5: Intern-S2-Preview OPD training dynamics when masking the special tokens such as </think> and <|im_end|>. The special-token masking alone helps mitigate length-related instability but cannot resolve the length expansion problem.
Intern-S2-Preview OPD training dynamics when adding student reference KL loss. The training could be stabilized, and the truncation rate is effectively reduced to nearly zero.
Figure 6: Intern-S2-Preview OPD training dynamics when adding student reference KL loss. The training could be stabilized, and the truncation rate is effectively reduced to nearly zero.
The lexical-overlap curves of Qwen3.5-35B-A3B, Intern-S2-Preview and GLM-4.7-Flash during OPD training from the teacher SU-01.
Figure 9: The lexical-overlap curves of Qwen3.5-35B-A3B, Intern-S2-Preview and GLM-4.7-Flash during OPD training from the teacher SU-01.

实验结果

主实验(Table 2)中 Intern-S2-Preview 的 ProofBench@4 从 21.70 升至 44.50(+22.80),几乎追平教师 SU-01 的 45.00;换 Gemini-2.5-Pro 评审(Figure 1)则从 34.0 升至 55.2(+21.2,+62.3%),超过 Gemini-2.5-Pro(52.9)和 GPT-5(47.2)。同族 Qwen3-4B 四项全涨:ProofBench +12.30、AnswerBench 47.50→64.50、AIME25 71.25→90.83;Qwen3-30B-A3B 的 ProofBench 13.80→36.47。跨族 Qwen3.5-35B-A3B ProofBench 26.78→42.39;GLM-4.7-Flash 30.8→39.7;分词差异最大的 Gemma-4-26B-A4B 仅 ProofBench 25.5→34.2,AnswerBench 反而 68.8→67.5。稳定化消融(Table 1):仅终止 token 掩码提至 38.10,加参考 KL 后 38.50、AIME25 95.80,截断率归零。换 158B 的 DeepSeek-V4-Flash 当教师(Table 5),6K 长度即把 AIME25 提到 97.50(+9.17)。域外(Table 3):HiPhO 38.6→41.1、HLE 38.6→41.1。基线对比(Figure 8):四项基准中三项大幅领先 EOPD 与 G-OPD。

OPD results from SU-01 to Intern-S2-Preview with masking termination tokens and adding student reference KL loss.
Table 1: OPD results from SU-01 to Intern-S2-Preview with masking termination tokens and adding student reference KL loss.
Evaluation results of distilling SU-01 to students on ProofBench, AnswerBench, AIME25, and AMOBench. Green values indicate improvements over the corresponding base model.
Table 2: Evaluation results of distilling SU-01 to students on ProofBench, AnswerBench, AIME25, and AMOBench. Green values indicate improvements over the corresponding base model.
Evaluation results of Intern-S2-OPD distilled from SU-01 on scientific reasoning benchmarks.
Table 3: Evaluation results of Intern-S2-OPD distilled from SU-01 on scientific reasoning benchmarks.
Results of different distillation lengths on Intern-S2-Preview and Qwen3.5-35B-A3B distilled from the teacher SU-01.
Table 4: Results of different distillation lengths on Intern-S2-Preview and Qwen3.5-35B-A3B distilled from the teacher SU-01.
SimpleOPD results from DeepSeek-V4-Flash to Intern-S2-Preview with masking termination tokens and adding student reference KL loss. The distillation length is 6k for computational efficiency.
Table 5: SimpleOPD results from DeepSeek-V4-Flash to Intern-S2-Preview with masking termination tokens and adding student reference KL loss. The distillation length is 6k for computational efficiency.
Ablation study on the student-reference KL coefficient in the setting from SU-01 to GLM-4.7-Flash.
Table 6: Ablation study on the student-reference KL coefficient in the setting from SU-01 to GLM-4.7-Flash.
Evaluation performance on ProofBench using Gemini-2.5-Pro as the judge, under the same evaluation setting as SU-01. With SimpleOPD, Intern-S2-OPD achieves performance comparable to DeepSeek-V3.2-Speciale.
Figure 1: Evaluation performance on ProofBench using Gemini-2.5-Pro as the judge, under the same evaluation setting as SU-01. With SimpleOPD, Intern-S2-OPD achieves performance comparable to DeepSeek-V3.2-Speciale.
Cross-family distillation results for GLM-4.7-Flash and Gemma-4-26B-A4B from SU-01.
Figure 7: Cross-family distillation results for GLM-4.7-Flash and Gemma-4-26B-A4B from SU-01.
Comparison of the Intern-S2 base model distilled from SU-01 with EOPD, G-OPD, and SimpleOPD across four reasoning benchmarks. All scores are reported as percentages.
Figure 8: Comparison of the Intern-S2 base model distilled from SU-01 with EOPD, G-OPD, and SimpleOPD across four reasoning benchmarks. All scores are reported as percentages.
查看结构化数据
任务指标本文基线提升
数学证明 ProofBench(Gemini-2.5-Pro 评审) 评分(%) Intern-S2-OPD 55.2 Intern-S2-Preview 34.0 +21.2(+62.3%),超过 Gemini-2.5-Pro 的 52.9 与 GPT-5 的 47.2
数学证明 ProofBench@4(DeepSeek-V4-Flash 评审) 评分(%) Intern-S2-OPD 44.50 Intern-S2-Preview 21.70 +22.80,几乎追平教师 SU-01 的 45.00
AIME25@8(同族学生) 准确率(%) Qwen3-4B-OPD 90.83 Qwen3-4B 71.25 +19.58
AnswerBench@8(同族学生) 准确率(%) Qwen3-4B-OPD 64.50 Qwen3-4B 47.50 +17.00
ProofBench@4(30B 级同族学生) 评分(%) Qwen3-30B-A3B-OPD 36.47 Qwen3-30B-A3B 13.80 +22.67
ProofBench@4(跨族 GLM) 评分(%) GLM-4.7-OPD 39.7 GLM-4.7-Flash 30.8 +8.9(AnswerBench 69.6→72.0)
AIME25@8(换更强教师,6K 长度) 准确率(%) Intern-S2-DS-OPD 97.50(教师 DeepSeek-V4-Flash) Intern-S2-Preview 88.33 +9.17,ProofBench 39.71 反超同长度 SU-01 教师的 38.80

局限与改进

作者承认的局限:跨族蒸馏效果与分词差异强相关,Gemma-4-26B-A4B 用 SentencePiece、词表与分段行为差异大,AnswerBench 从 68.8 微降至 67.5,只有 ProofBench 提升;学生参考 KL 系数需按模型手工调节(0.5 对 GLM 欠正则、1.2 又限制吸收能力,最优 1.0)。我的补充观察:(1) ProofBench 高度依赖 LLM-as-judge,SU-01 自身在两个评审下分别为 45.00 与 57.6,相差 12.6 分,跨论文比较需谨慎;(2) 部分重叠 token 被完全丢弃,教师信号在跨度不匹配处全部浪费,对词法重叠率低的学生损害更大;(3) 参考 KL 锚定在学生初始策略上,若基座较弱会拖慢向教师靠拢;(4) 训练只用约 4528 道数学证明题,域外提升有限(FrontierScience-Research 仅 1.7→5.0);(5) 教师需对每条学生 rollout 做完整前向打分,32K 蒸馏比 6K 贵数倍,论文未给出训练成本数字。

独立分析的弱点

弱点一:硬对齐浪费监督。未对齐位置的优势实际为零,等于没有学习信号;对 BPE 与 SentencePiece 这类差异大的分词,可改用字符级重叠比例做软分配,把教师 token 的 log-prob 按跨度重叠比例摊给相邻学生 token,或用动态规划允许 k:m 跨度合并。弱点二:KL 系数与蒸馏长度是静态超参,GLM 最优 1.0 与 Qwen 系的 0.5 不同,可设计随词法重叠率、截断率等在线指标自适应的调度器。弱点三:终止 token 掩码是补丁式方案,更根本的做法是把长度预算显式纳入目标(预算内奖励或长度控制头)。弱点四:ProofBench 靠 LLM judge 且取 4 次平均,论文未报告 judge 与人工评审的一致性,建议补充多 judge 相关性或小规模人工抽查。弱点五:只在数学证明域训练,虽 HiPhO 有 +2.5 的物理迁移证据,但代码、agent 等长程推理域未验证,FrontierScience-Research 仅 1.7→5.0。

未来方向

作者方向上,论文给出三条明确延伸:更强的教师带来更大的学生收益(DeepSeek-V4-Flash 在同 6K 长度下 ProofBench 反超 SU-01 达 0.91 分),跨分词器 OPD 因此可无缝接入任何前沿闭源或开源大模型当教师;蒸馏长度从 6K 增至 32K 在所有基准一致有益,值得探索按任务难度的课程式长度调度;纯证明数据优于混合可验证数学数据(ProofBench 44.50 对 38.50),提示按目标能力定制蒸馏数据比堆数据更重要。基于成果可继续延伸:把 OPD 与 RLVR 串联成'先蒸馏对齐、后强化突破'的两阶段后训练流水线;多教师跨分词器集成蒸馏,让不同家族的强项互补;把终止 token 掩码与参考 KL 推广到 agent 长程任务与视觉-语言推理模型;从理论上分析对齐映射的覆盖率与蒸馏收益的关系,指导针对低重叠分词对的预对齐或词表适配。

复现评估

复现条件较好。方法组件(双指针对齐、优势掩码、参考 KL)在开源框架 Slime 中实现,评测 rollout 用 SGLang;论文页面提供 Project Page、Code 与 Models 链接,预计会放出蒸馏后权重。训练数据全部公开:Open Proof Corpus 63 题、AoPS 2948 题、竞赛书籍 900 题、数谜米论坛与 Evan Chen 材料 617 题,合计约 4528 题。算力方面,需同时部署教师(30B-A3B 级)做逐 token 打分并训练学生:100 个 rollout 迭代、批 64、每 prompt 4 条回答、Qwen 系 32K 最大长度,估计需要多卡 A100/H100 集群,成本低于完整 RL 但显著高于普通 SFT。评测需 LLM judge(DeepSeek-V4-Flash 或 Gemini-2.5-Pro)跑 ProofBench@4 与 8 次采样的 AIME25 等,开销不小。总体难度中上:算法简单易实现,门槛主要在基础设施与教师推理成本。