arXiv ScienceSearch

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

Structure and dynamics of the negative thermal expansion material Cd(CN)$_2$ under hydrostatic pressure

We use a combination of variable-temperature / variable-pressure neutron powder diffraction, variable-pressure inelastic neutron scattering, and quantum chemical calculations to interrogate the behaviour of the negative thermal expansion (NTE) material $^{114}$Cd(CN)$_2$ under hydrostatic pressure. We determine the equation of state of the ambient-pressure phase, and discover the so-called `warm hardening' effect whereby the material becomes elastically stiffer as it is heated. We also identify a number of high-pressure phases, and map out the phase behaviour of Cd(CN)$_2$ over the range $0\leq p\leq0.5$\,GPa, $100\leq T\leq300$\,K. As expected for an NTE material, the low-energy phonon frequencies are found to soften under pressure, and we determine an effective Gr{ü}neisen parameter for these modes. Finally, we show that the elastic behaviour of Cd(CN)$_2$ is sensitive to the local Cd coordination environment, which suggests an interplay between short- (phononic) and long-timescale (cyanide flips) fluctuations in Cd(CN)$_2$.

cond-mat.mtrl-sci

Unconventional Magnetism, Sliding Ferroelectricity, and Magneto-Optical Kerr Effect in Multiferroic Bilayers

Antiferromagnetic (AFM) materials provide a platform to couple altermagnetic (AM) spin-splitting with the magneto-optical Kerr effect (MOKE), offering potential for next-generation quantum technologies. In this work, first-principles calculations, symmetry analysis, and kp modeling are employed to show that interlayer sliding in AFM multiferroic bilayers enables control of electronic, magnetic, and magneto-optical properties. This study reveals an intriguing dimension-driven AM crossover: the 2D paraelectric (PE) bilayer exhibits spin-degenerate bands protected by the [C2||Mc] spin-space symmetry, whereas the 3D counterpart manifests AM spin-splitting along kz \neq 0 paths. Furthermore, interlayer sliding breaks this Mc symmetry and stabilizes a ferroelectric (FE) state with compensated ferrimagnetism, where the Zeeman-like field is responsible for the nonrelativistic spin-splitting. In the FE phase, spin-orbit coupling (SOC) lifts accidental degeneracies and produces `alternating' spin-polarized bands through the interplay of Zeeman and Rashba effects. Crucially, spin polarization, ferrovalley polarization, and the Kerr angle can all be reversed by switching either sliding ferroelectricity or the Neel vector. Our findings reveal the rich coupling among electronic, magnetic, and optical orders in sliding multiferroics, illustrating new prospects for ultralow-power spintronic and optoelectronic devices.

cond-mat.mtrl-sci

Lead-free piezoelectric perovskites for arterial-pulse e-skin: from configurational complexity to equivariant machine-learning potentials

Continuous, non-invasive monitoring of the arterial pulse is a clinical priority for cardiovascular disease, the leading cause of global mortality. Flexible piezoelectric electronic skins can transduce the 1-10 kPa pressure wave into a self-powered voltage, but the best-performing piezoceramics are lead-based, and their toxicity is incompatible with skin contact and with tightening RoHS/REACH regulation. Among lead-free alternatives, the BaTiO$3$-based solid solution BZT-BCT reaches $d{33} \approx 620$ pC/N near its tricritical morphotropic phase boundary, rivalling soft PZT while remaining biocompatible. Exploiting this in a wearable confronts a sensitivity-flexibility paradox and three computational walls: the combinatorial explosion of atomic configurations in a disordered solid solution, the band-gap error of affordable density-functional approximations, which corrupts leakage and insulation estimates, and the 0 K nature of standard calculations against a 310 K operating temperature. We review lead-free piezoelectrics, morphotropic-boundary physics and fabricated flexible devices, then argue that equivariant machine-learning interatomic potentials --- coupled to a tiered functional hierarchy and finite-temperature lattice dynamics --- can survey the full configurational ensemble at body temperature and close the gap to a clinically viable lead-free pulse sensor.

cond-mat.mtrl-sci