Search arXivSearch

arXiv · 2507.00683

Testing the spin-bath view of self-attention: A Hamiltonian analysis of GPT-2 Transformer

Abstract

The recently proposed physics-based framework by Huo and Johnson~\cite{huo2024capturing} models the attention mechanism of Large Language Models (LLMs) as an interacting two-body spin system, offering a first-principles explanation for phenomena like repetition and bias. Building on this hypothesis, we extract the complete Query-Key weight matrices from a production-grade GPT-2 model and derive the corresponding effective Hamiltonian for every attention head. From these Hamiltonians, we obtain analytic phase boundaries and logit gap criteria that predict which token should dominate the next-token distribution for a given context. A systematic evaluation on 144 heads across 20 factual-recall prompts reveals a strong negative correlation between the theoretical logit gaps and the model's empirical token rankings ($r\approx-0.70$, $p<10^{-3}$).Targeted ablations further show that suppressing the heads most aligned with the spin-bath predictions induces the anticipated shifts in output probabilities, confirming a causal link rather than a coincidental association. Taken together, our findings provide the first strong empirical evidence for the spin-bath analogy in a production-grade model. In this work, we utilize the context-field lens, which provides physics-grounded interpretability and motivates the development of novel generative models bridging theoretical condensed matter physics and artificial intelligence.

Explore related subjects

Keep this discovery

Explore connections, maps & timelines

BibTeXRIS

Satadeep Bhattacharjee, Seung-Cheol Lee. 2025-12-30. Testing the spin-bath view of self-attention: A Hamiltonian analysis of GPT-2 Transformer. https://arxiv.org/abs/2507.00683

Cite the original work for its findings. Save a collection to share your selection of sources.

KEEP EXPLORING

Related papers

Electronic States, Spin-Orbit Coupling and Magnetism in Germanium 60° Dislocations

Defects in semiconductors have recently attracted renewed interest owing to their potential in novel quantum applications. Here we investigate the electronic and magnetic properties induced by 60° dislocations in Ge. Using large-scale DFT calculations, we determine the band structure for both the shuffle and glide sets in their lowest-energy configurations. The band structure for the shuffle set reveals defect-induced dispersive bands localized within the band gap near the $Γ$ point, whereas for the glide set, we observe strong overlap with the conduction band. Defect-induced band splitting evident away from $Γ$ reveals Rashba-Dresselhaus spin-orbit coupling, an effect previously reported only for screw dislocations. Remarkably, we find evidence that specific dislocation arrangements can stabilize antiferromagnetic ordering with sizable local magnetic moments and considerable exchange splitting between opposite spin states. These results uncover rich physics in Ge dislocations through the combination of spin-orbit coupling and magnetic ordering, potentially enabling novel defect-based functionalities in Ge devices.

cond-mat.mtrl-sci

Thermal Hall resistivity and transverse entropy production in a phonon gas

Most theories of the phonon thermal Hall effect ignore phonon-phonon interactions. Here, by recalling the Senftleben-Beenakker effect in molecular gases, we argue that a magnetic field, by influencing collisions between neutral non-chiral [quasi-]particles, can induce a Hall response. Our study of two insulators with distinct crystal structures, layered honeycomb WS$_2$ and ferroelectric perovskite LiNbO$_3$, finds that $κ_{xx}$ and $κ_{xy}$ peak at nearly the same temperature in both materials, as reported in other insulators. We show that the amplitude of transverse thermal \emph{resistivity} in clean and simple insulators is of the order of $|W_\perp/B|\simeq \frac{e}{k_B u}$, where $e$ and $k_B$ are fundamental constants and $u$ is the binding energy density of the crystal. In complex and dirty insulators, $|W_\perp/B|$ is much larger and has a significant temperature dependence. Nevertheless, the peak thermal Hall \textit{angle} in all insulators remains roughly the same.

cond-mat.mtrl-sci

First-principles calculations of electronic structure

The emergence of high-mobility at provides a fertile platform for exploring emergent quantum phenomena and next-generation oxide electronics. Here, using first-principles density functional theory (DFT) calculations, we uncover the microscopic origin of the formed at the interface between insulators. Despite both constituents being insulating in bulk, the heterostructure develops robust metallicity at the interface, in agreement with experimental observations. This charge redistribution stabilizes at the interface. The electronic states forming enforcing carrier motion strictly within the interfacial plane. Remarkably, the spin-up parabolic band hosting the 2DEG exhibits an exceptionally small effective mass -- indicating the potential for significantly enhanced carrier mobility. Furthermore, the calculated interfacial electron density exceeds that of by nearly an order of magnitude, consistent with experimental measurement. These findings identify the heterostructure as a compelling platform for realizing and open new avenues for engineering correlated oxide interfaces for quantum electronic applications.

cond-mat.mtrl-sci