We apply Koopman operator theory and Dynamic Mode Decomposition (DMD) to characterise how large language models (LLMs) process different input topics. Treating the layer-to-layer evolution of hidden states as a dynamical system, we fit a linear Koopman operator and take the subspace spanned by its dominant modes as a per-topic spectral fingerprint. Four findings emerge. First, the depth map is near-linear: a single linear operator predicts each next-layer state to within approx. 18% relative error (interior variance explained approx. 0.99). Second, over the 57 MMLU subjects the fingerprint is topic-discriminative, matching the MMLU taxonomy at 0.72 nearest-neighbour purity and each subject's semantic neighbourhood at 0.75 any-hit@3. Third, it is a reproducible signature (split-half self-retrieval approx. 0.97$). Finally, these findings are consistent across seven base models (Qwen2.5 0.5-7B, Llama-3 1-8B), with a suggestive trend of alignment rising with MMLU accuracy. The spectral fingerprint thus provides a probe of how transformers process different topics across depth. Code is available at https://github.com/DeepK/koopman-llm-eacl27.
Figures & tables
Depth transition
Variance explained
h0→h1 (embedding ingest)
−0.04
h1→h2
0.35
h2→h3
0.48
interior ( h3→h33 )
≈0.99
h35→h36 (final layer)
0.73
interior mean (steps 1 - 34 )
0.94
Table 1: Per-step variance explained by linear DMD on Qwen2.5-3B, averaged over all 57 subjects.
Figure 1: The layer-to-layer map is near-linear in the interior across all models. Per-step variance explained R2 (top) and relative prediction error (bottom) of the linear Koopman operator, averaged over the 57 MMLU subjects, against relative depth (input transition at 0 , output at 1 ) for the seven base models (Qwen2.5 in blue, Llama in orange). The interior is flat at R2≈0.99 ( ≈ 5–15% error) for every model, while both boundaries (embedding ingestion and final-layer projection) are strongly nonlinear.
Configuration
no whiten
whiten
Linear DMD
0.190
Kernel, σ×0.1
0.64
0.98
Kernel, σ×0.25
0.81
0.93
Kernel, σ×0.5
2.92
1.13
Kernel, σ×1.0
5.66
5.60
Kernel, σ×2.0
11.83
4.66
Table 2: Mean per-step prediction error on five random subjects, lower is better. Linear whitening is omitted as it is a basis change that leaves the original-space operator, and hence the error, unchanged (0.190 either way). The five-subject linear value ( 0.190 ) is close to the all-57 mean ( 0.184 , Section 5.1 ).
Table 3: The 57 MMLU subjects grouped into four top-level categories (official categories.py mapping), with the number of subjects in each. Chance 1-NN category purity is ≈0.24 .
Figure 2: Mode-subspace fingerprints of the 57 MMLU subjects. Two-dimensional t-SNE of the K=50 fingerprint (Grassmann) distances among the 57 subjects for Qwen2.5-3B, with every subject labelled and coloured by top-level category. Same-category subjects largely group together (history at the bottom, physics and chemistry upper-left, medicine and biology upper-centre, pure mathematics at the right), but the salient structure is cross-category : the quantitative/algorithmic subjects (machine learning, computer science, computer security, econometrics, statistics, and the economics subjects) form a single cluster, and electrical engineering joins the physics group.
Representation
top-1
any-hit@3
Mode subspace (fingerprint)
0.33
0.75
chance
0.02
0.16
Table 4: Overlap between dynamics-space (the mode-subspace fingerprint) and semantic (label-embedding) neighbourhoods over 57 subjects. “top-1” is the fraction sharing the single nearest neighbour; “any-hit@3” is the fraction of subjects with ≥1 of their top-3 dynamics neighbours among their top-3 semantic neighbours. Chance rows give the expected overlap under random labelling.
Table 5: Top-3 nearest neighbours of each subject in semantic vs. mode-subspace dynamics space ( K=50 , Qwen2.5-3B). Agreement cases are tight same-family clusters; among the divergences, quantitative/algorithmic subjects have machine learning among their nearest dynamics neighbours. “HS” = high school, “coll.” = college, “CS” = computer science.
K (modes)
cat. 1-NN
any-hit@3
1
0.44
0.19
2
0.42
0.21
3
0.49
0.35
5
0.51
0.32
10
0.65
0.61
20
0.61
0.65
Table 6: Effect of subspace dimension K on Qwen2.5-3B. Category 1-NN purity (chance ≈0.24 ) and semantic any-hit@3 (fraction of subjects with ≥1 shared top-3 neighbour; chance ≈0.16 ). Both rise sharply up to K≈10 ; any-hit@3 peaks around K=50 and plateaus.
Model
MMLU
split-half
cat 1-NN
any-hit@3
med. VE
Qwen2.5-0.5B
47.5
0.95
0.67
0.67
0.990
Qwen2.5-1.5B
60.9
0.97
0.68
0.75
0.997
Qwen2.5-3B
65.6
0.97
0.72
0.75
0.992
Qwen2.5-7B
74.2
1.00
0.74
0.78
0.998
Llama-3.2-1B
32.2
0.93
0.63
0.68
0.993
Llama-3.2-3B
58.0
1.00
0.74
0.73
0.990
Table 7: Per-model fingerprint metrics at K=50 , grouped by family and ordered by size within each family (MMLU shown as context). split-half: fingerprint self-retrieval top-1 (chance 0.02 ); cat 1-NN: category nearest-neighbour purity (chance 0.24 ); any-hit@3: fraction of subjects with ≥1 of their top-3 dynamics neighbours among their top-3 semantic neighbours (chance 0.16 ); med. VE: median per-step variance explained.