[Paper Review] Differential Transformer
Differential Transformer introduces a differential attention mechanism that subtracts two softmax attention maps to cancel noise, yielding sparser, more relevant attention and better performance across scaling, long context, retrieval, and in-context learning tasks.
Transformer tends to overallocate attention to irrelevant context. In this work, we introduce Diff Transformer, which amplifies attention to the relevant context while canceling noise. Specifically, the differential attention mechanism calculates attention scores as the difference between two separate softmax attention maps. The subtraction cancels noise, promoting the emergence of sparse attention patterns. Experimental results on language modeling show that Diff Transformer outperforms Transformer in various settings of scaling up model size and training tokens. More intriguingly, it offers notable advantages in practical applications, such as long-context modeling, key information retrieval, hallucination mitigation, in-context learning, and reduction of activation outliers. By being less distracted by irrelevant context, Diff Transformer can mitigate hallucination in question answering and text summarization. For in-context learning, Diff Transformer not only enhances accuracy but is also more robust to order permutation, which was considered as a chronic robustness issue. The results position Diff Transformer as a highly effective and promising architecture to advance large language models.
Motivation & Objective
- Motivate reducing attention noise in Transformers to improve key information retrieval and contextual understanding.
- Propose a differential attention mechanism that promotes focus on relevant context while suppressing noise.
- Demonstrate scalability, long-context capability, and robustness across downstream tasks and in-context learning scenarios.
- Explore practical benefits such as hallucination mitigation and reduced activation outliers.
Proposed method
- Split input projections into two groups to compute two separate queries and keys.
- Compute two softmax attention maps and take their difference to form differential attention.
- Introduce a learnable scalar lambda to balance the two attention maps and re-parameterize lambda for stable training.
- Apply multi-head differential attention with head-wise normalization and a fixed gradient-aligned scaling, followed by a SwiGLU feed-forward block.
- Use RMSNorm and GroupNorm to stabilize training across heads and layers.
- Maintain a decoder-style architecture with residual connections and LayerNorm-like normalization, enabling compatibility with standard LLM hyperparameters.
Experimental results
Research questions
- RQ1Does differential attention improve the model’s ability to retrieve key information from long contexts compared with standard attention?
- RQ2Can Diff Transformer achieve comparable or better language modeling performance with fewer parameters or tokens?
- RQ3Does the approach reduce attention noise and activation outliers, enabling better quantization and long-context processing?
- RQ4Is in-context learning more robust to prompt order permutations under differential attention?
- RQ5Do the benefits extend to hallucination mitigation in summarization and question answering?
Key findings
- Diff Transformer outperforms Transformer in language modeling across scaling, tokens, and context length, achieving similar performance with roughly 65% of the parameters or tokens.
- In long-context and needle-in-a-haystack tasks, Diff Transformer shows higher accuracy and substantially less attention noise than Transformer.
- Diff Transformer reduces contextual hallucination in summarization and QA datasets compared with Transformer.
- Many-shot in-context learning with Diff Transformer is more accurate and robust to demonstration order than Transformer, across several datasets.
- Diff Transformer exhibits fewer activation outliers and maintains performance under lower-bit quantization, enabling more efficient hardware implementations.
- Diff Transformer maintains stable retrieval of key information across 64K contexts, with notable gains when the target information is early in the sequence.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.