Why are Sensitive Functions Hard for Transformers?

Michael Hahn, Mark Rofin

Abstract

Transformers exhibit a notable bias toward low-sensitivity functions, struggling to learn tasks like PARITY where a single bit flip changes the output. This research identifies the root cause in the loss landscape: high-sensitivity functions inhabit increasingly sharp and brittle minima as sequence length grows. This "sharpness barrier" explains why stochastic gradient descent (SGD) fails to find these solutions and why they fail to generalize across lengths.

Introduction: The Learnability Gap

Despite their theoretical expressivity, Transformers often fail on simple formal languages. While they can represent functions like PARITY, they rarely do in practice. This paper resolves the tension between expressivity and learnability by analyzing the geometry of the loss landscape. The authors ask: even if a solution exists in the weight space, is it actually findable and stable under gradient descent?

Quantifying Sensitivity and Sharpness

The study employs Average Sensitivity ($as_n$) to measure how much a function's output depends on individual input bits. For instance, PARITY has maximum sensitivity ($n$), whereas MAJORITY has much lower sensitivity ($\sqrt{n}$).

The core theoretical contribution proves that representing high-sensitivity functions requires the model to inhabit regions of the parameter space with high sharpness. This is often achieved through "LayerNorm blowup," where normalization factors must increase to amplify small weight signals, making the output extremely sensitive to parameter perturbations.

Correlation between average sensitivity and sharpness across different training set sizes and random functions.

As shown in the figure above, there is a direct positive correlation between the average sensitivity of the learned function and the sharpness of the resulting minimum across various training conditions.

Key Results: The Sharpness Barrier

Empirical validation on synthetic Boolean tasks confirms the theoretical predictions regarding the difficulty of learning sensitive functions.

Sharpness vs. Sequence Length

For PARITY, the sharpness of the loss landscape increases significantly as the sequence length grows. In contrast, low-sensitivity functions like MAJORITY maintain low and relatively constant sharpness, making them easier for the model to learn and maintain.

Sharpness of the loss landscape increases with sequence length for high-sensitivity functions like PARITY, but remains low for MAJORITY.

The SGD Filter

Stochastic Gradient Descent (SGD) naturally favors "flat" minima because they are more robust and easier to encounter during optimization. Since sensitive functions are confined to increasingly "sharp" regions as task complexity grows, SGD effectively filters them out, leading to the observed low-sensitivity inductive bias in Transformers.

Why Scratchpads Help

The paper provides a rigorous explanation for the success of "Chain-of-Thought" or scratchpads. By decomposing a sensitive task into intermediate steps, each individual step becomes a low-sensitivity function ($O(1)$). These simpler functions reside in flat, stable regions of the landscape, making them easily learnable and robust for the Transformer architecture.

Conclusion and Future Work

The findings suggest that the difficulty of learning sensitive functions is an inherent property of the Transformer's loss landscape geometry. While the model may have the capacity to represent these functions, the optimization process is biased against the sharp minima they require. Future work remains to characterize the exact sharpness thresholds for finite lengths and to extend this analysis to decoder-only architectures and sequence-to-sequence tasks.

Summary updated

BibTeX
@inproceedings{hahn2024why,
  author = {Michael Hahn and Mark Rofin},
  title = {{Why are Sensitive Functions Hard for Transformers?}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2024},
  doi = {10.18653/v1/2024.acl-long.800},
}
Figure