TL;DR
Standard Transformer attention struggles to separate relevant signals from input noise, while recent differential attention methods rely on coarse, scalar-based noise subtraction. Inspired by biological lateral inhibition, this paper introduces Multihead Differential Gated Self-Attention (M-DGSA), which learns a lightweight, per-token, per-head gate to dynamically subtract an inhibitory attention stream from an excitatory one. Across vision and language tasks—as well as corrupted datasets—M-DGSA consistently sharpens attention focus and boosts classification accuracy with virtually no change in FLOPs.
What Problem Does This Paper Address?
Standard scaled dot-product self-attention distributes attention weights across all query-key pairs uniformly via softmax. Consequently, models readily pick up irrelevant clutter—such as sensor noise in images or filler words in text—which degrades generalization and robustness.
The recent Differential Transformer addressed this by splitting attention into two streams and subtracting them ($A_1 - \lambda A_2$) to cancel out common-mode noise. However, it modulates this cancellation with a single learned scalar per head/layer. Real-world noise varies token by token; a static or layer-level scalar cannot adapt dynamically to local context.
Methods
M-DGSA combines differential attention with biological lateral inhibition—the neural mechanism where firing neurons suppress their neighbors to sharpen sensory contrast.
Key technical components include:
- Dual Excitatory and Inhibitory Substreams: Each attention head projects inputs into paired query-key sets: excitatory ($Q^+, K^+$) and inhibitory ($Q^-, K^-$), computing two parallel softmax attention maps ($A^+$ and $A^-$) over a shared value projection $V$.
- Input-Conditioned Gating: Rather than using a fixed scalar $\lambda$, M-DGSA predicts an input-dependent sigmoid gate per head and per token: $$g_{t,\text{head}} = \sigma(w_{g,\text{head}} x_t + b_{g,\text{head}})$$
-
Contrast-Enhancing Subtraction: The attention maps are fused via token-level subtractive gating: $$A_{t,\text{head}} = g_{t,\text{head}} A^+_{t,\text{head}} - (1 - g_{t,\text{head}}) A^-_{t,\text{head}}$$ Unlike traditional gating (which blends streams additively), subtraction explicitly quells background noise and sharpens salient boundaries.
-
Architecture Instantiations:
- DGViT (Vision Transformer variant): Incorporates M-DGSA with SwiGLU activations in the feed-forward network and an internal attention residual connection.
- DGT (Language Transformer variant): Embeds M-DGSA into encoder blocks alongside SwiGLU.
Datasets
The authors evaluated models trained from scratch on diverse public benchmarks:
- Vision: CIFAR-10, CIFAR-100, Fashion-MNIST, Street View House Numbers (SVHN), and ImageNet-1k. Robustness was evaluated using CIFAR-10-C and CIFAR-100-C across 19 corruption types (noise, blur, weather, digital artifacts).
- Language: Rotten Tomatoes and IMDB (binary sentiment), AG News (4-class topic categorization), 20 Newsgroups (fine-grained 20-class classification), and MNLI (multi-genre natural language inference).
Key Insights and Ideas
- Subtractive vs. Additive Gating: Most gated architectures perform convex combinations ($g A + (1-g) B$). M-DGSA's subtractive formulation ($g A^+ - (1-g) A^-$) directly operationalizes biological noise cancellation, allowing tokens to selectively zero out spurious correlations.
- Context Granularity Matters: The leap from a global scalar to per-token gating enables individual tokens to dictate their own suppression level—critical for distinguishing subtle semantic cues from noisy backgrounds.
- Simplicity Prevents Overfitting: Ablations reveal that a single-layer projection for the gate performs better than multi-layer MLPs, preserving lightweight parameter efficiency without complicating optimization.
Key Results
- Small Vision Benchmarks: DGViT consistently outperformed both baseline ViT and Differential ViT (DViT). On CIFAR-10, DGViT reached 78.31% accuracy compared to 75.90% (ViT) and 77.16% (DViT). On CIFAR-100, DGViT closed DViT’s performance deficit, achieving 47.72% (vs. 47.01% ViT and 45.66% DViT).
- ImageNet-1k: At scale, DGViT reached 67.08% accuracy (at $16/3\times$ expansion), improving over baseline ViT (59.94%) and DViT (66.66%).
- Language Understanding: In text classification, DGT delivered notable gains on fine-grained, high-variance tasks: on 20 Newsgroups, DGT reached 63.53% vs. 51.54% (Transformer) and 58.75% (DT). On MNLI, DGT improved by up to +3% over vanilla Transformers.
- Corruption Robustness & Visualizations: On CIFAR-10/100-C, M-DGSA showed superior resilience against severe distortions (especially fog, frost, and contrast shifts). Attention rollout heatmaps confirmed that M-DGSA sharply focuses on semantic contours (e.g., digit strokes, class keywords) while actively attenuating background clutter.
Limitations and Future Work
- Throughput and Latency Overhead: While parameter count and FLOPs remain comparable or lower due to SwiGLU design choices, the parallel softmax maps and gating projections reduce throughput (e.g., 23.7 it/s for DGViT vs. 40.2 it/s for standard ViT on CIFAR-10) and increase forward memory.
- Evaluation Scope: Experiments focused on synthetic noise benchmarks and training from scratch; testing on real-world corruptions (motion blur, occlusions) and large pretrained foundation models remains open.
- Cross-Attention: M-DGSA is currently restricted to self-attention. Extending input-conditioned lateral inhibition to cross-attention mechanisms in vision-language models (e.g., VQA, captioning) is highlighted as a promising direction.
Summary updated