Views
No views yet
gpt2_L10_routing_ffn_only.pt — Surgically corrected L10 layer weights (FFN-only retraining). Standard GPT-2 layer format, loadable directly into transformer.h[9].results/gpt2_qkv_full.json — Full QKV decomposition analysis (all layers × all heads)results/gpt2_qkv_xai.json — QKV-based explainability resultsresults/gpt2_surgical_fix.json — Surgical correction evaluation (capitals, general, side effects)results/gpt2_routing_test.json — Knowledge routing pathway tests (Attention/FFN/V-only)results/gpt2_weight_diagnosis.json — Weight-based diagnosis without inputresults/gpt2_separability.json — Layer separability analysis for GPT-2results/qkv_dashboard_data.json — QKV dashboard visualization dataresults/xai_validate.json — XAI validation resultsqkv_dashboard.html — Interactive QKV analysis dashboard. Open in browser, loads results/qkv_dashboard_data.json automatically.figures/fig1_paris_trace.png — Knowledge path: "The capital of France is ___" (Paris vs "the" logit trace)figures/fig2_k_response.png — W_k response by token type (K-norm heatmap)figures/fig3_surgical.png — Before/after surgical editing (2/8 → 8/8)figures/fig4_routing.png — Knowledge routing: all pathways succeed (8/8)figures/fig5_qk_overlap.png — QK overlap analysis (W_q ∩ W_k top-100 dimensions)1import torch
2from transformers import GPT2LMHeadModel, GPT2Tokenizer
3
4model = GPT2LMHeadModel.from_pretrained("gpt2")
5tokenizer = GPT2Tokenizer.from_pretrained("gpt2")
6
7# Replace L10 with corrected weights
8corrected = torch.load("gpt2_L10_routing_ffn_only.pt", map_location="cpu")
9model.transformer.h[9].load_state_dict(corrected)
10model.eval()
11
12# Test
13prompt = "The capital of France is"
14ids = tokenizer.encode(prompt, return_tensors="pt")
15with torch.no_grad():
16 logits = model(ids).logits[0, -1, :]
17print(tokenizer.decode(logits.argmax())) # ParisOriginal GPT-2: 2/8 capitals correct (Italy, Spain only)
After L10 edit: 8/8 capitals correct
General ability: 15/15 unchanged
PPL: 42.7 → 42.6