Abstract
Knocking-Heads Attention (KHA) is a simple yet powerful modification to the standard Multi-Head Attention mechanism that allows individual attention heads to interact at the feature level. By introducing shared, diagonally-initialized projection matrices across heads, KHA achieves more stable training and significant performance gains in complex reasoning tasks with less than 1% additional computational overhead.
Introduction
In modern Large Language Models (LLMs), Multi-Head Attention (MHA) is the standard for processing information. It works by splitting the model's hidden state into multiple "heads," each attending to different parts of the sequence in parallel. However, a fundamental design flaw exists: these heads operate in total isolation, only "meeting" during concatenation at the end of the block. As models scale and head counts increase, individual head capacity weakens without a mechanism for coordination. Previous solutions like "Talking-Heads Attention" were computationally impractical due to quadratic scaling with the number of heads.
Methodology
The authors propose Knocking-Heads Attention (KHA), which facilitates cross-head communication before the attention calculation. The core mechanism involves adding a shared transformation matrix ($T$) across all heads. The paper explores two primary variants:
- KHA-Linear: Applies a shared linear transformation to the Query ($Q$), Key ($K$), and Value ($V$) representations. During inference, these shared matrices can be mathematically absorbed into the original weight matrices, resulting in zero additional latency.
- KHA-MLP: Uses a non-linear, gated MLP structure specifically for the Value ($V$) representations. While adding a minimal amount of compute, it provides superior representational power.
To prevent heads from becoming identical and losing specialized roles at the start of training, the authors utilize Diagonal Initialization. These shared matrices are initialized as near-identity matrices, allowing the model to start with standard MHA behavior and gradually learn beneficial cross-head interactions.
Experimental Setup
The researchers validated KHA through extensive training and benchmarking:
- Pre-training: A 6.1B parameter Mixture-of-Experts (MoE) model (with 1.01B active parameters) was trained on 1 Trillion high-quality tokens.
- Ablation Studies: Smaller models (0.44B to 14.6B parameters) were trained on 75B to 100B tokens to test different configurations.
- Evaluation Benchmarks: The models were tested on a comprehensive suite including ARC, HellaSwag, MMLU, GPQA (General Knowledge), RACE (Language Understanding), HumanEval-Plus, MBPP (Coding), and GSM8K, MATH, CMATH (Mathematics).
Results and Analysis
KHA provides a "free lunch" in terms of performance versus cost. On the 6.1B MoE model, KHA improved Language Understanding by +4.32 points, Coding by +3.90 points, and Math by +1.62 points compared to the baseline. The computational overhead is minimal, adding less than 1% to total parameters and training FLOPs.
Key insights from the study include:
- Value Interaction is Critical: Letting Value ($V$) representations interact across heads yields the highest performance gains. Interactions between Queries and Keys are helpful but optional.
- Training Stability: KHA significantly reduces "loss spikes"—sudden jumps in error during training—particularly in early stages.
- Universal Compatibility: KHA works seamlessly with Grouped-Query Attention (GQA), Grouped-Tied Attention (GTA), and Multi-Head Latent Attention (MLA) architectures.
Conclusion and Future Work
Knocking-Heads Attention demonstrates that allowing inter-head communication through shared, diagonally-initialized transformations can significantly enhance LLM performance and training stability. While the Linear variant offers zero inference overhead, the MLP version provides higher representational power. Future work will investigate further optimization of the MLP variant and the impact of cross-head interaction on coherence over extremely long sequences.
Summary updated