Knocking-Heads Attention
该论文提出了敲击头部注意力(KHA),一种通过共享变换矩阵实现头部间通信的多头注意力机制,显著提高了模型性能和训练稳定性。
更新于 2025-12-08。作者:Zhanchao Zhou、Xiaodong Chen、Haoxing Chen、Zhenzhong Lan、Jianguo Li。
中文摘要
多头注意力(MHA)已成为现代大型语言模型的基础,通过并行注意力头来增强表征能力。然而,增加头部的数量本质上会削弱单个头部的容量,而现有的注意力机制——无论是标准MHA还是其变体,如分组查询注意力(GQA)和分组绑定注意力(GTA)——只是简单地将孤立头部的输出连接起来,而没有强大的交互。为了解决这一限制,我们提出了敲头注意力(KHA),它使得注意力头部能够“敲击”彼此——在缩放点积注意力之前促进跨头部特征级别的交互。这是通过将共享的对角初始化投影矩阵应用于所有头部来实现的。对角初始化在训练开始时保留了头部特定的专业化,同时允许模型逐步学习跨头部的集成表示。KHA仅添加了最小的参数和FLOPs,并且可以无缝集成到MHA、GQA、GTA和其他注意力变体中。我们通过在1T高质量标记上训练一个6.1B参数的MoE模型(激活1.01B)来验证KHA。与基线注意力机制相比,KHA带来了更优和更稳定的训练动态,在下游任务中实现了更好的性能。
英文摘要
Multi-head attention (MHA) has become the cornerstone of modern large language models, enhancing representational capacity through parallel attention heads. However, increasing the number of heads inherently weakens individual head capacity, and existing attention mechanisms - whether standard MHA or its variants like grouped-query attention (GQA) and grouped-tied attention (GTA) - simply concatenate outputs from isolated heads without strong interaction. To address this limitation, we propose knocking-heads attention (KHA), which enables attention heads to "knock" on each other - facilitating cross-head feature-level interactions before the scaled dot-product attention. This is achieved by applying a shared, diagonally-initialized projection matrix across all heads. The diagonal initialization preserves head-specific specialization at the start of training while allowing the model to progressively learn integrated cross-head representations. KHA adds only minimal parameters and FLOPs and can be seamlessly integrated into MHA, GQA, GTA, and other attention variants. We validate KHA by training a 6.1B parameter MoE model (1.01B activated) on 1T high-quality tokens. Compared to baseline attention mechanisms, KHA brings superior and more stable training dynamics, achieving better performance across downstream tasks.
解读
一句话总结
该论文提出了敲击头部注意力(KHA),一种通过共享变换矩阵实现头部间通信的多头注意力机制,显著提高了模型性能和训练稳定性。
问题1:这篇论文想要解决什么具体问题?
- 问题背景:多头部注意力(MHA)是现代大型语言模型的核心,但头部之间缺乏有效的交互,导致每个头部的能力被弱化。
- 现有方案不足:现有的注意力机制,如标准MHA及其变体,简单地连接各个头部的输出,缺乏头部间的强交互。
- 研究目标:提出敲击头部注意力(KHA),通过在缩放点积注意力之前促进头部间的特征级交互,增强头部能力。
问题2:论文的核心创新点是什么?
- 技术创新:提出敲击头部注意力(KHA),通过应用共享的对角初始化投影矩阵,实现头部间的“敲击”交互。
- 方法改进:对现有MHA进行改进,增加共享投影,允许模型从孤立头部开始,逐步学习头部间的集成表示。
- 优势:KHA增加的参数和FLOPs非常少,可以无缝集成到MHA、GQA、GTA和其他注意力变体中。
问题3:实验结果如何验证了方法的有效性?
- 关键实验:在1T标记上使用1.01B激活参数、6.1B总参数的MoE模型进行训练。
- 性能提升:与基线注意力机制相比,KHA带来了更好的训练动态,并在下游任务中实现了更好的性能。
- 对比结果:KHA在语言理解、代码和数学任务上分别提高了4.32、3.9和1.62个点,总体平均分数提高了1.26个点。
问题4:这个研究的实际应用价值是什么?
- 应用场景:适用于大型语言模型,如语言理解、代码生成和数学问题解决等。
- 实施建议:可以轻松集成到现有的Transformer架构中,提高模型性能和训练稳定性。
- 局限与展望:虽然KHA在大型模型中表现出色,但在小规模模型中的效果可能有限。未来的研究可以探索KHA在不同类型模型中的应用和优化。
来源
机器可读索引:llms.txt