itzPotato commited on
Commit
095edfb
·
verified ·
1 Parent(s): d3ef504

arithmetic relu-2layer-seed2: checkpoint, config, training history

Browse files
Files changed (4) hide show
  1. README.md +90 -0
  2. config.json +45 -0
  3. history.json +213 -0
  4. model.safetensors +3 -0
README.md ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: pytorch
3
+ tags:
4
+ - arithmetic
5
+ - interpretability
6
+ - bilinear
7
+ - transcoder
8
+ ---
9
+
10
+ # arithmetic-relu-2layer-seed2
11
+
12
+ A 2-layer, bias-free, norm-free decoder-only transformer with a
13
+ **relu** MLP, trained on 4-digit signed addition and subtraction. One of
14
+ twelve models ({relu, bilinear} x {1, 2} layers x seeds {0, 1, 2}) trained under an
15
+ identical recipe so that MLP type is the only structural difference between them.
16
+
17
+ ## Task format
18
+
19
+ One token per digit, operator and `=`; operands zero-padded to 4 digits, answer to 5,
20
+ preceded by a sign token:
21
+
22
+ ```
23
+ 1 2 3 4 + 0 5 6 7 = + 0 1 8 0 1 (16 tokens)
24
+ ^^^^^^^^^ loss is on these 5 digits only
25
+ ```
26
+
27
+ Token ids: digits `0`-`9` are themselves, `+`=10, `-`=11, `=`=12, `d_vocab`=13.
28
+
29
+ **These ids are this project's own numbering.** They were intended to match a reference
30
+ Hub model, but that model (`melephant/1-layer-addition-v2`) turns out to be
31
+ **addition-only** with a 13-token vocabulary containing no `-` and no answer-sign token,
32
+ so it cannot express this task and its tokenisation could not have been adopted. Compare
33
+ token ids before using activations from this model alongside anyone else's.
34
+
35
+ ## Architecture
36
+
37
+ | | |
38
+ |---|---|
39
+ | d_model | 32 |
40
+ | d_mlp | 64 |
41
+ | n_heads | 4 |
42
+ | d_head | 8 |
43
+ | n_layers | 2 |
44
+ | MLP | `relu` |
45
+ | parameters | 17,728 |
46
+ | bias / norm | none |
47
+
48
+ `relu` is `W_out ReLU(W_in x)`; `bilinear` is `W_out[(W_L x) * (W_R x)]`.
49
+
50
+ ## Training
51
+
52
+ Identical recipe for every one of the twelve models: AdamW, lr 0.02
53
+ (cosine, 200 warmup steps), batch 1024, weight decay
54
+ 0.01, grad clip 1.0, one pass over 5,000,000 examples.
55
+ The learning rate was chosen by a six-point probe run on **both** MLP variants and set to
56
+ the highest rate at which both remain stable, so the shared recipe favours neither.
57
+
58
+ Model seed 2; data seed 1234, identical across all twelve.
59
+ Best step 4883 of 4883.
60
+
61
+ ## Results
62
+
63
+ | split | loss | digit acc | seq acc | sign acc |
64
+ |---|---:|---:|---:|---:|
65
+ | validation | 0.0009 | 0.9997 | **0.9983** | 0.0000 |
66
+ | test | 0.0009 | 0.9997 | **0.9983** | 0.0000 |
67
+
68
+ ## Accuracy by operator
69
+
70
+ | operator | seq acc | digit acc | loss |
71
+ | --- | ---: | ---: | ---: |
72
+ | addition | 0.9988 | 0.9998 | 0.0005 |
73
+ | subtraction | 0.9978 | 0.9996 | 0.0013 |
74
+
75
+ `seq acc` requires all five digits correct. **`sign acc` is ~0 by construction and is not a
76
+ bug:** the loss covers the five answer digits only, so the position predicting the sign
77
+ token receives no gradient. The sign is teacher-forced as input, so digit accuracy is
78
+ unaffected.
79
+
80
+ The 1-layer models have solved addition and not subtraction; the 2-layer models solve both.
81
+ The second layer is buying borrow propagation specifically.
82
+
83
+ ## Loading
84
+
85
+ ```python
86
+ from src.pretraining.model import PretrainTransformer
87
+ model, config = PretrainTransformer.from_directory("path/to/checkpoint")
88
+ ```
89
+
90
+ `history.json` carries the full training curve and the checkpoint-selection trace.
config.json ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "d_model": 32,
3
+ "d_mlp": 64,
4
+ "n_heads": 4,
5
+ "d_head": 8,
6
+ "n_layers": 2,
7
+ "mlp_type": "relu",
8
+ "d_vocab": 13,
9
+ "n_ctx": 16,
10
+ "bias": false,
11
+ "norm": false,
12
+ "tie_unembed": false,
13
+ "model_seed": 2,
14
+ "data_config": {
15
+ "n_train": 5000000,
16
+ "n_val": 10000,
17
+ "n_test": 10000,
18
+ "seed": 1234,
19
+ "balanced_ops": true
20
+ },
21
+ "vocab": {
22
+ "plus": 10,
23
+ "minus": 11,
24
+ "equals": 12,
25
+ "n_operand_digits": 4,
26
+ "n_answer_digits": 5
27
+ },
28
+ "train_config": {
29
+ "lr": 0.02,
30
+ "betas": [
31
+ 0.9,
32
+ 0.98
33
+ ],
34
+ "weight_decay": 0.01,
35
+ "batch_size": 1024,
36
+ "warmup_steps": 200,
37
+ "lr_schedule": "cosine",
38
+ "lr_min_frac": 0.1,
39
+ "eval_every_steps": 200,
40
+ "seed": 2,
41
+ "max_steps": null,
42
+ "grad_clip": 1.0
43
+ },
44
+ "planned_repo_id": "itzPotato/arithmetic-relu-2layer-seed2"
45
+ }
history.json ADDED
@@ -0,0 +1,213 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "steps": [
3
+ 200,
4
+ 400,
5
+ 600,
6
+ 800,
7
+ 1000,
8
+ 1200,
9
+ 1400,
10
+ 1600,
11
+ 1800,
12
+ 2000,
13
+ 2200,
14
+ 2400,
15
+ 2600,
16
+ 2800,
17
+ 3000,
18
+ 3200,
19
+ 3400,
20
+ 3600,
21
+ 3800,
22
+ 4000,
23
+ 4200,
24
+ 4400,
25
+ 4600,
26
+ 4800,
27
+ 4883
28
+ ],
29
+ "train_loss": [
30
+ 1.5722284317016602,
31
+ 0.628692090511322,
32
+ 0.32719022035598755,
33
+ 0.12961021065711975,
34
+ 0.20075900852680206,
35
+ 0.06205069273710251,
36
+ 0.04518857225775719,
37
+ 0.02749330922961235,
38
+ 0.04564381390810013,
39
+ 0.04888881370425224,
40
+ 0.03712354227900505,
41
+ 0.029449349269270897,
42
+ 0.02453625202178955,
43
+ 0.015443632379174232,
44
+ 0.01518481969833374,
45
+ 0.014887431636452675,
46
+ 0.015574837103486061,
47
+ 0.008070074021816254,
48
+ 0.01065557636320591,
49
+ 0.0158293005079031,
50
+ 0.0032624073792248964,
51
+ 0.0007429839461110532,
52
+ 0.0011565109016373754,
53
+ 0.006390308029949665,
54
+ 0.0003882101736962795
55
+ ],
56
+ "val_loss": [
57
+ 1.60806677734375,
58
+ 0.5938065234375,
59
+ 0.273192080078125,
60
+ 0.11908873046875,
61
+ 0.1072494384765625,
62
+ 0.062252421875,
63
+ 0.05844634765625,
64
+ 0.03443075622558594,
65
+ 0.0377742578125,
66
+ 0.05226347839355469,
67
+ 0.03548737426757813,
68
+ 0.023215485534667967,
69
+ 0.020486417846679688,
70
+ 0.017016024780273437,
71
+ 0.028689197387695313,
72
+ 0.012433219299316406,
73
+ 0.014155939636230469,
74
+ 0.009152752685546875,
75
+ 0.007206977081298828,
76
+ 0.008440182037353515,
77
+ 0.0041812696838378904,
78
+ 0.0034816056442260744,
79
+ 0.0021877392196655273,
80
+ 0.0014594219970703124,
81
+ 0.0009101939392089844
82
+ ],
83
+ "val_digit_acc": [
84
+ 0.36168,
85
+ 0.72716,
86
+ 0.88346,
87
+ 0.95826,
88
+ 0.96028,
89
+ 0.98076,
90
+ 0.98198,
91
+ 0.9901,
92
+ 0.98874,
93
+ 0.983,
94
+ 0.99032,
95
+ 0.99304,
96
+ 0.9937,
97
+ 0.9943,
98
+ 0.99078,
99
+ 0.99614,
100
+ 0.99578,
101
+ 0.997,
102
+ 0.9979,
103
+ 0.99746,
104
+ 0.9985,
105
+ 0.9991,
106
+ 0.9993,
107
+ 0.99956,
108
+ 0.99966
109
+ ],
110
+ "val_seq_acc": [
111
+ 0.0005,
112
+ 0.224,
113
+ 0.5383,
114
+ 0.8081,
115
+ 0.8187,
116
+ 0.9079,
117
+ 0.9178,
118
+ 0.9529,
119
+ 0.9462,
120
+ 0.9183,
121
+ 0.9541,
122
+ 0.9661,
123
+ 0.9695,
124
+ 0.9721,
125
+ 0.9549,
126
+ 0.9812,
127
+ 0.9799,
128
+ 0.9854,
129
+ 0.9903,
130
+ 0.9876,
131
+ 0.9929,
132
+ 0.9956,
133
+ 0.9965,
134
+ 0.9978,
135
+ 0.9983
136
+ ],
137
+ "val_sign_acc": [
138
+ 0.0,
139
+ 0.0,
140
+ 0.0,
141
+ 0.0,
142
+ 0.0,
143
+ 0.0,
144
+ 0.0,
145
+ 0.0,
146
+ 0.0,
147
+ 0.0,
148
+ 0.0,
149
+ 0.0,
150
+ 0.0,
151
+ 0.0,
152
+ 0.0,
153
+ 0.0,
154
+ 0.0,
155
+ 0.0,
156
+ 0.0,
157
+ 0.0,
158
+ 0.0,
159
+ 0.0,
160
+ 0.0,
161
+ 0.0,
162
+ 0.0
163
+ ],
164
+ "lr": [
165
+ 0.02,
166
+ 0.019919114190346594,
167
+ 0.01967791065343155,
168
+ 0.019280724932227013,
169
+ 0.018734696290875732,
170
+ 0.018049639389099856,
171
+ 0.017237867867379117,
172
+ 0.016313973013888615,
173
+ 0.015294561491574842,
174
+ 0.014197956839627206,
175
+ 0.013043870114744036,
176
+ 0.011853045592292541,
177
+ 0.010646887895751307,
178
+ 0.009447077256643526,
179
+ 0.00827517982051921,
180
+ 0.007152260003589835,
181
+ 0.006098501867759447,
182
+ 0.0051328463196937115,
183
+ 0.004272650655137428,
184
+ 0.00353337656804348,
185
+ 0.0029283122324319567,
186
+ 0.002468333452453597,
187
+ 0.002161708173895497,
188
+ 0.0020139478709612964,
189
+ 0.002
190
+ ],
191
+ "best_step": 4883,
192
+ "best_val_seq_acc": 0.9983,
193
+ "best_val_loss": 0.0009101939392089844,
194
+ "final": {
195
+ "loss": 0.0009101939392089844,
196
+ "digit_acc": 0.99966,
197
+ "seq_acc": 0.9983,
198
+ "sign_acc": 0.0,
199
+ "n": 10000
200
+ },
201
+ "total_steps": 4883,
202
+ "wall_clock_s": 258.4060242176056,
203
+ "metadata": {
204
+ "seed": 2,
205
+ "git_commit": "b757908e274621a108b0af21e5348ffba407a074-dirty",
206
+ "torch_version": "2.13.0+cu130",
207
+ "numpy_version": "2.4.6",
208
+ "python_version": "3.11.15",
209
+ "platform": "Linux-6.18.44-fc-v22-x86_64-with-glibc2.39",
210
+ "device": "cpu",
211
+ "wandb_mode": "disabled"
212
+ }
213
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:726a01d75e2dde1088d4cee0c8127c4c233071e104b274d001bd8d6670a28e34
3
+ size 72096