talks
|
texts
MIIII
Copenhagen, Denmark
January 7, 2025
Talk on Mechanistic Interpretability of Deep Learning Models presented at the University of Copenhagen
MIIII
Noah Syrkis
January 8, 2025
1 | All 29 tasks grok when stable
2 | Embeddings carry order and tasks
3 | Each task keeps few frequencies
4 | Some frequencies are transient
5 | Transients slow grokking
A disgusting pile of matrices is often a poorly written elegant algorithm.
After Neel Nanda
Introduction
▶
Deep learning is sub-symbolic
▶
Interpretability turns weights into maths
▶
We train a model, then reverse engineer it
Figure 1: One neuron of a model trained on
(
𝑥
0
+
𝑥
1
)
mod
𝑝
3 of
22
Introduction
▶
We ask when each task is learned
▶
We ask whether the mechanisms stay fixed
▶
We ask how they are learned
▶
We ask how to write them as maths
↓
𝑓
(
𝑥
)
=
sin
𝑤
𝑒
𝑥
+
cos
𝑤
𝑒
𝑥
Figure 2: From parameters to a formula
4 of
22
Introduction
▶
Grokking is late generalization
[1]
▶
A mechanism needs a general model
▶
Weights turn from table to algorithm
Figure 3: Training loss above and validation loss
below, from a grokking run
5 of
22
Introduction
▶
Prior work studies modular addition
[2]
▶
We read the pair as a base
𝑝
number
▶
We predict it modulo each smaller prime
▶
So there are many tasks and order matters
𝑦
=
(
𝑥
0
+
𝑥
1
)
mod
𝑝
(1.1)
𝑦
⃗
=
(
𝑥
0
+
𝑥
1
𝑝
)
mod
𝑞
∀
𝑞
<
𝑝
(1.2)
Figure 4: Modular addition above and our task
below. Both
𝑝
and
𝑞
are prime
6 of
22
Introduction
▶
Inputs are all pairs of digits below
𝑝
▶
Targets are their remainders for each
𝑞
↓
Figure 5: Inputs for
𝑝
=
7
above. Targets for
𝑞
=
1
1
with
𝑝
=
1
3
below
7 of
22
1 |
All 29 tasks grok when stable
▶
All 29 tasks generalize at
𝑝
=
1
1
3
▶
GrokFast amplifies slow gradients
[3]
▶
Without it the model did not converge
Figure 6: Training accuracy above and validation
accuracy below, per task, at
𝑝
=
1
1
3
8 of
22
1 |
All 29 tasks grok when stable
▶
A learning rate of 0.003 collapses
▶
Each collapse follows a loss spike
▶
Lower rates never collapse
▶
Clipping at norm 1 changes nothing
Rate 0.003, 12 collapses
Rate 0.001, 0 collapses
Rate 0.0003, 0 collapses
1
0
3
1
0
4
epoch
0
.
0
0
.
2
0
.
4
0
.
6
0
.
8
1
.
0
mean validation accuracy
Figure 7: Mean validation accuracy at
𝑝
=
1
1
3
.
One seed per setting, so preliminary
9 of
22
2 |
Embeddings carry order and tasks
▶
In addition the positions look alike
▶
They correlate at 0.95, ours at
−
0
.
6
4
▶
So our input tells
𝑥
0
from
𝑥
1
Figure 8: Positional embeddings for modular ad
dition above and our task below
10 of
22
2 |
Embeddings carry order and tasks
▶
Modular addition uses five frequencies
▶
Our task uses many more
▶
Its embedding table is nearly saturated
Figure 9: Token embeddings in a Fourier basis,
for modular addition above and our task below
11 of
22
3 |
Each task keeps few frequencies
▶
We remove one frequency from task
𝑞
▶
It matters if the task’s loss rises 0.05 nats
▶
At the end only a few still matter
▶
Larger tasks keep a few more
2
5
11
17
23
31
task
𝑞
0
2
4
answer frequencies
Figure 10: Frequencies that matter at the end, at
𝑝
=
3
7
. Standard errors over 9 seeds
12 of
22
4 |
Some frequencies are transient
▶
Others matter only early in training
▶
Removing them later costs under 0.01 nats
▶
Every seed has them in every task from 11 up
▶
Larger tasks have more of them
1
0
2
1
0
3
1
0
4
epoch
0
1
2
3
loss rise when removed
Figure 11: Task 19 in one seed. Solid frequencies
last and dashed ones fade
13 of
22
5 |
Transients slow grokking
▶
A is plain and B suppresses transients
▶
C and D suppress unused or lasting ones
▶
B takes 0.38 of C’s time, give or take 0.04
▶
Transients slow learning rather than help it
A
B
C
D
0
2
4
6
8
1
0
thousand epochs
Figure 12: Epochs for tasks 11 to 19 to reach 0.95
accuracy. Standard errors over five seeds
14 of
22
Transient frequencies are detours, not scaffolding. Suppressing them speeds grokking.
References
[1]
A. Power, Y. Burda, H. Edwards, I. Babuschkin, and V. Misra, “Grokking: Generalization Beyond
Overfitting on Small Algorithmic Datasets.” Accessed: Feb. 13, 2024. [Online]. Available:
http://
arxiv.org/abs/2201.02177
[2]
N. Nanda, L. Chan, T. Lieberum, J. Smith, and J. Steinhardt, “Progress Measures for Grokking via
Mechanistic Interpretability.” Accessed: Dec. 16, 2023. [Online]. Available:
http://arxiv.org/
abs/2301.05217
[3]
J. Lee, B. G. Kang, K. Kim, and K. M. Lee, “Grokfast: Accelerated Grokking by Amplifying Slow
Gradients.” Accessed: Jun. 09, 2024. [Online]. Available:
http://arxiv.org/abs/2405.20233
References
17 of
22
Hyperparameters
rate
𝜆
wd
𝑑
lr
heads
1
1
0
1
2
1
3
256
3
1
0
4
4
Table 1: Hyperparameters for our task
18 of
22
An earlier frequency count
▶
An earlier analysis counted strong frequencies
▶
The count rose from 0 to 18, then fell to 10
▶
That rule also flags noise and single digits
▶
Causal ablation replaces it
Figure 13: Active neuron frequencies through
training, one per row, from an earlier analysis
19 of
22
Gradients as a signal
Write the weights of a model as
𝜃
and the gradient of the loss at step
𝑡
as
𝑔
(
𝑡
)
. Over training,
𝑔
(
𝑡
)
moves
up and down like a stochastic signal, so it can be written in a Fourier basis. GrokFast
[3]
holds that the
slowly varying frequencies drive grokking. Amplifying them relative to faster ones does accelerate it.
20 of
22
Discrete Fourier transform
A function can be written as a sum of sines and cosines. The discrete Fourier transform does the same
for a vector.
21 of
22
Singular value decomposition
An
𝑚
×
𝑛
matrix
𝑀
factors as
𝑈
Σ
𝑉
∗
. Here
𝑈
is an
𝑚
×
𝑚
unitary matrix,
Σ
is an
𝑚
×
𝑛
diagonal
matrix, and
𝑉
is an
𝑛
×
𝑛
unitary matrix. Multiplying a vector by
𝑀
thus first rotates it by
𝑉
∗
, then
scales it by
Σ
, then rotates it by
𝑈
.
22 of
22
part@syrkis.com
library