让文字算术模型抗位置偏移,提升真实场景泛化能力
Mitigating Position-Shift Failures in Text-Based Modular Arithmetic via Position Curriculum and Template Diversity
- 用位置课程+模板多样性训练,显式学习位置不变性
- 在p=97下,模型对位置偏移和自然语言模板的鲁棒性提升显著
- 适合关注小样本程序推理与分布外泛化的研究者
基于grokking研究的启发,我们研究了字符级Transformer在文本形式的模加法计算任务中的表现,重点关注输入格式变化下的鲁棒性,而非仅分布内准确率。我们发现一种此前被忽视的失败模式:即使模型在分布内达到高准确率,当表达式整体移至不同绝对字符位置(“位置偏移”)或使用分布外自然语言模板时,性能会崩溃。通过对p=97的所有有序对进行不相交对划分,我们发现基线模型虽在分布内表现良好,但在位置偏移和模板分布外时完全失效。随后提出一个简单训练策略:(i)显式表达式边界标记,(ii)位置课程以扩大训练中覆盖的绝对位置范围,(iii)多样模板混合,(iv)每例多变体一致性训练。在三个随机种子下,该方法显著提升对位置偏移和模板分布外的鲁棒性,同时保持高分布内准确率;而类似ALiBi的消融实验则无法学习该任务。结果表明,在噪声监督下引导程序泛化,需显式训练数据分布中缺失的位置不变性,我们还提供了可复现的评估协议与实验资源。
原文摘要 · Abstract (English)
Building on insights from the grokking literature, we study character-level Transformers trained to compute modular addition from text, and focus on robustness under input-format variation rather than only in-distribution accuracy. We identify a previously under-emphasized failure mode: models that achieve high in-distribution accuracy can fail catastrophically when the same expression is shifted to different absolute character positions ("position shift") or presented under out-of-distribution natural-language templates. Using a disjoint-pair split over all ordered pairs for p=97, we show that a baseline model reaches strong in-distribution performance yet collapses under position shift and template OOD. We then introduce a simple training recipe that combines (i) explicit expression boundary markers, (ii) position curriculum that broadens the range of absolute positions seen during training, (iii) diverse template mixtures, and (iv) consistency training across multiple variants per example. Across three seeds, this intervention substantially improves robustness to position shift and template OOD while maintaining high in-distribution accuracy, whereas an ALiBi-style ablation fails to learn the task under our setup. Our results suggest that steering procedural generalization under noisy supervision benefits from explicitly training invariances that are otherwise absent from the data distribution, and we provide a reproducible evaluation protocol and artifacts.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。