cybertronak commited on
Commit
fd99bf9
·
verified ·
1 Parent(s): 43a5d5f

gradient attribution layer scores + arms

Browse files
code/ck_diag.py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+
2
+ import inspect, pathlib, circuitkit as ck
3
+ root = pathlib.Path(ck.__file__).parent
4
+ print("files mentioning chat_template:", [str(p.relative_to(root)) for p in root.rglob("*.py") if "chat_template" in p.read_text(errors="ignore")][:8])
5
+ try:
6
+ t = ck.get_task("multilingual_refusal"); print("task object:", type(t), "| file:", inspect.getsourcefile(type(t)))
7
+ print(inspect.getsource(type(t))[:2500])
8
+ except Exception as e: print("task inspect failed:", repr(e)[:200])
code/ck_discover.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import sys, json, re, gc, math, torch
3
+ import circuitkit as ck
4
+ cfg = json.loads(sys.argv[1]); out = sys.argv[2]
5
+ print("visible gpus:", torch.cuda.device_count(), "| config:", cfg, flush=True)
6
+ model = ck.load_model("CohereLabs/tiny-aya-global", dtype="float16", algorithm=cfg["algo"])
7
+ tk = model.tokenizer; MARK = "<|START_OF_TURN_TOKEN|><|USER_TOKEN|>"
8
+ try: # Tiny Aya's default chat template prepends a long system preamble to every prompt; the task would carry it into every position of the attribution buffers
9
+ probe = tk.apply_chat_template([{"role": "user", "content": "XQXQ"}], tokenize=False, add_generation_prompt=True)
10
+ pre, post = probe[probe.rindex(MARK):].split("XQXQ")
11
+ n_before = len(tk(probe, add_special_tokens=False).input_ids)
12
+ tk.chat_template = "{{ bos_token }}" + pre + "{{ messages[-1]['content'] }}" + post
13
+ probe2 = tk.apply_chat_template([{"role": "user", "content": "XQXQ"}], tokenize=False, add_generation_prompt=True)
14
+ print("chat template shortened: overhead tokens", n_before, "->", len(tk(probe2, add_special_tokens=False).input_ids), "| new text:", repr(probe2), flush=True)
15
+ except Exception as e: print("template shortening skipped:", repr(e)[:200], flush=True)
16
+ for p in model.parameters(): p.requires_grad_(False) # no parameter gradients (saves ~6.7 GB of grad buffers)
17
+ def _grad_on(t, hook): # but keep the activation graph alive: embedding output is the graph root
18
+ return t.detach().requires_grad_(True) if (torch.is_floating_point(t) and not t.requires_grad) else t
19
+ model.hook_embed.add_hook(_grad_on, dir="fwd", is_permanent=True)
20
+ try: # TransformerLens keeps W_E and W_U as two copies; Tiny Aya ties them. If identical, share one copy (~1 GB back).
21
+ WE, WU = model.embed.W_E, model.unembed.W_U
22
+ if WE.shape == WU.T.shape and torch.equal(WE.data, WU.data.T):
23
+ model.unembed.W_U = torch.nn.Parameter(WE.data.T, requires_grad=False); print("tied W_U to W_E (identical weights), freed", round(WE.numel() * 2 / 1e9, 2), "GB", flush=True)
24
+ else: print("W_U differs from W_E.T, left untouched", flush=True)
25
+ except Exception as e: print("tie skipped:", repr(e)[:200], flush=True)
26
+ gc.collect(); torch.cuda.empty_cache()
27
+ print("GPU memory after load: allocated GB", round(torch.cuda.memory_allocated() / 1e9, 2), flush=True)
28
+ try: torch.cuda.memory._record_memory_history(max_entries=200000)
29
+ except Exception as e: print("memory history unavailable:", repr(e)[:100], flush=True)
30
+ def _who_holds(): # on failure: biggest live allocations grouped by the code that made them
31
+ try:
32
+ agg = {}
33
+ for seg in torch.cuda.memory._snapshot()["segments"]:
34
+ for b in seg["blocks"]:
35
+ if b["state"] != "active_allocated": continue
36
+ fr = [f for f in b.get("frames", []) if "site-packages/torch/" not in f["filename"]][:3] or b.get("frames", [])[:2]
37
+ k = " <- ".join(f"{f['filename'].split('site-packages/')[-1]}:{f['line']}" for f in fr) or "unknown"
38
+ agg[k] = agg.get(k, 0) + b["size"]
39
+ for k, v in sorted(agg.items(), key=lambda kv: -kv[1])[:8]: print("TOPALLOC", round(v / 1e9, 2), "GB", k, flush=True)
40
+ except Exception as e: print("TOPALLOC snapshot failed:", repr(e)[:150], flush=True)
41
+ try:
42
+ circuit = ck.discover(model, "multilingual_refusal", algorithm=cfg["algo"], n_examples=cfg["n"], batch_size=1, sparsity=0.3, scope=cfg["scope"], output_path=out + "/circuit.pt", **cfg.get("extra", {}))
43
+ except Exception:
44
+ _who_holds(); raise
45
+ names = list(circuit.scores.keys()); print("sample node names:", names[:8], "| n nodes:", len(names), flush=True)
46
+ layers = {}; bad = 0
47
+ for name, s in circuit.scores.items():
48
+ low = str(name).lower(); nums = re.findall(r"\d+", str(name)); v = float(s)
49
+ if not nums or not math.isfinite(v): bad += (not math.isfinite(v)); continue
50
+ kind = "mlp" if ("mlp" in low or re.match(r"m[\s_.]?\d", low)) else ("attn" if (low.startswith("a") or "attn" in low or "head" in low) else None)
51
+ if kind is None or int(nums[0]) > 200: continue
52
+ d = layers.setdefault(int(nums[0]), {"attn": 0.0, "mlp": 0.0}); d[kind] += abs(v)
53
+ assert layers and sum(d["attn"] + d["mlp"] for d in layers.values()) > 0, f"no usable layer scores (non-finite scores: {bad}); see 'sample node names' above"
54
+ json.dump({"algo": cfg["algo"], "scope": cfg["scope"], "n_examples": cfg["n"], "layers": layers, "n_nodes": len(names), "nonfinite": bad}, open(out + "/ck_layer_scores.json", "w"))
55
+ print("layers scored:", len(layers), "| nodes:", len(names), "| non-finite:", bad)
code/w_attr.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import sys, json, time
3
+ from lab_common import *
4
+ shard, nsh = int(sys.argv[1]), int(sys.argv[2]); groups = json.load(open(ROOT / "scores" / "patch_groups.json"))[shard::nsh]
5
+ m = load_fp16(); L = len(m.model.layers); REF_T, COMP_T = load_ref(); BS, SC = 4, 256.0
6
+ gap = lambda lg, lang: torch.logsumexp(lg[:, REF_T[lang]], -1) - torch.logsumexp(lg[:, COMP_T[lang]], -1)
7
+ CAP = {"on": False, "attn": {}, "mlp": {}}
8
+ m.model.embed_tokens.register_forward_hook(lambda mod, inp, out: out.detach().requires_grad_(True) if CAP["on"] else out) # params are frozen, so make the embedding output the root of the graph
9
+ def hook(kind, l):
10
+ def f(mod, inp, out):
11
+ if not CAP["on"]: return
12
+ o = out[0] if isinstance(out, tuple) else out
13
+ if o.requires_grad: o.retain_grad()
14
+ CAP[kind][l] = o
15
+ return f
16
+ for l, layer in enumerate(m.model.layers): layer.self_attn.register_forward_hook(hook("attn", l)); layer.mlp.register_forward_hook(hook("mlp", l))
17
+ def run(ids, lang):
18
+ CAP.update(on=True, attn={}, mlp={})
19
+ with torch.enable_grad():
20
+ lg = m(input_ids=ids, logits_to_keep=1).logits[:, -1].float(); g = gap(lg, lang); (g.sum() * SC).backward()
21
+ out = {k: {l: (v.detach(), (v.grad / SC) if v.grad is not None else None) for l, v in CAP[k].items()} for k in ("attn", "mlp")}
22
+ CAP.update(on=False, attn={}, mlp={}); m.zero_grad(set_to_none=True); return g.detach(), out
23
+ acc = defaultdict(lambda: [0.0, 0.0]); den_sum = defaultdict(float); nvalid = defaultdict(int); nonfinite = 0; t0 = time.time(); nb = 0; tot = sum((len(g["pairs"]) + BS - 1) // BS for g in groups)
24
+ for g in groups:
25
+ lang, ps = g["lang"], g["pairs"]
26
+ for i in range(0, len(ps), BS):
27
+ b = ps[i:i + BS]; H = torch.tensor([p["h"] for p in b], device=dev); Bn = torch.tensor([p["b"] for p in b], device=dev)
28
+ gh, oh = run(H, lang); gb, ob = run(Bn, lang); den = gh - gb; ok = (den >= 2.0) & torch.isfinite(den); nb += 1
29
+ if ok.any():
30
+ den_sum[lang] += float(den[ok].sum()); nvalid[lang] += int(ok.sum())
31
+ for kind in ("attn", "mlp"):
32
+ for l in range(L):
33
+ ah, grh = oh[kind][l]; ab, grb = ob[kind][l]
34
+ if grh is None or grb is None: nonfinite += 1; continue
35
+ d_est = ((ab - ah).float() * grh.float()).sum((1, 2)) # predicted change of the harmful-run gap if this output is replaced by the benign one
36
+ n_est = ((ah - ab).float() * grb.float()).sum((1, 2)) # predicted change of the benign-run gap if replaced by the harmful one
37
+ bad = ~(torch.isfinite(d_est) & torch.isfinite(n_est)); nonfinite += int((bad & ok).sum()); keep = ok & ~bad
38
+ k = f"{lang}|{kind}|{l}"; acc[k][0] += float((-d_est * keep).sum()); acc[k][1] += float((n_est * keep).sum()) # denoise score = -d_est/den, noise score = n_est/den (same convention as Cell 5)
39
+ print(f"batch {nb}/{tot} | {time.time() - t0:.0f}s", flush=True)
40
+ json.dump({"acc": dict(acc), "den": dict(den_sum), "nvalid": dict(nvalid), "nonfinite": nonfinite}, open(ROOT / "scores" / f"attr_part{shard}.json", "w"))
scores/arms.json CHANGED
@@ -203,6 +203,30 @@
203
  ],
204
  16,
205
  4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
206
  ]
207
  ],
208
  "sets": {
@@ -240,6 +264,13 @@
240
  31,
241
  33,
242
  34
 
 
 
 
 
 
 
243
  ]
244
  },
245
  "random_sets": [
 
203
  ],
204
  16,
205
  4
206
+ ],
207
+ [
208
+ "S_G_gradattr_FP16_W4",
209
+ [
210
+ 17,
211
+ 19,
212
+ 22,
213
+ 27,
214
+ 29
215
+ ],
216
+ 16,
217
+ 4
218
+ ],
219
+ [
220
+ "S_G_gradattr_W8_W4",
221
+ [
222
+ 17,
223
+ 19,
224
+ 22,
225
+ 27,
226
+ 29
227
+ ],
228
+ 8,
229
+ 4
230
  ]
231
  ],
232
  "sets": {
 
264
  31,
265
  33,
266
  34
267
+ ],
268
+ "G_gradattr": [
269
+ 17,
270
+ 19,
271
+ 22,
272
+ 27,
273
+ 29
274
  ]
275
  },
276
  "random_sets": [
scores/attr_part0.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"acc": {"hi|attn|0": [-5.888759970664978, 12.016094259917736], "hi|attn|1": [-2.1554155722260475, 3.847527526319027], "hi|attn|2": [-7.849340975284576, 8.554765194654465], "hi|attn|3": [-1.7349631786346436, -0.555500254034996], "hi|attn|4": [-14.746372073888779, 15.59770154953003], "hi|attn|5": [1.8500772640109062, -2.6892480701208115], "hi|attn|6": [-3.636364061385393, -6.828571289777756], "hi|attn|7": [4.549724232405424, -3.8949441611766815], "hi|attn|8": [10.37247009202838, 26.50528447329998], "hi|attn|9": [8.385404024273157, -2.721497818827629], "hi|attn|10": [-9.037163987755775, 78.02486096322536], "hi|attn|11": [4.986181303858757, 3.6610726416110992], "hi|attn|12": [11.410553373396397, -31.921279579401016], "hi|attn|13": [0.7698353156447411, 7.04081154614687], "hi|attn|14": [20.81006683409214, 42.47729575634003], "hi|attn|15": [10.378378342837095, -13.81904225051403], "hi|attn|16": [47.285060718655586, 89.44591537863016], "hi|attn|17": [26.97913058847189, 49.18431033194065], "hi|attn|18": [15.606678925454617, 5.442658416926861], "hi|attn|19": [0.26891081780195236, 8.35527828335762], "hi|attn|20": [6.308950886130333, 20.93749925121665], "hi|attn|21": [0.023675136268138885, -16.9899162389338], "hi|attn|22": [-12.033726900815964, 16.077299363911152], "hi|attn|23": [1.5691359490156174, -5.965314246714115], "hi|attn|24": [8.348350990563631, 4.915967680513859], "hi|attn|25": [-4.835324652493, 0.025201957672834396], "hi|attn|26": [0.03324056416749954, 3.214747827500105], "hi|attn|27": [-1.4298210069537163, 5.691966973245144], "hi|attn|28": [0.375357948243618, -6.689065810292959], "hi|attn|29": [3.3268868066370487, 89.1352561712265], "hi|attn|30": [-0.3650135137140751, 3.6112928297370672], "hi|attn|31": [-5.329165733768605, 1.1297544296830893], "hi|attn|32": [9.689089799299836, 22.03810679912567], "hi|attn|33": [5.945028869435191, 7.014975607395172], "hi|attn|34": [2.532123874872923, 13.0365636870265], "hi|attn|35": [2.5453082248568535, 3.9461096338927746], "hi|mlp|0": [4.223760545253754, -1.653530314564705], "hi|mlp|1": [-4.368489935994148, 5.085530020296574], "hi|mlp|2": [-3.193201944231987, 15.008582782000303], "hi|mlp|3": [-2.734387621283531, -10.153674852102995], "hi|mlp|4": [-9.12537381798029, 2.8515551760792732], "hi|mlp|5": [3.168596252799034, 9.622499376535416], "hi|mlp|6": [1.5217269994318485, 3.6830310970544815], "hi|mlp|7": [6.960808202624321, 35.79452487826347], "hi|mlp|8": [-15.181555703282356, -15.395048469305038], "hi|mlp|9": [16.72142133116722, 25.50998406112194], "hi|mlp|10": [-8.971708938479424, -11.611373871564865], "hi|mlp|11": [-8.186561614274979, 6.955997958779335], "hi|mlp|12": [18.210255473852158, 34.310643181204796], "hi|mlp|13": [6.171909101307392, -15.100187987089157], "hi|mlp|14": [-18.995084561407566, -40.174880027770996], "hi|mlp|15": [19.74622006714344, 19.419668525457382], "hi|mlp|16": [-24.16655272245407, -33.259224474430084], "hi|mlp|17": [14.22481718659401, 22.53254160284996], "hi|mlp|18": [39.596576035022736, 60.52941316366196], "hi|mlp|19": [26.536898404359818, 105.42102926969528], "hi|mlp|20": [53.279027700424194, 1.7962614446878433], "hi|mlp|21": [-11.037309676408768, 86.46294005215168], "hi|mlp|22": [7.922252103686333, 123.80139127373695], "hi|mlp|23": [17.06938523799181, 75.23906816542149], "hi|mlp|24": [9.519349038600922, 57.71558412909508], "hi|mlp|25": [-1.6916395127773285, 57.41644290089607], "hi|mlp|26": [6.969479225575924, 59.33183819800615], "hi|mlp|27": [22.23199127614498, 78.28577667474747], "hi|mlp|28": [34.093896213918924, 43.89969910681248], "hi|mlp|29": [-1.4927479922771454, 27.87815237045288], "hi|mlp|30": [-14.596352823078632, -29.828446500003338], "hi|mlp|31": [15.261979334056377, 24.943432115018368], "hi|mlp|32": [18.70204369723797, 17.567384213209152], "hi|mlp|33": [15.986785121262074, 26.06552153080702], "hi|mlp|34": [-47.72295019030571, 35.60460403561592], "hi|mlp|35": [31.2801626175642, -12.021660268306732], "en|attn|0": [4.5185738280415535, -2.9824300706386566], "en|attn|1": [2.8401018492877483, -6.995471507310867], "en|attn|2": [-6.622735947370529, -2.801667384803295], "en|attn|3": [3.3165599051862955, 4.361821785569191], "en|attn|4": [4.544790118932724, 3.331657364964485], "en|attn|5": [-7.349983658641577, -7.0509795024991035], "en|attn|6": [0.1963728666305542, -10.632554303854704], "en|attn|7": [-6.956691112369299, -6.686375338584185], "en|attn|8": [-0.3500531166791916, 3.3519525974988937], "en|attn|9": [3.0915439799427986, 2.458911921828985], "en|attn|10": [-11.763293996453285, -10.875964634120464], "en|attn|11": [10.665400303900242, -9.586532220244408], "en|attn|12": [12.520072184503078, -6.624506244435906], "en|attn|13": [-11.24101646989584, -2.8408234119415283], "en|attn|14": [50.98579062521458, 14.122423473745584], "en|attn|15": [9.925348326563835, -10.878219649195671], "en|attn|16": [52.00918033719063, 36.98295573890209], "en|attn|17": [19.80061937868595, 19.823662631213665], "en|attn|18": [10.074936039745808, 2.313046293333173], "en|attn|19": [2.4371845219284296, 5.626549396663904], "en|attn|20": [3.957289181649685, 5.599835366010666], "en|attn|21": [-1.1002453230321407, -3.213772490620613], "en|attn|22": [14.677371144294739, 6.431480519473553], "en|attn|23": [6.082105934619904, 2.8074618838727474], "en|attn|24": [2.2150088995695114, -0.01450897566974163], "en|attn|25": [1.8055804651230574, 0.7267184602096677], "en|attn|26": [7.7142986580729485, 2.7476182472892106], "en|attn|27": [1.886576883494854, -0.7658612380619161], "en|attn|28": [5.61733715981245, -1.2109585870057344], "en|attn|29": [8.610818196088076, 25.42704522050917], "en|attn|30": [18.19599457271397, 2.6963124684989452], "en|attn|31": [4.728240557014942, 1.418612003326416], "en|attn|32": [12.003245927393436, 21.990494010969996], "en|attn|33": [11.103896886110306, 8.476043581962585], "en|attn|34": [1.7227264922112226, 5.293952784501016], "en|attn|35": [-1.9156774338334799, -2.0481990538537502], "en|mlp|0": [9.804464608430862, 21.351499766111374], "en|mlp|1": [2.156081773340702, 2.594684213399887], "en|mlp|2": [-0.8773496970534325, -9.450066652148962], "en|mlp|3": [-4.574442088603973, 1.8493786975741386], "en|mlp|4": [1.994899943470955, -0.9445455819368362], "en|mlp|5": [4.745202988386154, -10.222723845392466], "en|mlp|6": [2.971816387027502, -3.6000778824090958], "en|mlp|7": [14.8117850497365, -10.579112008213997], "en|mlp|8": [-12.419558957219124, -5.497956827282906], "en|mlp|9": [11.407359555363655, -16.94715677201748], "en|mlp|10": [18.03018018603325, -9.504936262965202], "en|mlp|11": [-1.850457064807415, -6.025816522538662], "en|mlp|12": [-2.175429418683052, -13.690460540354252], "en|mlp|13": [4.05741274356842, 9.52589313685894], "en|mlp|14": [-33.02806447446346, -24.867582872509956], "en|mlp|15": [20.506730303168297, -1.0185256823897362], "en|mlp|16": [-25.187319666147232, -37.02333743870258], "en|mlp|17": [25.15655057504773, 12.450096316635609], "en|mlp|18": [27.24354499578476, 16.047737315297127], "en|mlp|19": [29.693078935146332, 52.66054359078407], "en|mlp|20": [3.010521426796913, 4.22174983471632], "en|mlp|21": [13.862995155155659, 21.549510665237904], "en|mlp|22": [63.75752158463001, 63.989457592368126], "en|mlp|23": [32.07215964794159, 20.1532349511981], "en|mlp|24": [40.167621314525604, 32.80211502313614], "en|mlp|25": [18.454588294029236, 20.066643983125687], "en|mlp|26": [54.878598153591156, 34.27820475399494], "en|mlp|27": [57.10836968570948, 39.521581932902336], "en|mlp|28": [37.04298397898674, 21.708730421960354], "en|mlp|29": [22.521710596978664, 14.435716141015291], "en|mlp|30": [-3.8024173378944397, 1.910230852663517], "en|mlp|31": [2.4580211117863655, -3.7915471345186234], "en|mlp|32": [11.502873752266169, 12.110261298716068], "en|mlp|33": [10.967954654246569, 18.176640901714563], "en|mlp|34": [10.543002534657717, 24.047680588439107], "en|mlp|35": [-116.26647752523422, -91.38734060525894]}, "den": {"hi": 345.90759563446045, "en": 309.51403045654297}, "nvalid": {"hi": 46, "en": 35}, "nonfinite": 0}
scores/attr_part1.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"acc": {"en|attn|0": [1.6062216013669968, -0.6551710590720177], "en|attn|1": [-1.5953130349516869, -2.765104867517948], "en|attn|2": [-9.448351254686713, -1.8845122903585434], "en|attn|3": [3.5005095824599266, 1.7163686081767082], "en|attn|4": [-17.629097759723663, 1.1379961855709553], "en|attn|5": [-4.671257831156254, 6.106395810842514], "en|attn|6": [3.115094870328903, -11.703612387180328], "en|attn|7": [-3.6610862277448177, -2.104005254805088], "en|attn|8": [-4.680707931518555, 11.802940711379051], "en|attn|9": [1.0325456149876118, 4.954250566661358], "en|attn|10": [-23.349625565111637, 10.921386808156967], "en|attn|11": [6.381922423839569, -21.249155335128307], "en|attn|12": [14.34157483279705, -30.852284252643585], "en|attn|13": [9.085815846920013, -8.468730226159096], "en|attn|14": [58.9477077126503, 27.795680288225412], "en|attn|15": [6.197632163763046, -12.816091697663069], "en|attn|16": [54.00379651784897, 54.08400559425354], "en|attn|17": [23.97376063466072, 39.36236645281315], "en|attn|18": [18.1804136633873, 11.763615608215332], "en|attn|19": [7.591793961822987, 7.443112231791019], "en|attn|20": [8.167919836938381, 15.959877755492926], "en|attn|21": [2.5803026109933853, 0.38933756202459335], "en|attn|22": [20.111624531447887, 6.438972674310207], "en|attn|23": [6.2301483657211065, 5.398499120026827], "en|attn|24": [5.332316767424345, 3.06475942209363], "en|attn|25": [2.834517154842615, 5.404318526387215], "en|attn|26": [11.564942307770252, 4.829520646482706], "en|attn|27": [2.4483730318024755, 4.080816735513508], "en|attn|28": [-2.026276670396328, -1.1349496189504862], "en|attn|29": [9.249242439400405, 47.9585822597146], "en|attn|30": [21.29409484937787, 5.607035432010889], "en|attn|31": [-0.7133255697553977, -0.5210709357634187], "en|attn|32": [12.381354119628668, 27.762974102050066], "en|attn|33": [7.816932633519173, 10.19593896344304], "en|attn|34": [1.2494966555386782, 9.020982338115573], "en|attn|35": [-4.6637475760653615, -4.385962816886604], "en|mlp|0": [0.4240945428609848, 21.342632979154587], "en|mlp|1": [-0.6564072817564011, -2.090123377740383], "en|mlp|2": [3.381009414792061, 5.87293666601181], "en|mlp|3": [-3.531512163579464, -3.118429910391569], "en|mlp|4": [3.4746692404150963, 1.6797986179590225], "en|mlp|5": [-1.3224831819534302, -12.240774676203728], "en|mlp|6": [-4.7861277759075165, -5.219223827123642], "en|mlp|7": [-6.894214972853661, -13.579717140644789], "en|mlp|8": [-8.782341413199902, -7.666182428598404], "en|mlp|9": [3.971749857068062, 15.838066190481186], "en|mlp|10": [25.24323071539402, -0.8948803395032883], "en|mlp|11": [2.4004066586494446, -38.86937512457371], "en|mlp|12": [-4.793412581086159, -19.40378627181053], "en|mlp|13": [3.630003906786442, 17.69179081916809], "en|mlp|14": [-32.53354462981224, -15.119088381528854], "en|mlp|15": [25.50482042133808, 37.07616725564003], "en|mlp|16": [-19.6755108833313, -43.008420675992966], "en|mlp|17": [22.775017715990543, 17.636898461729288], "en|mlp|18": [28.920188054442406, 24.576463788747787], "en|mlp|19": [34.15008630603552, 72.95891961455345], "en|mlp|20": [20.280153945088387, 16.038343150168657], "en|mlp|21": [-0.820753775537014, 37.15801854431629], "en|mlp|22": [88.06939725577831, 93.26214826107025], "en|mlp|23": [51.657851457595825, 38.812514275312424], "en|mlp|24": [38.99294210970402, 32.84221130609512], "en|mlp|25": [10.092905342578888, 20.70772612094879], "en|mlp|26": [57.42493414878845, 44.91000194847584], "en|mlp|27": [71.02756313234568, 59.051215291023254], "en|mlp|28": [48.743219405412674, 32.97142085433006], "en|mlp|29": [26.06965147703886, 18.121215671300888], "en|mlp|30": [-14.451089210808277, -5.355938412249088], "en|mlp|31": [5.915422290563583, -2.5710690394043922], "en|mlp|32": [13.542061364278197, 14.045977421104908], "en|mlp|33": [5.239132344722748, 40.580731585621834], "en|mlp|34": [3.647107183933258, 34.21062245965004], "en|mlp|35": [-173.37950906157494, -117.69877600669861], "hi|attn|0": [-5.808067448437214, -1.5916451811790466], "hi|attn|1": [-7.277379646897316, -4.149621561169624], "hi|attn|2": [0.7007234841585159, -1.2516465336084366], "hi|attn|3": [-5.874295819550753, 4.011258952319622], "hi|attn|4": [-11.45068646967411, 4.432619422674179], "hi|attn|5": [2.892414003610611, -10.097328409552574], "hi|attn|6": [-1.0248220711946487, -22.42382237315178], "hi|attn|7": [-0.282178508117795, -7.800659917294979], "hi|attn|8": [1.5036444514989853, -2.7147341072559357], "hi|attn|9": [-3.546915642917156, -2.6966714933514595], "hi|attn|10": [-22.189012840390205, 16.052214086055756], "hi|attn|11": [-10.210364781320095, 3.1467778608202934], "hi|attn|12": [6.271718770265579, -18.290082573890686], "hi|attn|13": [-8.274970419704914, -3.614957347512245], "hi|attn|14": [17.373829543590546, 24.927933916449547], "hi|attn|15": [2.2574440464377403, -6.272593803703785], "hi|attn|16": [24.08352565765381, 43.4548482298851], "hi|attn|17": [5.165761172771454, 30.33346350491047], "hi|attn|18": [6.169866409152746, 3.417096272110939], "hi|attn|19": [1.6046586446464062, 8.1927020996809], "hi|attn|20": [2.774340007454157, 4.760919094085693], "hi|attn|21": [2.2286947295069695, -12.822448171675205], "hi|attn|22": [-3.614727646112442, 10.281980603933334], "hi|attn|23": [3.1199793461710215, 0.9997347518801689], "hi|attn|24": [4.915800411254168, 2.7142996564507484], "hi|attn|25": [-3.6566303465515375, -5.749489724636078], "hi|attn|26": [0.09585711546242237, 3.4483153223991394], "hi|attn|27": [0.8344123251736164, 2.495465198531747], "hi|attn|28": [-4.240188270807266, -3.441596496850252], "hi|attn|29": [4.669077664613724, 45.914082795381546], "hi|attn|30": [2.4629308842122555, 2.28316330909729], "hi|attn|31": [-1.727017067372799, 3.0692112296819687], "hi|attn|32": [6.628581248223782, 11.929021567106247], "hi|attn|33": [3.767534114420414, 4.662008926272392], "hi|attn|34": [0.8347376007586718, 6.027791693806648], "hi|attn|35": [2.4460567981004715, 4.339560430496931], "hi|mlp|0": [6.928284838795662, -8.4894660115242], "hi|mlp|1": [5.697053954005241, 2.3763839676976204], "hi|mlp|2": [-16.121840573847294, 11.216529428958893], "hi|mlp|3": [-7.1733690202236176, -3.8514419496059418], "hi|mlp|4": [1.937892872840166, -4.712865471839905], "hi|mlp|5": [-0.5466014295816422, 5.368068873882294], "hi|mlp|6": [-5.178258527070284, 5.608849674463272], "hi|mlp|7": [-3.892700120806694, 4.548625662922859], "hi|mlp|8": [-9.825796909630299, 17.68418598175049], "hi|mlp|9": [-7.61312834918499, -2.0983238220214844], "hi|mlp|10": [-14.203799605369568, 8.278584569692612], "hi|mlp|11": [4.398025378584862, 4.929410427808762], "hi|mlp|12": [6.462236054241657, 7.318319275975227], "hi|mlp|13": [3.9882357120513916, 6.3062156438827515], "hi|mlp|14": [-24.404238305985928, -22.56959158182144], "hi|mlp|15": [4.517887718975544, 9.405981063842773], "hi|mlp|16": [-7.1379373371601105, -14.780316978693008], "hi|mlp|17": [5.937967419624329, -0.39897653460502625], "hi|mlp|18": [14.285053476691246, 26.793286308646202], "hi|mlp|19": [21.46745267510414, 65.0707773566246], "hi|mlp|20": [18.231715574860573, -10.327462807297707], "hi|mlp|21": [-8.543439447879791, 51.6644047498703], "hi|mlp|22": [7.02204692363739, 77.66944643855095], "hi|mlp|23": [7.421805411577225, 28.04675130546093], "hi|mlp|24": [-0.10910844057798386, 23.88830317556858], "hi|mlp|25": [-1.4725980460643768, 24.087146386504173], "hi|mlp|26": [7.588218420743942, 21.31541658937931], "hi|mlp|27": [14.998698964715004, 35.988309025764465], "hi|mlp|28": [24.869547218084335, 20.893500864505768], "hi|mlp|29": [1.7623078227043152, 15.16930489987135], "hi|mlp|30": [-7.381012722849846, -14.74677774310112], "hi|mlp|31": [6.692464351654053, 13.19746407866478], "hi|mlp|32": [6.175895661115646, 9.47001976519823], "hi|mlp|33": [11.77458630502224, 15.052979566156864], "hi|mlp|34": [-23.237008810043335, 19.56792962551117], "hi|mlp|35": [30.036182701587677, -2.74345001578331]}, "den": {"en": 422.66267108917236, "hi": 209.54637956619263}, "nvalid": {"en": 44, "hi": 29}, "nonfinite": 0}
scores/gradattr_layer_scores.csv ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ layer,ga_attn,ga_mlp,ga_block
2
+ 0,0.0002765716370237086,0.01852448287450726,0.018801054511530968
3
+ 1,-0.007289196784425876,0.004640779920136066,-0.0026484168642898105
4
+ 2,-0.0070179813539739695,0.0027435661471354273,-0.004274415206838542
5
+ 3,0.0025336389860013122,-0.013963834366456783,-0.01143019538045547
6
+ 4,-0.005716992628069155,-0.0019540788839675118,-0.007671071512036666
7
+ 5,-0.008047650622838904,0.0014256740323203548,-0.006621976590518549
8
+ 6,-0.02175984021333673,-0.001094451076713208,-0.022854291290049938
9
+ 7,-0.009970107095183835,0.013993099485939312,0.004022992390755476
10
+ 8,0.01950979537565073,-0.021959269200887616,-0.0024494738252368864
11
+ 9,0.0036784632649367317,0.019509119303339165,0.023187582568275897
12
+ 10,0.016314362624929205,-0.0007063046483878135,0.015608057976541391
13
+ 11,-0.003995224012360243,-0.011497319031029237,-0.01549254304338948
14
+ 12,-0.018265283080938822,0.016161663826910776,-0.002103619254028046
15
+ 13,-0.006433520552879247,0.012533153942475889,0.006099633389596642
16
+ 14,0.09937316594977189,-0.08381265288581391,0.015560513063957976
17
+ 15,-0.005940942708658694,0.05191709111159391,0.04597614840293522
18
+ 16,0.15923049582063914,-0.07835630519571837,0.08087419062492077
19
+ 17,0.08541297655593783,0.04567609164833851,0.13108906820427635
20
+ 18,0.028243021294461653,0.09660157926986636,0.12484460056432801
21
+ 19,0.016178189373209376,0.16303281772848904,0.1792110071016984
22
+ 20,0.027156268378153936,0.04321628344137886,0.0703725518195328
23
+ 21,-0.012863300158805699,0.07785451303432109,0.06499121287551539
24
+ 22,0.02109395878542669,0.2029387514040854,0.2240327101895121
25
+ 23,0.0068814643604229574,0.10623329925745192,0.11311476361787488
26
+ 24,0.013022725196596262,0.09040713409690496,0.10342985929350122
27
+ 25,-0.002720700780904115,0.05892894135564705,0.05620824057474294
28
+ 26,0.012227078607450686,0.10823446408228923,0.12046154268973992
29
+ 27,0.006029077435392801,0.1455987760124765,0.1516278534478693
30
+ 28,-0.005873969147265187,0.10366257809375799,0.0977886089464928
31
+ 29,0.0955377824986845,0.047204115158316046,0.14274189765700054
32
+ 30,0.01991618174969222,-0.03736328760483584,-0.017447105855143624
33
+ 31,0.0003913636319914464,0.027734440692720005,0.028125804324711453
34
+ 32,0.04794656564880419,0.040848696377443844,0.08879526202624803
35
+ 33,0.022463033249714454,0.05659804819250974,0.0790610814422242
36
+ 34,0.015998552798456297,0.017631698256557696,0.03363025105501399
37
+ 35,0.001532300017332418,-0.1493390082876782,-0.14780670827034578