Initial upload: MAGIC scores for GPT-2 / wikitext-2 / test[3:4] query
Browse files- README.md +113 -0
- scores.pt +3 -0
- summary.csv +2 -0
- validation.csv +101 -0
README.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
tags:
|
| 6 |
+
- influence-functions
|
| 7 |
+
- attribution
|
| 8 |
+
- magic
|
| 9 |
+
- bergson
|
| 10 |
+
- gpt-2
|
| 11 |
+
- wikitext
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# bergson MAGIC scores — GPT-2 / wikitext-2 / random validation
|
| 15 |
+
|
| 16 |
+
Per-document MAGIC attribution scores for a GPT-2 model fine-tuned on
|
| 17 |
+
`Salesforce/wikitext` `wikitext-2-raw-v1` `train`, attributing the
|
| 18 |
+
training-loss gradient with respect to the model's output on
|
| 19 |
+
`test[3:4]` (a single test example, taken as the query).
|
| 20 |
+
|
| 21 |
+
Scores were produced by the [`bergson`](https://github.com/EleutherAI/bergson)
|
| 22 |
+
attribution toolkit's MAGIC subcommand, which back-propagates through
|
| 23 |
+
the entire training trajectory to compute, for each training doc `d`,
|
| 24 |
+
`∂(L_query)/∂(w_d)` — the first-order Taylor expansion of how much
|
| 25 |
+
removing doc `d` from training would change the query loss.
|
| 26 |
+
|
| 27 |
+
## Files
|
| 28 |
+
|
| 29 |
+
| file | description |
|
| 30 |
+
|---|---|
|
| 31 |
+
| `scores.pt` | torch.float32 tensor, shape `(36718,)`. Indexed by original wikitext-2 train row position (filtered <2-token rows have score 0). |
|
| 32 |
+
| `summary.csv` | Final Spearman/Pearson correlation between MAGIC scores and 100-subset leave-k-out training-loss diffs at validate time. |
|
| 33 |
+
| `validation.csv` | Per-subset (`subset, diff, score_sum`) records from the leave-k-out validation. |
|
| 34 |
+
|
| 35 |
+
## Loading
|
| 36 |
+
|
| 37 |
+
```python
|
| 38 |
+
import torch
|
| 39 |
+
scores = torch.load("scores.pt", map_location="cpu", weights_only=True)
|
| 40 |
+
# scores.shape == (36718,), one entry per original wikitext-2 train row.
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
## Validation result
|
| 44 |
+
|
| 45 |
+
Random-strategy 100-subset leave-k-out validation, batch_size=256,
|
| 46 |
+
num_epochs=2, polynomial LR schedule:
|
| 47 |
+
|
| 48 |
+
| metric | value | p |
|
| 49 |
+
|---|---|---|
|
| 50 |
+
| Spearman ρ | **+0.9731** | 2.71e-64 |
|
| 51 |
+
| Pearson r | **+0.9724** | 1.00e-63 |
|
| 52 |
+
| baseline_loss | 3.6840 | |
|
| 53 |
+
|
| 54 |
+
(Sorted-strategy validation against the same scores reaches ρ = +0.9926
|
| 55 |
+
on the same 100 subsets.)
|
| 56 |
+
|
| 57 |
+
## YAML used to generate these scores
|
| 58 |
+
|
| 59 |
+
```yaml
|
| 60 |
+
- magic:
|
| 61 |
+
run_path: runs/compare/q3_random
|
| 62 |
+
model: gpt2
|
| 63 |
+
overwrite: true
|
| 64 |
+
|
| 65 |
+
data:
|
| 66 |
+
dataset: Salesforce/wikitext
|
| 67 |
+
subset: wikitext-2-raw-v1
|
| 68 |
+
split: "train"
|
| 69 |
+
chunk_length: 512
|
| 70 |
+
|
| 71 |
+
query:
|
| 72 |
+
dataset: Salesforce/wikitext
|
| 73 |
+
subset: wikitext-2-raw-v1
|
| 74 |
+
split: "test[3:4]"
|
| 75 |
+
chunk_length: 0
|
| 76 |
+
|
| 77 |
+
distributed:
|
| 78 |
+
nproc_per_node: 4
|
| 79 |
+
nnode: 4
|
| 80 |
+
|
| 81 |
+
batch_size: 256
|
| 82 |
+
num_epochs: 2
|
| 83 |
+
lr_schedule:
|
| 84 |
+
lr_scheduler_type: polynomial
|
| 85 |
+
lr: 0.0008
|
| 86 |
+
lr_start: 1e-6
|
| 87 |
+
lr_end: 0.00008
|
| 88 |
+
warmup_steps: 0.25
|
| 89 |
+
|
| 90 |
+
subset_strategy: random
|
| 91 |
+
wandb_project: magic
|
| 92 |
+
```
|
| 93 |
+
|
| 94 |
+
Saved as `examples/magic/compare/q3_magic.yaml` in the bergson repo
|
| 95 |
+
(the consolidated pipeline that produces both random and sorted
|
| 96 |
+
validates from a single MAGIC backward pass).
|
| 97 |
+
|
| 98 |
+
Run with:
|
| 99 |
+
|
| 100 |
+
```bash
|
| 101 |
+
bergson pipeline examples/magic/compare/q3_magic.yaml
|
| 102 |
+
```
|
| 103 |
+
|
| 104 |
+
## Citation
|
| 105 |
+
|
| 106 |
+
```
|
| 107 |
+
@misc{bergson,
|
| 108 |
+
title = {bergson: gradient-based attribution for language models},
|
| 109 |
+
author = {EleutherAI},
|
| 110 |
+
year = {2026},
|
| 111 |
+
url = {https://github.com/EleutherAI/bergson},
|
| 112 |
+
}
|
| 113 |
+
```
|
scores.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b0cd23a1ed53ddc38db3dd474c7be9c9db551df75784cfa976567e61a0552d54
|
| 3 |
+
size 148386
|
summary.csv
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
spearman_corr,spearman_p,pearson_corr,pearson_p,N,baseline_loss
|
| 2 |
+
0.973105310531053,2.7091898753024367e-64,0.9723677280660237,1.0022088934671183e-63,100,3.6840500831604004
|
validation.csv
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
subset,diff,score_sum
|
| 2 |
+
0,-0.0018310546875,-0.029189864173531532
|
| 3 |
+
1,-0.0013134479522705078,-0.022047167643904686
|
| 4 |
+
2,-0.0009467601776123047,-0.01643146015703678
|
| 5 |
+
3,0.0018296241760253906,0.033269889652729034
|
| 6 |
+
4,0.0031800270080566406,0.04270397126674652
|
| 7 |
+
5,-0.0015027523040771484,-0.01642679050564766
|
| 8 |
+
6,0.0008563995361328125,0.00962444394826889
|
| 9 |
+
7,0.0005595684051513672,0.016617674380540848
|
| 10 |
+
8,-0.0004363059997558594,-0.006987039931118488
|
| 11 |
+
9,0.001634836196899414,0.02674231119453907
|
| 12 |
+
10,-3.6716461181640625e-05,-0.0027552940882742405
|
| 13 |
+
11,0.002792835235595703,0.0499853640794754
|
| 14 |
+
12,-3.0994415283203125e-06,0.003259955905377865
|
| 15 |
+
13,0.0001537799835205078,0.005294406320899725
|
| 16 |
+
14,0.0016977787017822266,0.024854004383087158
|
| 17 |
+
15,0.0017843246459960938,0.03346139192581177
|
| 18 |
+
16,0.0012364387512207031,0.021332142874598503
|
| 19 |
+
17,-0.002604246139526367,-0.03763214871287346
|
| 20 |
+
18,-0.001325368881225586,-0.022946178913116455
|
| 21 |
+
19,0.0031244754791259766,0.048977550119161606
|
| 22 |
+
20,0.001478433609008789,0.02487548254430294
|
| 23 |
+
21,-0.0016148090362548828,-0.030084803700447083
|
| 24 |
+
22,-0.0020041465759277344,-0.02288348600268364
|
| 25 |
+
23,-0.0005414485931396484,-0.006325895432382822
|
| 26 |
+
24,-0.0022764205932617188,-0.02015402913093567
|
| 27 |
+
25,-0.00021648406982421875,-0.006860801950097084
|
| 28 |
+
26,0.0009942054748535156,0.011761580593883991
|
| 29 |
+
27,-0.0025680065155029297,-0.04330901801586151
|
| 30 |
+
28,-0.0010652542114257812,-0.020170079544186592
|
| 31 |
+
29,0.0003962516784667969,0.006441427394747734
|
| 32 |
+
30,0.0008099079132080078,0.01868048869073391
|
| 33 |
+
31,-0.0024933815002441406,-0.037735529243946075
|
| 34 |
+
32,-0.00014138221740722656,-0.0009743906557559967
|
| 35 |
+
33,-0.002919435501098633,-0.04292494058609009
|
| 36 |
+
34,0.00034928321838378906,0.005179773084819317
|
| 37 |
+
35,-0.0002903938293457031,0.007907246239483356
|
| 38 |
+
36,0.0010368824005126953,0.019828442484140396
|
| 39 |
+
37,-0.0028319358825683594,-0.025016576051712036
|
| 40 |
+
38,0.0005180835723876953,0.004872254561632872
|
| 41 |
+
39,0.0026693344116210938,0.035355955362319946
|
| 42 |
+
40,-0.0001232624053955078,-0.011232763528823853
|
| 43 |
+
41,0.0009353160858154297,0.025380903854966164
|
| 44 |
+
42,0.002220630645751953,0.032907065004110336
|
| 45 |
+
43,0.0010669231414794922,0.01819712668657303
|
| 46 |
+
44,-0.0002465248107910156,0.0034509990364313126
|
| 47 |
+
45,0.0021257400512695312,0.04210555553436279
|
| 48 |
+
46,-0.002271413803100586,-0.04287688434123993
|
| 49 |
+
47,-0.0014812946319580078,-0.016457801684737206
|
| 50 |
+
48,0.0010526180267333984,0.01314145140349865
|
| 51 |
+
49,0.0016613006591796875,0.030897097662091255
|
| 52 |
+
50,0.0010073184967041016,0.015840895473957062
|
| 53 |
+
51,0.00032019615173339844,0.006934883072972298
|
| 54 |
+
52,-0.0007016658782958984,-0.012217387557029724
|
| 55 |
+
53,-0.0004940032958984375,-0.007514691445976496
|
| 56 |
+
54,0.0003879070281982422,0.010312681086361408
|
| 57 |
+
55,0.001552581787109375,0.02759663015604019
|
| 58 |
+
56,0.0004470348358154297,0.004183738026767969
|
| 59 |
+
57,0.0021224021911621094,0.03304430469870567
|
| 60 |
+
58,-0.0004887580871582031,0.005980587564408779
|
| 61 |
+
59,0.0019378662109375,0.03738723322749138
|
| 62 |
+
60,-0.0011758804321289062,-0.018757693469524384
|
| 63 |
+
61,-0.00015592575073242188,0.004054620862007141
|
| 64 |
+
62,0.0011279582977294922,0.01150202751159668
|
| 65 |
+
63,0.0019664764404296875,0.03209429234266281
|
| 66 |
+
64,0.00013780593872070312,0.010195817798376083
|
| 67 |
+
65,0.001668691635131836,0.02927013300359249
|
| 68 |
+
66,0.0007617473602294922,0.004966499749571085
|
| 69 |
+
67,0.0011334419250488281,0.023897934705018997
|
| 70 |
+
68,-0.0010595321655273438,-0.0056649986654520035
|
| 71 |
+
69,-0.002534627914428711,-0.033193040639162064
|
| 72 |
+
70,0.0011744499206542969,0.02143128588795662
|
| 73 |
+
71,-0.0005335807800292969,-0.0032467744313180447
|
| 74 |
+
72,0.0008752346038818359,0.015030361711978912
|
| 75 |
+
73,-0.0014462471008300781,-0.03063521906733513
|
| 76 |
+
74,-0.00019431114196777344,-0.000977933406829834
|
| 77 |
+
75,-0.0014472007751464844,-0.005219193175435066
|
| 78 |
+
76,-0.002418994903564453,-0.02468314953148365
|
| 79 |
+
77,-0.0003635883331298828,-0.002361757680773735
|
| 80 |
+
78,-0.0039768218994140625,-0.057306695729494095
|
| 81 |
+
79,-0.0016314983367919922,-0.03249344602227211
|
| 82 |
+
80,0.00024127960205078125,0.005457842722535133
|
| 83 |
+
81,0.0016019344329833984,0.022662054747343063
|
| 84 |
+
82,-0.0007393360137939453,-0.012122330255806446
|
| 85 |
+
83,0.0028350353240966797,0.049485936760902405
|
| 86 |
+
84,0.0005719661712646484,-0.0009666034020483494
|
| 87 |
+
85,-0.002422332763671875,-0.03476095199584961
|
| 88 |
+
86,-0.0012798309326171875,-0.014440640807151794
|
| 89 |
+
87,0.00026607513427734375,0.0011126925237476826
|
| 90 |
+
88,0.00023508071899414062,0.004115729592740536
|
| 91 |
+
89,0.0020787715911865234,0.028063565492630005
|
| 92 |
+
90,0.001421213150024414,0.025426872074604034
|
| 93 |
+
91,0.0023102760314941406,0.0365045890212059
|
| 94 |
+
92,-0.0005500316619873047,-0.013258624821901321
|
| 95 |
+
93,0.0008111000061035156,0.016341816633939743
|
| 96 |
+
94,-0.00020933151245117188,-0.002287695650011301
|
| 97 |
+
95,0.0021834373474121094,0.03424829989671707
|
| 98 |
+
96,-1.3589859008789062e-05,0.0005636848509311676
|
| 99 |
+
97,0.0012981891632080078,0.012789108790457249
|
| 100 |
+
98,0.0011246204376220703,0.021215496584773064
|
| 101 |
+
99,0.0002624988555908203,0.005299761425703764
|