arXiv:2608.00418cs.AI2026-08被引 2

用可学习的注意力掩码替代查询键初始化,提升Transformer在布尔推理中的泛化能力。

Mask-Based Priors Are More Persistent than Query-Key Initializations

论文配图:Mask-Based Priors Are More Persistent than Query-Key Initializations
图 1 · 摘自论文原文
  • 直接初始化注意力掩码以注入结构先验,避免被训练过程覆盖
  • 在布尔推理任务上实现接近完美的外推性能,远超传统方法
  • 适用于低数据场景,且不影响视觉与语言任务表现,适合需要稳定归纳偏置的场景

Transformers 在某些布尔外推任务中不仅缺乏数据,还会系统性地错误泛化。尽管能拟合已知数据,但它们常按更简单的最小次数插值器而非真实目标函数进行外推。这类任务虽非实际应用,但作为理解Transformer归纳偏置的受控压力测试。我们探究是否可通过在注意力机制中注入显式结构先验来纠正此失败模式。现有结构化初始化方法通过设计查询与键投影使相似度分数逼近期望注意力模式,间接改变归纳偏置。然而,我们在布尔外推任务中发现,此类基于QK的先验易在训练中被快速覆盖,无法改变学习到的外推规则。为此,我们提出一种更简单的方法:直接初始化加性注意力掩码。不同于用于因果或局部性的硬掩码,我们的掩码是有限、可学习的注意力对数偏差,从任务级交互结构初始化。该方法将结构先验与内容依赖的注意力得分分离,使其在优化过程中持续存在。在布尔推理任务中,基于掩码的初始化实现了接近完美的外推性能,而标准及QK初始化的Transformer仍受默认归纳偏置束缚。相同机制也提升了低数据算术任务表现,并在视觉与语言基准上保持竞争力。结果表明,注意力掩码不仅能作为架构约束,还可作为编码持久归纳偏置的简单基础。

原文摘要 · Abstract (English)

Transformers do not merely lack data on some Boolean extrapolation tasks; they generalize in a systematically wrong way. Recent work on generalization on the unseen has shown that, despite fitting the observed domain, Transformers often extrapolate according to a simpler minimum-degree interpolator rather than the true target function. These Boolean tasks are not practical applications, but controlled stress tests for understanding Transformer inductive bias. We ask whether this failure mode can be corrected by injecting explicit structural priors into attention. Existing structured-initialization methods alter Transformer inductive bias indirectly, by choosing query and key projections whose similarity scores approximate a desired attention pattern. However, we find that when applied to Boolean extrapolation, these QK-based priors can be rapidly overwritten during training and fail to change the learned extrapolation rule. We propose a simpler alternative: initialize the additive attention mask directly. Unlike standard hard masks used for causality or locality attention, our mask is a finite, learnable attention-logit bias initialized from task-level interaction structure. This separates the structural prior from content-dependent attention scores, allowing it to persist throughout optimization. On Boolean reasoning tasks, mask-based initialization achieves near-perfect extrapolation where vanilla and QK-initialized Transformers remain trapped by the default inductive bias. The same mechanism also improves low-data arithmetic performance and remains competitive on vision and language benchmarks. These results show that attention masks can serve not only as architectural constraints, but as a simple substrate for encoding persistent inductive bias in Transformers.

注意力机制归纳偏置布尔推理可学习掩码

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。