TL;DR
Transformers struggle with data that has complex spatial or network structures (like 2D grids or brain connectivity) because standard positional encodings (PE) are designed for 1D sequences. This paper demonstrates that by initializing learnable PEs with a small norm, transformers can autonomously discover the underlying geometry of the data, leading to significantly better generalization and highly interpretable representations.
What Problem Does This Paper Address?
Transformers are inherently "permutation invariant"—they treat a sequence of tokens like a bag of words unless we explicitly tell them where each token sits. The standard solution is Positional Encoding (PE), usually a fixed 1D sinusoidal signal.
While 1D PEs work for text, they fail for datasets with non-trivial arrangements, such as 2D images, 3D brain scans, or complex biological networks. In these cases, "closeness" in a 1D flattened sequence doesn't reflect actual physical or functional proximity. While we could learn PEs from scratch, doing so often leads to poor generalization. The authors investigate how the initialization of these learnable PEs determines whether a model simply "memorizes" the training data or actually learns the underlying spatial structure.
Methods
The researchers used a standard encoder-only transformer and replaced the fixed PE with a learnable parameter initialized from a multivariate Normal distribution: $\mathcal{N}(0, \sigma I)$. The key variable was $\sigma$ (the norm of the initialization).
To evaluate if the model actually "learned" the right geometry, they used:
- Orthogonal Procrustes Transform: A method to rotate and align the learned high-dimensional PE embeddings with known "ground truth" coordinates to see if they match.
- Attention Map Analysis: Comparing the model's internal attention patterns to those of a model equipped with perfect ground-truth spatial information.
- Network Science Metrics: Using modularity and clustering statistics to see if learned PEs for brain regions naturally grouped into known functional networks.
Datasets
- Latin Square Task (LST): A synthetic 2D relational reasoning task (similar to Sudoku). The model must infer a missing symbol in a 4x4 grid. This tests if the model can recover 2D coordinates from a flattened 1D input.
- Nonlinear Stochastic Network (NMAR): A simulation of 15 nodes organized into three distinct clusters.
- Human Connectome Project (HCP): Real-world resting-state fMRI data from 100 participants. The task was to predict masked brain activity across 360 cortical regions, which are known to be organized into 12 functional networks.
Key Insights and Ideas
- The "Rich" vs. "Lazy" Regime: The paper applies deep learning theory to PEs. Large-norm initializations ($\sigma > 1.0$) put the model in a "lazy" regime (Neural Tangent Kernel), where it converges but learns random, high-dimensional representations that fail to generalize. Small-norm initializations ($\sigma \approx 0.1-0.2$) trigger a "rich" feature-learning regime, where the model is forced to find structured, low-dimensional representations—essentially "discovering" the grid or network.
- Interpretability Equals Generalization: There is a near-perfect correlation between how well the learned PE matches the ground-truth geometry and how well the model performs on unseen data.
- Geometry from Scratch: Even when the model has zero prior knowledge of 2D or 3D space, a small-norm initialization allows it to reconstruct the spatial relationships of tokens just by observing their interactions.
Key Results
- LST Performance: Learnable PEs with $\sigma=0.2$ achieved 95.6% accuracy, nearly matching the "ground truth" 2D fixed PE (97.7%) and vastly outperforming the standard 1D fixed PE (78.1%).
- Initialization Sensitivity: As shown in Figure 2, generalization performance drops sharply as the initialization norm $\sigma$ increases, even though all models converged during training.
- Brain Network Recovery: In the fMRI experiment, only small-norm PEs successfully recovered the modular organization of the human brain. The learned embeddings for regions within the same functional network (e.g., the visual system) were automatically placed closer together in the embedding space.
Limitations and Future Work
- Linear Superposition: The current approach adds the PE to the token embedding ($token + PE$). The authors suggest that learning nonlinear PE functions ($PE(token)$) could provide even greater expressive power.
- Optimizer Interactions: The study found that the Adam optimizer can sometimes interfere with very small initializations ($\sigma < 0.1$) due to its adaptive learning rates, suggesting that optimizer choice is a critical hyperparameter for feature learning.
- Dynamic Sequences: It remains unclear how this approach scales to tasks where the number of tokens or their relative positions change dynamically (e.g., length generalization).
Summary updated