Normalized Attention Without Probability Cage

Oliver Richter, Roger Wattenhofer

TL;DR

Standard Transformer attention relies on the softmax function, which forces attention weights to sum to one. This paper demonstrates that this "probability cage" restricts the network's mathematical expressivity and introduces an unwanted sequence-length bias at initialization. By replacing softmax with a simple normalization function, the authors introduce Normalized Attention Pooling (NAP), an alternative that is significantly more robust to hyperparameter choices and data biases.

What Problem Does This Paper Address?

Transformers have achieved dominant success across deep learning, yet the geometric implications of their core mechanism—softmax attention—remain largely unexamined. Softmax maps attention logits to a probability simplex, meaning the output of an attention head is always a convex combination of its value vectors.

The authors call this constraint the probability cage because the output vector can never escape the convex hull spanned by the input value vectors. This geometric restriction limits flexibility; for instance, a single attention head cannot compute a simple non-linear function like exclusive OR (XOR). Furthermore, it introduces an innate, sequence-length-dependent bias at initialization that forces the model to favor local tokens over broader context in longer sequences, making the architecture highly sensitive to hyperparameter tuning.

The geometric limitation of softmax attention (left) and its scaling behavior relative to sequence length (middle/right).

Methods

The authors propose Normalized Attention Pooling (NAP). Instead of applying softmax to project attention logits into a probability distribution, NAP applies a standard normalization function over the sequence dimension:

$$a_m^i = \text{normalize}([l_m^{i,1}, \dots, l_m^{i,N}])$$

where the normalization is defined as:

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

Here, $g$ and $b$ are learnable scalar parameters initialized to 1 and 0, respectively. This swap removes the convex hull constraint while preserving the stabilizing benefits of online logit normalization.

The authors evaluate NAP against several baselines:

  • Standard BERT: The classic Transformer encoder setup.
  • Modified Transformer Encoder (MTE): A controlled baseline that applies PreNorm adjustments and removes learning rate warm-up/clipping to isolate purely structural architectural effects.
  • No Online Logit Normalization (NON): Uses raw logits directly with a GELU activation.
  • Sum Pooling and Max Pooling: Simple, non-attentive aggregation baselines.

Datasets

To evaluate pure learning dynamics without the confounding effects of regularization, the authors design two synthetic tasks where data biases and sequence lengths can be explicitly manipulated:

  1. Argmin-First-Argmax Case Distinction Task: The model processes a sequence of integers and must pinpoint a specific token based on conditional rules (e.g., locate the minimum value if a specific flag integer is present, otherwise locate the first token or the maximum value). This creates highly skewed data distributions depending on the sequence length.
  2. Mode Finding Task: A set-based task where the model must identify the most common integer (the mode) in an input sequence across varying vocabulary sizes.

Key Insights and Ideas

  • The Convex Hull Limitation: Because softmax outputs are bound to a probability simplex, the final representation cannot escape the geometric boundaries of its inputs. NAP breaks this cage, allowing a single layer to compute complex non-linear relationships like XOR.
  • Innate Local Bias: At initialization, attention logits typically hover near zero, causing softmax attention to approximate a simple mean pooling. For longer sequences, this averaging effect reduces the variance of the context information, meaning the model implicitly relies almost entirely on local residual connections.
  • Hyperparameter Decoupling: Standard Transformers exhibit a fragile dependency between model dimension and the optimal learning rate. NAP eliminates this sensitivity, dramatically widening the hyperparameter window for successful training.

Key Results

  • Based on a massive empirical study of over 25,000 trained models, NAP demonstrated exceptional robustness. In the case distinction task, NAP successfully mastered all conditional sub-cases even under extreme data bias, whereas standard BERT often failed by focusing exclusively on the easiest local features.
  • NAP generalized significantly better to unseen sequence lengths. When trained on sequences of length $N=128$ and evaluated on length $N=64$, NAP retained its accuracy, while standard attention and sum-pooling performance degraded.
  • In the mode-finding task, NAP scaled efficiently to larger vocabulary sizes, significantly outperforming standard attention and completely outclassing max-pooling (which fails entirely on frequency-based tasks).

Limitations and Future Work

The primary limitation of this work is its exclusive focus on synthetic datasets. While synthetic tasks are ideal for isolating mathematical properties and structural failures cleanly, they do not perfectly mirror the noise and complexity of real-world data. The authors acknowledge that evaluating NAP on large-scale, practical NLP benchmarks—such as pre-training a language model from scratch on a massive text corpus—is an essential next step for future work.

Summary updated

BibTeX
@misc{richter2020normalized,
  author = {Oliver 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