Normalized Attention Without Probability Cage

Oliver Paul Richter, Roger Wattenhofer

Abstract

Standard Transformer architectures rely on softmax-based attention, which constrains outputs to the convex hull of input vectors—a "probability cage" that limits mathematical expressivity. This paper introduces Normalized Attention Pooling (NAP), which replaces the softmax with a sequence-wise normalization scheme. NAP breaks the geometric constraints of the probability simplex and mitigates sequence length bias at initialization. Through extensive synthetic benchmarks involving over 25,000 model runs, the authors demonstrate that NAP offers superior hyperparameter robustness and better generalization across varying sequence lengths compared to traditional attention mechanisms.

Introduction: The Softmax Constraint

While Transformers have revolutionized AI, their core mechanism—softmax attention—imposes significant geometric restrictions. By forcing attention weights to lie on a probability simplex (summing to one and being non-negative), the output of an attention head is mathematically restricted to a convex combination of its input values.

This creates two primary issues:

  1. The "Probability Cage": Outputs are trapped within the convex hull of input vectors. Consequently, a single attention head cannot represent simple non-linear logic, such as an XOR function, which requires moving outside this hull.
  2. Sequence Length Bias: At initialization, the relative influence of context tokens versus the local token varies significantly with sequence length. This inconsistency complicates hyperparameter tuning for models intended to operate across diverse input lengths.

Normalized Attention Pooling (NAP)

To address these limitations, the authors propose Normalized Attention Pooling (NAP). Instead of using the exponential-based softmax to generate weights, NAP treats attention logits as standard neural activations and applies a normalization similar to Layer Normalization across the sequence dimension:

$$a_m^i = \text{normalize}(l_m^i) = g \cdot \frac{x^j - \mu_x}{\sigma_x} + b$$

This approach removes the requirement that weights be positive or sum to unity, effectively "breaking the cage."

The Probability Cage and Scaling Bias

Geometric constraints of the probability simplex (left) and the scaling behavior of norm and variance across sequence lengths (right). Normalized Attention Without Probability Cage, page 3

Geometric constraints of the probability simplex (left) and the scaling behavior of norm and variance across sequence lengths (right).

As shown in the figure above, standard attention (blue line) exhibits specific scaling properties for its norm and standard deviation ($\sigma$) as sequence length increases. NAP (normalized, purple line) maintains a constant scale, providing a more stable initialization regardless of input size.

Experimental Setup

The authors evaluated NAP against several baselines, including standard BERT, a "Modified Transformer Encoder" (MTE) designed to isolate attention effects, and simple pooling methods (Sum/Max).

To avoid the confounding biases of natural language datasets, the study utilized synthetic tasks:

  • Argmin-First-Argmax: A task requiring complex conditional logic to pinpoint specific tokens.
  • Mode Finding: Identifying the most frequent integer in a sequence, testing global aggregation capabilities.

The scale of the study was massive, involving over 25,000 models to explore a wide range of learning rates, dimensions, and sequence lengths.

Key Insights and Results

The experiments revealed several critical advantages for the NAP architecture:

  • Hyperparameter Robustness: NAP models successfully learned tasks across a much broader range of learning rates and model dimensions. While BERT-style models often required precise "sweet spots" to converge, NAP demonstrated a significantly flatter loss landscape.
  • Superior Accuracy: In the "First Token Output" task, NAP achieved 98.7% accuracy, vastly outperforming the MTE baseline's 75.4%.
  • Generalization: NAP showed superior performance when transferring from short training sequences to long validation sequences, a direct result of its stable initialization scaling.
  • Aggregation vs. Pinpointing: While simple max-pooling performed well on pinpointing tasks, it failed on global aggregation tasks like Mode Finding. NAP was the only architecture to handle both effectively.

Conclusion and Future Work

NAP represents a promising alternative to softmax attention by providing higher expressivity per head and greater architectural stability. While this study focused on synthetic validation, the results suggest that breaking the "probability cage" is a viable path toward more robust and generalizable Transformers. Future research will focus on scaling NAP to large-scale real-world pre-training and investigating its impact on model depth and interpretability.

Summary updated

BibTeX
@misc{richter2020normalized,
  author = {Oliver Paul Richter and Roger Wattenhofer},
  title = {{Normalized Attention Without Probability Cage}},
  year = {2020},
  eprint = {2005.09561},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2005.09561},
}
Figure