Abstract
While mechanistic interpretability has successfully decoded the final representations of models trained on modular arithmetic, the underlying training dynamics remain opaque. This paper introduces a framework of physical "interaction forces"—clustering and alignment—to explain how neural networks self-organize into functional geometric structures. Using a toy transformer model and particle simulations, we demonstrate that modular addition tasks naturally lead to the emergence of grids and circles in embedding space. We find that the precision of these geometries is a direct predictor of generalization, and that weight decay serves as a necessary catalyst for the formation of optimal circular representations.
Introduction
In the study of neural network internals, researchers have identified distinct geometric patterns, such as "clocks" or "pizza slices," that emerge when models learn modular arithmetic. However, these observations are often static snapshots of fully trained models. This paper seeks to move beyond descriptive progress measures to provide a mechanical explanation for the optimization process itself: how does a random cloud of embeddings evolve into a structured, functional geometry?
Methodology
We utilize a simplified single-layer transformer with constant attention and 2-dimensional embeddings, allowing for direct visualization of the model's internal representations. The primary task is modular addition ($a + b \pmod{17}$) using a synthetic dataset of all possible pairs.
To isolate the drivers of learning, we propose two mathematical forces that approximate the gradients produced during backpropagation:
- Clustering: A force that repels embedding pairs associated with incorrect classifications and attracts those that belong within the same classification region.
- Alignment: A force, primarily driven by weight decay, that encourages embeddings to align with the weight vectors of the linear layer, keeping them centered near the origin.
To validate these forces, we developed a particle simulation that treats embeddings as physical entities. By applying only these two forces, we can observe the self-organization of embeddings without traditional neural network training, effectively treating the "mind" of the network as a physical system.
Geometric Emergence and Generalization
Our experiments reveal that training dynamics typically converge toward one of two primary geometric structures: grids or circles.
The "pizza" algorithm, characterized by the circular structure shown in Figure 1, is highly efficient for modular tasks. We observed a direct link between the "cleanliness" of these geometric structures and the model's ability to generalize to unseen data. In models that form grids, there is a strong negative correlation (up to -0.92) between the number of "grid imperfections" and validation accuracy.
As shown in Figure 4, disorganized states represent a failure of the model to fully resolve the underlying mathematical rule. These "imperfect grids" often occur when the balancing forces of clustering and alignment are not optimally tuned, leading to a model that memorizes the training table rather than learning the modular rule.
The Role of Weight Decay
Weight decay is traditionally viewed as a regularization technique to prevent overfitting. However, our results suggest it acts as a crucial physical force in the training process. By increasing weight decay, we observed a significant shift in model behavior, moving from 0% circular structures to 18% in transformer experiments. This shift corresponded with a dramatic improvement in average validation accuracy, rising from approximately 18% to over 50%. Weight decay provides the necessary "inward" force to catalyze the formation of circular geometries, acting as a catalyst for functional organization.
Discussion and Limitations
This work provides a compelling mechanical bridge between optimization and representation. However, several limitations remain. The use of constant attention and 2D embeddings simplifies the architecture significantly compared to real-world models. Furthermore, while the proposed forces behave like gradients, a formal mathematical derivation from the cross-entropy loss function is still required to fully ground the theory. Future research will explore these dynamics in higher-dimensional spaces and more complex architectures to see if these physical analogies hold at scale.
Summary updated