SamZou commited on
Commit
a544de6
·
verified ·
1 Parent(s): a34ac58

Upload Phase 2 scaling: activations, probing results, figures, code

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. phase2_scaling/activations/llama_3_1_70b/layer_19.npy +3 -0
  2. phase2_scaling/activations/llama_3_1_70b/layer_39.npy +3 -0
  3. phase2_scaling/activations/llama_3_1_70b/layer_59.npy +3 -0
  4. phase2_scaling/activations/llama_3_1_70b/layer_79.npy +3 -0
  5. phase2_scaling/activations/llama_3_1_70b/manifest.json +56 -0
  6. phase2_scaling/activations/llama_3_1_70b/sample_index.parquet +3 -0
  7. phase2_scaling/activations/llama_3_1_8b/layer_15.npy +3 -0
  8. phase2_scaling/activations/llama_3_1_8b/layer_23.npy +3 -0
  9. phase2_scaling/activations/llama_3_1_8b/layer_31.npy +3 -0
  10. phase2_scaling/activations/llama_3_1_8b/layer_7.npy +3 -0
  11. phase2_scaling/activations/llama_3_1_8b/manifest.json +56 -0
  12. phase2_scaling/activations/llama_3_1_8b/sample_index.parquet +3 -0
  13. phase2_scaling/data/processed/dataset_manifest.json +84 -0
  14. phase2_scaling/data/processed/examples.parquet +3 -0
  15. phase2_scaling/data/processed/relations.json +1134 -0
  16. phase2_scaling/data/processed/splits.parquet +3 -0
  17. phase2_scaling/experiment_config.json +19 -0
  18. phase2_scaling/extract_activations.py +314 -0
  19. phase2_scaling/figures/fig1_depth_profile.pdf +0 -0
  20. phase2_scaling/figures/fig1_depth_profile.png +3 -0
  21. phase2_scaling/figures/fig2_generality_gap.pdf +0 -0
  22. phase2_scaling/figures/fig2_generality_gap.png +3 -0
  23. phase2_scaling/figures/fig3_transfer_matrices.pdf +0 -0
  24. phase2_scaling/figures/fig3_transfer_matrices.png +3 -0
  25. phase2_scaling/figures/fig4_relation_gap_detail.pdf +0 -0
  26. phase2_scaling/figures/fig4_relation_gap_detail.png +3 -0
  27. phase2_scaling/figures/fig5_relation_profiles.pdf +0 -0
  28. phase2_scaling/figures/fig5_relation_profiles.png +3 -0
  29. phase2_scaling/generate_figures.py +389 -0
  30. phase2_scaling/generate_splits.py +106 -0
  31. phase2_scaling/ndif_smoke_test.py +77 -0
  32. phase2_scaling/phase2_final_plan.md +419 -0
  33. phase2_scaling/phase2_notes.txt +842 -0
  34. phase2_scaling/prepare_counterfact_multirelation.py +552 -0
  35. phase2_scaling/prepare_counterfact_p103.py +214 -0
  36. phase2_scaling/results/generality_gap.csv +49 -0
  37. phase2_scaling/results/probe_weights/s1a_llama_3_1_70b_L19_P101_f0.npz +3 -0
  38. phase2_scaling/results/probe_weights/s1a_llama_3_1_70b_L19_P101_f0_manifest.json +151 -0
  39. phase2_scaling/results/probe_weights/s1a_llama_3_1_70b_L19_P101_f1.npz +3 -0
  40. phase2_scaling/results/probe_weights/s1a_llama_3_1_70b_L19_P101_f1_manifest.json +153 -0
  41. phase2_scaling/results/probe_weights/s1a_llama_3_1_70b_L19_P101_f2.npz +3 -0
  42. phase2_scaling/results/probe_weights/s1a_llama_3_1_70b_L19_P101_f2_manifest.json +153 -0
  43. phase2_scaling/results/probe_weights/s1a_llama_3_1_70b_L19_P103_f0.npz +3 -0
  44. phase2_scaling/results/probe_weights/s1a_llama_3_1_70b_L19_P103_f0_manifest.json +151 -0
  45. phase2_scaling/results/probe_weights/s1a_llama_3_1_70b_L19_P103_f1.npz +3 -0
  46. phase2_scaling/results/probe_weights/s1a_llama_3_1_70b_L19_P103_f1_manifest.json +153 -0
  47. phase2_scaling/results/probe_weights/s1a_llama_3_1_70b_L19_P103_f2.npz +3 -0
  48. phase2_scaling/results/probe_weights/s1a_llama_3_1_70b_L19_P103_f2_manifest.json +153 -0
  49. phase2_scaling/results/probe_weights/s1a_llama_3_1_70b_L19_P138_f0.npz +3 -0
  50. phase2_scaling/results/probe_weights/s1a_llama_3_1_70b_L19_P138_f0_manifest.json +151 -0
phase2_scaling/activations/llama_3_1_70b/layer_19.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c9b150cb264abb735ed46433463d30c7156ad99f64bd7dbc6f5ccec741eaf482
3
+ size 19660928
phase2_scaling/activations/llama_3_1_70b/layer_39.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:951c53e0fd52a15e78be416ab62dc5a8eee4810df8405c02f7e1f487dd72b04c
3
+ size 19660928
phase2_scaling/activations/llama_3_1_70b/layer_59.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9ce9c3e02366e21415d7afe387b042aa678294a8855ded09d01aef2e70af3f53
3
+ size 19660928
phase2_scaling/activations/llama_3_1_70b/layer_79.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0137324cb4d4fdb8f5eb60e9813c260c2eeb0379dd08a88ca59f996eabed11b2
3
+ size 19660928
phase2_scaling/activations/llama_3_1_70b/manifest.json ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_id": "meta-llama/Llama-3.1-70B",
3
+ "model_key": "llama_3_1_70b",
4
+ "num_layers": 80,
5
+ "hidden_dim": 8192,
6
+ "sentences_processed": 1200,
7
+ "model_init_seconds": 1.53,
8
+ "remote_execution_seconds": 2817.34,
9
+ "total_wall_clock_seconds": 2817.79,
10
+ "seconds_per_sentence": 2.348,
11
+ "target_layers": [
12
+ {
13
+ "depth": 0.25,
14
+ "layer_index": 19
15
+ },
16
+ {
17
+ "depth": 0.5,
18
+ "layer_index": 39
19
+ },
20
+ {
21
+ "depth": 0.75,
22
+ "layer_index": 59
23
+ },
24
+ {
25
+ "depth": 1.0,
26
+ "layer_index": 79
27
+ }
28
+ ],
29
+ "activation_shapes": {
30
+ "19": [
31
+ 1200,
32
+ 8192
33
+ ],
34
+ "39": [
35
+ 1200,
36
+ 8192
37
+ ],
38
+ "59": [
39
+ 1200,
40
+ 8192
41
+ ],
42
+ "79": [
43
+ 1200,
44
+ 8192
45
+ ]
46
+ },
47
+ "activation_dtype": "float16",
48
+ "dataset_hash": "7ef95d79b694631d",
49
+ "token_position_strategy": "last_real_token (= final subtoken of target attribute)",
50
+ "file_sha256": {
51
+ "layer_19.npy": "c9b150cb264abb735ed46433463d30c7156ad99f64bd7dbc6f5ccec741eaf482",
52
+ "layer_39.npy": "951c53e0fd52a15e78be416ab62dc5a8eee4810df8405c02f7e1f487dd72b04c",
53
+ "layer_59.npy": "9ce9c3e02366e21415d7afe387b042aa678294a8855ded09d01aef2e70af3f53",
54
+ "layer_79.npy": "0137324cb4d4fdb8f5eb60e9813c260c2eeb0379dd08a88ca59f996eabed11b2"
55
+ }
56
+ }
phase2_scaling/activations/llama_3_1_70b/sample_index.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dd4d6cd970225a4e27e00e7231058a979a4cffdb4671fc80b66c5e2ef3e5dbe0
3
+ size 35192
phase2_scaling/activations/llama_3_1_8b/layer_15.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e9b228bd68a8810dc4125fdc212f390c665a922ab2af24751d0b2d87ef4da4d0
3
+ size 9830528
phase2_scaling/activations/llama_3_1_8b/layer_23.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c7fbca43028b48b13e221e5460cad6b4c0fccd400835dfb7bdd816d36c7f0a73
3
+ size 9830528
phase2_scaling/activations/llama_3_1_8b/layer_31.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:065bb1e6b2ec547cb3b4ce3c358c0416500d6234a19680b3755afe5923c881d4
3
+ size 9830528
phase2_scaling/activations/llama_3_1_8b/layer_7.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:15cc395553ae9c8e67fe2f8c0d2d7f31558bd3ab55bf902f728f2340797cd825
3
+ size 9830528
phase2_scaling/activations/llama_3_1_8b/manifest.json ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_id": "meta-llama/Llama-3.1-8B",
3
+ "model_key": "llama_3_1_8b",
4
+ "num_layers": 32,
5
+ "hidden_dim": 4096,
6
+ "sentences_processed": 1200,
7
+ "model_init_seconds": 1.45,
8
+ "remote_execution_seconds": 1956.55,
9
+ "total_wall_clock_seconds": 1956.88,
10
+ "seconds_per_sentence": 1.631,
11
+ "target_layers": [
12
+ {
13
+ "depth": 0.25,
14
+ "layer_index": 7
15
+ },
16
+ {
17
+ "depth": 0.5,
18
+ "layer_index": 15
19
+ },
20
+ {
21
+ "depth": 0.75,
22
+ "layer_index": 23
23
+ },
24
+ {
25
+ "depth": 1.0,
26
+ "layer_index": 31
27
+ }
28
+ ],
29
+ "activation_shapes": {
30
+ "7": [
31
+ 1200,
32
+ 4096
33
+ ],
34
+ "15": [
35
+ 1200,
36
+ 4096
37
+ ],
38
+ "23": [
39
+ 1200,
40
+ 4096
41
+ ],
42
+ "31": [
43
+ 1200,
44
+ 4096
45
+ ]
46
+ },
47
+ "activation_dtype": "float16",
48
+ "dataset_hash": "7ef95d79b694631d",
49
+ "token_position_strategy": "last_real_token (= final subtoken of target attribute)",
50
+ "file_sha256": {
51
+ "layer_7.npy": "15cc395553ae9c8e67fe2f8c0d2d7f31558bd3ab55bf902f728f2340797cd825",
52
+ "layer_15.npy": "e9b228bd68a8810dc4125fdc212f390c665a922ab2af24751d0b2d87ef4da4d0",
53
+ "layer_23.npy": "c7fbca43028b48b13e221e5460cad6b4c0fccd400835dfb7bdd816d36c7f0a73",
54
+ "layer_31.npy": "065bb1e6b2ec547cb3b4ce3c358c0416500d6234a19680b3755afe5923c881d4"
55
+ }
56
+ }
phase2_scaling/activations/llama_3_1_8b/sample_index.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dd4d6cd970225a4e27e00e7231058a979a4cffdb4671fc80b66c5e2ef3e5dbe0
3
+ size 35192
phase2_scaling/data/processed/dataset_manifest.json ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "seed": 20260712,
3
+ "relations": [
4
+ "P19",
5
+ "P103",
6
+ "P176",
7
+ "P101",
8
+ "P159",
9
+ "P138"
10
+ ],
11
+ "subset_sizes": {
12
+ "N50": 50,
13
+ "N75": 75,
14
+ "N100": 100
15
+ },
16
+ "p103_french_caps": {
17
+ "N50": 20,
18
+ "N75": 30,
19
+ "N100": 40
20
+ },
21
+ "cleaning_stages": {
22
+ "stage1_raw": {
23
+ "P103": 919,
24
+ "P176": 911,
25
+ "P159": 756,
26
+ "P101": 545,
27
+ "P19": 779,
28
+ "P138": 279
29
+ },
30
+ "stage2_subject_dedup": {
31
+ "P103": 918,
32
+ "P176": 900,
33
+ "P159": 754,
34
+ "P101": 519,
35
+ "P19": 779,
36
+ "P138": 272
37
+ },
38
+ "stage3_cross_relation": {
39
+ "P103": 908,
40
+ "P176": 899,
41
+ "P159": 753,
42
+ "P101": 512,
43
+ "P19": 776,
44
+ "P138": 270
45
+ },
46
+ "stage4_sentence_dedup": {
47
+ "P103": 908,
48
+ "P176": 899,
49
+ "P159": 753,
50
+ "P101": 512,
51
+ "P19": 776,
52
+ "P138": 270
53
+ }
54
+ },
55
+ "cross_relation_subjects": [
56
+ "Armand Trousseau",
57
+ "Claude Bernard",
58
+ "Edward Burnett Tylor",
59
+ "John Calvin",
60
+ "John Dalton",
61
+ "John Stuart Mill",
62
+ "Marie Curie",
63
+ "Michel Brault",
64
+ "PGM-17 Thor",
65
+ "Pierre Braunberger",
66
+ "Sergey Lavrov",
67
+ "Sheffield United F.C."
68
+ ],
69
+ "total_examples": 2700,
70
+ "examples_per_subset": {
71
+ "N50": 600,
72
+ "N75": 900,
73
+ "N100": 1200
74
+ },
75
+ "validation": {
76
+ "all_subset_checks_passed": true,
77
+ "nesting_checks_passed": true,
78
+ "cross_relation_check_passed": true,
79
+ "checks_passed": 18,
80
+ "checks_total": 18
81
+ },
82
+ "raw_data_hash": "d017056125178a13728594e66a801357a8db9ed7973a7425554bb4271de9fc6f",
83
+ "output_hash": "5f526e216cbc5e1db494ca62340ecaad42c4515045ede33ec3658bde958a2d8d"
84
+ }
phase2_scaling/data/processed/examples.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5f526e216cbc5e1db494ca62340ecaad42c4515045ede33ec3658bde958a2d8d
3
+ size 102391
phase2_scaling/data/processed/relations.json ADDED
@@ -0,0 +1,1134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "P19": {
3
+ "relation_id": "P19",
4
+ "relation_name": "place of birth",
5
+ "cleaning_counts": {
6
+ "raw": 779,
7
+ "after_subject_dedup": 779,
8
+ "after_cross_relation_removal": 776,
9
+ "after_sentence_dedup": 776
10
+ },
11
+ "subsets": {
12
+ "N50": {
13
+ "pairs": 50,
14
+ "examples": 100,
15
+ "attribute_distribution": {
16
+ "Philadelphia": 3,
17
+ "Naples": 2,
18
+ "Berlin": 2,
19
+ "Warsaw": 2,
20
+ "Milan": 2,
21
+ "Bristol": 2,
22
+ "Montreal": 2,
23
+ "Detroit": 2,
24
+ "Bangalore": 1,
25
+ "Gary": 1,
26
+ "Lyon": 1,
27
+ "Madrid": 1,
28
+ "Rome": 1,
29
+ "Medina": 1,
30
+ "Lisbon": 1,
31
+ "Leigh": 1,
32
+ "Beijing": 1,
33
+ "Lund": 1,
34
+ "Florence": 1,
35
+ "Scotland": 1,
36
+ "Japan": 1,
37
+ "Jakarta": 1,
38
+ "Sydney": 1,
39
+ "Dublin": 1,
40
+ "Quincy": 1,
41
+ "Birmingham": 1,
42
+ "Derby": 1,
43
+ "Cornwall": 1,
44
+ "Syracuse": 1,
45
+ "Stockholm": 1,
46
+ "Auckland": 1,
47
+ "Moscow": 1,
48
+ "Frankfurt": 1,
49
+ "Atlanta": 1,
50
+ "Venice": 1,
51
+ "Paris": 1,
52
+ "London": 1,
53
+ "Glasgow": 1,
54
+ "Budapest": 1,
55
+ "Oslo": 1,
56
+ "Bolton": 1
57
+ },
58
+ "unique_templates": 7,
59
+ "unique_subjects": 50,
60
+ "validation": {
61
+ "relation_id": "P19",
62
+ "subset": "N50",
63
+ "pairs": 50,
64
+ "examples": 100,
65
+ "unique_subjects": 50,
66
+ "unique_attributes_true": 41,
67
+ "unique_attributes_false": 41,
68
+ "marginals_match": true,
69
+ "errors": [],
70
+ "valid": true
71
+ }
72
+ },
73
+ "N75": {
74
+ "pairs": 75,
75
+ "examples": 150,
76
+ "attribute_distribution": {
77
+ "Philadelphia": 4,
78
+ "Paris": 4,
79
+ "Frankfurt": 3,
80
+ "Milan": 3,
81
+ "Shanghai": 2,
82
+ "Budapest": 2,
83
+ "Rome": 2,
84
+ "Naples": 2,
85
+ "Berlin": 2,
86
+ "Lisbon": 2,
87
+ "Warsaw": 2,
88
+ "Bristol": 2,
89
+ "Montreal": 2,
90
+ "Detroit": 2,
91
+ "Tokyo": 2,
92
+ "London": 2,
93
+ "Bangalore": 1,
94
+ "Gary": 1,
95
+ "Lyon": 1,
96
+ "Houston": 1,
97
+ "Madrid": 1,
98
+ "Mercedes": 1,
99
+ "Medina": 1,
100
+ "Leigh": 1,
101
+ "Beijing": 1,
102
+ "Lund": 1,
103
+ "Chicago": 1,
104
+ "Florence": 1,
105
+ "Scotland": 1,
106
+ "Japan": 1,
107
+ "Jakarta": 1,
108
+ "Sydney": 1,
109
+ "Dublin": 1,
110
+ "Constantinople": 1,
111
+ "Quincy": 1,
112
+ "Belfast": 1,
113
+ "Birmingham": 1,
114
+ "Leeds": 1,
115
+ "Barcelona": 1,
116
+ "Boston": 1,
117
+ "Derby": 1,
118
+ "Cornwall": 1,
119
+ "Syracuse": 1,
120
+ "Stockholm": 1,
121
+ "Auckland": 1,
122
+ "Spokane": 1,
123
+ "Moscow": 1,
124
+ "Atlanta": 1,
125
+ "Bihar": 1,
126
+ "Venice": 1,
127
+ "Glasgow": 1,
128
+ "Oslo": 1,
129
+ "Bolton": 1
130
+ },
131
+ "unique_templates": 7,
132
+ "unique_subjects": 75,
133
+ "validation": {
134
+ "relation_id": "P19",
135
+ "subset": "N75",
136
+ "pairs": 75,
137
+ "examples": 150,
138
+ "unique_subjects": 75,
139
+ "unique_attributes_true": 53,
140
+ "unique_attributes_false": 53,
141
+ "marginals_match": true,
142
+ "errors": [],
143
+ "valid": true
144
+ }
145
+ },
146
+ "N100": {
147
+ "pairs": 100,
148
+ "examples": 200,
149
+ "attribute_distribution": {
150
+ "London": 5,
151
+ "Philadelphia": 4,
152
+ "Paris": 4,
153
+ "Milan": 4,
154
+ "Frankfurt": 3,
155
+ "Lisbon": 3,
156
+ "Rome": 3,
157
+ "Naples": 3,
158
+ "Boston": 3,
159
+ "Shanghai": 2,
160
+ "Glasgow": 2,
161
+ "Budapest": 2,
162
+ "Venice": 2,
163
+ "Lyon": 2,
164
+ "Houston": 2,
165
+ "Berlin": 2,
166
+ "Florence": 2,
167
+ "Chicago": 2,
168
+ "Warsaw": 2,
169
+ "Bristol": 2,
170
+ "Montreal": 2,
171
+ "Detroit": 2,
172
+ "Tokyo": 2,
173
+ "Bangalore": 1,
174
+ "Gary": 1,
175
+ "Honolulu": 1,
176
+ "Madrid": 1,
177
+ "Mercedes": 1,
178
+ "Medina": 1,
179
+ "Leigh": 1,
180
+ "Beijing": 1,
181
+ "Lund": 1,
182
+ "Scotland": 1,
183
+ "Minneapolis": 1,
184
+ "Japan": 1,
185
+ "Albuquerque": 1,
186
+ "Jakarta": 1,
187
+ "Sydney": 1,
188
+ "Dublin": 1,
189
+ "Constantinople": 1,
190
+ "Clinton": 1,
191
+ "Quincy": 1,
192
+ "Belfast": 1,
193
+ "Birmingham": 1,
194
+ "Leeds": 1,
195
+ "Barcelona": 1,
196
+ "Derby": 1,
197
+ "Cornwall": 1,
198
+ "Thailand": 1,
199
+ "Syracuse": 1,
200
+ "Stockholm": 1,
201
+ "Auckland": 1,
202
+ "Spokane": 1,
203
+ "Moscow": 1,
204
+ "Atlanta": 1,
205
+ "Baltimore": 1,
206
+ "Bihar": 1,
207
+ "Munich": 1,
208
+ "Jerusalem": 1,
209
+ "Edinburgh": 1,
210
+ "Mecca": 1,
211
+ "Oslo": 1,
212
+ "Bolton": 1
213
+ },
214
+ "unique_templates": 7,
215
+ "unique_subjects": 100,
216
+ "validation": {
217
+ "relation_id": "P19",
218
+ "subset": "N100",
219
+ "pairs": 100,
220
+ "examples": 200,
221
+ "unique_subjects": 100,
222
+ "unique_attributes_true": 63,
223
+ "unique_attributes_false": 63,
224
+ "marginals_match": true,
225
+ "errors": [],
226
+ "valid": true
227
+ }
228
+ }
229
+ }
230
+ },
231
+ "P103": {
232
+ "relation_id": "P103",
233
+ "relation_name": "native language",
234
+ "cleaning_counts": {
235
+ "raw": 919,
236
+ "after_subject_dedup": 918,
237
+ "after_cross_relation_removal": 908,
238
+ "after_sentence_dedup": 908
239
+ },
240
+ "subsets": {
241
+ "N50": {
242
+ "pairs": 50,
243
+ "examples": 100,
244
+ "attribute_distribution": {
245
+ "French": 20,
246
+ "Russian": 13,
247
+ "Dutch": 3,
248
+ "Italian": 2,
249
+ "English": 2,
250
+ "Romanian": 1,
251
+ "Latin": 1,
252
+ "Chinese": 1,
253
+ "Polish": 1,
254
+ "Hebrew": 1,
255
+ "Greek": 1,
256
+ "German": 1,
257
+ "Korean": 1,
258
+ "Croatian": 1,
259
+ "Swedish": 1
260
+ },
261
+ "unique_templates": 6,
262
+ "unique_subjects": 50,
263
+ "validation": {
264
+ "relation_id": "P103",
265
+ "subset": "N50",
266
+ "pairs": 50,
267
+ "examples": 100,
268
+ "unique_subjects": 50,
269
+ "unique_attributes_true": 15,
270
+ "unique_attributes_false": 15,
271
+ "marginals_match": true,
272
+ "errors": [],
273
+ "valid": true
274
+ }
275
+ },
276
+ "N75": {
277
+ "pairs": 75,
278
+ "examples": 150,
279
+ "attribute_distribution": {
280
+ "French": 30,
281
+ "Russian": 19,
282
+ "Dutch": 6,
283
+ "Italian": 2,
284
+ "Chinese": 2,
285
+ "English": 2,
286
+ "Romanian": 1,
287
+ "Latin": 1,
288
+ "Polish": 1,
289
+ "Spanish": 1,
290
+ "Japanese": 1,
291
+ "Hebrew": 1,
292
+ "Greek": 1,
293
+ "Tamil": 1,
294
+ "German": 1,
295
+ "Korean": 1,
296
+ "Indonesian": 1,
297
+ "Hindi": 1,
298
+ "Croatian": 1,
299
+ "Swedish": 1
300
+ },
301
+ "unique_templates": 6,
302
+ "unique_subjects": 75,
303
+ "validation": {
304
+ "relation_id": "P103",
305
+ "subset": "N75",
306
+ "pairs": 75,
307
+ "examples": 150,
308
+ "unique_subjects": 75,
309
+ "unique_attributes_true": 20,
310
+ "unique_attributes_false": 20,
311
+ "marginals_match": true,
312
+ "errors": [],
313
+ "valid": true
314
+ }
315
+ },
316
+ "N100": {
317
+ "pairs": 100,
318
+ "examples": 200,
319
+ "attribute_distribution": {
320
+ "French": 40,
321
+ "Russian": 21,
322
+ "Dutch": 11,
323
+ "English": 5,
324
+ "Italian": 3,
325
+ "Romanian": 2,
326
+ "Spanish": 2,
327
+ "Chinese": 2,
328
+ "Swedish": 2,
329
+ "Latin": 1,
330
+ "Polish": 1,
331
+ "Japanese": 1,
332
+ "Hebrew": 1,
333
+ "Greek": 1,
334
+ "Tamil": 1,
335
+ "German": 1,
336
+ "Korean": 1,
337
+ "Indonesian": 1,
338
+ "Hindi": 1,
339
+ "Croatian": 1,
340
+ "Danish": 1
341
+ },
342
+ "unique_templates": 6,
343
+ "unique_subjects": 100,
344
+ "validation": {
345
+ "relation_id": "P103",
346
+ "subset": "N100",
347
+ "pairs": 100,
348
+ "examples": 200,
349
+ "unique_subjects": 100,
350
+ "unique_attributes_true": 21,
351
+ "unique_attributes_false": 21,
352
+ "marginals_match": true,
353
+ "errors": [],
354
+ "valid": true
355
+ }
356
+ }
357
+ }
358
+ },
359
+ "P176": {
360
+ "relation_id": "P176",
361
+ "relation_name": "manufacturer",
362
+ "cleaning_counts": {
363
+ "raw": 911,
364
+ "after_subject_dedup": 900,
365
+ "after_cross_relation_removal": 899,
366
+ "after_sentence_dedup": 899
367
+ },
368
+ "subsets": {
369
+ "N50": {
370
+ "pairs": 50,
371
+ "examples": 100,
372
+ "attribute_distribution": {
373
+ "Fiat": 6,
374
+ "Toyota": 6,
375
+ "Honda": 5,
376
+ "Dodge": 4,
377
+ "Nokia": 3,
378
+ "Nissan": 3,
379
+ "Ferrari": 3,
380
+ "Suzuki": 3,
381
+ "Triumph": 2,
382
+ "BMW": 2,
383
+ "Nintendo": 2,
384
+ "Renault": 2,
385
+ "Apple": 1,
386
+ "IBM": 1,
387
+ "Volvo": 1,
388
+ "Boeing": 1,
389
+ "Samsung": 1,
390
+ "Yamaha": 1,
391
+ "McLaren": 1,
392
+ "Iran": 1,
393
+ "Chevrolet": 1
394
+ },
395
+ "unique_templates": 7,
396
+ "unique_subjects": 50,
397
+ "validation": {
398
+ "relation_id": "P176",
399
+ "subset": "N50",
400
+ "pairs": 50,
401
+ "examples": 100,
402
+ "unique_subjects": 50,
403
+ "unique_attributes_true": 21,
404
+ "unique_attributes_false": 21,
405
+ "marginals_match": true,
406
+ "errors": [],
407
+ "valid": true
408
+ }
409
+ },
410
+ "N75": {
411
+ "pairs": 75,
412
+ "examples": 150,
413
+ "attribute_distribution": {
414
+ "Honda": 9,
415
+ "Toyota": 9,
416
+ "Fiat": 8,
417
+ "Nissan": 5,
418
+ "Suzuki": 5,
419
+ "Dodge": 4,
420
+ "Renault": 4,
421
+ "Triumph": 3,
422
+ "Nokia": 3,
423
+ "Ferrari": 3,
424
+ "Chevrolet": 2,
425
+ "Chrysler": 2,
426
+ "Airbus": 2,
427
+ "Volvo": 2,
428
+ "BMW": 2,
429
+ "Boeing": 2,
430
+ "Nintendo": 2,
431
+ "Cadillac": 2,
432
+ "Apple": 1,
433
+ "IBM": 1,
434
+ "Samsung": 1,
435
+ "Yamaha": 1,
436
+ "McLaren": 1,
437
+ "Iran": 1
438
+ },
439
+ "unique_templates": 7,
440
+ "unique_subjects": 75,
441
+ "validation": {
442
+ "relation_id": "P176",
443
+ "subset": "N75",
444
+ "pairs": 75,
445
+ "examples": 150,
446
+ "unique_subjects": 75,
447
+ "unique_attributes_true": 24,
448
+ "unique_attributes_false": 24,
449
+ "marginals_match": true,
450
+ "errors": [],
451
+ "valid": true
452
+ }
453
+ },
454
+ "N100": {
455
+ "pairs": 100,
456
+ "examples": 200,
457
+ "attribute_distribution": {
458
+ "Honda": 11,
459
+ "Toyota": 11,
460
+ "Fiat": 9,
461
+ "Nissan": 7,
462
+ "Renault": 6,
463
+ "Suzuki": 6,
464
+ "Ferrari": 5,
465
+ "Dodge": 5,
466
+ "Chevrolet": 4,
467
+ "Nokia": 4,
468
+ "Triumph": 3,
469
+ "Cadillac": 3,
470
+ "IBM": 3,
471
+ "Boeing": 3,
472
+ "Chrysler": 2,
473
+ "Airbus": 2,
474
+ "Volvo": 2,
475
+ "BMW": 2,
476
+ "Nintendo": 2,
477
+ "Porsche": 1,
478
+ "Apple": 1,
479
+ "Mercury": 1,
480
+ "Intel": 1,
481
+ "Samsung": 1,
482
+ "Yamaha": 1,
483
+ "McLaren": 1,
484
+ "Iran": 1,
485
+ "Douglas": 1,
486
+ "Bentley": 1
487
+ },
488
+ "unique_templates": 7,
489
+ "unique_subjects": 100,
490
+ "validation": {
491
+ "relation_id": "P176",
492
+ "subset": "N100",
493
+ "pairs": 100,
494
+ "examples": 200,
495
+ "unique_subjects": 100,
496
+ "unique_attributes_true": 29,
497
+ "unique_attributes_false": 29,
498
+ "marginals_match": true,
499
+ "errors": [],
500
+ "valid": true
501
+ }
502
+ }
503
+ }
504
+ },
505
+ "P101": {
506
+ "relation_id": "P101",
507
+ "relation_name": "field of work",
508
+ "cleaning_counts": {
509
+ "raw": 545,
510
+ "after_subject_dedup": 519,
511
+ "after_cross_relation_removal": 512,
512
+ "after_sentence_dedup": 512
513
+ },
514
+ "subsets": {
515
+ "N50": {
516
+ "pairs": 50,
517
+ "examples": 100,
518
+ "attribute_distribution": {
519
+ "physics": 8,
520
+ "mathematics": 7,
521
+ "physiology": 4,
522
+ "chemistry": 3,
523
+ "medicine": 3,
524
+ "history": 3,
525
+ "photography": 2,
526
+ "psychology": 2,
527
+ "LGBT": 2,
528
+ "anatomy": 2,
529
+ "sociology": 2,
530
+ "philosophy": 1,
531
+ "espionage": 1,
532
+ "classics": 1,
533
+ "mechanics": 1,
534
+ "theology": 1,
535
+ "Buddhism": 1,
536
+ "geography": 1,
537
+ "biology": 1,
538
+ "ballet": 1,
539
+ "geometry": 1,
540
+ "mythology": 1,
541
+ "astronomy": 1
542
+ },
543
+ "unique_templates": 10,
544
+ "unique_subjects": 50,
545
+ "validation": {
546
+ "relation_id": "P101",
547
+ "subset": "N50",
548
+ "pairs": 50,
549
+ "examples": 100,
550
+ "unique_subjects": 50,
551
+ "unique_attributes_true": 23,
552
+ "unique_attributes_false": 23,
553
+ "marginals_match": true,
554
+ "errors": [],
555
+ "valid": true
556
+ }
557
+ },
558
+ "N75": {
559
+ "pairs": 75,
560
+ "examples": 150,
561
+ "attribute_distribution": {
562
+ "physics": 11,
563
+ "mathematics": 10,
564
+ "physiology": 6,
565
+ "anatomy": 4,
566
+ "chemistry": 4,
567
+ "psychology": 3,
568
+ "biology": 3,
569
+ "medicine": 3,
570
+ "sociology": 3,
571
+ "history": 3,
572
+ "geography": 2,
573
+ "photography": 2,
574
+ "geometry": 2,
575
+ "LGBT": 2,
576
+ "philosophy": 1,
577
+ "economics": 1,
578
+ "espionage": 1,
579
+ "classics": 1,
580
+ "mechanics": 1,
581
+ "statistics": 1,
582
+ "ecology": 1,
583
+ "anthropology": 1,
584
+ "programmer": 1,
585
+ "logic": 1,
586
+ "theology": 1,
587
+ "Buddhism": 1,
588
+ "aviation": 1,
589
+ "drawing": 1,
590
+ "ballet": 1,
591
+ "mythology": 1,
592
+ "astronomy": 1
593
+ },
594
+ "unique_templates": 10,
595
+ "unique_subjects": 75,
596
+ "validation": {
597
+ "relation_id": "P101",
598
+ "subset": "N75",
599
+ "pairs": 75,
600
+ "examples": 150,
601
+ "unique_subjects": 75,
602
+ "unique_attributes_true": 31,
603
+ "unique_attributes_false": 31,
604
+ "marginals_match": true,
605
+ "errors": [],
606
+ "valid": true
607
+ }
608
+ },
609
+ "N100": {
610
+ "pairs": 100,
611
+ "examples": 200,
612
+ "attribute_distribution": {
613
+ "physics": 15,
614
+ "mathematics": 15,
615
+ "physiology": 8,
616
+ "anatomy": 5,
617
+ "medicine": 5,
618
+ "chemistry": 4,
619
+ "sociology": 4,
620
+ "psychology": 3,
621
+ "geometry": 3,
622
+ "biology": 3,
623
+ "geography": 3,
624
+ "history": 3,
625
+ "philosophy": 2,
626
+ "ecology": 2,
627
+ "photography": 2,
628
+ "theology": 2,
629
+ "logic": 2,
630
+ "LGBT": 2,
631
+ "economics": 1,
632
+ "espionage": 1,
633
+ "classics": 1,
634
+ "mechanics": 1,
635
+ "statistics": 1,
636
+ "anthropology": 1,
637
+ "programmer": 1,
638
+ "hunting": 1,
639
+ "forestry": 1,
640
+ "Buddhism": 1,
641
+ "aviation": 1,
642
+ "Hebrew": 1,
643
+ "drawing": 1,
644
+ "manga": 1,
645
+ "ballet": 1,
646
+ "mythology": 1,
647
+ "astronomy": 1
648
+ },
649
+ "unique_templates": 10,
650
+ "unique_subjects": 100,
651
+ "validation": {
652
+ "relation_id": "P101",
653
+ "subset": "N100",
654
+ "pairs": 100,
655
+ "examples": 200,
656
+ "unique_subjects": 100,
657
+ "unique_attributes_true": 35,
658
+ "unique_attributes_false": 35,
659
+ "marginals_match": true,
660
+ "errors": [],
661
+ "valid": true
662
+ }
663
+ }
664
+ }
665
+ },
666
+ "P159": {
667
+ "relation_id": "P159",
668
+ "relation_name": "headquarters location",
669
+ "cleaning_counts": {
670
+ "raw": 756,
671
+ "after_subject_dedup": 754,
672
+ "after_cross_relation_removal": 753,
673
+ "after_sentence_dedup": 753
674
+ },
675
+ "subsets": {
676
+ "N50": {
677
+ "pairs": 50,
678
+ "examples": 100,
679
+ "attribute_distribution": {
680
+ "London": 7,
681
+ "Oslo": 4,
682
+ "Chicago": 3,
683
+ "Istanbul": 2,
684
+ "Montreal": 2,
685
+ "Edmonton": 2,
686
+ "Copenhagen": 2,
687
+ "Georgetown": 1,
688
+ "Norman": 1,
689
+ "Geneva": 1,
690
+ "Scotland": 1,
691
+ "Canberra": 1,
692
+ "Moscow": 1,
693
+ "Vancouver": 1,
694
+ "Columbus": 1,
695
+ "Paris": 1,
696
+ "Burlington": 1,
697
+ "Valencia": 1,
698
+ "Frankfurt": 1,
699
+ "California": 1,
700
+ "Dallas": 1,
701
+ "Milwaukee": 1,
702
+ "Beijing": 1,
703
+ "Charlotte": 1,
704
+ "Sheffield": 1,
705
+ "Jakarta": 1,
706
+ "Prague": 1,
707
+ "Madrid": 1,
708
+ "Barcelona": 1,
709
+ "France": 1,
710
+ "Ottawa": 1,
711
+ "Irvine": 1,
712
+ "Boston": 1,
713
+ "Berlin": 1,
714
+ "Bradford": 1
715
+ },
716
+ "unique_templates": 7,
717
+ "unique_subjects": 50,
718
+ "validation": {
719
+ "relation_id": "P159",
720
+ "subset": "N50",
721
+ "pairs": 50,
722
+ "examples": 100,
723
+ "unique_subjects": 50,
724
+ "unique_attributes_true": 35,
725
+ "unique_attributes_false": 35,
726
+ "marginals_match": true,
727
+ "errors": [],
728
+ "valid": true
729
+ }
730
+ },
731
+ "N75": {
732
+ "pairs": 75,
733
+ "examples": 150,
734
+ "attribute_distribution": {
735
+ "London": 11,
736
+ "Chicago": 5,
737
+ "Oslo": 4,
738
+ "Paris": 3,
739
+ "Geneva": 2,
740
+ "Istanbul": 2,
741
+ "Montreal": 2,
742
+ "Edmonton": 2,
743
+ "Copenhagen": 2,
744
+ "Detroit": 2,
745
+ "Princeton": 1,
746
+ "Georgetown": 1,
747
+ "Norman": 1,
748
+ "Scotland": 1,
749
+ "Canberra": 1,
750
+ "Moscow": 1,
751
+ "Atlanta": 1,
752
+ "Philadelphia": 1,
753
+ "Melbourne": 1,
754
+ "Stockholm": 1,
755
+ "Southampton": 1,
756
+ "Vancouver": 1,
757
+ "Columbus": 1,
758
+ "Lyon": 1,
759
+ "Burlington": 1,
760
+ "Valencia": 1,
761
+ "Perth": 1,
762
+ "Frankfurt": 1,
763
+ "California": 1,
764
+ "Dallas": 1,
765
+ "Milwaukee": 1,
766
+ "Beijing": 1,
767
+ "Portsmouth": 1,
768
+ "Charlotte": 1,
769
+ "Sheffield": 1,
770
+ "Jakarta": 1,
771
+ "Prague": 1,
772
+ "Tehran": 1,
773
+ "Madrid": 1,
774
+ "Japan": 1,
775
+ "Sydney": 1,
776
+ "Barcelona": 1,
777
+ "France": 1,
778
+ "Ottawa": 1,
779
+ "Seattle": 1,
780
+ "Pittsburgh": 1,
781
+ "Irvine": 1,
782
+ "Boston": 1,
783
+ "Berlin": 1,
784
+ "Bradford": 1
785
+ },
786
+ "unique_templates": 7,
787
+ "unique_subjects": 75,
788
+ "validation": {
789
+ "relation_id": "P159",
790
+ "subset": "N75",
791
+ "pairs": 75,
792
+ "examples": 150,
793
+ "unique_subjects": 75,
794
+ "unique_attributes_true": 50,
795
+ "unique_attributes_false": 50,
796
+ "marginals_match": true,
797
+ "errors": [],
798
+ "valid": true
799
+ }
800
+ },
801
+ "N100": {
802
+ "pairs": 100,
803
+ "examples": 200,
804
+ "attribute_distribution": {
805
+ "London": 13,
806
+ "Chicago": 6,
807
+ "Paris": 4,
808
+ "Oslo": 4,
809
+ "Detroit": 3,
810
+ "Stockholm": 3,
811
+ "Vancouver": 3,
812
+ "Montreal": 3,
813
+ "Edmonton": 3,
814
+ "Geneva": 2,
815
+ "Prague": 2,
816
+ "Moscow": 2,
817
+ "Seattle": 2,
818
+ "Munich": 2,
819
+ "Istanbul": 2,
820
+ "Copenhagen": 2,
821
+ "Princeton": 1,
822
+ "Georgetown": 1,
823
+ "Norman": 1,
824
+ "Scotland": 1,
825
+ "Liverpool": 1,
826
+ "Canberra": 1,
827
+ "Atlanta": 1,
828
+ "Philadelphia": 1,
829
+ "Melbourne": 1,
830
+ "Hamilton": 1,
831
+ "Southampton": 1,
832
+ "Columbus": 1,
833
+ "Warsaw": 1,
834
+ "Lyon": 1,
835
+ "Burlington": 1,
836
+ "Ireland": 1,
837
+ "Manchester": 1,
838
+ "Valencia": 1,
839
+ "Milan": 1,
840
+ "Perth": 1,
841
+ "Frankfurt": 1,
842
+ "Wellington": 1,
843
+ "California": 1,
844
+ "Dallas": 1,
845
+ "Milwaukee": 1,
846
+ "Beijing": 1,
847
+ "Portsmouth": 1,
848
+ "Charlotte": 1,
849
+ "Sheffield": 1,
850
+ "Jakarta": 1,
851
+ "Santiago": 1,
852
+ "Tehran": 1,
853
+ "Madrid": 1,
854
+ "Japan": 1,
855
+ "Sydney": 1,
856
+ "Barcelona": 1,
857
+ "France": 1,
858
+ "Ottawa": 1,
859
+ "Pittsburgh": 1,
860
+ "Irvine": 1,
861
+ "Boston": 1,
862
+ "Berlin": 1,
863
+ "Bradford": 1,
864
+ "Toronto": 1
865
+ },
866
+ "unique_templates": 7,
867
+ "unique_subjects": 100,
868
+ "validation": {
869
+ "relation_id": "P159",
870
+ "subset": "N100",
871
+ "pairs": 100,
872
+ "examples": 200,
873
+ "unique_subjects": 100,
874
+ "unique_attributes_true": 60,
875
+ "unique_attributes_false": 60,
876
+ "marginals_match": true,
877
+ "errors": [],
878
+ "valid": true
879
+ }
880
+ }
881
+ }
882
+ },
883
+ "P138": {
884
+ "relation_id": "P138",
885
+ "relation_name": "named after",
886
+ "cleaning_counts": {
887
+ "raw": 279,
888
+ "after_subject_dedup": 272,
889
+ "after_cross_relation_removal": 270,
890
+ "after_sentence_dedup": 270
891
+ },
892
+ "subsets": {
893
+ "N50": {
894
+ "pairs": 50,
895
+ "examples": 100,
896
+ "attribute_distribution": {
897
+ "Plato": 3,
898
+ "Victoria": 3,
899
+ "London": 2,
900
+ "Thor": 2,
901
+ "Bristol": 2,
902
+ "Peter": 2,
903
+ "Helsinki": 2,
904
+ "Toronto": 2,
905
+ "Vancouver": 2,
906
+ "Montreal": 1,
907
+ "Holland": 1,
908
+ "Cairo": 1,
909
+ "England": 1,
910
+ "Athena": 1,
911
+ "Pittsburgh": 1,
912
+ "Amsterdam": 1,
913
+ "granite": 1,
914
+ "Brittany": 1,
915
+ "Hamburg": 1,
916
+ "Beijing": 1,
917
+ "Kyoto": 1,
918
+ "Portland": 1,
919
+ "Richmond": 1,
920
+ "Milwaukee": 1,
921
+ "Easter": 1,
922
+ "Ohio": 1,
923
+ "silver": 1,
924
+ "Philadelphia": 1,
925
+ "Cleveland": 1,
926
+ "Alps": 1,
927
+ "Birmingham": 1,
928
+ "Cambridge": 1,
929
+ "honey": 1,
930
+ "Brighton": 1,
931
+ "Delaware": 1,
932
+ "Minneapolis": 1,
933
+ "Gibraltar": 1,
934
+ "Albany": 1,
935
+ "Cologne": 1
936
+ },
937
+ "unique_templates": 15,
938
+ "unique_subjects": 50,
939
+ "validation": {
940
+ "relation_id": "P138",
941
+ "subset": "N50",
942
+ "pairs": 50,
943
+ "examples": 100,
944
+ "unique_subjects": 50,
945
+ "unique_attributes_true": 39,
946
+ "unique_attributes_false": 39,
947
+ "marginals_match": true,
948
+ "errors": [],
949
+ "valid": true
950
+ }
951
+ },
952
+ "N75": {
953
+ "pairs": 75,
954
+ "examples": 150,
955
+ "attribute_distribution": {
956
+ "Victoria": 4,
957
+ "Plato": 3,
958
+ "Cleveland": 2,
959
+ "London": 2,
960
+ "Thor": 2,
961
+ "Bristol": 2,
962
+ "Gibraltar": 2,
963
+ "Peter": 2,
964
+ "Helsinki": 2,
965
+ "Amsterdam": 2,
966
+ "Toronto": 2,
967
+ "Vancouver": 2,
968
+ "Oslo": 1,
969
+ "Montreal": 1,
970
+ "Paris": 1,
971
+ "Cork": 1,
972
+ "Holland": 1,
973
+ "Cairo": 1,
974
+ "England": 1,
975
+ "Athena": 1,
976
+ "Tibet": 1,
977
+ "chalk": 1,
978
+ "Naples": 1,
979
+ "Pittsburgh": 1,
980
+ "nickel": 1,
981
+ "granite": 1,
982
+ "Brittany": 1,
983
+ "Split": 1,
984
+ "Hamburg": 1,
985
+ "Manhattan": 1,
986
+ "Beijing": 1,
987
+ "Neptune": 1,
988
+ "Virginia": 1,
989
+ "Kyoto": 1,
990
+ "Shanghai": 1,
991
+ "Portland": 1,
992
+ "Finland": 1,
993
+ "Richmond": 1,
994
+ "Indianapolis": 1,
995
+ "Milwaukee": 1,
996
+ "Easter": 1,
997
+ "Edinburgh": 1,
998
+ "Ohio": 1,
999
+ "silver": 1,
1000
+ "Philadelphia": 1,
1001
+ "Alps": 1,
1002
+ "Birmingham": 1,
1003
+ "France": 1,
1004
+ "Greenwich": 1,
1005
+ "Auckland": 1,
1006
+ "Napoleon": 1,
1007
+ "Manchester": 1,
1008
+ "Cambridge": 1,
1009
+ "honey": 1,
1010
+ "Brighton": 1,
1011
+ "Toyota": 1,
1012
+ "Delaware": 1,
1013
+ "Minneapolis": 1,
1014
+ "Albany": 1,
1015
+ "Cologne": 1
1016
+ },
1017
+ "unique_templates": 15,
1018
+ "unique_subjects": 75,
1019
+ "validation": {
1020
+ "relation_id": "P138",
1021
+ "subset": "N75",
1022
+ "pairs": 75,
1023
+ "examples": 150,
1024
+ "unique_subjects": 75,
1025
+ "unique_attributes_true": 60,
1026
+ "unique_attributes_false": 60,
1027
+ "marginals_match": true,
1028
+ "errors": [],
1029
+ "valid": true
1030
+ }
1031
+ },
1032
+ "N100": {
1033
+ "pairs": 100,
1034
+ "examples": 200,
1035
+ "attribute_distribution": {
1036
+ "Victoria": 5,
1037
+ "Plato": 3,
1038
+ "Peter": 3,
1039
+ "Trinity": 2,
1040
+ "Cleveland": 2,
1041
+ "London": 2,
1042
+ "Holland": 2,
1043
+ "Thor": 2,
1044
+ "Bristol": 2,
1045
+ "Gibraltar": 2,
1046
+ "Helsinki": 2,
1047
+ "Amsterdam": 2,
1048
+ "Toronto": 2,
1049
+ "Beijing": 2,
1050
+ "Vancouver": 2,
1051
+ "Oslo": 1,
1052
+ "Moscow": 1,
1053
+ "Ankara": 1,
1054
+ "Montreal": 1,
1055
+ "Paris": 1,
1056
+ "Italy": 1,
1057
+ "Cork": 1,
1058
+ "Cairo": 1,
1059
+ "Earth": 1,
1060
+ "England": 1,
1061
+ "Athena": 1,
1062
+ "Tibet": 1,
1063
+ "chalk": 1,
1064
+ "Naples": 1,
1065
+ "Pittsburgh": 1,
1066
+ "Rosa": 1,
1067
+ "Ireland": 1,
1068
+ "nickel": 1,
1069
+ "granite": 1,
1070
+ "Brittany": 1,
1071
+ "Split": 1,
1072
+ "Hamburg": 1,
1073
+ "Solomon": 1,
1074
+ "Manhattan": 1,
1075
+ "Neptune": 1,
1076
+ "Jerusalem": 1,
1077
+ "Chicago": 1,
1078
+ "Virginia": 1,
1079
+ "David": 1,
1080
+ "Kyoto": 1,
1081
+ "Shanghai": 1,
1082
+ "Europe": 1,
1083
+ "Macedonia": 1,
1084
+ "Portland": 1,
1085
+ "Finland": 1,
1086
+ "Richmond": 1,
1087
+ "Poland": 1,
1088
+ "Indianapolis": 1,
1089
+ "Hollywood": 1,
1090
+ "Milwaukee": 1,
1091
+ "Easter": 1,
1092
+ "Edinburgh": 1,
1093
+ "Southampton": 1,
1094
+ "Chester": 1,
1095
+ "Ohio": 1,
1096
+ "silver": 1,
1097
+ "Philadelphia": 1,
1098
+ "Alps": 1,
1099
+ "Birmingham": 1,
1100
+ "France": 1,
1101
+ "Greenwich": 1,
1102
+ "Auckland": 1,
1103
+ "Napoleon": 1,
1104
+ "Leicester": 1,
1105
+ "Dublin": 1,
1106
+ "Mars": 1,
1107
+ "Manchester": 1,
1108
+ "Cambridge": 1,
1109
+ "honey": 1,
1110
+ "Brighton": 1,
1111
+ "Toyota": 1,
1112
+ "Delaware": 1,
1113
+ "Minneapolis": 1,
1114
+ "Albany": 1,
1115
+ "Cologne": 1
1116
+ },
1117
+ "unique_templates": 15,
1118
+ "unique_subjects": 100,
1119
+ "validation": {
1120
+ "relation_id": "P138",
1121
+ "subset": "N100",
1122
+ "pairs": 100,
1123
+ "examples": 200,
1124
+ "unique_subjects": 100,
1125
+ "unique_attributes_true": 80,
1126
+ "unique_attributes_false": 80,
1127
+ "marginals_match": true,
1128
+ "errors": [],
1129
+ "valid": true
1130
+ }
1131
+ }
1132
+ }
1133
+ }
1134
+ }
phase2_scaling/data/processed/splits.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ec812741ef1b68b097eaadc3d76331e44b52adc8cbed2b2507bd50d2ea64812f
3
+ size 23804
phase2_scaling/experiment_config.json ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "probe": {
3
+ "model": "LogisticRegression",
4
+ "solver": "lbfgs",
5
+ "penalty": "l2",
6
+ "C": 1.0,
7
+ "max_iter": 1000,
8
+ "tol": 0.0001,
9
+ "fit_intercept": true,
10
+ "class_weight": null,
11
+ "random_state": 42
12
+ },
13
+ "scaler": "StandardScaler",
14
+ "primary_metric": "roc_auc",
15
+ "secondary_metric": "balanced_accuracy",
16
+ "balanced_accuracy_threshold": 0.5,
17
+ "n_folds": 3,
18
+ "layer_selection_tie_tolerance": 0.005
19
+ }
phase2_scaling/extract_activations.py ADDED
@@ -0,0 +1,314 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Extract activations from Llama models via NDIF for Phase 2.
2
+
3
+ Handles both pilot timing runs and full six-relation extraction.
4
+ Uses the blackboxnlp-ndif conda environment.
5
+
6
+ Usage:
7
+ # Pilot: one relation, N50, both models, record timing
8
+ python extract_activations.py --pilot
9
+
10
+ # Full extraction after N_final is frozen
11
+ python extract_activations.py --subset N50 # or N75, N100
12
+ """
13
+
14
+ from __future__ import annotations
15
+
16
+ import argparse
17
+ import hashlib
18
+ import json
19
+ import math
20
+ import os
21
+ import time
22
+ from pathlib import Path
23
+ from typing import Any
24
+
25
+ import numpy as np
26
+ import pandas as pd
27
+
28
+ ROOT = Path(__file__).resolve().parent
29
+ ENV_PATH = ROOT / ".env"
30
+ DATA_PATH = ROOT / "data" / "processed" / "examples.parquet"
31
+ ACTIVATIONS_DIR = ROOT / "activations"
32
+ PILOT_DIR = ROOT / "activations" / "pilot"
33
+
34
+ MODELS = {
35
+ "llama_3_1_8b": "meta-llama/Llama-3.1-8B",
36
+ "llama_3_1_70b": "meta-llama/Llama-3.1-70B",
37
+ }
38
+
39
+ DEPTHS = [0.25, 0.50, 0.75, 1.00]
40
+
41
+ PILOT_RELATION = "P19"
42
+
43
+ def load_env() -> str:
44
+ if not ENV_PATH.exists():
45
+ raise FileNotFoundError(f"Missing .env: {ENV_PATH}")
46
+ for line in ENV_PATH.read_text(encoding="utf-8").splitlines():
47
+ line = line.strip()
48
+ if not line or line.startswith("#"):
49
+ continue
50
+ if "=" in line:
51
+ k, v = line.split("=", 1)
52
+ os.environ.setdefault(k.strip(), v.strip())
53
+ api_key = os.environ.get("NDIF_API_KEY", "").strip()
54
+ if not api_key or api_key.startswith("PASTE_YOUR_"):
55
+ raise RuntimeError("Set NDIF_API_KEY in .env")
56
+ hf_token = os.environ.get("HF_TOKEN", "").strip()
57
+ if not hf_token or hf_token.startswith("PASTE_YOUR_"):
58
+ raise RuntimeError("Set HF_TOKEN in .env")
59
+ return api_key
60
+
61
+
62
+ def get_layer_indices(num_layers: int) -> list[tuple[float, int]]:
63
+ return [(d, math.ceil(d * num_layers) - 1) for d in DEPTHS]
64
+
65
+
66
+ def load_sentences(subset: str, relation: str | None = None) -> pd.DataFrame:
67
+ df = pd.read_parquet(DATA_PATH)
68
+ df = df[df["subset"] == subset]
69
+ if relation:
70
+ df = df[df["relation_id"] == relation]
71
+ return df.sort_values("example_id").reset_index(drop=True)
72
+
73
+
74
+ def extract_for_model(
75
+ model_key: str,
76
+ model_id: str,
77
+ sentences: list[str],
78
+ api_key: str,
79
+ ) -> dict[str, Any]:
80
+ """Run extraction for one model, one sentence at a time.
81
+
82
+ Passes each sentence as a raw string to match the NNsight/NDIF
83
+ remote trace pattern validated in the smoke test.
84
+ """
85
+ from nnsight import CONFIG, LanguageModel
86
+
87
+ CONFIG.set_default_api_key(api_key)
88
+
89
+ print(f"\n{'='*50}")
90
+ print(f"Model: {model_id}")
91
+ print(f"Sentences: {len(sentences)}")
92
+ print(f"{'='*50}")
93
+
94
+ t_init_start = time.time()
95
+ model = LanguageModel(model_id)
96
+ num_layers = model.config.num_hidden_layers
97
+ hidden_dim = model.config.hidden_size
98
+ t_init = time.time() - t_init_start
99
+ print(f"Model init: {t_init:.1f}s (layers={num_layers}, hidden={hidden_dim})")
100
+
101
+ layers = get_layer_indices(num_layers)
102
+ print(f"Target layers: {[(d, i) for d, i in layers]}")
103
+
104
+ tokenizer = model.tokenizer
105
+
106
+ assert len(layers) == 4, f"Expected 4 depths, got {len(layers)}"
107
+ li0, li1, li2, li3 = [idx for _, idx in layers]
108
+
109
+ all_activations: dict[int, list[np.ndarray]] = {
110
+ li0: [], li1: [], li2: [], li3: [],
111
+ }
112
+ all_positions: list[int] = []
113
+
114
+ t_remote_total = 0.0
115
+ t_wall_start = time.time()
116
+
117
+ for i, sent in enumerate(sentences):
118
+ tok_len = len(tokenizer(sent)["input_ids"])
119
+ last_pos = tok_len - 1
120
+ all_positions.append(last_pos)
121
+
122
+ t_sub = time.time()
123
+
124
+ # NNsight 0.7 does not trace Python for-loops inside the
125
+ # context manager — .save() calls inside a loop are silently
126
+ # dropped. Unroll the four depths explicitly.
127
+ with model.trace(sent, remote=True):
128
+ s0 = model.model.layers[li0].output[0].save()
129
+ s1 = model.model.layers[li1].output[0].save()
130
+ s2 = model.model.layers[li2].output[0].save()
131
+ s3 = model.model.layers[li3].output[0].save()
132
+
133
+ t_remote_total += time.time() - t_sub
134
+
135
+ for li, tensor in [(li0, s0), (li1, s1), (li2, s2), (li3, s3)]:
136
+ t = tensor[0] if tensor.dim() == 3 else tensor
137
+ vec = t[last_pos, :].detach().cpu().float().numpy()
138
+ all_activations[li].append(vec)
139
+
140
+ if (i + 1) % 10 == 0 or i == 0:
141
+ elapsed = time.time() - t_wall_start
142
+ print(f" {i+1}/{len(sentences)} "
143
+ f"({elapsed:.0f}s elapsed, "
144
+ f"~{elapsed/(i+1):.2f}s/sent)")
145
+
146
+ t_wall_total = time.time() - t_wall_start
147
+
148
+ activation_arrays = {}
149
+ for layer_idx, vecs in all_activations.items():
150
+ arr = np.stack(vecs).astype(np.float16)
151
+ activation_arrays[layer_idx] = arr
152
+ print(f" Layer {layer_idx}: shape={arr.shape}, dtype={arr.dtype}")
153
+
154
+ timing = {
155
+ "model_id": model_id,
156
+ "model_key": model_key,
157
+ "num_layers": num_layers,
158
+ "hidden_dim": hidden_dim,
159
+ "sentences_processed": len(sentences),
160
+ "model_init_seconds": round(t_init, 2),
161
+ "remote_execution_seconds": round(t_remote_total, 2),
162
+ "total_wall_clock_seconds": round(t_wall_total, 2),
163
+ "seconds_per_sentence": round(t_wall_total / len(sentences), 3),
164
+ }
165
+
166
+ return {
167
+ "activations": activation_arrays,
168
+ "positions": all_positions,
169
+ "layers": layers,
170
+ "timing": timing,
171
+ }
172
+
173
+
174
+ def save_activations(
175
+ result: dict[str, Any],
176
+ output_dir: Path,
177
+ model_key: str,
178
+ df: pd.DataFrame,
179
+ dataset_hash: str,
180
+ ) -> None:
181
+ model_dir = output_dir / model_key
182
+ model_dir.mkdir(parents=True, exist_ok=True)
183
+
184
+ for layer_idx, arr in result["activations"].items():
185
+ np.save(model_dir / f"layer_{layer_idx}.npy", arr)
186
+
187
+ sample_index = df[["example_id", "pair_id", "case_id", "relation_id",
188
+ "subject", "label", "subset"]].copy()
189
+ sample_index["token_position"] = result["positions"]
190
+ sample_index.to_parquet(model_dir / "sample_index.parquet", index=False)
191
+
192
+ manifest = {
193
+ **result["timing"],
194
+ "target_layers": [
195
+ {"depth": d, "layer_index": i} for d, i in result["layers"]
196
+ ],
197
+ "activation_shapes": {
198
+ str(idx): list(arr.shape)
199
+ for idx, arr in result["activations"].items()
200
+ },
201
+ "activation_dtype": "float16",
202
+ "dataset_hash": dataset_hash,
203
+ "token_position_strategy": "last_real_token (= final subtoken of target attribute)",
204
+ }
205
+ (model_dir / "manifest.json").write_text(
206
+ json.dumps(manifest, indent=2) + "\n", encoding="utf-8"
207
+ )
208
+
209
+
210
+ def run_pilot(api_key: str) -> None:
211
+ print("=" * 60)
212
+ print(f"PILOT TIMING: relation={PILOT_RELATION}, subset=N50")
213
+ print("=" * 60)
214
+
215
+ df = load_sentences("N50", PILOT_RELATION)
216
+ sentences = df["sentence"].tolist()
217
+ print(f"Loaded {len(sentences)} pilot sentences")
218
+
219
+ dataset_hash = hashlib.sha256(
220
+ "\n".join(sentences).encode()
221
+ ).hexdigest()[:16]
222
+
223
+ all_timing = {}
224
+
225
+ for model_key, model_id in MODELS.items():
226
+ result = extract_for_model(model_key, model_id, sentences, api_key)
227
+ all_timing[model_key] = result["timing"]
228
+
229
+ save_activations(result, PILOT_DIR, model_key, df, dataset_hash)
230
+ print(f"\nSaved pilot activations to {PILOT_DIR / model_key}")
231
+
232
+ print("\n" + "=" * 60)
233
+ print("PILOT TIMING SUMMARY")
234
+ print("=" * 60)
235
+
236
+ for mk, t in all_timing.items():
237
+ print(f"\n {mk}:")
238
+ print(f" Wall clock: {t['total_wall_clock_seconds']:.1f}s")
239
+ print(f" Remote exec: {t['remote_execution_seconds']:.1f}s")
240
+ print(f" Per sentence: {t['seconds_per_sentence']:.3f}s")
241
+ print(f" Sentences: {t['sentences_processed']}")
242
+
243
+ total_8b = all_timing["llama_3_1_8b"]["total_wall_clock_seconds"]
244
+ total_70b = all_timing["llama_3_1_70b"]["total_wall_clock_seconds"]
245
+
246
+ print("\n Estimated full extraction times:")
247
+ for label, n_pairs in [("N50", 50), ("N75", 75), ("N100", 100)]:
248
+ multiplier = (6 * n_pairs * 2) / 100
249
+ est_8b = total_8b * multiplier
250
+ est_70b = total_70b * multiplier
251
+ est_total = est_8b + est_70b
252
+ print(f" {label}: 8B={est_8b/60:.0f}min + 70B={est_70b/60:.0f}min "
253
+ f"= {est_total/60:.0f}min total")
254
+
255
+ decision_path = ROOT / "sample_size_decision.json"
256
+ decision = {
257
+ "pilot_relation": PILOT_RELATION,
258
+ "pilot_subset": "N50",
259
+ "pilot_sentences": len(sentences),
260
+ "pilot_timing": all_timing,
261
+ "estimated_full_extraction": {},
262
+ }
263
+ for label, n_pairs in [("N50", 50), ("N75", 75), ("N100", 100)]:
264
+ mult = (6 * n_pairs * 2) / 100
265
+ decision["estimated_full_extraction"][label] = {
266
+ "sentences": 6 * n_pairs * 2,
267
+ "multiplier": mult,
268
+ "estimated_8b_seconds": round(total_8b * mult, 1),
269
+ "estimated_70b_seconds": round(total_70b * mult, 1),
270
+ "estimated_total_seconds": round((total_8b + total_70b) * mult, 1),
271
+ }
272
+ decision_path.write_text(json.dumps(decision, indent=2) + "\n", encoding="utf-8")
273
+ print(f"\nSaved timing decision to {decision_path}")
274
+
275
+
276
+ def run_full(api_key: str, subset: str) -> None:
277
+ print("=" * 60)
278
+ print(f"FULL EXTRACTION: subset={subset}, all relations")
279
+ print("=" * 60)
280
+
281
+ df = load_sentences(subset)
282
+ sentences = df["sentence"].tolist()
283
+ print(f"Loaded {len(sentences)} sentences across {df['relation_id'].nunique()} relations")
284
+
285
+ dataset_hash = hashlib.sha256(
286
+ "\n".join(sentences).encode()
287
+ ).hexdigest()[:16]
288
+
289
+ for model_key, model_id in MODELS.items():
290
+ result = extract_for_model(model_key, model_id, sentences, api_key)
291
+ out_dir = ACTIVATIONS_DIR / model_key
292
+ save_activations(result, ACTIVATIONS_DIR, model_key, df, dataset_hash)
293
+ print(f"\nSaved activations to {out_dir}")
294
+
295
+
296
+ def main() -> None:
297
+ parser = argparse.ArgumentParser()
298
+ group = parser.add_mutually_exclusive_group(required=True)
299
+ group.add_argument("--pilot", action="store_true",
300
+ help="Run pilot timing with one relation")
301
+ group.add_argument("--subset", choices=["N50", "N75", "N100"],
302
+ help="Run full extraction for this subset")
303
+ args = parser.parse_args()
304
+
305
+ api_key = load_env()
306
+
307
+ if args.pilot:
308
+ run_pilot(api_key)
309
+ else:
310
+ run_full(api_key, args.subset)
311
+
312
+
313
+ if __name__ == "__main__":
314
+ main()
phase2_scaling/figures/fig1_depth_profile.pdf ADDED
Binary file (20.2 kB). View file
 
phase2_scaling/figures/fig1_depth_profile.png ADDED

Git LFS Details

  • SHA256: b19efbb13ff6889a43425e725598c957225be9e76ce8aac69c568c79a8be6fa7
  • Pointer size: 131 Bytes
  • Size of remote file: 107 kB
phase2_scaling/figures/fig2_generality_gap.pdf ADDED
Binary file (17 kB). View file
 
phase2_scaling/figures/fig2_generality_gap.png ADDED

Git LFS Details

  • SHA256: ad10ed0a2cdf4e38ebcf2375c72aa6f4f67abeee72b2635d97b92c093052f0c5
  • Pointer size: 130 Bytes
  • Size of remote file: 61.6 kB
phase2_scaling/figures/fig3_transfer_matrices.pdf ADDED
Binary file (39.8 kB). View file
 
phase2_scaling/figures/fig3_transfer_matrices.png ADDED

Git LFS Details

  • SHA256: 6019e3dc95fe6a8e6fb1a007ee34d599a077ba94697d19c967491ead897a3a4e
  • Pointer size: 131 Bytes
  • Size of remote file: 266 kB
phase2_scaling/figures/fig4_relation_gap_detail.pdf ADDED
Binary file (18.9 kB). View file
 
phase2_scaling/figures/fig4_relation_gap_detail.png ADDED

Git LFS Details

  • SHA256: ddccf83127159fb4cab03519b5dfaafad412270834aadf7900322921f4b0c4b6
  • Pointer size: 130 Bytes
  • Size of remote file: 92.6 kB
phase2_scaling/figures/fig5_relation_profiles.pdf ADDED
Binary file (31.3 kB). View file
 
phase2_scaling/figures/fig5_relation_profiles.png ADDED

Git LFS Details

  • SHA256: 79ed7dbc43f18cfaaf3cfb1228e3d3a8fee6a7872c0721600fe030ff689253a4
  • Pointer size: 131 Bytes
  • Size of remote file: 195 kB
phase2_scaling/generate_figures.py ADDED
@@ -0,0 +1,389 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Generate Phase 2 publication figures.
2
+
3
+ Run from workspace/reproduction/scaling/ under the blackboxnlp conda env:
4
+ python generate_figures.py
5
+ """
6
+ from __future__ import annotations
7
+
8
+ import json
9
+ from pathlib import Path
10
+
11
+ import matplotlib
12
+ matplotlib.use("Agg")
13
+ import matplotlib.pyplot as plt
14
+ import matplotlib.ticker as mticker
15
+ import numpy as np
16
+ import pandas as pd
17
+ from matplotlib.colors import LinearSegmentedColormap
18
+
19
+ ROOT = Path(__file__).resolve().parent
20
+ RESULTS_DIR = ROOT / "results"
21
+ FIGURES_DIR = ROOT / "figures"
22
+ FIGURES_DIR.mkdir(exist_ok=True)
23
+
24
+ RELATION_ORDER = ["P19", "P103", "P101", "P159", "P176", "P138"]
25
+ RELATION_LABELS = {
26
+ "P19": "P19\nplace of birth",
27
+ "P103": "P103\nnative language",
28
+ "P101": "P101\nfield of work",
29
+ "P159": "P159\nHQ location",
30
+ "P176": "P176\nmanufacturer",
31
+ "P138": "P138\nnamed after",
32
+ }
33
+ RELATION_SHORT = {
34
+ "P19": "P19",
35
+ "P103": "P103",
36
+ "P101": "P101",
37
+ "P159": "P159",
38
+ "P176": "P176",
39
+ "P138": "P138",
40
+ }
41
+
42
+ C_8B = "#2a78d6"
43
+ C_70B = "#1baf7a"
44
+ C_8B_LIGHT = "#86b6ef"
45
+ C_70B_LIGHT = "#7dd4b0"
46
+
47
+ DEPTHS = [0.25, 0.5, 0.75, 1.0]
48
+ DEPTH_LABELS = ["25%", "50%", "75%", "100%"]
49
+
50
+
51
+ def setup_style():
52
+ plt.rcParams.update({
53
+ "font.family": "sans-serif",
54
+ "font.sans-serif": ["Segoe UI", "Arial", "Helvetica", "sans-serif"],
55
+ "font.size": 9,
56
+ "axes.titlesize": 10,
57
+ "axes.labelsize": 9,
58
+ "xtick.labelsize": 8,
59
+ "ytick.labelsize": 8,
60
+ "legend.fontsize": 8,
61
+ "figure.dpi": 300,
62
+ "savefig.dpi": 300,
63
+ "savefig.bbox": "tight",
64
+ "savefig.pad_inches": 0.05,
65
+ "axes.spines.top": False,
66
+ "axes.spines.right": False,
67
+ "axes.linewidth": 0.6,
68
+ "xtick.major.width": 0.6,
69
+ "ytick.major.width": 0.6,
70
+ "axes.grid": True,
71
+ "grid.alpha": 0.3,
72
+ "grid.linewidth": 0.5,
73
+ "lines.linewidth": 1.8,
74
+ "lines.markersize": 6,
75
+ })
76
+
77
+
78
+ def load_data():
79
+ gap = pd.read_csv(RESULTS_DIR / "generality_gap.csv")
80
+ with open(RESULTS_DIR / "selected_layers.json") as f:
81
+ selected = json.load(f)
82
+ matrix_8b = pd.read_csv(RESULTS_DIR / "stage2_matrix_8b.csv", index_col=0)
83
+ matrix_70b = pd.read_csv(RESULTS_DIR / "stage2_matrix_70b.csv", index_col=0)
84
+ return gap, selected, matrix_8b, matrix_70b
85
+
86
+
87
+ def fig1_depth_profile(gap: pd.DataFrame, selected: dict):
88
+ """Within-relation and LOO AUC across depths for both models."""
89
+ fig, ax = plt.subplots(figsize=(4.5, 3.2))
90
+
91
+ for model_key, color, label in [
92
+ ("llama_3_1_8b", C_8B, "8B"),
93
+ ("llama_3_1_70b", C_70B, "70B"),
94
+ ]:
95
+ m = gap[gap["model_key"] == model_key]
96
+
97
+ within_means = []
98
+ within_stds = []
99
+ loo_means = []
100
+ loo_stds = []
101
+ for d in DEPTHS:
102
+ depth_data = m[m["normalized_depth"] == d]
103
+ within_means.append(depth_data["within_mean_auc"].mean())
104
+ within_stds.append(depth_data["within_mean_auc"].std())
105
+ loo_means.append(depth_data["loo_auc"].mean())
106
+ loo_stds.append(depth_data["loo_auc"].std())
107
+
108
+ x = np.arange(len(DEPTHS))
109
+
110
+ ax.errorbar(x, within_means, yerr=within_stds, color=color,
111
+ marker="o", linestyle="-", label=f"{label} within",
112
+ capsize=3, capthick=1.2, markeredgecolor="white",
113
+ markeredgewidth=1)
114
+ ax.errorbar(x, loo_means, yerr=loo_stds, color=color,
115
+ marker="s", linestyle="--", label=f"{label} leave-one-out",
116
+ capsize=3, capthick=1.2, markeredgecolor="white",
117
+ markeredgewidth=1)
118
+
119
+ best_8b_idx = DEPTHS.index(selected["llama_3_1_8b"]["normalized_depth"])
120
+ best_70b_idx = DEPTHS.index(selected["llama_3_1_70b"]["normalized_depth"])
121
+ ax.axvline(best_8b_idx, color=C_8B, alpha=0.15, linewidth=8, zorder=0)
122
+ ax.axvline(best_70b_idx, color=C_70B, alpha=0.15, linewidth=8, zorder=0)
123
+
124
+ ax.set_xticks(range(len(DEPTHS)))
125
+ ax.set_xticklabels(DEPTH_LABELS)
126
+ ax.set_xlabel("Normalized depth")
127
+ ax.set_ylabel("ROC-AUC")
128
+ ax.set_ylim(0.88, 1.005)
129
+ ax.yaxis.set_major_formatter(mticker.FormatStrFormatter("%.2f"))
130
+ ax.legend(loc="lower left", framealpha=0.9, edgecolor="none")
131
+ ax.set_title("Within-relation and leave-one-out AUC by depth")
132
+
133
+ fig.tight_layout()
134
+ fig.savefig(FIGURES_DIR / "fig1_depth_profile.pdf")
135
+ fig.savefig(FIGURES_DIR / "fig1_depth_profile.png")
136
+ plt.close(fig)
137
+ print(" fig1_depth_profile.pdf")
138
+
139
+
140
+ def fig2_generality_gap(gap: pd.DataFrame, selected: dict):
141
+ """Mean absolute generality gap by depth for both models."""
142
+ fig, ax = plt.subplots(figsize=(4.0, 3.0))
143
+
144
+ bar_width = 0.35
145
+ x = np.arange(len(DEPTHS))
146
+
147
+ for i, (model_key, color, label) in enumerate([
148
+ ("llama_3_1_8b", C_8B, "8B"),
149
+ ("llama_3_1_70b", C_70B, "70B"),
150
+ ]):
151
+ m = gap[gap["model_key"] == model_key]
152
+ mean_abs_gaps = []
153
+ for d in DEPTHS:
154
+ depth_data = m[m["normalized_depth"] == d]
155
+ mean_abs_gaps.append(depth_data["generality_gap"].abs().mean())
156
+
157
+ offset = (i - 0.5) * bar_width
158
+ bars = ax.bar(x + offset, mean_abs_gaps, bar_width * 0.88,
159
+ color=color, alpha=0.85, label=label,
160
+ edgecolor="white", linewidth=0.5)
161
+ for bar, val in zip(bars, mean_abs_gaps):
162
+ ax.text(bar.get_x() + bar.get_width() / 2, bar.get_height() + 0.001,
163
+ f"{val:.3f}", ha="center", va="bottom", fontsize=7,
164
+ color="#52514e")
165
+
166
+ ax.set_xticks(x)
167
+ ax.set_xticklabels(DEPTH_LABELS)
168
+ ax.set_xlabel("Normalized depth")
169
+ ax.set_ylabel("Mean |generality gap|")
170
+ ax.set_ylim(0, 0.06)
171
+ ax.legend(framealpha=0.9, edgecolor="none")
172
+ ax.set_title("Generality gap: 8B vs 70B")
173
+
174
+ fig.tight_layout()
175
+ fig.savefig(FIGURES_DIR / "fig2_generality_gap.pdf")
176
+ fig.savefig(FIGURES_DIR / "fig2_generality_gap.png")
177
+ plt.close(fig)
178
+ print(" fig2_generality_gap.pdf")
179
+
180
+
181
+ def _draw_heatmap(ax, matrix: pd.DataFrame, title: str, vmin: float, vmax: float,
182
+ cmap, show_cbar: bool = False):
183
+ """Draw a single transfer matrix heatmap."""
184
+ ordered = matrix.loc[RELATION_ORDER, RELATION_ORDER].astype(float)
185
+ data = ordered.values
186
+
187
+ im = ax.imshow(data, cmap=cmap, vmin=vmin, vmax=vmax, aspect="equal")
188
+
189
+ n = len(RELATION_ORDER)
190
+ for i in range(n):
191
+ for j in range(n):
192
+ val = data[i, j]
193
+ text_color = "white" if val > 0.97 else "#0b0b0b"
194
+ weight = "bold" if i == j else "normal"
195
+ ax.text(j, i, f"{val:.3f}", ha="center", va="center",
196
+ fontsize=7, color=text_color, fontweight=weight)
197
+
198
+ ax.set_xticks(range(n))
199
+ ax.set_yticks(range(n))
200
+ short_labels = [RELATION_SHORT[r] for r in RELATION_ORDER]
201
+ ax.set_xticklabels(short_labels, fontsize=8)
202
+ ax.set_yticklabels(short_labels, fontsize=8)
203
+ ax.set_xlabel("Target relation", fontsize=9)
204
+ ax.set_ylabel("Source relation", fontsize=9)
205
+ ax.set_title(title, fontsize=10, pad=8)
206
+
207
+ ax.spines[:].set_visible(True)
208
+ ax.spines[:].set_linewidth(0.5)
209
+ ax.spines[:].set_color("#c3c2b7")
210
+ ax.tick_params(length=0)
211
+
212
+ return im
213
+
214
+
215
+ def fig3_transfer_matrices(matrix_8b: pd.DataFrame, matrix_70b: pd.DataFrame):
216
+ """Side-by-side 6×6 transfer matrix heatmaps."""
217
+ blues = LinearSegmentedColormap.from_list("custom_blues", [
218
+ "#cde2fb", "#86b6ef", "#3987e5", "#1c5cab", "#104281"
219
+ ])
220
+
221
+ fig = plt.figure(figsize=(9.5, 3.8))
222
+ gs = fig.add_gridspec(1, 3, width_ratios=[1, 1, 0.05], wspace=0.3)
223
+ ax1 = fig.add_subplot(gs[0, 0])
224
+ ax2 = fig.add_subplot(gs[0, 1])
225
+ cax = fig.add_subplot(gs[0, 2])
226
+
227
+ _draw_heatmap(ax1, matrix_8b, "Llama-3.1-8B (layer 7, depth 25%)",
228
+ vmin=0.84, vmax=1.0, cmap=blues)
229
+ im = _draw_heatmap(ax2, matrix_70b, "Llama-3.1-70B (layer 39, depth 50%)",
230
+ vmin=0.84, vmax=1.0, cmap=blues)
231
+
232
+ cbar = fig.colorbar(im, cax=cax)
233
+ cbar.set_label("ROC-AUC", fontsize=9)
234
+ cbar.ax.tick_params(labelsize=8)
235
+ cbar.outline.set_linewidth(0.5)
236
+
237
+ fig.savefig(FIGURES_DIR / "fig3_transfer_matrices.pdf")
238
+ fig.savefig(FIGURES_DIR / "fig3_transfer_matrices.png")
239
+ plt.close(fig)
240
+ print(" fig3_transfer_matrices.pdf")
241
+
242
+
243
+ def _fmt_gap(val: float) -> str:
244
+ if abs(val) < 0.0005:
245
+ return "0.000"
246
+ return f"{val:+.3f}"
247
+
248
+
249
+ def fig4_relation_gap_detail(gap: pd.DataFrame, selected: dict):
250
+ """Per-relation generality gap at the selected layer for each model."""
251
+ fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(7.5, 3.0))
252
+
253
+ n = len(RELATION_ORDER)
254
+ y_positions = np.arange(n)
255
+
256
+ for ax, model_key, color, title, layer_depth in [
257
+ (ax1, "llama_3_1_8b", C_8B, "8B (layer 7)", 0.25),
258
+ (ax2, "llama_3_1_70b", C_70B, "70B (layer 39)", 0.5),
259
+ ]:
260
+ m = gap[(gap["model_key"] == model_key) &
261
+ (gap["normalized_depth"] == layer_depth)]
262
+ m = m.set_index("target_relation").loc[RELATION_ORDER]
263
+
264
+ gaps = m["generality_gap"].values
265
+
266
+ colors = [color if g >= 0 else "#e34948" for g in gaps]
267
+ bars = ax.barh(y_positions, gaps, height=0.6, color=colors, alpha=0.8,
268
+ edgecolor="white", linewidth=0.5)
269
+
270
+ for bar, val in zip(bars, gaps):
271
+ x_pos = val + 0.002 if val >= 0 else val - 0.002
272
+ ha = "left" if val >= 0 else "right"
273
+ ax.text(x_pos, bar.get_y() + bar.get_height() / 2,
274
+ _fmt_gap(val), ha=ha, va="center", fontsize=7,
275
+ color="#52514e")
276
+
277
+ ax.set_yticks(y_positions)
278
+ ax.set_yticklabels(RELATION_ORDER, fontsize=8)
279
+ ax.axvline(0, color="#c3c2b7", linewidth=0.8, zorder=0)
280
+ ax.set_xlabel("Generality gap (within − leave-one-out)", fontsize=8)
281
+ ax.set_title(title, fontsize=10)
282
+ ax.set_xlim(-0.035, 0.065)
283
+ ax.set_ylim(n - 0.5, -0.5)
284
+
285
+ fig.suptitle("Per-relation generality gap at selected layer",
286
+ fontsize=10)
287
+ fig.tight_layout(rect=[0, 0, 1, 0.95])
288
+ fig.savefig(FIGURES_DIR / "fig4_relation_gap_detail.pdf")
289
+ fig.savefig(FIGURES_DIR / "fig4_relation_gap_detail.png")
290
+ plt.close(fig)
291
+ print(" fig4_relation_gap_detail.pdf")
292
+
293
+
294
+ def fig5_relation_depth_profiles(gap: pd.DataFrame):
295
+ """Small multiples: each relation's within AUC trajectory across depths."""
296
+ fig, axes = plt.subplots(2, 3, figsize=(8, 4.5), sharex=True, sharey=True)
297
+
298
+ for idx, rel in enumerate(RELATION_ORDER):
299
+ ax = axes[idx // 3, idx % 3]
300
+
301
+ for model_key, color, label in [
302
+ ("llama_3_1_8b", C_8B, "8B"),
303
+ ("llama_3_1_70b", C_70B, "70B"),
304
+ ]:
305
+ m = gap[(gap["model_key"] == model_key) &
306
+ (gap["target_relation"] == rel)]
307
+ m = m.sort_values("normalized_depth")
308
+ x = np.arange(len(DEPTHS))
309
+ ax.plot(x, m["within_mean_auc"].values, color=color,
310
+ marker="o", markersize=4, label=f"{label} within",
311
+ markeredgecolor="white", markeredgewidth=0.8)
312
+ ax.plot(x, m["loo_auc"].values, color=color,
313
+ marker="s", markersize=4, linestyle="--",
314
+ label=f"{label} leave-one-out",
315
+ markeredgecolor="white", markeredgewidth=0.8)
316
+
317
+ ax.set_title(f"{rel}", fontsize=9, fontweight="bold")
318
+ ax.set_xticks(range(len(DEPTHS)))
319
+ ax.set_xticklabels(DEPTH_LABELS, fontsize=7)
320
+ ax.set_ylim(0.80, 1.01)
321
+ ax.yaxis.set_major_formatter(mticker.FormatStrFormatter("%.2f"))
322
+
323
+ if idx == 0:
324
+ ax.legend(fontsize=6, loc="lower left", framealpha=0.9,
325
+ edgecolor="none")
326
+
327
+ fig.supxlabel("Normalized depth", fontsize=9)
328
+ fig.supylabel("ROC-AUC", fontsize=9)
329
+ fig.suptitle("Per-relation AUC profiles", fontsize=10, y=1.0)
330
+ fig.tight_layout()
331
+ fig.savefig(FIGURES_DIR / "fig5_relation_profiles.pdf")
332
+ fig.savefig(FIGURES_DIR / "fig5_relation_profiles.png")
333
+ plt.close(fig)
334
+ print(" fig5_relation_profiles.pdf")
335
+
336
+
337
+ def table1_relation_results(gap: pd.DataFrame, selected: dict):
338
+ """Relation-level table at selected layers."""
339
+ rows = []
340
+ for rel in RELATION_ORDER:
341
+ row = {"Relation": rel}
342
+ for model_key, short, depth in [
343
+ ("llama_3_1_8b", "8B", 0.25),
344
+ ("llama_3_1_70b", "70B", 0.5),
345
+ ]:
346
+ m = gap[(gap["model_key"] == model_key) &
347
+ (gap["normalized_depth"] == depth) &
348
+ (gap["target_relation"] == rel)]
349
+ row[f"{short} within"] = f"{m['within_mean_auc'].values[0]:.3f}"
350
+ row[f"{short} std"] = f"{m['within_std_auc'].values[0]:.3f}"
351
+ row[f"{short} leave-one-out"] = f"{m['loo_auc'].values[0]:.3f}"
352
+ row[f"{short} gap"] = _fmt_gap(m['generality_gap'].values[0])
353
+ rows.append(row)
354
+
355
+ mean_row = {"Relation": "Mean"}
356
+ for model_key, short, depth in [
357
+ ("llama_3_1_8b", "8B", 0.25),
358
+ ("llama_3_1_70b", "70B", 0.5),
359
+ ]:
360
+ m = gap[(gap["model_key"] == model_key) &
361
+ (gap["normalized_depth"] == depth)]
362
+ mean_row[f"{short} within"] = f"{m['within_mean_auc'].mean():.3f}"
363
+ mean_row[f"{short} std"] = f"{m['within_std_auc'].mean():.3f}"
364
+ mean_row[f"{short} leave-one-out"] = f"{m['loo_auc'].mean():.3f}"
365
+ mean_row[f"{short} gap"] = _fmt_gap(m['generality_gap'].mean())
366
+ rows.append(mean_row)
367
+
368
+ table = pd.DataFrame(rows)
369
+ table.to_csv(RESULTS_DIR / "table1_relation_results.csv", index=False)
370
+ print(" table1_relation_results.csv")
371
+ print(table.to_string(index=False))
372
+
373
+
374
+ def main():
375
+ setup_style()
376
+ gap, selected, matrix_8b, matrix_70b = load_data()
377
+
378
+ print("Generating figures...")
379
+ fig1_depth_profile(gap, selected)
380
+ fig2_generality_gap(gap, selected)
381
+ fig3_transfer_matrices(matrix_8b, matrix_70b)
382
+ fig4_relation_gap_detail(gap, selected)
383
+ fig5_relation_depth_profiles(gap)
384
+ table1_relation_results(gap, selected)
385
+ print("\nAll figures saved to figures/")
386
+
387
+
388
+ if __name__ == "__main__":
389
+ main()
phase2_scaling/generate_splits.py ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Generate 3-fold pair-grouped cross-validation splits for N100.
2
+
3
+ True/false examples from the same pair are always in the same fold.
4
+ Downstream code joins on example_id, never on row index.
5
+
6
+ Run from workspace/reproduction/scaling/ under the blackboxnlp conda env:
7
+ python generate_splits.py
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ import json
13
+ from pathlib import Path
14
+
15
+ import numpy as np
16
+ import pandas as pd
17
+
18
+ SEED = 20260712_03
19
+ ROOT = Path(__file__).resolve().parent
20
+ DATA_PATH = ROOT / "data" / "processed" / "examples.parquet"
21
+ OUTPUT_PATH = ROOT / "data" / "processed" / "splits.parquet"
22
+
23
+ N_FOLDS = 3
24
+
25
+
26
+ def main() -> None:
27
+ df = pd.read_parquet(DATA_PATH)
28
+ df = df[df["subset"] == "N100"]
29
+ print(f"Loaded {len(df)} N100 examples across "
30
+ f"{df['relation_id'].nunique()} relations")
31
+
32
+ rng = np.random.RandomState(SEED)
33
+
34
+ fold_assignments: list[dict] = []
35
+
36
+ for rel in sorted(df["relation_id"].unique()):
37
+ rel_df = df[df["relation_id"] == rel]
38
+ pairs = sorted(rel_df[rel_df["label"] == 1]["case_id"].unique())
39
+ n_pairs = len(pairs)
40
+
41
+ shuffled = rng.permutation(pairs)
42
+ folds = np.array_split(shuffled, N_FOLDS)
43
+ fold_sizes = [len(f) for f in folds]
44
+
45
+ pair_to_fold = {}
46
+ for fold_idx, fold_pairs in enumerate(folds):
47
+ for case_id in fold_pairs:
48
+ pair_to_fold[case_id] = fold_idx
49
+
50
+ for _, row in rel_df.iterrows():
51
+ fold_assignments.append({
52
+ "example_id": row["example_id"],
53
+ "pair_id": row["pair_id"],
54
+ "case_id": row["case_id"],
55
+ "relation_id": row["relation_id"],
56
+ "within_relation_fold": pair_to_fold[row["case_id"]],
57
+ })
58
+
59
+ print(f" {rel}: {n_pairs} pairs -> folds {fold_sizes}")
60
+
61
+ splits = pd.DataFrame(fold_assignments)
62
+
63
+ # --- Validation ---
64
+ errors = []
65
+
66
+ for rel in splits["relation_id"].unique():
67
+ rel_splits = splits[splits["relation_id"] == rel]
68
+
69
+ for case_id in rel_splits["case_id"].unique():
70
+ pair_rows = rel_splits[rel_splits["case_id"] == case_id]
71
+ if pair_rows["within_relation_fold"].nunique() != 1:
72
+ errors.append(f"{rel} case_id={case_id}: pair split across folds")
73
+
74
+ fold_counts = rel_splits.groupby("within_relation_fold").size()
75
+ if len(fold_counts) != N_FOLDS:
76
+ errors.append(f"{rel}: expected {N_FOLDS} folds, got {len(fold_counts)}")
77
+
78
+ joined = splits.merge(
79
+ df[["example_id", "label"]], on="example_id", how="left"
80
+ )
81
+ for rel in splits["relation_id"].unique():
82
+ rel_j = joined[joined["relation_id"] == rel]
83
+ for fold in range(N_FOLDS):
84
+ fold_j = rel_j[rel_j["within_relation_fold"] == fold]
85
+ n_true = (fold_j["label"] == 1).sum()
86
+ n_false = (fold_j["label"] == 0).sum()
87
+ if n_true != n_false:
88
+ errors.append(f"{rel} fold {fold}: {n_true} true vs {n_false} false")
89
+
90
+ if errors:
91
+ for e in errors:
92
+ print(f" ERROR: {e}")
93
+ raise RuntimeError("Split validation failed")
94
+
95
+ print(f"\nValidation passed:")
96
+ print(f" All pairs have true/false in same fold")
97
+ print(f" All relations have {N_FOLDS} folds")
98
+ print(f" Class balance OK within every fold")
99
+
100
+ splits.to_parquet(OUTPUT_PATH, index=False, engine="pyarrow")
101
+ print(f"\nSaved {len(splits)} rows to {OUTPUT_PATH}")
102
+ print(f"Split seed: {SEED}")
103
+
104
+
105
+ if __name__ == "__main__":
106
+ main()
phase2_scaling/ndif_smoke_test.py ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Minimal remote Llama-3.1-8B test using NNsight and NDIF.
2
+
3
+ Before running:
4
+ 1. Put NDIF_API_KEY and HF_TOKEN in the adjacent .env file.
5
+ 2. Ensure the Hugging Face account behind HF_TOKEN has Meta Llama 3.1 access.
6
+ 3. Install the workspace requirements.
7
+
8
+ Run from workspace/reproduction/scaling:
9
+ python ndif_smoke_test.py
10
+
11
+ This script sends one short prompt to NDIF. It does not download or run
12
+ Llama weights on the local computer.
13
+ """
14
+
15
+ from __future__ import annotations
16
+
17
+ import os
18
+ from pathlib import Path
19
+
20
+
21
+ def load_local_env(env_path: Path) -> None:
22
+ """Load simple KEY=VALUE entries without adding a python-dotenv dependency."""
23
+ if not env_path.exists():
24
+ raise FileNotFoundError(f"Missing credentials file: {env_path}")
25
+
26
+ for raw_line in env_path.read_text(encoding="utf-8").splitlines():
27
+ line = raw_line.strip()
28
+ if not line or line.startswith("#"):
29
+ continue
30
+ if "=" not in line:
31
+ raise ValueError(f"Invalid .env line: {raw_line!r}")
32
+
33
+ key, value = line.split("=", 1)
34
+ os.environ.setdefault(key.strip(), value.strip())
35
+
36
+
37
+ def require_secret(name: str) -> str:
38
+ value = os.environ.get(name, "").strip()
39
+ if not value or value.startswith("PASTE_YOUR_"):
40
+ raise RuntimeError(
41
+ f"Set {name} in .env before running this script. "
42
+ "Do not paste the key into Python code or commit it to Git."
43
+ )
44
+ return value
45
+
46
+
47
+ def main() -> None:
48
+ load_local_env(Path(__file__).with_name(".env"))
49
+
50
+ ndif_api_key = require_secret("NDIF_API_KEY")
51
+ require_secret("HF_TOKEN")
52
+ from nnsight import CONFIG, LanguageModel
53
+
54
+ # The key is read from the local environment, never written into source code.
55
+ CONFIG.set_default_api_key(ndif_api_key)
56
+
57
+ print("Creating the lightweight local model definition...")
58
+ # This exact ID is currently listed by ndif_status() as a running model.
59
+ model = LanguageModel("meta-llama/Llama-3.1-8B")
60
+
61
+ prompt = "The Eiffel Tower is located in"
62
+ print("Submitting one remote NDIF trace for Llama-3.1-8B...")
63
+ with model.trace(prompt, remote=True):
64
+ # Save the final layer's small sequence tensor. Indexing is performed
65
+ # locally below because this NDIF deployment does not whitelist the
66
+ # internal module NNsight uses to serialize remote tensor slicing.
67
+ hidden_sequence = model.model.layers[-1].output[0].save()
68
+
69
+ hidden = hidden_sequence[-1, :]
70
+
71
+ print("Success: NDIF returned one hidden representation.")
72
+ print(f"Returned shape: {tuple(hidden.shape)}")
73
+ print(f"Returned dtype: {hidden.dtype}")
74
+
75
+
76
+ if __name__ == "__main__":
77
+ main()
phase2_scaling/phase2_final_plan.md ADDED
@@ -0,0 +1,419 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Phase 2 Final Plan: Scaling of Cross-Relation Truth Representations
2
+
3
+ **Date:** 2026-07-11
4
+ **Time budget:** approximately 1.5 days
5
+ **Purpose:** implementation and paper-writing specification
6
+
7
+ ## 1. Research question
8
+
9
+ Phase 1 showed that breaking cross-pair truth co-occurrence removes truth decodability in the tested fully trainable synthetic model while preserving factual memorization.
10
+
11
+ Phase 2 asks:
12
+
13
+ > Does model scale make a linearly decodable truth representation more transferable across factual relations?
14
+
15
+ The main comparison is Llama-3.1-8B versus Llama-3.1-70B. Layer-wise probing is a measurement tool; the contribution is cross-relation generalization, not the location of the single strongest layer.
16
+
17
+ The final claim remains scoped to the evaluated CounterFact relations.
18
+
19
+ ## 2. Fixed scope
20
+
21
+ ### Models
22
+
23
+ - `meta-llama/Llama-3.1-8B`
24
+ - `meta-llama/Llama-3.1-70B`
25
+
26
+ Use base checkpoints for both models and record exact revisions. Llama-3.1-405B is optional future work and does not block this experiment.
27
+
28
+ ### Dataset
29
+
30
+ - 6 semantically diverse CounterFact relations
31
+ - final sample size selected from 50, 75, or 100 factual records per relation
32
+ - one matched true/false pair per record
33
+ - 600, 900, or 1,200 sentences in total
34
+
35
+ Select relations before probing. Each relation must contain at least 50 usable records and should contain 100 if possible. Generate false examples by replacing the true attribute with a different attribute from the same relation using a deterministic permutation and fixed seed.
36
+
37
+ Each processed example preserves:
38
+
39
+ ```text
40
+ example_id
41
+ pair_id
42
+ case_id
43
+ relation_id
44
+ subject
45
+ template
46
+ true_attribute
47
+ used_attribute
48
+ sentence
49
+ label
50
+ false_attribute_source_id
51
+ ```
52
+
53
+ Prepare nested datasets with a fixed ordering:
54
+
55
+ ```text
56
+ N50 = first 50 pairs per relation
57
+ N75 = N50 + the next 25 pairs per relation
58
+ N100 = N75 + the next 25 pairs per relation
59
+ ```
60
+
61
+ The final selected subset and ordering are used for both models.
62
+
63
+ ### Sample-size timing gate
64
+
65
+ The final sample size is selected using a disposable pilot before any full six-relation extraction.
66
+
67
+ Choose one of the six relations and take its first 50 fact pairs, giving 100 pilot sentences. Run the exact four-depth activation extraction on this pilot subset for both 8B and 70B. The pilot must use the same batch size, representation position, dtype, NNsight code path, and output format intended for the final run.
68
+
69
+ Record separately for each model:
70
+
71
+ ```text
72
+ queue_wait_seconds
73
+ remote_execution_seconds
74
+ result_transfer_seconds
75
+ total_wall_clock_seconds
76
+ sentences_processed
77
+ seconds_per_sentence
78
+ ```
79
+
80
+ For a candidate size `N` pairs per relation, estimate full extraction time as:
81
+
82
+ ```text
83
+ full_sentence_count = 6 relations * N pairs * 2 labels
84
+ pilot_sentence_count = 100
85
+ scaling_multiplier = full_sentence_count / 100
86
+ ```
87
+
88
+ Therefore:
89
+
90
+ | Candidate | Full sentences | Pilot-time multiplier per model |
91
+ |---:|---:|---:|
92
+ | 50 pairs/relation | 600 | 6x |
93
+ | 75 pairs/relation | 900 | 9x |
94
+ | 100 pairs/relation | 1,200 | 12x |
95
+
96
+ Estimate 8B and 70B separately from their own pilot timings, then add them to estimate total active extraction time. Queue time is reported separately because it may not scale linearly.
97
+
98
+ Choose `N_final` from 50, 75, or 100 using the remaining wall-clock budget. Reserve at least six hours after activation extraction for probe runs, validation, figures, and debugging. Save the decision and timing evidence in `sample_size_decision.json`.
99
+
100
+ After validating tensor shapes, example ordering, saved metadata, and timing, discard the pilot activation files. Keep only the pilot logs and timing record. Once `N_final` is frozen, start a fresh activation extraction for all six relations on both models. The maximum wasted inference is one relation out of six at the 50-pair setting, and less proportionally if `N_final` is 75 or 100.
101
+
102
+ ## 3. Splits
103
+
104
+ The true and false sentences from the same `pair_id` remain in the same fold.
105
+
106
+ ### Within-relation splits
107
+
108
+ Create one fixed three-fold split independently inside each relation. Reuse it across all layers and models.
109
+
110
+ ### Leave-one-relation-out splits
111
+
112
+ For each target relation, train on the other five complete relations and evaluate on the target relation.
113
+
114
+ ## 4. Activation extraction
115
+
116
+ For each sentence, save the transformer-block output at the final subtoken of the target attribute.
117
+
118
+ Extract four normalized depths:
119
+
120
+ | Depth | 8B block index | 70B block index |
121
+ |---:|---:|---:|
122
+ | 25% | 7 | 19 |
123
+ | 50% | 15 | 39 |
124
+ | 75% | 23 | 59 |
125
+ | 100% | 31 | 79 |
126
+
127
+ Indices are zero-based. Compute them dynamically:
128
+
129
+ ```python
130
+ layer_index = math.ceil(depth * model.config.num_hidden_layers) - 1
131
+ ```
132
+
133
+ Save float16 activation matrices and convert them to float32 for probe training.
134
+
135
+ Expected activation volume:
136
+
137
+ | Pairs/relation | Sentences | Activation vectors | 8B + 70B storage |
138
+ |---:|---:|---:|---:|
139
+ | 50 | 600 | 4,800 | approximately 59 MB |
140
+ | 75 | 900 | 7,200 | approximately 89 MB |
141
+ | 100 | 1,200 | 9,600 | approximately 118 MB |
142
+
143
+ Per-layer matrix shapes are `[12 * N_final, 4096]` for 8B and `[12 * N_final, 8192]` for 70B.
144
+
145
+ Also save token position information, model ID and revision, layer index, normalized depth, activation shape, and dataset hash.
146
+
147
+ ## 5. Probe configuration
148
+
149
+ Use one fixed scikit-learn pipeline throughout:
150
+
151
+ ```text
152
+ StandardScaler
153
+ L2-regularized LogisticRegression
154
+ ```
155
+
156
+ Fix the solver, `C`, maximum iterations, and random seed in `experiment_config.json` before Stage 2.
157
+
158
+ Primary metric: ROC-AUC.
159
+ Secondary metric: balanced accuracy.
160
+
161
+ ## 6. Stage 1A: Within-relation probing
162
+
163
+ For every model, depth, and relation, run three-fold pair-grouped cross-validation using only that relation.
164
+
165
+ For each fold:
166
+
167
+ 1. fit the probe on two folds;
168
+ 2. evaluate it on the held-out fold;
169
+ 3. record fold AUC and per-example prediction scores.
170
+
171
+ The official within-relation result is:
172
+
173
+ ```text
174
+ mean of the three fold AUCs +/- standard deviation
175
+ ```
176
+
177
+ It is used for:
178
+
179
+ - the within-relation baseline;
180
+ - global layer selection for Stage 2;
181
+ - the within-to-unseen generality gap;
182
+ - the diagonal of the Stage 2 transfer matrix.
183
+
184
+ Pooled OOF AUC may be stored as an additional diagnostic, but it is not the primary metric because scores from independently fitted fold models need not share an identical calibration scale.
185
+
186
+ Training count:
187
+
188
+ ```text
189
+ 6 relations x 3 folds x 4 depths = 72 fits per model
190
+ ```
191
+
192
+ ## 7. Stage 1B: Leave-one-relation-out probing
193
+
194
+ For every model and depth, run six experiments:
195
+
196
+ ```text
197
+ train on five relations -> evaluate on the sixth unseen relation
198
+ ```
199
+
200
+ Report one AUC for each held-out relation, followed by mean and variation across the six relations. Retain all four depths.
201
+
202
+ Training count:
203
+
204
+ ```text
205
+ 6 held-out relations x 4 depths = 24 fits per model
206
+ ```
207
+
208
+ ### Generality gap
209
+
210
+ For each model, depth, and target relation:
211
+
212
+ ```text
213
+ generality_gap = mean_within_relation_auc - leave_one_out_auc
214
+ ```
215
+
216
+ Interpretation:
217
+
218
+ - high within and high leave-one-out AUC: relation-general decodability;
219
+ - high within and low leave-one-out AUC: relation-specific decodability;
220
+ - a smaller 70B gap: evidence that scaling improves transfer across the evaluated relations.
221
+
222
+ ## 8. Global layer selection for Stage 2
223
+
224
+ Select one layer per model from Stage 1A:
225
+
226
+ ```text
227
+ best_layer(model)
228
+ = layer with the highest mean within-relation AUC,
229
+ averaged first across folds and then across the six relations
230
+ ```
231
+
232
+ If two depths differ by no more than 0.005 mean AUC, select the shallower depth.
233
+
234
+ Selection is global per model, not per relation. The 8B and 70B matrices may use different normalized depths and are therefore results at each model's best within-relation layer.
235
+
236
+ ## 9. Stage 2: Six-by-six pairwise transfer matrix
237
+
238
+ At each model's selected layer, fit one probe on all examples from each source relation:
239
+
240
+ ```text
241
+ 6 source relations = 6 full-source probes per model
242
+ ```
243
+
244
+ Apply each probe to the other five relations:
245
+
246
+ ```text
247
+ 6 sources x 5 targets = 30 off-diagonal evaluations per model
248
+ ```
249
+
250
+ Rows are source relations and columns are target relations. Transfer is directional, so `R1 -> R2` and `R2 -> R1` are separate results.
251
+
252
+ For each diagonal cell, reuse the mean three-fold within-relation AUC from Stage 1A at the selected layer. The diagonal is cross-validated, whereas each off-diagonal probe is fitted on the full source relation; state this in the figure caption.
253
+
254
+ Stage 2 explains whether transfer is broad, clustered among semantically related relations, or asymmetric.
255
+
256
+ ## 10. Compute summary
257
+
258
+ | Quantity | Total after timing decision |
259
+ |---|---:|
260
+ | Sentences | 600, 900, or 1,200 |
261
+ | Activation vectors | 4,800, 7,200, or 9,600 |
262
+ | Activation storage | approximately 59, 89, or 118 MB |
263
+ | Stage 1 within-relation fits | 144 across two models |
264
+ | Stage 1 leave-one-out fits | 48 across two models |
265
+ | Stage 2 full-source fits | 12 across two models |
266
+ | Total logistic-regression fits | 204 |
267
+ | Saved probe models | all 204 fitted probes |
268
+ | Stage 2 off-diagonal evaluations | 60 across two models |
269
+
270
+ Remote activation extraction is the main time cost. Probe training is local and inexpensive.
271
+
272
+ ## 11. Required artifacts
273
+
274
+ ```text
275
+ reproduction/scaling/
276
+ |-- phase2_final_plan.md
277
+ |-- experiment_config.json
278
+ |-- sample_size_decision.json
279
+ |-- data/
280
+ | |-- raw/counterfact.json
281
+ | |-- processed/examples.parquet
282
+ | |-- processed/relations.json
283
+ | |-- processed/splits.parquet
284
+ | `-- processed/dataset_manifest.json
285
+ |-- activations/
286
+ | |-- llama_3_1_8b/
287
+ | | |-- manifest.json
288
+ | | |-- sample_index.parquet
289
+ | | `-- layer_*.npy
290
+ | `-- llama_3_1_70b/
291
+ | |-- manifest.json
292
+ | |-- sample_index.parquet
293
+ | `-- layer_*.npy
294
+ |-- results/
295
+ | |-- stage1_predictions.parquet
296
+ | |-- stage1_metrics.csv
297
+ | |-- selected_layers.json
298
+ | |-- stage2_predictions.parquet
299
+ | |-- stage2_matrix_8b.csv
300
+ | |-- stage2_matrix_70b.csv
301
+ | `-- probe_weights/
302
+ `-- figures/
303
+ ```
304
+
305
+ ### Data and split files
306
+
307
+ `examples.parquet` contains sentence text, labels, relation and pair identity, subject, attributes, and false-attribute provenance.
308
+
309
+ `splits.parquet` contains:
310
+
311
+ ```text
312
+ example_id, pair_id, relation_id, within_relation_fold
313
+ ```
314
+
315
+ ### Activations
316
+
317
+ After the pilot is discarded and `N_final` is frozen, store one float16 matrix per model and layer. `sample_index.parquet` defines row-to-example correspondence. The manifest records model/data revisions, timing, shapes, and checksums.
318
+
319
+ ### Predictions
320
+
321
+ Store per-example scores:
322
+
323
+ ```text
324
+ stage, model_id, layer_index, normalized_depth, protocol,
325
+ source_relations, target_relation, fold, example_id,
326
+ true_label, prediction_score
327
+ ```
328
+
329
+ ### Metrics
330
+
331
+ ```text
332
+ stage, model_id, layer_index, normalized_depth, protocol,
333
+ source_relations, target_relation, fold,
334
+ auc, balanced_accuracy, n_train, n_test
335
+ ```
336
+
337
+ ### Probe weights
338
+
339
+ Save all 204 fitted probes from Stage 1 and Stage 2. This includes every within-relation fold probe, every leave-one-relation-out probe, and every Stage 2 full-source probe.
340
+
341
+ Store portable parameter arrays rather than relying only on pickled sklearn objects:
342
+
343
+ ```text
344
+ coefficient
345
+ intercept
346
+ scaler_mean
347
+ scaler_scale
348
+ classes
349
+ ```
350
+
351
+ Each saved probe also needs a manifest entry containing:
352
+
353
+ ```text
354
+ probe_id
355
+ stage
356
+ protocol
357
+ model_id
358
+ model_revision
359
+ layer_index
360
+ normalized_depth
361
+ source_relations
362
+ target_relation
363
+ fold
364
+ training_example_ids
365
+ probe_configuration_hash
366
+ sklearn_version
367
+ ```
368
+
369
+ The expected storage is only on the order of tens of megabytes when arrays are stored as float32. Saving every probe makes later prediction checks, coefficient analysis, and paper revisions possible without retraining.
370
+
371
+ ## 12. Required figures and tables
372
+
373
+ 1. **Stage 1 depth plot:** mean within-relation and leave-one-out AUC across the four depths for 8B and 70B.
374
+ 2. **Generality-gap summary:** within AUC, unseen AUC, and gap by model and depth.
375
+ 3. **Two transfer matrices:** one 6-by-6 heatmap per model using the same relation order and color scale.
376
+ 4. **Relation-level table:** within AUC, leave-one-out AUC, and gap for every target relation.
377
+
378
+ Relations are the unit of generalization. Keep relation-level results visible alongside aggregate means.
379
+
380
+ ## 13. Implementation sequence
381
+
382
+ 1. Select and freeze six relations.
383
+ 2. Prepare and validate nested `N50`, `N75`, and `N100` subsets where data availability permits.
384
+ 3. Choose one pilot relation and run its first 50 pairs through all four depths on 8B and 70B.
385
+ 4. Validate the extraction and record model-specific timing components.
386
+ 5. Estimate the 50-, 75-, and 100-pair full-run costs and freeze `N_final`.
387
+ 6. Discard pilot activations while preserving logs and `sample_size_decision.json`.
388
+ 7. Generate fixed three-fold pair assignments for the final dataset.
389
+ 8. Start fresh four-depth activation extraction for all six relations on 8B and 70B.
390
+ 9. Run Stage 1 on both models.
391
+ 10. Select one global layer per model.
392
+ 11. Run Stage 2 and generate the two matrices.
393
+ 12. Produce final figures and freeze result files before interpretation.
394
+
395
+ ## 14. Completion criteria
396
+
397
+ The experiment is complete when:
398
+
399
+ - the timing benchmark and final sample-size decision are saved;
400
+ - the balanced six-relation `N_final` dataset and fixed splits are saved;
401
+ - four activation depths are available for both models;
402
+ - within-relation and leave-one-out results exist for every model, depth, and relation;
403
+ - selected layers were produced by the fixed mean-within-AUC rule;
404
+ - both 6-by-6 transfer matrices are complete;
405
+ - all 204 probe models, per-example predictions, metrics, manifests, and final figures are saved.
406
+
407
+ ## 15. Optional low-cost controls
408
+
409
+ If time permits, add two local controls; neither requires additional activation extraction.
410
+
411
+ ### Text-only baseline
412
+
413
+ Train a TF-IDF logistic classifier on the raw sentences using the same within-relation and leave-one-relation-out splits. Near-chance performance would show that the activation results are not easily explained by surface lexical cues alone.
414
+
415
+ ### Pair-balanced label permutation
416
+
417
+ At each model's selected layer, repeat probe evaluation with randomly swapped true/false labels inside each fact pair, preserving class balance. Run approximately 10 random permutations. The resulting AUC distribution should be near 0.5 and serves as a pipeline/split sanity check.
418
+
419
+ These controls are optional and must not delay the main 8B-versus-70B experiment.
phase2_scaling/phase2_notes.txt ADDED
@@ -0,0 +1,842 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Phase 2: Scaling Experiment Notes
2
+ =================================
3
+ Authoritative specification: phase2_final_plan.md
4
+ This file records decisions, reasoning, and data-quality observations
5
+ for paper writing. It does not duplicate the full protocol.
6
+
7
+
8
+ SUPERSEDED: initial design (2026-07-11)
9
+ ----------------------------------------
10
+ The initial plan (also in phase2_notes.txt prior to this revision and
11
+ in the Phase 2 section of updated_plan.md) described:
12
+ - three models: 8B, 70B, 405B
13
+ - extraction at every transformer layer
14
+ - single relation P103 first, then top-25 relations
15
+ - research focus on locating the highest-AUC layer
16
+ - three normalised-depth AUC curves as the main figure
17
+
18
+ This was superseded on 2026-07-11 by phase2_final_plan.md, which
19
+ reframes the contribution around cross-relation generalisation rather
20
+ than layer location. The current design is:
21
+ - two models: Llama-3.1-8B and Llama-3.1-70B (405B is optional
22
+ future work and does not block this experiment)
23
+ - six finalised CounterFact relations
24
+ - four normalised depths: 25%, 50%, 75%, 100%
25
+ - Stage 1: within-relation 3-fold CV + leave-one-relation-out
26
+ - Stage 2: 6x6 pairwise transfer matrices at each model's best
27
+ within-relation layer
28
+ - a disposable timing pilot (1 relation x 50 pairs x 2 models)
29
+ to select N_final from {50, 75, 100} pairs per relation
30
+
31
+ What is preserved from the initial plan:
32
+ - all compute runs through NNsight + NDIF (no local Llama hosting)
33
+ - the local RTX 5080 laptop handles only data prep, probe training,
34
+ and figures
35
+ - NDIF/NNsight citation requirement and acknowledgement
36
+
37
+
38
+ Relation selection (finalised 2026-07-12)
39
+ ------------------------------------------
40
+ Six semantically diverse CounterFact relations:
41
+
42
+ P19 (place of birth) biographical, location-type target
43
+ P103 (native language) biographical, language-type target
44
+ P101 (field of work) biographical, domain-type target
45
+ P159 (headquarters location) organisation, location-type target
46
+ P176 (manufacturer) product/organisation
47
+ P138 (named after) diverse entity types
48
+
49
+ Design reasoning (recorded before seeing any probe results):
50
+
51
+ P19 and P103 were selected a priori, before observing any probe
52
+ results, as a conceptually related biographical pair: same subject
53
+ type (people), shared cultural/geographic
54
+ background, but nearly no subject overlap (3 out of ~800) and zero
55
+ target-vocabulary overlap (place names vs language names). We
56
+ hypothesise stronger transfer between these two than between
57
+ unrelated pairs.
58
+
59
+ P19 and P159 share location-type targets (cities, countries) but
60
+ differ in subject type (people vs organisations) and predicate.
61
+ This allows comparison of whether conceptual similarity or shared
62
+ target vocabulary drives transfer.
63
+
64
+ P101 provides intermediate semantic distance from the biographical
65
+ pair. P176 and P138 provide more distant relation structures.
66
+
67
+ These expectations are NOT built into the sampling or filtering
68
+ code. The preprocessing treats all six relations identically
69
+ (except P103 French capping); hypotheses are tested only at the
70
+ analysis stage.
71
+
72
+
73
+ Data statistics
74
+ ----------------
75
+ Counts at each cleaning stage for the six target relations:
76
+
77
+ Stage 1 — Raw records in counterfact.json:
78
+
79
+ Relation Records Subjects Top attribute (%)
80
+ P19 779 779 London (7.6%)
81
+ P103 919 919 French (63.9%)
82
+ P176 911 911 Toyota (11.0%)
83
+ P101 545 545 physics (13.4%)
84
+ P159 756 756 London (11.4%)
85
+ P138 279 279 Victoria (3.6%)
86
+
87
+ Stage 2 — After within-relation subject deduplication
88
+ (keep lowest case_id per subject):
89
+
90
+ P19 779 -> 779 (0 removed)
91
+ P103 919 -> 918 (1 removed)
92
+ P176 911 -> 900 (11 removed)
93
+ P101 545 -> 519 (26 removed)
94
+ P159 756 -> 754 (2 removed)
95
+ P138 279 -> 272 (7 removed)
96
+
97
+ Stage 3 — After cross-relation subject removal
98
+ (12 subjects appear in more than one target relation):
99
+
100
+ P19 779 -> 776 (3 removed: Michel Brault, Pierre Braunberger,
101
+ Sergey Lavrov — shared with P103)
102
+ P103 918 -> 908 (10 removed: 7 shared with P101, 3 with P19)
103
+ P176 900 -> 899 (1 removed: PGM-17 Thor — shared with P138)
104
+ P101 519 -> 512 (7 removed: shared with P103)
105
+ P159 754 -> 753 (1 removed: Sheffield United F.C. — with P138)
106
+ P138 272 -> 270 (2 removed: PGM-17 Thor, Sheffield United F.C.)
107
+
108
+ Stage 4 — After duplicate-sentence removal:
109
+
110
+ No duplicate sentences found in any relation after prior cleaning.
111
+ All counts unchanged from Stage 3.
112
+
113
+ Final cleaned pool sizes:
114
+ P19=776, P103=908, P176=899, P101=512, P159=753, P138=270
115
+
116
+ The tightest relation is P138 with 270 usable records, well above
117
+ the N100 requirement.
118
+
119
+ P103 after cleaning: 908 records, French=582 (64.1%).
120
+
121
+
122
+ Negative construction via derangement
123
+ --------------------------------------
124
+ False sentences are constructed by permuting true attributes within
125
+ each relation using a fixed-seed derangement: a permutation sigma of
126
+ {1, ..., n} such that a_{sigma(i)} != a_i for every record i.
127
+
128
+ Why this guarantees identical attribute marginals:
129
+
130
+ A permutation is a bijection. The multiset of false attributes
131
+ {a_{sigma(1)}, ..., a_{sigma(n)}} is identical to the multiset of
132
+ true attributes {a_1, ..., a_n}. Every attribute value appears
133
+ exactly the same number of times as true and as false. This is an
134
+ exact algebraic guarantee.
135
+
136
+ Consequence: a linear probe cannot succeed merely because some
137
+ attribute word appears more often with one label.
138
+
139
+ The no-self-match constraint ensures no record's false sentence
140
+ contains the same attribute as its true sentence.
141
+
142
+ Existence condition: a valid derangement exists whenever no single
143
+ attribute occupies more than floor(n/2) positions.
144
+
145
+ This approach is better suited to our probing control than using
146
+ CounterFact's built-in target_new field, which was designed for
147
+ knowledge-editing experiments and does not match attribute marginals
148
+ across labels.
149
+
150
+
151
+ P103 French capping
152
+ ---------------------
153
+ French represents 587/919 = 63.9% of P103 raw records, exceeding
154
+ the derangement feasibility threshold (50%) at every sample size.
155
+
156
+ Capping strategy: limit French records to 20/30/40 in the
157
+ N50/N75/N100 subsets (= 40% of each subset), safely below the 50%
158
+ derangement ceiling. Non-French records are sampled with the same
159
+ fixed seed used for all other relations.
160
+
161
+ Other relations have no attribute exceeding 14% and need no capping.
162
+
163
+ Scope of this control: capping eliminates unigram attribute-frequency
164
+ difference between labels. It does not rule out all forms of lexical
165
+ leakage (e.g., correlated subject names or template structure). The
166
+ optional TF-IDF baseline described in phase2_final_plan.md Section 15
167
+ addresses surface-lexical confounds more broadly.
168
+
169
+
170
+ Nested subset construction
171
+ ----------------------------
172
+ Three nested subsets per relation support the timing gate:
173
+
174
+ N50 = 50 pairs (first selected)
175
+ N75 = N50 + 25 additional pairs
176
+ N100 = N75 + 25 additional pairs
177
+
178
+ Nesting is strict: N50 subset N75 subset N100. The same seed
179
+ controls selection at every level.
180
+
181
+ Derangements are computed independently per subset level because the
182
+ attribute composition changes. A given record's false attribute at
183
+ N50 may differ from its false attribute at N100.
184
+
185
+
186
+ Timing gate
187
+ ------------
188
+ Before committing to a full six-relation extraction, a disposable
189
+ pilot determines N_final.
190
+
191
+ Pilot procedure:
192
+ 1. Choose one of the six relations and take its first 50 pairs
193
+ (100 sentences).
194
+ 2. Run the exact four-depth activation extraction on 8B and 70B
195
+ using the same batch size, token position, dtype, and NNsight
196
+ code path intended for the final run.
197
+ 3. Record per model: queue wait, remote execution, result transfer,
198
+ and total wall-clock time.
199
+ 4. Estimate full extraction time as:
200
+ N50 -> 6x pilot time per model
201
+ N75 -> 9x pilot time per model
202
+ N100 -> 12x pilot time per model
203
+ 5. Choose N_final from {50, 75, 100} using the remaining time
204
+ budget, reserving at least six hours for probing, validation,
205
+ figures, and debugging.
206
+ 6. Validate pilot tensor shapes and metadata, then discard pilot
207
+ activation files. Keep only logs and timing record in
208
+ sample_size_decision.json.
209
+ 7. Start fresh extraction for all six relations on both models.
210
+
211
+ Maximum wasted inference: one relation at the 50-pair level.
212
+
213
+
214
+ Cleaning pipeline summary
215
+ ---------------------------
216
+ 1. Filter to six target relations.
217
+ 2. Remove duplicate subjects within each relation (keep lowest
218
+ case_id).
219
+ 3. Remove subjects appearing in more than one target relation.
220
+ 4. Remove duplicate sentences.
221
+ 5. Apply P103 French cap.
222
+ 6. Sample nested N50/N75/N100 subsets (fixed seed).
223
+ 7. Construct derangement-based negatives per relation per subset.
224
+ 8. Validate: class balance, no true==false, exact attribute
225
+ marginals, correct subset sizes, no duplicate examples.
226
+
227
+
228
+ Output files
229
+ -------------
230
+ data/processed/examples.parquet
231
+ All examples with columns: example_id, pair_id, case_id,
232
+ relation_id, subject, template, true_attribute, used_attribute,
233
+ sentence, label, false_attribute_source_id, subset.
234
+
235
+ data/processed/relations.json
236
+ Per-relation metadata: record counts at each cleaning stage,
237
+ attribute distribution, French cap details (P103), template
238
+ statistics.
239
+
240
+ data/processed/dataset_manifest.json
241
+ Global seed, file hashes, counts, sampling decisions, validation
242
+ results.
243
+
244
+ Splits (3-fold pair-grouped CV assignments) are generated in a
245
+ separate step after data preparation is validated.
246
+
247
+
248
+ Preprocessing execution record (2026-07-12)
249
+ ----------------------------------------------
250
+ Script: prepare_counterfact_multirelation.py
251
+ Seed: 20260712
252
+ Command: python prepare_counterfact_multirelation.py
253
+ Conda env: blackboxnlp
254
+
255
+ Derangement algorithm: sort records by (attribute, case_id), then
256
+ shift indices by max_group_size. Deterministic given the selected
257
+ records — no additional random seed needed for the derangement itself.
258
+ Randomness enters only through subset sampling.
259
+
260
+ Per-relation RNG seeds (derived from global seed + relation index):
261
+ P19: 20260712 + 0*10007 = 20260712
262
+ P103: 20260712 + 1*10007 = 20270719 (sub-seeds +1/+2 for French/other)
263
+ P176: 20260712 + 2*10007 = 20280726
264
+ P101: 20260712 + 3*10007 = 20290733
265
+ P159: 20260712 + 4*10007 = 20300740
266
+ P138: 20260712 + 5*10007 = 20310747
267
+
268
+ Validation: 18/18 checks passed (6 relations x 3 subset levels).
269
+ All nesting checks passed (N50 ⊂ N75 ⊂ N100 by case_id).
270
+ Cross-relation subject check on N100: no overlap.
271
+
272
+ Output files:
273
+ data/processed/examples.parquet (2700 rows)
274
+ data/processed/relations.json
275
+ data/processed/dataset_manifest.json
276
+
277
+ Manifest hashes:
278
+ raw_data: d017056125178a13728594e66a801357a8db9ed7973a7425554bb4271de9fc6f
279
+ output: 5f526e216cbc5e1db494ca62340ecaad42c4515045ede33ec3658bde958a2d8d
280
+
281
+ Examples per subset:
282
+ N50: 600 (6 relations x 50 pairs x 2 labels)
283
+ N75: 900 (6 relations x 75 pairs x 2 labels)
284
+ N100: 1200 (6 relations x 100 pairs x 2 labels)
285
+
286
+ P103 French counts in selected subsets:
287
+ N50: 20/50 = 40% (cap: 20)
288
+ N75: 30/75 = 40% (cap: 30)
289
+ N100: 40/100 = 40% (cap: 40)
290
+
291
+ Note: Stage 4 (sentence dedup) removed 0 records across all relations.
292
+ The earlier estimate of 3 duplicate sentences in P176 was based on a
293
+ raw-data scan before subject deduplication; those duplicates were
294
+ already eliminated in Stage 2 (within-relation subject dedup).
295
+
296
+ Data-quality observation: attribute marginals verified to match exactly
297
+ between true and false examples at every relation x subset level. The
298
+ derangement shift algorithm guarantees this algebraically (permutation
299
+ preserves multiset), confirmed empirically.
300
+
301
+
302
+ NNsight implementation note
303
+ ----------------------------
304
+ NNsight 0.7.0 does not trace Python for-loops inside the
305
+ model.trace() context manager. Any .save() calls inside a for-loop
306
+ are silently dropped — the trace completes but returns no tensor data
307
+ (only ~341 bytes of metadata).
308
+
309
+ Workaround: unroll layer saves as four explicit statements. Since
310
+ Phase 2 always extracts exactly four depths, this is straightforward.
311
+ This behaviour was discovered during the pilot and is documented
312
+ here so future scripts do not repeat the debugging.
313
+
314
+
315
+ Pilot timing record (2026-07-12)
316
+ ----------------------------------
317
+ Script: extract_activations.py --pilot
318
+ Conda env: blackboxnlp-ndif
319
+ Pilot relation: P19
320
+ Pilot subset: N50 (50 pairs = 100 sentences)
321
+
322
+ Token position strategy: last real token in tokenised sequence.
323
+ Because the attribute is always the final word(s) in the sentence
324
+ (by construction in make_sentence()), the last token IS the final
325
+ subtoken of the target attribute.
326
+
327
+ 8B (meta-llama/Llama-3.1-8B):
328
+ Layers extracted: 7, 15, 23, 31 (depths 25%, 50%, 75%, 100%)
329
+ Wall clock: 171.3s
330
+ Per sentence: 1.71s
331
+ Activation shape: (100, 4096) per layer, dtype float16
332
+
333
+ 70B (meta-llama/Llama-3.1-70B):
334
+ Layers extracted: 19, 39, 59, 79 (depths 25%, 50%, 75%, 100%)
335
+ Wall clock: 231.9s
336
+ Per sentence: 2.32s
337
+ Activation shape: (100, 8192) per layer, dtype float16
338
+
339
+ Estimated full extraction times:
340
+ N50: 8B=17min + 70B=23min = 40min total
341
+ N75: 8B=26min + 70B=35min = 60min total
342
+ N100: 8B=34min + 70B=46min = 81min total
343
+
344
+ Pilot activations saved to activations/pilot/ for shape validation.
345
+ To be discarded after N_final is frozen.
346
+ Full timing evidence saved to sample_size_decision.json.
347
+
348
+
349
+ N_final decision (2026-07-12)
350
+ -------------------------------
351
+ N_final = 100 pairs per relation
352
+ Total sentences: 1200 (6 relations x 100 pairs x 2 labels)
353
+ Estimated extraction: ~81 min (8B: 34min, 70B: 46min)
354
+ Rationale: well within remaining time budget; 6+ hours reserved
355
+ for probing, validation, figures, and debugging.
356
+
357
+ Pilot activations discarded after shape validation.
358
+ Timing evidence preserved in sample_size_decision.json.
359
+
360
+
361
+ Full extraction record (2026-07-12)
362
+ --------------------------------------
363
+ Script: extract_activations.py --subset N100
364
+ Conda env: blackboxnlp-ndif
365
+
366
+ 8B (meta-llama/Llama-3.1-8B):
367
+ Layers: 7, 15, 23, 31 (depths 25%, 50%, 75%, 100%)
368
+ Sentences: 1200
369
+ Wall clock: 1957s (32.6 min)
370
+ Per sentence: 1.63s
371
+ Shape: (1200, 4096) per layer, dtype float16
372
+
373
+ 70B (meta-llama/Llama-3.1-70B):
374
+ Layers: 19, 39, 59, 79 (depths 25%, 50%, 75%, 100%)
375
+ Sentences: 1200
376
+ Wall clock: 2818s (47.0 min)
377
+ Per sentence: 2.35s
378
+ Shape: (1200, 8192) per layer, dtype float16
379
+
380
+ Total extraction: 4775s (79.6 min)
381
+ Estimated was 81 min — actual within 2% of estimate.
382
+
383
+ Dataset hash (both models): 7ef95d79b694631d
384
+ Token position: last real token (final subtoken of target attribute)
385
+
386
+ Output files:
387
+ activations/llama_3_1_8b/layer_{7,15,23,31}.npy
388
+ activations/llama_3_1_8b/sample_index.parquet
389
+ activations/llama_3_1_8b/manifest.json
390
+ activations/llama_3_1_70b/layer_{19,39,59,79}.npy
391
+ activations/llama_3_1_70b/sample_index.parquet
392
+ activations/llama_3_1_70b/manifest.json
393
+
394
+
395
+ Checklist: filled after later stages
396
+ --------------------------------------
397
+ [x] Split seed: 2026071203
398
+ [x] Per-relation fold counts: 34/33/33 for all six relations
399
+ Same-pair constraint enforced: true/false in same fold.
400
+ Downstream join on example_id, not row index.
401
+ [x] Observed tokenisation edge cases: none encountered.
402
+ [x] Final figure paths: see "Output figures" section below.
403
+
404
+
405
+ Probing execution record (2026-07-12)
406
+ ---------------------------------------
407
+ Script: run_probing.py
408
+ Conda env: blackboxnlp
409
+ Config: experiment_config.json (hash: 667540b0fa890cca)
410
+
411
+ Probe: StandardScaler + LogisticRegression(solver=lbfgs, C=1.0,
412
+ penalty=l2, max_iter=1000, tol=0.0001, fit_intercept=True,
413
+ class_weight=None, random_state=42)
414
+ Scaler fitted only on each probe's training set.
415
+ ConvergenceWarning monitored: none triggered (all 204 probes converged).
416
+
417
+ Stage 1A (within-relation 3-fold CV):
418
+ 144 fits (6 relations × 4 depths × 3 folds × 2 models)
419
+
420
+ Stage 1B (leave-one-relation-out):
421
+ 48 fits (6 relations × 4 depths × 2 models)
422
+
423
+ Layer selection:
424
+ 8B: layer 7 (depth=0.25, mean_auc=0.9620, best=0.9660)
425
+ Within 0.005 tolerance → selected shallowest qualifying layer.
426
+ 70B: layer 39 (depth=0.50, mean_auc=0.9770, best=0.9770)
427
+ Unique best — no tie-breaking needed.
428
+
429
+ Stage 2 (6×6 transfer matrix at selected layer):
430
+ 12 full-source fits (6 sources × 2 models)
431
+ 60 off-diagonal evaluations
432
+ Diagonal: mean 3-fold within AUC from Stage 1A
433
+
434
+ Total: 204 probes fitted, 204 npz + manifest saved.
435
+ Stage 2 predictions: 12,000 rows (off-diagonal only).
436
+
437
+ Output files:
438
+ results/stage1_metrics.csv (192 rows: 1A + 1B)
439
+ results/stage2_metrics.csv (60 rows: off-diagonal)
440
+ results/generality_gap.csv (48 rows)
441
+ results/stage1_predictions.parquet (19,200 rows: 1A + 1B)
442
+ results/stage2_predictions.parquet (12,000 rows: off-diagonal only)
443
+ results/stage2_matrix_8b.csv
444
+ results/stage2_matrix_70b.csv
445
+ results/selected_layers.json
446
+ results/probe_weights/ (204 npz + 204 manifest json)
447
+
448
+ Relation order (fixed for all figures and matrices):
449
+ P19, P103, P101, P159, P176, P138
450
+
451
+
452
+ Output figures (2026-07-12)
453
+ ----------------------------
454
+ Script: generate_figures.py
455
+ Conda env: blackboxnlp
456
+ Colors: 8B = #2a78d6 (blue), 70B = #1baf7a (green/aqua)
457
+
458
+ figures/fig1_depth_profile.{pdf,png}
459
+ figures/fig2_generality_gap.{pdf,png}
460
+ figures/fig3_transfer_matrices.{pdf,png}
461
+ figures/fig4_relation_gap_detail.{pdf,png}
462
+ figures/fig5_relation_profiles.{pdf,png}
463
+ results/table1_relation_results.csv
464
+
465
+
466
+ ===============================================================
467
+ PAPER-WRITING REFERENCE (below this line)
468
+ ===============================================================
469
+
470
+ Experiment summary
471
+ --------------------
472
+ Research question:
473
+ Does model scale make a linearly decodable truth representation
474
+ more transferable across factual relations?
475
+
476
+ Design:
477
+ - Two models: Llama-3.1-8B (32 layers) and Llama-3.1-70B (80 layers)
478
+ - Six semantically diverse CounterFact relations:
479
+ P19 (place of birth), P103 (native language),
480
+ P101 (field of work), P159 (headquarters location),
481
+ P176 (manufacturer), P138 (named after)
482
+ - 100 factual pairs per relation (N100), 1200 sentences total
483
+ - Derangement-based negatives: a permutation that preserves
484
+ exact attribute marginals between true and false examples
485
+ - Four normalised depths per model: 25%, 50%, 75%, 100%
486
+ - Probe: StandardScaler + L2-regularised logistic regression
487
+ - Three evaluation stages:
488
+ 1A. Within-relation 3-fold CV (pair-grouped)
489
+ 1B. Leave-one-relation-out (train on 5, test on 1)
490
+ 2. 6×6 pairwise transfer matrix at each model's best layer
491
+ - Generality gap = within-relation mean AUC − leave-one-out AUC
492
+ (positive = within > leave-one-out = relation-specific;
493
+ negative = leave-one-out > within = more general)
494
+ - Activations extracted via NNsight + NDIF (remote inference)
495
+
496
+
497
+ Figure-by-figure interpretation
498
+ ----------------------------------
499
+
500
+ Fig 1: Depth profile (fig1_depth_profile.pdf)
501
+ ................................................
502
+ Shows mean ROC-AUC across all six relations at each normalised
503
+ depth, separately for within-relation 3-fold CV and leave-one-out,
504
+ for both models. Error bars = SD across 6 relations.
505
+ Background colour bands mark each model's selected layer depth.
506
+
507
+ Key observations:
508
+ - 70B achieves uniformly higher AUC than 8B at every depth in
509
+ both evaluation protocols.
510
+ - Both models peak in the first half of the network (8B at 25%,
511
+ 70B at 50%), consistent with truth-relevant features being
512
+ encoded relatively early.
513
+ - 70B's within and leave-one-out curves track each other closely
514
+ (small gap), whereas 8B's curves diverge more, especially at
515
+ deeper layers. This is the visual signature of better cross-
516
+ relation transfer at larger scale.
517
+ - The decline at depth 100% is steeper for 8B than 70B.
518
+
519
+ Caption requirements:
520
+ - State that error bars are SD across 6 relations, not SE.
521
+ - Note background bands mark the selected layer per model.
522
+ - Clarify that within = mean 3-fold CV AUC, leave-one-out =
523
+ train-on-5-relations AUC.
524
+
525
+ Fig 2: Generality gap summary (fig2_generality_gap.pdf)
526
+ .........................................................
527
+ Grouped bar chart showing mean |gap| per depth for each model.
528
+
529
+ Key observations:
530
+ - 70B has smaller mean absolute generality gap at every depth:
531
+ depth 0.25: 70B 0.004 vs 8B 0.018
532
+ depth 0.50: 70B 0.003 vs 8B 0.011
533
+ depth 0.75: 70B 0.008 vs 8B 0.032
534
+ depth 1.00: 70B 0.025 vs 8B 0.048
535
+ - The gap advantage of 70B is most pronounced in the middle
536
+ layers (50–75%) and narrows at depth 100%.
537
+ - This directly addresses the RQ: scaling from 8B to 70B
538
+ reduces the difference between within-relation and cross-
539
+ relation probe performance.
540
+
541
+ Caption requirements:
542
+ - Define generality gap as within-relation mean AUC minus
543
+ leave-one-out AUC.
544
+ - State that bars show the mean absolute gap over 6 relations.
545
+
546
+ Fig 3: Transfer matrices (fig3_transfer_matrices.pdf)
547
+ ......................................................
548
+ Two 6×6 heatmaps side by side (8B left, 70B right) at each
549
+ model's selected layer. Rows = source relation, columns =
550
+ target relation. Diagonal = within-relation mean 3-fold CV AUC
551
+ (cross-validated). Off-diagonal = AUC from a probe trained on
552
+ the full source relation and evaluated on the full target.
553
+
554
+ Key observations:
555
+ - 70B off-diagonal values are uniformly higher than 8B (mean
556
+ off-diagonal: 70B ~0.972, 8B ~0.943).
557
+ - P19 (place of birth) is the weakest target for both models;
558
+ transferring into P19 yields the lowest values in both
559
+ matrices (8B: 0.849–0.918, 70B: 0.931–0.970).
560
+ - P176 and P138 are "easy" targets: nearly every source
561
+ relation transfers well to them at both scales.
562
+ - 70B shows a more uniform matrix with less row/column
563
+ variation, suggesting that the representation is more
564
+ relation-agnostic.
565
+ - The P19/P103 biographical pair does NOT show obviously
566
+ elevated mutual transfer relative to other pairs — this
567
+ is discussed under "Cannot claim" below.
568
+
569
+ Caption requirements:
570
+ - State that rows are source relations, columns are targets.
571
+ - State that diagonal values are mean 3-fold CV AUC (cross-
572
+ validated) and off-diagonal values come from probes trained
573
+ on the entire source relation.
574
+ - State which layer is shown per model (8B: layer 7 / depth
575
+ 25%; 70B: layer 39 / depth 50%).
576
+
577
+ Fig 4: Relation-level gap detail (fig4_relation_gap_detail.pdf)
578
+ ................................................................
579
+ Horizontal diverging bar chart showing the signed generality
580
+ gap per relation at each model's selected layer. Positive =
581
+ within > leave-one-out (probe loses accuracy on unseen
582
+ relations). Negative = leave-one-out > within (probe gains
583
+ from multi-relation training). Labels show the numeric gap
584
+ value.
585
+
586
+ Key observations:
587
+ - P138 (named after) has the largest positive gap in 8B
588
+ (+0.048) but essentially zero in 70B (+0.001). This is
589
+ the single most dramatic per-relation scaling effect.
590
+ - P101 (field of work) in 8B also shows a notable positive
591
+ gap (+0.031) that shrinks to 0.000 in 70B.
592
+ - Negative gaps (P19, P159) indicate that multi-relation
593
+ training can help: probes trained on five other relations
594
+ slightly outperform within-relation probes for these
595
+ targets. This is consistent across both scales.
596
+ - 70B's gaps are compressed toward zero on both sides,
597
+ meaning it is not just that 70B is better at within-relation
598
+ probing — its representation is also more transferable.
599
+
600
+ Caption requirements:
601
+ - Define positive and negative gap direction.
602
+ - State that values are at each model's selected layer.
603
+
604
+ Fig 5: Relation depth profiles (fig5_relation_profiles.pdf)
605
+ .............................................................
606
+ 2×3 small-multiple grid showing per-relation within-relation
607
+ AUC across the four depths for both models. Each panel is one
608
+ of the six relations.
609
+
610
+ Key observations:
611
+ - P176 and P138 are near ceiling (>0.99) for 70B at all
612
+ depths; 8B is also very high (>0.97).
613
+ - P19 is the hardest relation at both scales but still well
614
+ above chance (8B: 0.836–0.896, 70B: 0.935–0.950).
615
+ - The depth profiles are broadly similar across relations:
616
+ both models tend to peak early and decline at depth 100%.
617
+ - 70B shows a flatter profile (less depth-dependence) for
618
+ most relations compared to 8B.
619
+
620
+ Caption requirements:
621
+ - State that each panel shows within-relation mean 3-fold CV
622
+ AUC across four normalised depths.
623
+ - State that error bars or shaded bands (if present) are SD
624
+ across the 3 folds.
625
+
626
+ Table 1: Relation results (table1_relation_results.csv)
627
+ ........................................................
628
+ Columns: Relation, 8B within, 8B std, 8B leave-one-out,
629
+ 8B gap, 70B within, 70B std, 70B leave-one-out, 70B gap.
630
+ Values are at each model's selected layer.
631
+ Mean row: mean gap uses the signed mean, not the mean of
632
+ absolute values.
633
+
634
+ Key numbers:
635
+ Mean 8B within AUC: 0.962 (SD 0.013)
636
+ Mean 8B leave-one-out AUC: 0.953
637
+ Mean 8B gap: +0.009
638
+
639
+ Mean 70B within AUC: 0.977 (SD 0.007)
640
+ Mean 70B leave-one-out AUC: 0.979
641
+ Mean 70B gap: −0.002
642
+
643
+ Interpretation:
644
+ - 70B has higher within-relation AUC (0.977 vs 0.962) and
645
+ even slightly higher leave-one-out AUC than within — the
646
+ mean gap is slightly negative (−0.002), meaning cross-
647
+ relation training marginally helps on average.
648
+ - 8B's mean gap is +0.009, meaning within-relation probes
649
+ are slightly better on average — there is a small cost
650
+ to generalising.
651
+ - 70B has lower within-relation SD (0.007 vs 0.013),
652
+ indicating more consistent performance across relations.
653
+
654
+ Caption requirements:
655
+ - State that values are at each model's selected layer
656
+ (8B layer 7 / 25%, 70B layer 39 / 50%).
657
+ - Define gap = within − leave-one-out.
658
+
659
+
660
+ Core conclusions
661
+ ------------------
662
+ 1. Cross-relation truth signal exists at both scales: leave-one-
663
+ out probes trained on five unrelated relations substantially
664
+ exceed chance when tested on the sixth, for all six relations
665
+ and at all four depths tested.
666
+
667
+ 2. Scaling improves transferability: 70B has a smaller mean
668
+ absolute generality gap at every depth. At the selected layers,
669
+ 70B's signed mean gap is −0.002 (essentially zero / slightly
670
+ negative) versus 8B's +0.009.
671
+
672
+ 3. The 70B transfer matrix is more uniform: off-diagonal AUC
673
+ values are higher and less variable than 8B. The 70B
674
+ representation at its best layer is more relation-agnostic.
675
+
676
+ 4. Relation identity still matters: P19 (place of birth) is
677
+ consistently the hardest target. P176 (manufacturer) and P138
678
+ (named after) are the easiest. This variation persists at both
679
+ scales, though it is attenuated in 70B.
680
+
681
+
682
+ What CANNOT be claimed from these results
683
+ --------------------------------------------
684
+ 1. No universal truth direction: we observe cross-relation
685
+ linear decodability of truth labels, not a single truth
686
+ direction. The probes at different source relations may use
687
+ different linear combinations. The transfer matrix shows that
688
+ these linear combinations generalise, but we have not shown
689
+ (nor tested) that a single vector separates true from false
690
+ across all relations simultaneously.
691
+
692
+ 2. No causal claim: probing shows that truth-correlated
693
+ information is linearly decodable from the residual stream.
694
+ It does not demonstrate that the model uses this information
695
+ for prediction. Causal interventions (e.g., activation
696
+ patching, causal tracing) would be needed for that claim.
697
+
698
+ 3. Lexical confounds not fully excluded: the derangement
699
+ guarantees identical attribute marginals, eliminating the most
700
+ obvious unigram leakage. However, more subtle lexical or
701
+ distributional cues (e.g., subject–attribute co-occurrence
702
+ patterns in pretraining data) are not controlled for. The
703
+ optional TF-IDF baseline described in the plan was not run.
704
+
705
+ 4. No P19–P103 biographical cluster: we hypothesised ex ante
706
+ that the biographical pair (P19 place of birth, P103 native
707
+ language) might show stronger mutual transfer. The transfer
708
+ matrices do not support this: P19→P103 and P103→P19 are not
709
+ notably elevated relative to other source–target pairs. This
710
+ is an informative null — shared subject type does not
711
+ automatically yield privileged transfer.
712
+
713
+
714
+ Limitations and caveats
715
+ --------------------------
716
+ 1. Six relations only: the experiment covers six of the ~100
717
+ relations in CounterFact. Results may not generalise to
718
+ relations with very different structures (e.g., temporal,
719
+ numerical, or multi-hop relations).
720
+
721
+ 2. Sample size: 100 pairs per relation (200 examples per
722
+ relation). This is sufficient for the linear probes used
723
+ here but small by the standards of some probing studies.
724
+
725
+ 3. Single dataset: all data comes from CounterFact. Template-
726
+ generated sentences may contain distributional artifacts not
727
+ present in naturalistic text.
728
+
729
+ 4. Linear probe only: a linear probe tests linear decodability.
730
+ A nonlinear probe (e.g., MLP) might find additional signal
731
+ or show different scaling behaviour.
732
+
733
+ 5. NDIF-served models: activations were extracted via NNsight +
734
+ NDIF remote inference. We do not control exact batch
735
+ composition on the server side. Determinism is ensured by
736
+ per-sentence extraction and shape verification, but
737
+ floating-point non-determinism at the hardware level is
738
+ possible.
739
+
740
+ 6. Leave-one-out sample size asymmetry: the within-relation
741
+ probe trains on ~67 pairs (2 folds of 100), while the
742
+ leave-one-out probe trains on 500 pairs (5 relations × 100).
743
+ The leave-one-out probe sees ~7.5× more training data. The
744
+ generality gap therefore confounds transferability with
745
+ training-set size. This limitation should be acknowledged
746
+ in the paper; it is standard for LOO designs but worth
747
+ stating.
748
+
749
+ 7. Controls not run: the plan described two optional controls —
750
+ (a) a TF-IDF bag-of-words probe as a surface-feature
751
+ baseline, and (b) a random-labels sanity check. Neither was
752
+ run in this execution. The derangement design provides the
753
+ primary methodological control; the TF-IDF baseline would
754
+ strengthen the argument but is not essential.
755
+
756
+ 8. Two model scales only: with just two points (8B and 70B),
757
+ the relationship between scale and transferability is a
758
+ comparison, not a trend. We cannot extrapolate to smaller
759
+ or larger models.
760
+
761
+
762
+ Phase 1 ↔ Phase 2 narrative connection
763
+ -----------------------------------------
764
+ Phase 1 (reproduction/ablation) showed that in a controlled
765
+ synthetic setting, breaking cross-pair truth co-occurrence
766
+ removes truth decodability from a fully trainable model while
767
+ preserving factual memorization. This established that truth
768
+ decodability is a function of statistical structure in the
769
+ training data, not an automatic byproduct of storing factual
770
+ knowledge.
771
+
772
+ Phase 2 asks the natural follow-up question: given that truth
773
+ decodability exists in pretrained language models, how does it
774
+ behave across relations, and does model scale affect its
775
+ generality?
776
+
777
+ The connection:
778
+ - Phase 1 shows truth decodability is contingent (can be
779
+ removed). Phase 2 shows it is general (transfers across
780
+ relations) and that this generality is scale-dependent.
781
+ - Phase 1 uses a controlled toy model to isolate the mechanism.
782
+ Phase 2 uses production-scale LLMs to test whether the
783
+ phenomenon matters in practice.
784
+ - Together they argue that truth representations in LLMs are
785
+ (a) not an artifact of model architecture but of data
786
+ structure, and (b) more transferable across factual domains
787
+ at larger scale, suggesting that scaling encourages more
788
+ abstract, relation-agnostic truth representations.
789
+
790
+ The paper should present Phase 1 as establishing the mechanism
791
+ and Phase 2 as testing its ecological validity at scale. The
792
+ shared methodological thread is linear probing of truth labels
793
+ with controlled negatives.
794
+
795
+
796
+ Complete file inventory
797
+ -------------------------
798
+ Data:
799
+ data/raw/counterfact.json
800
+ data/processed/examples.parquet (2700 rows, all 3 subset levels)
801
+ data/processed/relations.json
802
+ data/processed/splits.parquet
803
+ data/processed/dataset_manifest.json
804
+
805
+ Activations:
806
+ activations/llama_3_1_8b/layer_{7,15,23,31}.npy
807
+ activations/llama_3_1_8b/sample_index.parquet
808
+ activations/llama_3_1_8b/manifest.json (includes file_sha256)
809
+ activations/llama_3_1_70b/layer_{19,39,59,79}.npy
810
+ activations/llama_3_1_70b/sample_index.parquet
811
+ activations/llama_3_1_70b/manifest.json (includes file_sha256)
812
+
813
+ Results:
814
+ results/stage1_metrics.csv (192 rows)
815
+ results/stage2_metrics.csv (60 rows)
816
+ results/generality_gap.csv (48 rows)
817
+ results/stage1_predictions.parquet (19,200 rows)
818
+ results/stage2_predictions.parquet (12,000 rows)
819
+ results/stage2_matrix_8b.csv
820
+ results/stage2_matrix_70b.csv
821
+ results/selected_layers.json
822
+ results/table1_relation_results.csv
823
+ results/probe_weights/ (204 npz + 204 manifest json)
824
+
825
+ Figures:
826
+ figures/fig1_depth_profile.{pdf,png}
827
+ figures/fig2_generality_gap.{pdf,png}
828
+ figures/fig3_transfer_matrices.{pdf,png}
829
+ figures/fig4_relation_gap_detail.{pdf,png}
830
+ figures/fig5_relation_profiles.{pdf,png}
831
+
832
+ Scripts:
833
+ prepare_counterfact_multirelation.py
834
+ extract_activations.py
835
+ run_probing.py
836
+ generate_figures.py
837
+
838
+ Configuration:
839
+ experiment_config.json
840
+ sample_size_decision.json
841
+ phase2_final_plan.md
842
+ phase2_notes.txt (this file)
phase2_scaling/prepare_counterfact_multirelation.py ADDED
@@ -0,0 +1,552 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Prepare multi-relation CounterFact dataset for Phase 2 scaling experiment.
2
+
3
+ Processes six CounterFact relations into balanced true/false sentence pairs
4
+ with derangement-based negative construction. Produces nested N50/N75/N100
5
+ subsets for the timing-gate sample-size selection.
6
+
7
+ Run from workspace/reproduction/scaling/ under the blackboxnlp conda env:
8
+ python prepare_counterfact_multirelation.py
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ import hashlib
14
+ import json
15
+ import random
16
+ from collections import Counter, defaultdict
17
+ from pathlib import Path
18
+ from typing import Any
19
+
20
+ import pandas as pd
21
+
22
+ SEED = 20260712
23
+
24
+ RELATIONS = ["P19", "P103", "P176", "P101", "P159", "P138"]
25
+ RELATION_NAMES = {
26
+ "P19": "place of birth",
27
+ "P103": "native language",
28
+ "P176": "manufacturer",
29
+ "P101": "field of work",
30
+ "P159": "headquarters location",
31
+ "P138": "named after",
32
+ }
33
+
34
+ SUBSET_SIZES = [("N50", 50), ("N75", 75), ("N100", 100)]
35
+
36
+ P103_FRENCH_CAPS = {"N50": 20, "N75": 30, "N100": 40}
37
+
38
+ ROOT = Path(__file__).resolve().parent
39
+ RAW_PATH = ROOT / "data" / "raw" / "counterfact.json"
40
+ OUTPUT_DIR = ROOT / "data" / "processed"
41
+
42
+
43
+ def make_sentence(template: str, subject: str, attribute: str) -> str:
44
+ return f"{template.format(subject).rstrip()} {attribute.strip()}"
45
+
46
+
47
+ def load_raw(path: Path) -> list[dict]:
48
+ if not path.exists():
49
+ raise FileNotFoundError(f"Raw CounterFact not found: {path}")
50
+ with path.open("r", encoding="utf-8") as f:
51
+ return json.load(f)
52
+
53
+
54
+ def relation_seed(rel: str) -> int:
55
+ return SEED + RELATIONS.index(rel) * 10007
56
+
57
+
58
+ # ---------------------------------------------------------------------------
59
+ # Cleaning
60
+ # ---------------------------------------------------------------------------
61
+
62
+ def filter_relations(records: list[dict]) -> dict[str, list[dict]]:
63
+ by_rel: dict[str, list[dict]] = defaultdict(list)
64
+ for r in records:
65
+ rel = r["requested_rewrite"]["relation_id"]
66
+ if rel in RELATIONS:
67
+ by_rel[rel].append(r)
68
+ return dict(by_rel)
69
+
70
+
71
+ def dedup_subjects(records: list[dict]) -> list[dict]:
72
+ """Keep lowest case_id per subject."""
73
+ sorted_recs = sorted(records, key=lambda r: r["case_id"])
74
+ seen: set[str] = set()
75
+ out = []
76
+ for r in sorted_recs:
77
+ subj = r["requested_rewrite"]["subject"]
78
+ if subj not in seen:
79
+ seen.add(subj)
80
+ out.append(r)
81
+ return out
82
+
83
+
84
+ def find_cross_relation_subjects(
85
+ by_rel: dict[str, list[dict]],
86
+ ) -> set[str]:
87
+ subj_rels: dict[str, set[str]] = defaultdict(set)
88
+ for rel, recs in by_rel.items():
89
+ for r in recs:
90
+ subj_rels[r["requested_rewrite"]["subject"]].add(rel)
91
+ return {s for s, rels in subj_rels.items() if len(rels) > 1}
92
+
93
+
94
+ def remove_subjects(records: list[dict], subjects: set[str]) -> list[dict]:
95
+ return [r for r in records if r["requested_rewrite"]["subject"] not in subjects]
96
+
97
+
98
+ def dedup_sentences(records: list[dict]) -> list[dict]:
99
+ seen: set[str] = set()
100
+ out = []
101
+ for r in records:
102
+ rw = r["requested_rewrite"]
103
+ sent = make_sentence(rw["prompt"], rw["subject"], rw["target_true"]["str"])
104
+ if sent not in seen:
105
+ seen.add(sent)
106
+ out.append(r)
107
+ return out
108
+
109
+
110
+ # ---------------------------------------------------------------------------
111
+ # Sampling
112
+ # ---------------------------------------------------------------------------
113
+
114
+ def sample_nested(
115
+ records: list[dict],
116
+ rel: str,
117
+ ) -> dict[str, list[dict]]:
118
+ if rel == "P103":
119
+ return _sample_p103(records)
120
+
121
+ rng = random.Random(relation_seed(rel))
122
+ pool = list(records)
123
+ rng.shuffle(pool)
124
+
125
+ subsets = {}
126
+ for name, size in SUBSET_SIZES:
127
+ if size > len(pool):
128
+ raise ValueError(f"{rel}: need {size} records for {name}, have {len(pool)}")
129
+ subsets[name] = sorted(pool[:size], key=lambda r: r["case_id"])
130
+ return subsets
131
+
132
+
133
+ def _sample_p103(records: list[dict]) -> dict[str, list[dict]]:
134
+ french = [r for r in records if r["requested_rewrite"]["target_true"]["str"] == "French"]
135
+ non_french = [r for r in records if r["requested_rewrite"]["target_true"]["str"] != "French"]
136
+
137
+ base = relation_seed("P103")
138
+ rng_fr = random.Random(base + 1)
139
+ rng_oth = random.Random(base + 2)
140
+ rng_fr.shuffle(french)
141
+ rng_oth.shuffle(non_french)
142
+
143
+ subsets = {}
144
+ for name, size in SUBSET_SIZES:
145
+ cap = P103_FRENCH_CAPS[name]
146
+ n_other = size - cap
147
+ if cap > len(french):
148
+ raise ValueError(f"P103: need {cap} French for {name}, have {len(french)}")
149
+ if n_other > len(non_french):
150
+ raise ValueError(f"P103: need {n_other} non-French for {name}, have {len(non_french)}")
151
+ selected = french[:cap] + non_french[:n_other]
152
+ subsets[name] = sorted(selected, key=lambda r: r["case_id"])
153
+ return subsets
154
+
155
+
156
+ # ---------------------------------------------------------------------------
157
+ # Derangement
158
+ # ---------------------------------------------------------------------------
159
+
160
+ def construct_derangement(
161
+ records: list[dict],
162
+ ) -> list[tuple[dict, str, int]]:
163
+ """Attribute-shifted derangement.
164
+
165
+ Sort records by (attribute, case_id), then shift indices by max group
166
+ size. Since max_group <= n//2, the shifted block never overlaps the
167
+ original block for any attribute, guaranteeing no self-match.
168
+
169
+ Returns (record, false_attribute, source_case_id) for each record.
170
+ """
171
+ n = len(records)
172
+ attrs = [r["requested_rewrite"]["target_true"]["str"] for r in records]
173
+
174
+ sorted_idx = sorted(range(n), key=lambda i: (attrs[i], records[i]["case_id"]))
175
+ sorted_attrs = [attrs[i] for i in sorted_idx]
176
+
177
+ max_group = max(Counter(attrs).values())
178
+ if max_group > n // 2:
179
+ attr_counts = Counter(attrs).most_common(3)
180
+ raise ValueError(
181
+ f"Derangement impossible: max group {max_group} > n//2={n // 2}. "
182
+ f"Top attributes: {attr_counts}"
183
+ )
184
+
185
+ shift = max_group
186
+ result: list[tuple[dict, str, int]] = []
187
+ for pos, orig_i in enumerate(sorted_idx):
188
+ target_pos = (pos + shift) % n
189
+ target_i = sorted_idx[target_pos]
190
+ false_attr = attrs[target_i]
191
+ assert false_attr != attrs[orig_i], (
192
+ f"Self-match at pos {pos}: {false_attr}"
193
+ )
194
+ result.append((records[orig_i], false_attr, records[target_i]["case_id"]))
195
+
196
+ return result
197
+
198
+
199
+ # ---------------------------------------------------------------------------
200
+ # Example construction
201
+ # ---------------------------------------------------------------------------
202
+
203
+ def build_examples(
204
+ deranged: list[tuple[dict, str, int]],
205
+ subset_name: str,
206
+ ) -> list[dict]:
207
+ examples = []
208
+ for record, false_attr, source_case_id in deranged:
209
+ rw = record["requested_rewrite"]
210
+ cid = record["case_id"]
211
+ subj = rw["subject"]
212
+ tpl = rw["prompt"]
213
+ true_attr = rw["target_true"]["str"]
214
+ rel = rw["relation_id"]
215
+
216
+ common = {
217
+ "pair_id": f"{rel}_{subset_name}_{cid}",
218
+ "case_id": cid,
219
+ "relation_id": rel,
220
+ "subject": subj,
221
+ "template": tpl,
222
+ "true_attribute": true_attr,
223
+ "false_attribute_source_id": source_case_id,
224
+ "subset": subset_name,
225
+ }
226
+ examples.append({
227
+ **common,
228
+ "example_id": f"{rel}_{subset_name}_{cid}_true",
229
+ "used_attribute": true_attr,
230
+ "sentence": make_sentence(tpl, subj, true_attr),
231
+ "label": 1,
232
+ })
233
+ examples.append({
234
+ **common,
235
+ "example_id": f"{rel}_{subset_name}_{cid}_false",
236
+ "used_attribute": false_attr,
237
+ "sentence": make_sentence(tpl, subj, false_attr),
238
+ "label": 0,
239
+ })
240
+ return examples
241
+
242
+
243
+ # ---------------------------------------------------------------------------
244
+ # Validation
245
+ # ---------------------------------------------------------------------------
246
+
247
+ def validate_subset(
248
+ examples: list[dict],
249
+ subset_name: str,
250
+ rel: str,
251
+ ) -> dict[str, Any]:
252
+ true_ex = [e for e in examples if e["label"] == 1]
253
+ false_ex = [e for e in examples if e["label"] == 0]
254
+ errors: list[str] = []
255
+
256
+ expected = dict(SUBSET_SIZES)[subset_name]
257
+ if len(true_ex) != expected:
258
+ errors.append(f"Expected {expected} pairs, got {len(true_ex)}")
259
+ if len(true_ex) != len(false_ex):
260
+ errors.append(f"Class imbalance: {len(true_ex)} true vs {len(false_ex)} false")
261
+
262
+ ids = [e["example_id"] for e in examples]
263
+ if len(ids) != len(set(ids)):
264
+ errors.append("Duplicate example_ids")
265
+
266
+ sents = [e["sentence"] for e in examples]
267
+ if len(sents) != len(set(sents)):
268
+ n_dup = len(sents) - len(set(sents))
269
+ errors.append(f"{n_dup} duplicate sentences")
270
+
271
+ subjects = [e["subject"] for e in true_ex]
272
+ if len(subjects) != len(set(subjects)):
273
+ errors.append("Duplicate subjects")
274
+
275
+ for e in false_ex:
276
+ if e["used_attribute"] == e["true_attribute"]:
277
+ errors.append(f"false==true for case_id {e['case_id']}")
278
+ break
279
+
280
+ true_marginals = Counter(e["used_attribute"] for e in true_ex)
281
+ false_marginals = Counter(e["used_attribute"] for e in false_ex)
282
+ marginals_match = true_marginals == false_marginals
283
+ if not marginals_match:
284
+ errors.append("Attribute marginals differ between true and false")
285
+
286
+ if rel == "P103":
287
+ n_french = sum(1 for e in true_ex if e["true_attribute"] == "French")
288
+ expected_cap = P103_FRENCH_CAPS[subset_name]
289
+ if n_french != expected_cap:
290
+ errors.append(f"P103 French count {n_french} != cap {expected_cap}")
291
+
292
+ return {
293
+ "relation_id": rel,
294
+ "subset": subset_name,
295
+ "pairs": len(true_ex),
296
+ "examples": len(examples),
297
+ "unique_subjects": len(set(subjects)),
298
+ "unique_attributes_true": len(true_marginals),
299
+ "unique_attributes_false": len(false_marginals),
300
+ "marginals_match": marginals_match,
301
+ "errors": errors,
302
+ "valid": len(errors) == 0,
303
+ }
304
+
305
+
306
+ def validate_nesting(
307
+ subsets: dict[str, list[dict]],
308
+ rel: str,
309
+ ) -> list[str]:
310
+ """Check N50 ⊂ N75 ⊂ N100 by case_id."""
311
+ errors = []
312
+ ids = {name: {e["example_id"] for e in exs if e["label"] == 1}
313
+ for name, exs in subsets.items()}
314
+ case_ids = {name: {e["case_id"] for e in exs if e["label"] == 1}
315
+ for name, exs in subsets.items()}
316
+
317
+ if not case_ids["N50"] <= case_ids["N75"]:
318
+ errors.append(f"{rel}: N50 not subset of N75")
319
+ if not case_ids["N75"] <= case_ids["N100"]:
320
+ errors.append(f"{rel}: N75 not subset of N100")
321
+ return errors
322
+
323
+
324
+ # ---------------------------------------------------------------------------
325
+ # Output
326
+ # ---------------------------------------------------------------------------
327
+
328
+ def sha256_file(path: Path) -> str:
329
+ h = hashlib.sha256()
330
+ with path.open("rb") as f:
331
+ for chunk in iter(lambda: f.read(8192), b""):
332
+ h.update(chunk)
333
+ return h.hexdigest()
334
+
335
+
336
+ def save_outputs(
337
+ all_examples: list[dict],
338
+ relation_meta: dict[str, Any],
339
+ manifest: dict[str, Any],
340
+ ) -> None:
341
+ OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
342
+
343
+ parquet_path = OUTPUT_DIR / "examples.parquet"
344
+ df = pd.DataFrame(all_examples)
345
+ col_order = [
346
+ "example_id", "pair_id", "case_id", "relation_id", "subject",
347
+ "template", "true_attribute", "used_attribute", "sentence",
348
+ "label", "false_attribute_source_id", "subset",
349
+ ]
350
+ df = df[col_order]
351
+ df.to_parquet(parquet_path, index=False, engine="pyarrow")
352
+ print(f"\nSaved {len(df)} examples to {parquet_path}")
353
+
354
+ manifest["output_hash"] = sha256_file(parquet_path)
355
+
356
+ rel_path = OUTPUT_DIR / "relations.json"
357
+ rel_path.write_text(
358
+ json.dumps(relation_meta, indent=2, ensure_ascii=False) + "\n",
359
+ encoding="utf-8",
360
+ )
361
+
362
+ manifest_path = OUTPUT_DIR / "dataset_manifest.json"
363
+ manifest_path.write_text(
364
+ json.dumps(manifest, indent=2, ensure_ascii=False) + "\n",
365
+ encoding="utf-8",
366
+ )
367
+ print(f"Saved relations.json and dataset_manifest.json")
368
+
369
+
370
+ # ---------------------------------------------------------------------------
371
+ # Main
372
+ # ---------------------------------------------------------------------------
373
+
374
+ def main() -> None:
375
+ print("=" * 60)
376
+ print("CounterFact multi-relation preprocessing")
377
+ print("=" * 60)
378
+
379
+ raw = load_raw(RAW_PATH)
380
+ print(f"Loaded {len(raw)} raw CounterFact records\n")
381
+
382
+ # --- Stage 1: filter ---
383
+ by_rel = filter_relations(raw)
384
+ s1 = {r: len(v) for r, v in by_rel.items()}
385
+ print("Stage 1 — Filter to target relations:")
386
+ for rel in RELATIONS:
387
+ print(f" {rel} ({RELATION_NAMES[rel]}): {s1[rel]}")
388
+
389
+ # --- Stage 2: within-relation subject dedup ---
390
+ for rel in RELATIONS:
391
+ by_rel[rel] = dedup_subjects(by_rel[rel])
392
+ s2 = {r: len(v) for r, v in by_rel.items()}
393
+ print("\nStage 2 — Within-relation subject dedup:")
394
+ for rel in RELATIONS:
395
+ d = s1[rel] - s2[rel]
396
+ print(f" {rel}: {s1[rel]} -> {s2[rel]} ({d} removed)")
397
+
398
+ # --- Stage 3: cross-relation subject removal ---
399
+ cross_subjs = find_cross_relation_subjects(by_rel)
400
+ for rel in RELATIONS:
401
+ by_rel[rel] = remove_subjects(by_rel[rel], cross_subjs)
402
+ s3 = {r: len(v) for r, v in by_rel.items()}
403
+ print(f"\nStage 3 — Cross-relation subject removal ({len(cross_subjs)} subjects):")
404
+ for rel in RELATIONS:
405
+ d = s2[rel] - s3[rel]
406
+ print(f" {rel}: {s2[rel]} -> {s3[rel]} ({d} removed)")
407
+ print(f" Removed subjects: {sorted(cross_subjs)}")
408
+
409
+ # --- Stage 4: sentence dedup ---
410
+ for rel in RELATIONS:
411
+ by_rel[rel] = dedup_sentences(by_rel[rel])
412
+ s4 = {r: len(v) for r, v in by_rel.items()}
413
+ print("\nStage 4 — Sentence dedup:")
414
+ for rel in RELATIONS:
415
+ d = s3[rel] - s4[rel]
416
+ print(f" {rel}: {s3[rel]} -> {s4[rel]} ({d} removed)")
417
+
418
+ # --- P103 attribute distribution after cleaning ---
419
+ p103_attrs = Counter(
420
+ r["requested_rewrite"]["target_true"]["str"] for r in by_rel["P103"]
421
+ )
422
+ n_french = p103_attrs.get("French", 0)
423
+ print(f"\nP103 after cleaning: {s4['P103']} records, "
424
+ f"French={n_french} ({100*n_french/s4['P103']:.1f}%)")
425
+
426
+ # --- Sample, derange, build examples ---
427
+ all_examples: list[dict] = []
428
+ all_validations: list[dict] = []
429
+ nesting_errors: list[str] = []
430
+ relation_meta: dict[str, Any] = {}
431
+
432
+ for rel in RELATIONS:
433
+ print(f"\nProcessing {rel}...")
434
+ subsets_records = sample_nested(by_rel[rel], rel)
435
+
436
+ rel_info: dict[str, Any] = {
437
+ "relation_id": rel,
438
+ "relation_name": RELATION_NAMES[rel],
439
+ "cleaning_counts": {
440
+ "raw": s1[rel],
441
+ "after_subject_dedup": s2[rel],
442
+ "after_cross_relation_removal": s3[rel],
443
+ "after_sentence_dedup": s4[rel],
444
+ },
445
+ "subsets": {},
446
+ }
447
+
448
+ subset_examples: dict[str, list[dict]] = {}
449
+
450
+ for subset_name, size in SUBSET_SIZES:
451
+ recs = subsets_records[subset_name]
452
+ deranged = construct_derangement(recs)
453
+ exs = build_examples(deranged, subset_name)
454
+
455
+ val = validate_subset(exs, subset_name, rel)
456
+ all_validations.append(val)
457
+ subset_examples[subset_name] = exs
458
+ all_examples.extend(exs)
459
+
460
+ attr_dist = Counter(
461
+ r["requested_rewrite"]["target_true"]["str"] for r in recs
462
+ )
463
+ rel_info["subsets"][subset_name] = {
464
+ "pairs": len(recs),
465
+ "examples": len(exs),
466
+ "attribute_distribution": dict(attr_dist.most_common()),
467
+ "unique_templates": len({r["requested_rewrite"]["prompt"] for r in recs}),
468
+ "unique_subjects": len({r["requested_rewrite"]["subject"] for r in recs}),
469
+ "validation": val,
470
+ }
471
+
472
+ status = "PASS" if val["valid"] else f"FAIL: {val['errors']}"
473
+ print(f" {subset_name}: {size} pairs -> {len(exs)} examples {status}")
474
+
475
+ nest_err = validate_nesting(subset_examples, rel)
476
+ nesting_errors.extend(nest_err)
477
+ if nest_err:
478
+ print(f" NESTING ERROR: {nest_err}")
479
+ else:
480
+ print(f" Nesting N50 ⊂ N75 ⊂ N100: OK")
481
+
482
+ relation_meta[rel] = rel_info
483
+
484
+ # --- Cross-relation duplicate check on N100 ---
485
+ n100_subjects: dict[str, set[str]] = defaultdict(set)
486
+ for e in all_examples:
487
+ if e["subset"] == "N100" and e["label"] == 1:
488
+ n100_subjects[e["relation_id"]].add(e["subject"])
489
+ cross_check_errors = []
490
+ for i, r1 in enumerate(RELATIONS):
491
+ for r2 in RELATIONS[i + 1:]:
492
+ overlap = n100_subjects[r1] & n100_subjects[r2]
493
+ if overlap:
494
+ cross_check_errors.append(f"{r1}+{r2}: {len(overlap)} shared subjects")
495
+ if cross_check_errors:
496
+ print(f"\nCROSS-RELATION SUBJECT LEAK: {cross_check_errors}")
497
+ else:
498
+ print("\nCross-relation subject check on N100: OK (no overlap)")
499
+
500
+ # --- Build manifest ---
501
+ manifest: dict[str, Any] = {
502
+ "seed": SEED,
503
+ "relations": RELATIONS,
504
+ "subset_sizes": {name: size for name, size in SUBSET_SIZES},
505
+ "p103_french_caps": P103_FRENCH_CAPS,
506
+ "cleaning_stages": {
507
+ "stage1_raw": s1,
508
+ "stage2_subject_dedup": s2,
509
+ "stage3_cross_relation": s3,
510
+ "stage4_sentence_dedup": s4,
511
+ },
512
+ "cross_relation_subjects": sorted(cross_subjs),
513
+ "total_examples": len(all_examples),
514
+ "examples_per_subset": {
515
+ name: sum(1 for e in all_examples if e["subset"] == name)
516
+ for name, _ in SUBSET_SIZES
517
+ },
518
+ "validation": {
519
+ "all_subset_checks_passed": all(v["valid"] for v in all_validations),
520
+ "nesting_checks_passed": len(nesting_errors) == 0,
521
+ "cross_relation_check_passed": len(cross_check_errors) == 0,
522
+ "checks_passed": sum(1 for v in all_validations if v["valid"]),
523
+ "checks_total": len(all_validations),
524
+ },
525
+ "raw_data_hash": sha256_file(RAW_PATH),
526
+ }
527
+
528
+ save_outputs(all_examples, relation_meta, manifest)
529
+
530
+ # --- Final report ---
531
+ all_passed = (
532
+ all(v["valid"] for v in all_validations)
533
+ and len(nesting_errors) == 0
534
+ and len(cross_check_errors) == 0
535
+ )
536
+ print("\n" + "=" * 60)
537
+ print("VALIDATION SUMMARY")
538
+ print("=" * 60)
539
+ for v in all_validations:
540
+ status = "PASS" if v["valid"] else f"FAIL: {v['errors']}"
541
+ print(f" {v['relation_id']} {v['subset']}: {status}")
542
+ if nesting_errors:
543
+ for err in nesting_errors:
544
+ print(f" NESTING: {err}")
545
+ print(f"\n{'ALL CHECKS PASSED' if all_passed else 'FAILURES DETECTED'}")
546
+
547
+ if not all_passed:
548
+ raise RuntimeError("Validation failures — see output above")
549
+
550
+
551
+ if __name__ == "__main__":
552
+ main()
phase2_scaling/prepare_counterfact_p103.py ADDED
@@ -0,0 +1,214 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Create a controlled, balanced true/false P103 dataset from CounterFact.
2
+
3
+ French occurs in more than half of raw P103 records, making a frequency-
4
+ preserving derangement of all P103 examples mathematically impossible. We
5
+ therefore retain every non-French record and deterministically sample an equal
6
+ number of French records. False attributes then exchange the French and
7
+ non-French pools. Every attribute has exactly the same frequency in both
8
+ labels, and no false sentence retains its own true attribute. This prevents a
9
+ linear probe from succeeding merely because a language name is more frequent
10
+ in one label.
11
+
12
+ Run from any directory:
13
+ python prepare_counterfact_p103.py
14
+ """
15
+
16
+ from __future__ import annotations
17
+
18
+ import json
19
+ import random
20
+ from collections import Counter
21
+ from pathlib import Path
22
+ from typing import Any
23
+
24
+
25
+ SEED = 20260711
26
+ RELATION_ID = "P103"
27
+ ROOT = Path(__file__).resolve().parent
28
+ RAW_PATH = ROOT / "data" / "raw" / "counterfact.json"
29
+ OUTPUT_PATH = ROOT / "data" / "processed" / "counterfact_p103_balanced_pairs.jsonl"
30
+ SUMMARY_PATH = ROOT / "data" / "processed" / "counterfact_p103_balanced_summary.json"
31
+
32
+
33
+ def make_sentence(template: str, subject: str, attribute: str) -> str:
34
+ """Fill CounterFact's subject placeholder and add exactly one word space."""
35
+ return f"{template.format(subject).rstrip()} {attribute.strip()}"
36
+
37
+
38
+ def load_p103_records(path: Path) -> list[dict[str, Any]]:
39
+ if not path.exists():
40
+ raise FileNotFoundError(
41
+ f"Raw CounterFact file is missing: {path}\n"
42
+ "Download it before running this preparation script."
43
+ )
44
+
45
+ with path.open("r", encoding="utf-8") as handle:
46
+ raw_records = json.load(handle)
47
+
48
+ records = [
49
+ record
50
+ for record in raw_records
51
+ if record["requested_rewrite"]["relation_id"] == RELATION_ID
52
+ ]
53
+ if not records:
54
+ raise RuntimeError(f"No records found for relation {RELATION_ID}.")
55
+ return records
56
+
57
+
58
+ def select_balanced_records(
59
+ records: list[dict[str, Any]],
60
+ ) -> tuple[list[dict[str, Any]], str, int]:
61
+ """Balance the dominant attribute against the aggregate of all others."""
62
+ attributes = [record["requested_rewrite"]["target_true"]["str"] for record in records]
63
+ dominant_attribute, dominant_count = Counter(attributes).most_common(1)[0]
64
+ dominant_records = [
65
+ record
66
+ for record in records
67
+ if record["requested_rewrite"]["target_true"]["str"] == dominant_attribute
68
+ ]
69
+ other_records = [record for record in records if record not in dominant_records]
70
+
71
+ if not other_records:
72
+ raise RuntimeError("P103 has no non-dominant attributes to construct negatives from.")
73
+
74
+ rng = random.Random(SEED)
75
+ sampled_dominant = rng.sample(dominant_records, len(other_records))
76
+ selected = sorted(sampled_dominant + other_records, key=lambda record: record["case_id"])
77
+ excluded = dominant_count - len(sampled_dominant)
78
+ return selected, dominant_attribute, excluded
79
+
80
+
81
+ def build_examples(records: list[dict[str, Any]], dominant_attribute: str) -> list[dict[str, Any]]:
82
+ dominant_records = [
83
+ record
84
+ for record in records
85
+ if record["requested_rewrite"]["target_true"]["str"] == dominant_attribute
86
+ ]
87
+ other_records = [record for record in records if record not in dominant_records]
88
+
89
+ false_by_case_id: dict[int, str] = {}
90
+ other_attributes = [record["requested_rewrite"]["target_true"]["str"] for record in other_records]
91
+ random.Random(SEED).shuffle(other_attributes)
92
+ for record, false_attribute in zip(dominant_records, other_attributes):
93
+ false_by_case_id[record["case_id"]] = false_attribute
94
+ for record in other_records:
95
+ false_by_case_id[record["case_id"]] = dominant_attribute
96
+
97
+ examples: list[dict[str, Any]] = []
98
+ for record in records:
99
+ rewrite = record["requested_rewrite"]
100
+ case_id = record["case_id"]
101
+ subject = rewrite["subject"]
102
+ template = rewrite["prompt"]
103
+ true_attribute = rewrite["target_true"]["str"]
104
+ false_attribute = false_by_case_id[case_id]
105
+
106
+ common = {
107
+ "pair_id": case_id,
108
+ "case_id": case_id,
109
+ "relation_id": rewrite["relation_id"],
110
+ "subject": subject,
111
+ "template": template,
112
+ "target_true": true_attribute,
113
+ "target_false": false_attribute,
114
+ "construction": "P103_balanced_dominant_attribute_exchange",
115
+ }
116
+ examples.append(
117
+ {
118
+ **common,
119
+ "example_id": f"{case_id}_true",
120
+ "label": 1,
121
+ "sentence": make_sentence(template, subject, true_attribute),
122
+ }
123
+ )
124
+ examples.append(
125
+ {
126
+ **common,
127
+ "example_id": f"{case_id}_false",
128
+ "label": 0,
129
+ "sentence": make_sentence(template, subject, false_attribute),
130
+ }
131
+ )
132
+
133
+ return examples
134
+
135
+
136
+ def validate(
137
+ source_records: int,
138
+ records: list[dict[str, Any]],
139
+ examples: list[dict[str, Any]],
140
+ dominant_attribute: str,
141
+ excluded_records: int,
142
+ ) -> dict[str, Any]:
143
+ true_examples = [example for example in examples if example["label"] == 1]
144
+ false_examples = [example for example in examples if example["label"] == 0]
145
+
146
+ if len(examples) != 2 * len(records):
147
+ raise AssertionError("Each source record must create exactly two examples.")
148
+ if len(true_examples) != len(false_examples):
149
+ raise AssertionError("The labels are not balanced.")
150
+ if any(example["target_true"] == example["target_false"] for example in examples):
151
+ raise AssertionError("A false example retained its true attribute.")
152
+ if Counter(example["target_true"] for example in true_examples) != Counter(
153
+ example["target_false"] for example in false_examples
154
+ ):
155
+ raise AssertionError("True and false attribute frequencies are not balanced.")
156
+
157
+ return {
158
+ "source": str(RAW_PATH),
159
+ "relation_id": RELATION_ID,
160
+ "seed": SEED,
161
+ "source_records": source_records,
162
+ "selected_records": len(records),
163
+ "excluded_records": excluded_records,
164
+ "dominant_attribute": dominant_attribute,
165
+ "pairs": len(records),
166
+ "examples": len(examples),
167
+ "true_examples": len(true_examples),
168
+ "false_examples": len(false_examples),
169
+ "unique_attributes": len({example["target_true"] for example in true_examples}),
170
+ "validation": {
171
+ "labels_balanced": True,
172
+ "no_false_attribute_equals_its_true_attribute": True,
173
+ "true_false_attribute_frequencies_match": True,
174
+ },
175
+ }
176
+
177
+
178
+ def write_jsonl(path: Path, examples: list[dict[str, Any]]) -> None:
179
+ path.parent.mkdir(parents=True, exist_ok=True)
180
+ with path.open("w", encoding="utf-8") as handle:
181
+ for example in examples:
182
+ handle.write(json.dumps(example, ensure_ascii=False) + "\n")
183
+
184
+
185
+ def main() -> None:
186
+ source_records = load_p103_records(RAW_PATH)
187
+ records, dominant_attribute, excluded_records = select_balanced_records(source_records)
188
+ examples = build_examples(records, dominant_attribute)
189
+ summary = validate(
190
+ len(source_records), records, examples, dominant_attribute, excluded_records
191
+ )
192
+ write_jsonl(OUTPUT_PATH, examples)
193
+ SUMMARY_PATH.write_text(json.dumps(summary, indent=2) + "\n", encoding="utf-8")
194
+
195
+ print("P103 CounterFact preparation completed.")
196
+ print(
197
+ f"Source P103 records: {summary['source_records']}; "
198
+ f"balanced pairs: {summary['pairs']}; examples: {summary['examples']}"
199
+ )
200
+ print(
201
+ f"Balanced dominant attribute: {summary['dominant_attribute']}; "
202
+ f"excluded source records: {summary['excluded_records']}"
203
+ )
204
+ print(f"Output: {OUTPUT_PATH}")
205
+ print("\nFirst five true/false pairs:")
206
+ for index in range(0, min(10, len(examples)), 2):
207
+ true_example, false_example = examples[index], examples[index + 1]
208
+ print(f"\nPair {true_example['pair_id']}")
209
+ print(f" TRUE : {true_example['sentence']}")
210
+ print(f" FALSE: {false_example['sentence']}")
211
+
212
+
213
+ if __name__ == "__main__":
214
+ main()
phase2_scaling/results/generality_gap.csv ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model_key,model_id,layer_index,normalized_depth,target_relation,within_mean_auc,within_std_auc,loo_auc,generality_gap
2
+ llama_3_1_8b,meta-llama/Llama-3.1-8B,7,0.25,P19,0.8955469023886765,0.022668309727661186,0.9149,-0.019353097611323533
3
+ llama_3_1_8b,meta-llama/Llama-3.1-8B,7,0.25,P103,0.9634197167226421,0.006907746310988974,0.96835,-0.004930283277357894
4
+ llama_3_1_8b,meta-llama/Llama-3.1-8B,7,0.25,P101,0.951708285539679,0.016645305624731127,0.9209,0.03080828553967896
5
+ llama_3_1_8b,meta-llama/Llama-3.1-8B,7,0.25,P159,0.9700517813131843,0.022577529258949035,0.9740000000000001,-0.00394821868681583
6
+ llama_3_1_8b,meta-llama/Llama-3.1-8B,7,0.25,P176,0.9976577137634074,0.0026318552518099668,0.9946,0.003057713763407355
7
+ llama_3_1_8b,meta-llama/Llama-3.1-8B,7,0.25,P138,0.9938381931933362,0.006512426318092702,0.9460999999999999,0.047738193193336276
8
+ llama_3_1_8b,meta-llama/Llama-3.1-8B,15,0.5,P19,0.8898598547072911,0.016801446615511882,0.916,-0.026140145292708916
9
+ llama_3_1_8b,meta-llama/Llama-3.1-8B,15,0.5,P103,0.976590641658273,0.018043967384776635,0.97475,0.0018406416582730234
10
+ llama_3_1_8b,meta-llama/Llama-3.1-8B,15,0.5,P101,0.9464560144805505,0.026117313271488796,0.9344,0.012056014480550492
11
+ llama_3_1_8b,meta-llama/Llama-3.1-8B,15,0.5,P159,0.9882221078351937,0.011548991624503286,0.9792000000000001,0.009022107835193638
12
+ llama_3_1_8b,meta-llama/Llama-3.1-8B,15,0.5,P176,0.9985050250857109,0.001392380621491347,0.9934,0.005105025085710979
13
+ llama_3_1_8b,meta-llama/Llama-3.1-8B,15,0.5,P138,0.9962514417531718,0.0064926933386376,0.9827999999999999,0.013451441753171922
14
+ llama_3_1_8b,meta-llama/Llama-3.1-8B,23,0.75,P19,0.8363558516908628,0.03035691098970964,0.9005000000000001,-0.06414414830913728
15
+ llama_3_1_8b,meta-llama/Llama-3.1-8B,23,0.75,P103,0.9639077150873313,0.012684054690592193,0.9414,0.022507715087331293
16
+ llama_3_1_8b,meta-llama/Llama-3.1-8B,23,0.75,P101,0.8999121444072687,0.028287228159289714,0.8527,0.04721214440726873
17
+ llama_3_1_8b,meta-llama/Llama-3.1-8B,23,0.75,P159,0.9536690168964469,0.021463637753379707,0.9753,-0.021630983103553048
18
+ llama_3_1_8b,meta-llama/Llama-3.1-8B,23,0.75,P176,0.998252155612961,0.0022788392178069317,0.984,0.014252155612961004
19
+ llama_3_1_8b,meta-llama/Llama-3.1-8B,23,0.75,P138,0.9909014651071901,0.009542947520784849,0.9664,0.02450146510719009
20
+ llama_3_1_8b,meta-llama/Llama-3.1-8B,31,1.0,P19,0.8604396168881857,0.03582658308296141,0.8906499999999999,-0.030210383111814232
21
+ llama_3_1_8b,meta-llama/Llama-3.1-8B,31,1.0,P103,0.9740664482721734,0.007537447087847342,0.8166499999999999,0.1574164482721735
22
+ llama_3_1_8b,meta-llama/Llama-3.1-8B,31,1.0,P101,0.8603861303609652,0.04129030163167838,0.8746,-0.014213869639034815
23
+ llama_3_1_8b,meta-llama/Llama-3.1-8B,31,1.0,P159,0.9540860529378931,0.01333910531934829,0.9624,-0.008313947062106974
24
+ llama_3_1_8b,meta-llama/Llama-3.1-8B,31,1.0,P176,0.9985405062473323,0.0017924699672771,0.9378500000000001,0.06069050624733219
25
+ llama_3_1_8b,meta-llama/Llama-3.1-8B,31,1.0,P138,0.9771405996634056,0.012282072950116886,0.9577,0.01944059966340561
26
+ llama_3_1_70b,meta-llama/Llama-3.1-70B,19,0.25,P19,0.9345449355672697,0.018533130425995168,0.9428000000000001,-0.008255064432730386
27
+ llama_3_1_70b,meta-llama/Llama-3.1-70B,19,0.25,P103,0.9769277126936768,0.010606938290128152,0.9778,-0.0008722873063231606
28
+ llama_3_1_70b,meta-llama/Llama-3.1-70B,19,0.25,P101,0.9547559584520893,0.00419244994970593,0.9577,-0.002944041547910725
29
+ llama_3_1_70b,meta-llama/Llama-3.1-70B,19,0.25,P159,0.9673856632805987,0.021916527947160487,0.9687000000000001,-0.0013143367194013988
30
+ llama_3_1_70b,meta-llama/Llama-3.1-70B,19,0.25,P176,0.9981989338705287,0.0018375752204767169,0.9964,0.0017989338705287627
31
+ llama_3_1_70b,meta-llama/Llama-3.1-70B,19,0.25,P138,0.9981634527089073,0.0018365472910927272,0.9875,0.010663452708907228
32
+ llama_3_1_70b,meta-llama/Llama-3.1-70B,39,0.5,P19,0.9487937993757433,0.01736535366475418,0.9588,-0.010006200624256723
33
+ llama_3_1_70b,meta-llama/Llama-3.1-70B,39,0.5,P103,0.9806053086172621,0.00866573858508008,0.9776,0.0030053086172621146
34
+ llama_3_1_70b,meta-llama/Llama-3.1-70B,39,0.5,P101,0.9478223039877648,0.004163751621872662,0.9481,-0.0002776960122352623
35
+ llama_3_1_70b,meta-llama/Llama-3.1-70B,39,0.5,P159,0.9868690575673904,0.009181158754609045,0.9922000000000001,-0.0053309424326096755
36
+ llama_3_1_70b,meta-llama/Llama-3.1-70B,39,0.5,P176,0.9990817263544537,0.001590496609337828,0.9985,0.0005817263544536377
37
+ llama_3_1_70b,meta-llama/Llama-3.1-70B,39,0.5,P138,0.9987756351392716,0.0014026861631330624,0.9979999999999999,0.000775635139271702
38
+ llama_3_1_70b,meta-llama/Llama-3.1-70B,59,0.75,P19,0.9410483147507369,0.006314369029452069,0.9587,-0.017651685249263083
39
+ llama_3_1_70b,meta-llama/Llama-3.1-70B,59,0.75,P103,0.978604594757473,0.005102540213092127,0.9702999999999999,0.008304594757473027
40
+ llama_3_1_70b,meta-llama/Llama-3.1-70B,59,0.75,P101,0.933267348964109,0.007372723654415499,0.9276,0.005667348964109031
41
+ llama_3_1_70b,meta-llama/Llama-3.1-70B,59,0.75,P159,0.9743857787267665,0.0077837106267824386,0.9874,-0.013014221273233595
42
+ llama_3_1_70b,meta-llama/Llama-3.1-70B,59,0.75,P176,0.9993878175696357,0.001060331072891864,0.9997,-0.00031218243036434945
43
+ llama_3_1_70b,meta-llama/Llama-3.1-70B,59,0.75,P138,0.9937140091276612,0.005994012830883151,0.9955999999999999,-0.0018859908723387608
44
+ llama_3_1_70b,meta-llama/Llama-3.1-70B,79,1.0,P19,0.9500181642364719,0.009090841970387453,0.9535,-0.0034818357635281183
45
+ llama_3_1_70b,meta-llama/Llama-3.1-70B,79,1.0,P103,0.9736893947337485,0.009312153707787782,0.9118999999999999,0.06178939473374856
46
+ llama_3_1_70b,meta-llama/Llama-3.1-70B,79,1.0,P101,0.9092767880122393,0.01181891763609088,0.8701,0.03917678801223934
47
+ llama_3_1_70b,meta-llama/Llama-3.1-70B,79,1.0,P159,0.9713426071557559,0.01052998387951711,0.9837,-0.012357392844244086
48
+ llama_3_1_70b,meta-llama/Llama-3.1-70B,79,1.0,P176,0.9985050250857109,0.0013923806214913971,0.9828,0.015705025085710922
49
+ llama_3_1_70b,meta-llama/Llama-3.1-70B,79,1.0,P138,0.9762977896825019,0.020204239854710086,0.9605000000000001,0.015797789682501784
phase2_scaling/results/probe_weights/s1a_llama_3_1_70b_L19_P101_f0.npz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a3d7e09123346fc18bc2d1663e64170c5ece28fad0ce6960a351753b1148ae9c
3
+ size 165142
phase2_scaling/results/probe_weights/s1a_llama_3_1_70b_L19_P101_f0_manifest.json ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "probe_id": "s1a_llama_3_1_70b_L19_P101_f0",
3
+ "stage": "1A",
4
+ "protocol": "within_relation",
5
+ "model_id": "meta-llama/Llama-3.1-70B",
6
+ "model_revision": "served via NDIF",
7
+ "layer_index": 19,
8
+ "normalized_depth": 0.25,
9
+ "source_relations": [
10
+ "P101"
11
+ ],
12
+ "target_relation": "P101",
13
+ "fold": 0,
14
+ "training_example_ids": [
15
+ "P101_N100_12043_true",
16
+ "P101_N100_12043_false",
17
+ "P101_N100_13802_true",
18
+ "P101_N100_13802_false",
19
+ "P101_N100_14775_true",
20
+ "P101_N100_14775_false",
21
+ "P101_N100_4262_true",
22
+ "P101_N100_4262_false",
23
+ "P101_N100_13859_true",
24
+ "P101_N100_13859_false",
25
+ "P101_N100_6052_true",
26
+ "P101_N100_6052_false",
27
+ "P101_N100_21804_true",
28
+ "P101_N100_21804_false",
29
+ "P101_N100_13429_true",
30
+ "P101_N100_13429_false",
31
+ "P101_N100_19546_true",
32
+ "P101_N100_19546_false",
33
+ "P101_N100_2196_true",
34
+ "P101_N100_2196_false",
35
+ "P101_N100_15564_true",
36
+ "P101_N100_15564_false",
37
+ "P101_N100_18180_true",
38
+ "P101_N100_18180_false",
39
+ "P101_N100_5410_true",
40
+ "P101_N100_5410_false",
41
+ "P101_N100_10164_true",
42
+ "P101_N100_10164_false",
43
+ "P101_N100_18105_true",
44
+ "P101_N100_18105_false",
45
+ "P101_N100_21528_true",
46
+ "P101_N100_21528_false",
47
+ "P101_N100_1266_true",
48
+ "P101_N100_1266_false",
49
+ "P101_N100_1437_true",
50
+ "P101_N100_1437_false",
51
+ "P101_N100_1725_true",
52
+ "P101_N100_1725_false",
53
+ "P101_N100_10526_true",
54
+ "P101_N100_10526_false",
55
+ "P101_N100_3003_true",
56
+ "P101_N100_3003_false",
57
+ "P101_N100_12450_true",
58
+ "P101_N100_12450_false",
59
+ "P101_N100_2033_true",
60
+ "P101_N100_2033_false",
61
+ "P101_N100_20184_true",
62
+ "P101_N100_20184_false",
63
+ "P101_N100_15216_true",
64
+ "P101_N100_15216_false",
65
+ "P101_N100_21235_true",
66
+ "P101_N100_21235_false",
67
+ "P101_N100_11093_true",
68
+ "P101_N100_11093_false",
69
+ "P101_N100_17581_true",
70
+ "P101_N100_17581_false",
71
+ "P101_N100_1740_true",
72
+ "P101_N100_1740_false",
73
+ "P101_N100_4233_true",
74
+ "P101_N100_4233_false",
75
+ "P101_N100_6710_true",
76
+ "P101_N100_6710_false",
77
+ "P101_N100_7677_true",
78
+ "P101_N100_7677_false",
79
+ "P101_N100_9975_true",
80
+ "P101_N100_9975_false",
81
+ "P101_N100_13587_true",
82
+ "P101_N100_13587_false",
83
+ "P101_N100_13901_true",
84
+ "P101_N100_13901_false",
85
+ "P101_N100_17125_true",
86
+ "P101_N100_17125_false",
87
+ "P101_N100_17502_true",
88
+ "P101_N100_17502_false",
89
+ "P101_N100_19551_true",
90
+ "P101_N100_19551_false",
91
+ "P101_N100_19658_true",
92
+ "P101_N100_19658_false",
93
+ "P101_N100_20567_true",
94
+ "P101_N100_20567_false",
95
+ "P101_N100_1900_true",
96
+ "P101_N100_1900_false",
97
+ "P101_N100_2522_true",
98
+ "P101_N100_2522_false",
99
+ "P101_N100_7174_true",
100
+ "P101_N100_7174_false",
101
+ "P101_N100_349_true",
102
+ "P101_N100_349_false",
103
+ "P101_N100_979_true",
104
+ "P101_N100_979_false",
105
+ "P101_N100_20839_true",
106
+ "P101_N100_20839_false",
107
+ "P101_N100_3247_true",
108
+ "P101_N100_3247_false",
109
+ "P101_N100_8360_true",
110
+ "P101_N100_8360_false",
111
+ "P101_N100_8895_true",
112
+ "P101_N100_8895_false",
113
+ "P101_N100_9305_true",
114
+ "P101_N100_9305_false",
115
+ "P101_N100_9493_true",
116
+ "P101_N100_9493_false",
117
+ "P101_N100_16916_true",
118
+ "P101_N100_16916_false",
119
+ "P101_N100_18280_true",
120
+ "P101_N100_18280_false",
121
+ "P101_N100_19067_true",
122
+ "P101_N100_19067_false",
123
+ "P101_N100_20542_true",
124
+ "P101_N100_20542_false",
125
+ "P101_N100_577_true",
126
+ "P101_N100_577_false",
127
+ "P101_N100_3928_true",
128
+ "P101_N100_3928_false",
129
+ "P101_N100_5134_true",
130
+ "P101_N100_5134_false",
131
+ "P101_N100_12085_true",
132
+ "P101_N100_12085_false",
133
+ "P101_N100_16538_true",
134
+ "P101_N100_16538_false",
135
+ "P101_N100_18818_true",
136
+ "P101_N100_18818_false",
137
+ "P101_N100_8579_true",
138
+ "P101_N100_8579_false",
139
+ "P101_N100_4081_true",
140
+ "P101_N100_4081_false",
141
+ "P101_N100_14668_true",
142
+ "P101_N100_14668_false",
143
+ "P101_N100_16952_true",
144
+ "P101_N100_16952_false",
145
+ "P101_N100_9193_true",
146
+ "P101_N100_9193_false"
147
+ ],
148
+ "probe_configuration_hash": "667540b0fa890cca",
149
+ "sklearn_version": "1.9.0",
150
+ "n_iter": 17
151
+ }
phase2_scaling/results/probe_weights/s1a_llama_3_1_70b_L19_P101_f1.npz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ade5e4ef5e36ccb639beeaf0ccdd858e2a7f0e3e47267edcf1a6186ac62a7b70
3
+ size 165142
phase2_scaling/results/probe_weights/s1a_llama_3_1_70b_L19_P101_f1_manifest.json ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "probe_id": "s1a_llama_3_1_70b_L19_P101_f1",
3
+ "stage": "1A",
4
+ "protocol": "within_relation",
5
+ "model_id": "meta-llama/Llama-3.1-70B",
6
+ "model_revision": "served via NDIF",
7
+ "layer_index": 19,
8
+ "normalized_depth": 0.25,
9
+ "source_relations": [
10
+ "P101"
11
+ ],
12
+ "target_relation": "P101",
13
+ "fold": 1,
14
+ "training_example_ids": [
15
+ "P101_N100_11510_true",
16
+ "P101_N100_11510_false",
17
+ "P101_N100_14775_true",
18
+ "P101_N100_14775_false",
19
+ "P101_N100_646_true",
20
+ "P101_N100_646_false",
21
+ "P101_N100_8198_true",
22
+ "P101_N100_8198_false",
23
+ "P101_N100_13859_true",
24
+ "P101_N100_13859_false",
25
+ "P101_N100_18360_true",
26
+ "P101_N100_18360_false",
27
+ "P101_N100_21804_true",
28
+ "P101_N100_21804_false",
29
+ "P101_N100_2196_true",
30
+ "P101_N100_2196_false",
31
+ "P101_N100_15564_true",
32
+ "P101_N100_15564_false",
33
+ "P101_N100_18180_true",
34
+ "P101_N100_18180_false",
35
+ "P101_N100_1778_true",
36
+ "P101_N100_1778_false",
37
+ "P101_N100_16637_true",
38
+ "P101_N100_16637_false",
39
+ "P101_N100_5409_true",
40
+ "P101_N100_5409_false",
41
+ "P101_N100_10526_true",
42
+ "P101_N100_10526_false",
43
+ "P101_N100_12450_true",
44
+ "P101_N100_12450_false",
45
+ "P101_N100_13844_true",
46
+ "P101_N100_13844_false",
47
+ "P101_N100_8515_true",
48
+ "P101_N100_8515_false",
49
+ "P101_N100_20184_true",
50
+ "P101_N100_20184_false",
51
+ "P101_N100_15216_true",
52
+ "P101_N100_15216_false",
53
+ "P101_N100_16292_true",
54
+ "P101_N100_16292_false",
55
+ "P101_N100_8809_true",
56
+ "P101_N100_8809_false",
57
+ "P101_N100_11093_true",
58
+ "P101_N100_11093_false",
59
+ "P101_N100_11531_true",
60
+ "P101_N100_11531_false",
61
+ "P101_N100_17581_true",
62
+ "P101_N100_17581_false",
63
+ "P101_N100_1021_true",
64
+ "P101_N100_1021_false",
65
+ "P101_N100_2439_true",
66
+ "P101_N100_2439_false",
67
+ "P101_N100_4233_true",
68
+ "P101_N100_4233_false",
69
+ "P101_N100_5328_true",
70
+ "P101_N100_5328_false",
71
+ "P101_N100_6710_true",
72
+ "P101_N100_6710_false",
73
+ "P101_N100_7677_true",
74
+ "P101_N100_7677_false",
75
+ "P101_N100_13587_true",
76
+ "P101_N100_13587_false",
77
+ "P101_N100_13901_true",
78
+ "P101_N100_13901_false",
79
+ "P101_N100_17125_true",
80
+ "P101_N100_17125_false",
81
+ "P101_N100_19551_true",
82
+ "P101_N100_19551_false",
83
+ "P101_N100_2522_true",
84
+ "P101_N100_2522_false",
85
+ "P101_N100_7174_true",
86
+ "P101_N100_7174_false",
87
+ "P101_N100_16931_true",
88
+ "P101_N100_16931_false",
89
+ "P101_N100_17366_true",
90
+ "P101_N100_17366_false",
91
+ "P101_N100_19122_true",
92
+ "P101_N100_19122_false",
93
+ "P101_N100_21584_true",
94
+ "P101_N100_21584_false",
95
+ "P101_N100_979_true",
96
+ "P101_N100_979_false",
97
+ "P101_N100_3456_true",
98
+ "P101_N100_3456_false",
99
+ "P101_N100_20839_true",
100
+ "P101_N100_20839_false",
101
+ "P101_N100_712_true",
102
+ "P101_N100_712_false",
103
+ "P101_N100_1851_true",
104
+ "P101_N100_1851_false",
105
+ "P101_N100_3673_true",
106
+ "P101_N100_3673_false",
107
+ "P101_N100_7406_true",
108
+ "P101_N100_7406_false",
109
+ "P101_N100_8674_true",
110
+ "P101_N100_8674_false",
111
+ "P101_N100_8895_true",
112
+ "P101_N100_8895_false",
113
+ "P101_N100_9305_true",
114
+ "P101_N100_9305_false",
115
+ "P101_N100_16454_true",
116
+ "P101_N100_16454_false",
117
+ "P101_N100_20542_true",
118
+ "P101_N100_20542_false",
119
+ "P101_N100_577_true",
120
+ "P101_N100_577_false",
121
+ "P101_N100_5134_true",
122
+ "P101_N100_5134_false",
123
+ "P101_N100_10791_true",
124
+ "P101_N100_10791_false",
125
+ "P101_N100_12085_true",
126
+ "P101_N100_12085_false",
127
+ "P101_N100_16538_true",
128
+ "P101_N100_16538_false",
129
+ "P101_N100_17132_true",
130
+ "P101_N100_17132_false",
131
+ "P101_N100_18818_true",
132
+ "P101_N100_18818_false",
133
+ "P101_N100_8579_true",
134
+ "P101_N100_8579_false",
135
+ "P101_N100_327_true",
136
+ "P101_N100_327_false",
137
+ "P101_N100_4081_true",
138
+ "P101_N100_4081_false",
139
+ "P101_N100_17757_true",
140
+ "P101_N100_17757_false",
141
+ "P101_N100_11905_true",
142
+ "P101_N100_11905_false",
143
+ "P101_N100_19532_true",
144
+ "P101_N100_19532_false",
145
+ "P101_N100_2276_true",
146
+ "P101_N100_2276_false",
147
+ "P101_N100_11223_true",
148
+ "P101_N100_11223_false"
149
+ ],
150
+ "probe_configuration_hash": "667540b0fa890cca",
151
+ "sklearn_version": "1.9.0",
152
+ "n_iter": 18
153
+ }
phase2_scaling/results/probe_weights/s1a_llama_3_1_70b_L19_P101_f2.npz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8f322416e6d6a3c0941e017d2c69f430133f815d73d224a575208382f95cc309
3
+ size 165142
phase2_scaling/results/probe_weights/s1a_llama_3_1_70b_L19_P101_f2_manifest.json ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "probe_id": "s1a_llama_3_1_70b_L19_P101_f2",
3
+ "stage": "1A",
4
+ "protocol": "within_relation",
5
+ "model_id": "meta-llama/Llama-3.1-70B",
6
+ "model_revision": "served via NDIF",
7
+ "layer_index": 19,
8
+ "normalized_depth": 0.25,
9
+ "source_relations": [
10
+ "P101"
11
+ ],
12
+ "target_relation": "P101",
13
+ "fold": 2,
14
+ "training_example_ids": [
15
+ "P101_N100_12043_true",
16
+ "P101_N100_12043_false",
17
+ "P101_N100_13802_true",
18
+ "P101_N100_13802_false",
19
+ "P101_N100_11510_true",
20
+ "P101_N100_11510_false",
21
+ "P101_N100_646_true",
22
+ "P101_N100_646_false",
23
+ "P101_N100_4262_true",
24
+ "P101_N100_4262_false",
25
+ "P101_N100_8198_true",
26
+ "P101_N100_8198_false",
27
+ "P101_N100_18360_true",
28
+ "P101_N100_18360_false",
29
+ "P101_N100_6052_true",
30
+ "P101_N100_6052_false",
31
+ "P101_N100_13429_true",
32
+ "P101_N100_13429_false",
33
+ "P101_N100_19546_true",
34
+ "P101_N100_19546_false",
35
+ "P101_N100_5410_true",
36
+ "P101_N100_5410_false",
37
+ "P101_N100_10164_true",
38
+ "P101_N100_10164_false",
39
+ "P101_N100_18105_true",
40
+ "P101_N100_18105_false",
41
+ "P101_N100_21528_true",
42
+ "P101_N100_21528_false",
43
+ "P101_N100_1778_true",
44
+ "P101_N100_1778_false",
45
+ "P101_N100_16637_true",
46
+ "P101_N100_16637_false",
47
+ "P101_N100_1266_true",
48
+ "P101_N100_1266_false",
49
+ "P101_N100_5409_true",
50
+ "P101_N100_5409_false",
51
+ "P101_N100_1437_true",
52
+ "P101_N100_1437_false",
53
+ "P101_N100_1725_true",
54
+ "P101_N100_1725_false",
55
+ "P101_N100_3003_true",
56
+ "P101_N100_3003_false",
57
+ "P101_N100_13844_true",
58
+ "P101_N100_13844_false",
59
+ "P101_N100_2033_true",
60
+ "P101_N100_2033_false",
61
+ "P101_N100_8515_true",
62
+ "P101_N100_8515_false",
63
+ "P101_N100_16292_true",
64
+ "P101_N100_16292_false",
65
+ "P101_N100_21235_true",
66
+ "P101_N100_21235_false",
67
+ "P101_N100_8809_true",
68
+ "P101_N100_8809_false",
69
+ "P101_N100_11531_true",
70
+ "P101_N100_11531_false",
71
+ "P101_N100_1021_true",
72
+ "P101_N100_1021_false",
73
+ "P101_N100_1740_true",
74
+ "P101_N100_1740_false",
75
+ "P101_N100_2439_true",
76
+ "P101_N100_2439_false",
77
+ "P101_N100_5328_true",
78
+ "P101_N100_5328_false",
79
+ "P101_N100_9975_true",
80
+ "P101_N100_9975_false",
81
+ "P101_N100_17502_true",
82
+ "P101_N100_17502_false",
83
+ "P101_N100_19658_true",
84
+ "P101_N100_19658_false",
85
+ "P101_N100_20567_true",
86
+ "P101_N100_20567_false",
87
+ "P101_N100_1900_true",
88
+ "P101_N100_1900_false",
89
+ "P101_N100_16931_true",
90
+ "P101_N100_16931_false",
91
+ "P101_N100_17366_true",
92
+ "P101_N100_17366_false",
93
+ "P101_N100_19122_true",
94
+ "P101_N100_19122_false",
95
+ "P101_N100_21584_true",
96
+ "P101_N100_21584_false",
97
+ "P101_N100_349_true",
98
+ "P101_N100_349_false",
99
+ "P101_N100_3456_true",
100
+ "P101_N100_3456_false",
101
+ "P101_N100_712_true",
102
+ "P101_N100_712_false",
103
+ "P101_N100_1851_true",
104
+ "P101_N100_1851_false",
105
+ "P101_N100_3247_true",
106
+ "P101_N100_3247_false",
107
+ "P101_N100_3673_true",
108
+ "P101_N100_3673_false",
109
+ "P101_N100_7406_true",
110
+ "P101_N100_7406_false",
111
+ "P101_N100_8360_true",
112
+ "P101_N100_8360_false",
113
+ "P101_N100_8674_true",
114
+ "P101_N100_8674_false",
115
+ "P101_N100_9493_true",
116
+ "P101_N100_9493_false",
117
+ "P101_N100_16454_true",
118
+ "P101_N100_16454_false",
119
+ "P101_N100_16916_true",
120
+ "P101_N100_16916_false",
121
+ "P101_N100_18280_true",
122
+ "P101_N100_18280_false",
123
+ "P101_N100_19067_true",
124
+ "P101_N100_19067_false",
125
+ "P101_N100_3928_true",
126
+ "P101_N100_3928_false",
127
+ "P101_N100_10791_true",
128
+ "P101_N100_10791_false",
129
+ "P101_N100_17132_true",
130
+ "P101_N100_17132_false",
131
+ "P101_N100_327_true",
132
+ "P101_N100_327_false",
133
+ "P101_N100_17757_true",
134
+ "P101_N100_17757_false",
135
+ "P101_N100_11905_true",
136
+ "P101_N100_11905_false",
137
+ "P101_N100_14668_true",
138
+ "P101_N100_14668_false",
139
+ "P101_N100_16952_true",
140
+ "P101_N100_16952_false",
141
+ "P101_N100_19532_true",
142
+ "P101_N100_19532_false",
143
+ "P101_N100_2276_true",
144
+ "P101_N100_2276_false",
145
+ "P101_N100_9193_true",
146
+ "P101_N100_9193_false",
147
+ "P101_N100_11223_true",
148
+ "P101_N100_11223_false"
149
+ ],
150
+ "probe_configuration_hash": "667540b0fa890cca",
151
+ "sklearn_version": "1.9.0",
152
+ "n_iter": 16
153
+ }
phase2_scaling/results/probe_weights/s1a_llama_3_1_70b_L19_P103_f0.npz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cf745e0b2c1de99cc707bb5842fe69b88921b16860c07af88595199acd218b4d
3
+ size 165142
phase2_scaling/results/probe_weights/s1a_llama_3_1_70b_L19_P103_f0_manifest.json ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "probe_id": "s1a_llama_3_1_70b_L19_P103_f0",
3
+ "stage": "1A",
4
+ "protocol": "within_relation",
5
+ "model_id": "meta-llama/Llama-3.1-70B",
6
+ "model_revision": "served via NDIF",
7
+ "layer_index": 19,
8
+ "normalized_depth": 0.25,
9
+ "source_relations": [
10
+ "P103"
11
+ ],
12
+ "target_relation": "P103",
13
+ "fold": 0,
14
+ "training_example_ids": [
15
+ "P103_N100_4100_true",
16
+ "P103_N100_4100_false",
17
+ "P103_N100_19920_true",
18
+ "P103_N100_19920_false",
19
+ "P103_N100_20406_true",
20
+ "P103_N100_20406_false",
21
+ "P103_N100_1322_true",
22
+ "P103_N100_1322_false",
23
+ "P103_N100_7100_true",
24
+ "P103_N100_7100_false",
25
+ "P103_N100_9094_true",
26
+ "P103_N100_9094_false",
27
+ "P103_N100_14052_true",
28
+ "P103_N100_14052_false",
29
+ "P103_N100_19509_true",
30
+ "P103_N100_19509_false",
31
+ "P103_N100_20586_true",
32
+ "P103_N100_20586_false",
33
+ "P103_N100_21825_true",
34
+ "P103_N100_21825_false",
35
+ "P103_N100_5614_true",
36
+ "P103_N100_5614_false",
37
+ "P103_N100_11941_true",
38
+ "P103_N100_11941_false",
39
+ "P103_N100_20837_true",
40
+ "P103_N100_20837_false",
41
+ "P103_N100_412_true",
42
+ "P103_N100_412_false",
43
+ "P103_N100_1442_true",
44
+ "P103_N100_1442_false",
45
+ "P103_N100_2092_true",
46
+ "P103_N100_2092_false",
47
+ "P103_N100_2335_true",
48
+ "P103_N100_2335_false",
49
+ "P103_N100_2606_true",
50
+ "P103_N100_2606_false",
51
+ "P103_N100_3849_true",
52
+ "P103_N100_3849_false",
53
+ "P103_N100_4433_true",
54
+ "P103_N100_4433_false",
55
+ "P103_N100_4501_true",
56
+ "P103_N100_4501_false",
57
+ "P103_N100_4656_true",
58
+ "P103_N100_4656_false",
59
+ "P103_N100_4842_true",
60
+ "P103_N100_4842_false",
61
+ "P103_N100_5771_true",
62
+ "P103_N100_5771_false",
63
+ "P103_N100_7533_true",
64
+ "P103_N100_7533_false",
65
+ "P103_N100_8185_true",
66
+ "P103_N100_8185_false",
67
+ "P103_N100_8899_true",
68
+ "P103_N100_8899_false",
69
+ "P103_N100_9271_true",
70
+ "P103_N100_9271_false",
71
+ "P103_N100_10963_true",
72
+ "P103_N100_10963_false",
73
+ "P103_N100_12950_true",
74
+ "P103_N100_12950_false",
75
+ "P103_N100_13542_true",
76
+ "P103_N100_13542_false",
77
+ "P103_N100_16451_true",
78
+ "P103_N100_16451_false",
79
+ "P103_N100_17475_true",
80
+ "P103_N100_17475_false",
81
+ "P103_N100_17917_true",
82
+ "P103_N100_17917_false",
83
+ "P103_N100_18593_true",
84
+ "P103_N100_18593_false",
85
+ "P103_N100_19121_true",
86
+ "P103_N100_19121_false",
87
+ "P103_N100_19381_true",
88
+ "P103_N100_19381_false",
89
+ "P103_N100_20106_true",
90
+ "P103_N100_20106_false",
91
+ "P103_N100_21442_true",
92
+ "P103_N100_21442_false",
93
+ "P103_N100_21772_true",
94
+ "P103_N100_21772_false",
95
+ "P103_N100_12470_true",
96
+ "P103_N100_12470_false",
97
+ "P103_N100_9006_true",
98
+ "P103_N100_9006_false",
99
+ "P103_N100_7382_true",
100
+ "P103_N100_7382_false",
101
+ "P103_N100_5542_true",
102
+ "P103_N100_5542_false",
103
+ "P103_N100_5844_true",
104
+ "P103_N100_5844_false",
105
+ "P103_N100_5519_true",
106
+ "P103_N100_5519_false",
107
+ "P103_N100_5740_true",
108
+ "P103_N100_5740_false",
109
+ "P103_N100_3405_true",
110
+ "P103_N100_3405_false",
111
+ "P103_N100_4199_true",
112
+ "P103_N100_4199_false",
113
+ "P103_N100_4932_true",
114
+ "P103_N100_4932_false",
115
+ "P103_N100_6215_true",
116
+ "P103_N100_6215_false",
117
+ "P103_N100_6447_true",
118
+ "P103_N100_6447_false",
119
+ "P103_N100_7675_true",
120
+ "P103_N100_7675_false",
121
+ "P103_N100_9599_true",
122
+ "P103_N100_9599_false",
123
+ "P103_N100_10630_true",
124
+ "P103_N100_10630_false",
125
+ "P103_N100_13517_true",
126
+ "P103_N100_13517_false",
127
+ "P103_N100_15455_true",
128
+ "P103_N100_15455_false",
129
+ "P103_N100_15770_true",
130
+ "P103_N100_15770_false",
131
+ "P103_N100_17584_true",
132
+ "P103_N100_17584_false",
133
+ "P103_N100_17708_true",
134
+ "P103_N100_17708_false",
135
+ "P103_N100_18385_true",
136
+ "P103_N100_18385_false",
137
+ "P103_N100_19784_true",
138
+ "P103_N100_19784_false",
139
+ "P103_N100_20804_true",
140
+ "P103_N100_20804_false",
141
+ "P103_N100_2371_true",
142
+ "P103_N100_2371_false",
143
+ "P103_N100_20607_true",
144
+ "P103_N100_20607_false",
145
+ "P103_N100_12327_true",
146
+ "P103_N100_12327_false"
147
+ ],
148
+ "probe_configuration_hash": "667540b0fa890cca",
149
+ "sklearn_version": "1.9.0",
150
+ "n_iter": 24
151
+ }
phase2_scaling/results/probe_weights/s1a_llama_3_1_70b_L19_P103_f1.npz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:84fecfbad2fa608a731e13ff70fa36b4e702ba0f885089272c681fcee25b83ac
3
+ size 165142
phase2_scaling/results/probe_weights/s1a_llama_3_1_70b_L19_P103_f1_manifest.json ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "probe_id": "s1a_llama_3_1_70b_L19_P103_f1",
3
+ "stage": "1A",
4
+ "protocol": "within_relation",
5
+ "model_id": "meta-llama/Llama-3.1-70B",
6
+ "model_revision": "served via NDIF",
7
+ "layer_index": 19,
8
+ "normalized_depth": 0.25,
9
+ "source_relations": [
10
+ "P103"
11
+ ],
12
+ "target_relation": "P103",
13
+ "fold": 1,
14
+ "training_example_ids": [
15
+ "P103_N100_18782_true",
16
+ "P103_N100_18782_false",
17
+ "P103_N100_20406_true",
18
+ "P103_N100_20406_false",
19
+ "P103_N100_1322_true",
20
+ "P103_N100_1322_false",
21
+ "P103_N100_5784_true",
22
+ "P103_N100_5784_false",
23
+ "P103_N100_5810_true",
24
+ "P103_N100_5810_false",
25
+ "P103_N100_7039_true",
26
+ "P103_N100_7039_false",
27
+ "P103_N100_9094_true",
28
+ "P103_N100_9094_false",
29
+ "P103_N100_14052_true",
30
+ "P103_N100_14052_false",
31
+ "P103_N100_18904_true",
32
+ "P103_N100_18904_false",
33
+ "P103_N100_8285_true",
34
+ "P103_N100_8285_false",
35
+ "P103_N100_18583_true",
36
+ "P103_N100_18583_false",
37
+ "P103_N100_20837_true",
38
+ "P103_N100_20837_false",
39
+ "P103_N100_27_true",
40
+ "P103_N100_27_false",
41
+ "P103_N100_838_true",
42
+ "P103_N100_838_false",
43
+ "P103_N100_1442_true",
44
+ "P103_N100_1442_false",
45
+ "P103_N100_2465_true",
46
+ "P103_N100_2465_false",
47
+ "P103_N100_2829_true",
48
+ "P103_N100_2829_false",
49
+ "P103_N100_4501_true",
50
+ "P103_N100_4501_false",
51
+ "P103_N100_4842_true",
52
+ "P103_N100_4842_false",
53
+ "P103_N100_6593_true",
54
+ "P103_N100_6593_false",
55
+ "P103_N100_6727_true",
56
+ "P103_N100_6727_false",
57
+ "P103_N100_8185_true",
58
+ "P103_N100_8185_false",
59
+ "P103_N100_8283_true",
60
+ "P103_N100_8283_false",
61
+ "P103_N100_8899_true",
62
+ "P103_N100_8899_false",
63
+ "P103_N100_10963_true",
64
+ "P103_N100_10963_false",
65
+ "P103_N100_12611_true",
66
+ "P103_N100_12611_false",
67
+ "P103_N100_13118_true",
68
+ "P103_N100_13118_false",
69
+ "P103_N100_13542_true",
70
+ "P103_N100_13542_false",
71
+ "P103_N100_14132_true",
72
+ "P103_N100_14132_false",
73
+ "P103_N100_16451_true",
74
+ "P103_N100_16451_false",
75
+ "P103_N100_18575_true",
76
+ "P103_N100_18575_false",
77
+ "P103_N100_19121_true",
78
+ "P103_N100_19121_false",
79
+ "P103_N100_20106_true",
80
+ "P103_N100_20106_false",
81
+ "P103_N100_20998_true",
82
+ "P103_N100_20998_false",
83
+ "P103_N100_21442_true",
84
+ "P103_N100_21442_false",
85
+ "P103_N100_21772_true",
86
+ "P103_N100_21772_false",
87
+ "P103_N100_21855_true",
88
+ "P103_N100_21855_false",
89
+ "P103_N100_12470_true",
90
+ "P103_N100_12470_false",
91
+ "P103_N100_7382_true",
92
+ "P103_N100_7382_false",
93
+ "P103_N100_19327_true",
94
+ "P103_N100_19327_false",
95
+ "P103_N100_17392_true",
96
+ "P103_N100_17392_false",
97
+ "P103_N100_2448_true",
98
+ "P103_N100_2448_false",
99
+ "P103_N100_17667_true",
100
+ "P103_N100_17667_false",
101
+ "P103_N100_14588_true",
102
+ "P103_N100_14588_false",
103
+ "P103_N100_3108_true",
104
+ "P103_N100_3108_false",
105
+ "P103_N100_5519_true",
106
+ "P103_N100_5519_false",
107
+ "P103_N100_1318_true",
108
+ "P103_N100_1318_false",
109
+ "P103_N100_5740_true",
110
+ "P103_N100_5740_false",
111
+ "P103_N100_2643_true",
112
+ "P103_N100_2643_false",
113
+ "P103_N100_3405_true",
114
+ "P103_N100_3405_false",
115
+ "P103_N100_4490_true",
116
+ "P103_N100_4490_false",
117
+ "P103_N100_4932_true",
118
+ "P103_N100_4932_false",
119
+ "P103_N100_5904_true",
120
+ "P103_N100_5904_false",
121
+ "P103_N100_7675_true",
122
+ "P103_N100_7675_false",
123
+ "P103_N100_7979_true",
124
+ "P103_N100_7979_false",
125
+ "P103_N100_9599_true",
126
+ "P103_N100_9599_false",
127
+ "P103_N100_10630_true",
128
+ "P103_N100_10630_false",
129
+ "P103_N100_13517_true",
130
+ "P103_N100_13517_false",
131
+ "P103_N100_15770_true",
132
+ "P103_N100_15770_false",
133
+ "P103_N100_16996_true",
134
+ "P103_N100_16996_false",
135
+ "P103_N100_17584_true",
136
+ "P103_N100_17584_false",
137
+ "P103_N100_17708_true",
138
+ "P103_N100_17708_false",
139
+ "P103_N100_18385_true",
140
+ "P103_N100_18385_false",
141
+ "P103_N100_19784_true",
142
+ "P103_N100_19784_false",
143
+ "P103_N100_5530_true",
144
+ "P103_N100_5530_false",
145
+ "P103_N100_20607_true",
146
+ "P103_N100_20607_false",
147
+ "P103_N100_21705_true",
148
+ "P103_N100_21705_false"
149
+ ],
150
+ "probe_configuration_hash": "667540b0fa890cca",
151
+ "sklearn_version": "1.9.0",
152
+ "n_iter": 20
153
+ }
phase2_scaling/results/probe_weights/s1a_llama_3_1_70b_L19_P103_f2.npz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b4f6465401f14d66716d952d640386569c8fa2bf15fb5cacb299dcf379bec8f8
3
+ size 165142
phase2_scaling/results/probe_weights/s1a_llama_3_1_70b_L19_P103_f2_manifest.json ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "probe_id": "s1a_llama_3_1_70b_L19_P103_f2",
3
+ "stage": "1A",
4
+ "protocol": "within_relation",
5
+ "model_id": "meta-llama/Llama-3.1-70B",
6
+ "model_revision": "served via NDIF",
7
+ "layer_index": 19,
8
+ "normalized_depth": 0.25,
9
+ "source_relations": [
10
+ "P103"
11
+ ],
12
+ "target_relation": "P103",
13
+ "fold": 2,
14
+ "training_example_ids": [
15
+ "P103_N100_4100_true",
16
+ "P103_N100_4100_false",
17
+ "P103_N100_18782_true",
18
+ "P103_N100_18782_false",
19
+ "P103_N100_19920_true",
20
+ "P103_N100_19920_false",
21
+ "P103_N100_5784_true",
22
+ "P103_N100_5784_false",
23
+ "P103_N100_5810_true",
24
+ "P103_N100_5810_false",
25
+ "P103_N100_7039_true",
26
+ "P103_N100_7039_false",
27
+ "P103_N100_7100_true",
28
+ "P103_N100_7100_false",
29
+ "P103_N100_18904_true",
30
+ "P103_N100_18904_false",
31
+ "P103_N100_19509_true",
32
+ "P103_N100_19509_false",
33
+ "P103_N100_20586_true",
34
+ "P103_N100_20586_false",
35
+ "P103_N100_21825_true",
36
+ "P103_N100_21825_false",
37
+ "P103_N100_5614_true",
38
+ "P103_N100_5614_false",
39
+ "P103_N100_8285_true",
40
+ "P103_N100_8285_false",
41
+ "P103_N100_11941_true",
42
+ "P103_N100_11941_false",
43
+ "P103_N100_18583_true",
44
+ "P103_N100_18583_false",
45
+ "P103_N100_27_true",
46
+ "P103_N100_27_false",
47
+ "P103_N100_412_true",
48
+ "P103_N100_412_false",
49
+ "P103_N100_838_true",
50
+ "P103_N100_838_false",
51
+ "P103_N100_2092_true",
52
+ "P103_N100_2092_false",
53
+ "P103_N100_2335_true",
54
+ "P103_N100_2335_false",
55
+ "P103_N100_2465_true",
56
+ "P103_N100_2465_false",
57
+ "P103_N100_2606_true",
58
+ "P103_N100_2606_false",
59
+ "P103_N100_2829_true",
60
+ "P103_N100_2829_false",
61
+ "P103_N100_3849_true",
62
+ "P103_N100_3849_false",
63
+ "P103_N100_4433_true",
64
+ "P103_N100_4433_false",
65
+ "P103_N100_4656_true",
66
+ "P103_N100_4656_false",
67
+ "P103_N100_5771_true",
68
+ "P103_N100_5771_false",
69
+ "P103_N100_6593_true",
70
+ "P103_N100_6593_false",
71
+ "P103_N100_6727_true",
72
+ "P103_N100_6727_false",
73
+ "P103_N100_7533_true",
74
+ "P103_N100_7533_false",
75
+ "P103_N100_8283_true",
76
+ "P103_N100_8283_false",
77
+ "P103_N100_9271_true",
78
+ "P103_N100_9271_false",
79
+ "P103_N100_12611_true",
80
+ "P103_N100_12611_false",
81
+ "P103_N100_12950_true",
82
+ "P103_N100_12950_false",
83
+ "P103_N100_13118_true",
84
+ "P103_N100_13118_false",
85
+ "P103_N100_14132_true",
86
+ "P103_N100_14132_false",
87
+ "P103_N100_17475_true",
88
+ "P103_N100_17475_false",
89
+ "P103_N100_17917_true",
90
+ "P103_N100_17917_false",
91
+ "P103_N100_18575_true",
92
+ "P103_N100_18575_false",
93
+ "P103_N100_18593_true",
94
+ "P103_N100_18593_false",
95
+ "P103_N100_19381_true",
96
+ "P103_N100_19381_false",
97
+ "P103_N100_20998_true",
98
+ "P103_N100_20998_false",
99
+ "P103_N100_21855_true",
100
+ "P103_N100_21855_false",
101
+ "P103_N100_9006_true",
102
+ "P103_N100_9006_false",
103
+ "P103_N100_19327_true",
104
+ "P103_N100_19327_false",
105
+ "P103_N100_17392_true",
106
+ "P103_N100_17392_false",
107
+ "P103_N100_2448_true",
108
+ "P103_N100_2448_false",
109
+ "P103_N100_5542_true",
110
+ "P103_N100_5542_false",
111
+ "P103_N100_17667_true",
112
+ "P103_N100_17667_false",
113
+ "P103_N100_5844_true",
114
+ "P103_N100_5844_false",
115
+ "P103_N100_14588_true",
116
+ "P103_N100_14588_false",
117
+ "P103_N100_3108_true",
118
+ "P103_N100_3108_false",
119
+ "P103_N100_1318_true",
120
+ "P103_N100_1318_false",
121
+ "P103_N100_2643_true",
122
+ "P103_N100_2643_false",
123
+ "P103_N100_4199_true",
124
+ "P103_N100_4199_false",
125
+ "P103_N100_4490_true",
126
+ "P103_N100_4490_false",
127
+ "P103_N100_5904_true",
128
+ "P103_N100_5904_false",
129
+ "P103_N100_6215_true",
130
+ "P103_N100_6215_false",
131
+ "P103_N100_6447_true",
132
+ "P103_N100_6447_false",
133
+ "P103_N100_7979_true",
134
+ "P103_N100_7979_false",
135
+ "P103_N100_15455_true",
136
+ "P103_N100_15455_false",
137
+ "P103_N100_16996_true",
138
+ "P103_N100_16996_false",
139
+ "P103_N100_20804_true",
140
+ "P103_N100_20804_false",
141
+ "P103_N100_2371_true",
142
+ "P103_N100_2371_false",
143
+ "P103_N100_5530_true",
144
+ "P103_N100_5530_false",
145
+ "P103_N100_21705_true",
146
+ "P103_N100_21705_false",
147
+ "P103_N100_12327_true",
148
+ "P103_N100_12327_false"
149
+ ],
150
+ "probe_configuration_hash": "667540b0fa890cca",
151
+ "sklearn_version": "1.9.0",
152
+ "n_iter": 20
153
+ }
phase2_scaling/results/probe_weights/s1a_llama_3_1_70b_L19_P138_f0.npz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4bbf1a1230331c7219d6805c45a005b63f8195d7a800d535bf852c86d5516bf9
3
+ size 165142
phase2_scaling/results/probe_weights/s1a_llama_3_1_70b_L19_P138_f0_manifest.json ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "probe_id": "s1a_llama_3_1_70b_L19_P138_f0",
3
+ "stage": "1A",
4
+ "protocol": "within_relation",
5
+ "model_id": "meta-llama/Llama-3.1-70B",
6
+ "model_revision": "served via NDIF",
7
+ "layer_index": 19,
8
+ "normalized_depth": 0.25,
9
+ "source_relations": [
10
+ "P138"
11
+ ],
12
+ "target_relation": "P138",
13
+ "fold": 0,
14
+ "training_example_ids": [
15
+ "P138_N100_21466_true",
16
+ "P138_N100_21466_false",
17
+ "P138_N100_18404_true",
18
+ "P138_N100_18404_false",
19
+ "P138_N100_7626_true",
20
+ "P138_N100_7626_false",
21
+ "P138_N100_684_true",
22
+ "P138_N100_684_false",
23
+ "P138_N100_18926_true",
24
+ "P138_N100_18926_false",
25
+ "P138_N100_15997_true",
26
+ "P138_N100_15997_false",
27
+ "P138_N100_8010_true",
28
+ "P138_N100_8010_false",
29
+ "P138_N100_2887_true",
30
+ "P138_N100_2887_false",
31
+ "P138_N100_18333_true",
32
+ "P138_N100_18333_false",
33
+ "P138_N100_21706_true",
34
+ "P138_N100_21706_false",
35
+ "P138_N100_2173_true",
36
+ "P138_N100_2173_false",
37
+ "P138_N100_11232_true",
38
+ "P138_N100_11232_false",
39
+ "P138_N100_19390_true",
40
+ "P138_N100_19390_false",
41
+ "P138_N100_15701_true",
42
+ "P138_N100_15701_false",
43
+ "P138_N100_15754_true",
44
+ "P138_N100_15754_false",
45
+ "P138_N100_3280_true",
46
+ "P138_N100_3280_false",
47
+ "P138_N100_12624_true",
48
+ "P138_N100_12624_false",
49
+ "P138_N100_18490_true",
50
+ "P138_N100_18490_false",
51
+ "P138_N100_21385_true",
52
+ "P138_N100_21385_false",
53
+ "P138_N100_8074_true",
54
+ "P138_N100_8074_false",
55
+ "P138_N100_5213_true",
56
+ "P138_N100_5213_false",
57
+ "P138_N100_2215_true",
58
+ "P138_N100_2215_false",
59
+ "P138_N100_20154_true",
60
+ "P138_N100_20154_false",
61
+ "P138_N100_14512_true",
62
+ "P138_N100_14512_false",
63
+ "P138_N100_14506_true",
64
+ "P138_N100_14506_false",
65
+ "P138_N100_2124_true",
66
+ "P138_N100_2124_false",
67
+ "P138_N100_19373_true",
68
+ "P138_N100_19373_false",
69
+ "P138_N100_19983_true",
70
+ "P138_N100_19983_false",
71
+ "P138_N100_9667_true",
72
+ "P138_N100_9667_false",
73
+ "P138_N100_19568_true",
74
+ "P138_N100_19568_false",
75
+ "P138_N100_14965_true",
76
+ "P138_N100_14965_false",
77
+ "P138_N100_21036_true",
78
+ "P138_N100_21036_false",
79
+ "P138_N100_737_true",
80
+ "P138_N100_737_false",
81
+ "P138_N100_466_true",
82
+ "P138_N100_466_false",
83
+ "P138_N100_4184_true",
84
+ "P138_N100_4184_false",
85
+ "P138_N100_10227_true",
86
+ "P138_N100_10227_false",
87
+ "P138_N100_17022_true",
88
+ "P138_N100_17022_false",
89
+ "P138_N100_415_true",
90
+ "P138_N100_415_false",
91
+ "P138_N100_4551_true",
92
+ "P138_N100_4551_false",
93
+ "P138_N100_11333_true",
94
+ "P138_N100_11333_false",
95
+ "P138_N100_18132_true",
96
+ "P138_N100_18132_false",
97
+ "P138_N100_4284_true",
98
+ "P138_N100_4284_false",
99
+ "P138_N100_9788_true",
100
+ "P138_N100_9788_false",
101
+ "P138_N100_15157_true",
102
+ "P138_N100_15157_false",
103
+ "P138_N100_13931_true",
104
+ "P138_N100_13931_false",
105
+ "P138_N100_12308_true",
106
+ "P138_N100_12308_false",
107
+ "P138_N100_8424_true",
108
+ "P138_N100_8424_false",
109
+ "P138_N100_15940_true",
110
+ "P138_N100_15940_false",
111
+ "P138_N100_2683_true",
112
+ "P138_N100_2683_false",
113
+ "P138_N100_15852_true",
114
+ "P138_N100_15852_false",
115
+ "P138_N100_4149_true",
116
+ "P138_N100_4149_false",
117
+ "P138_N100_17489_true",
118
+ "P138_N100_17489_false",
119
+ "P138_N100_20628_true",
120
+ "P138_N100_20628_false",
121
+ "P138_N100_456_true",
122
+ "P138_N100_456_false",
123
+ "P138_N100_16766_true",
124
+ "P138_N100_16766_false",
125
+ "P138_N100_17077_true",
126
+ "P138_N100_17077_false",
127
+ "P138_N100_1404_true",
128
+ "P138_N100_1404_false",
129
+ "P138_N100_2730_true",
130
+ "P138_N100_2730_false",
131
+ "P138_N100_15467_true",
132
+ "P138_N100_15467_false",
133
+ "P138_N100_18909_true",
134
+ "P138_N100_18909_false",
135
+ "P138_N100_11155_true",
136
+ "P138_N100_11155_false",
137
+ "P138_N100_4166_true",
138
+ "P138_N100_4166_false",
139
+ "P138_N100_7952_true",
140
+ "P138_N100_7952_false",
141
+ "P138_N100_20201_true",
142
+ "P138_N100_20201_false",
143
+ "P138_N100_6255_true",
144
+ "P138_N100_6255_false",
145
+ "P138_N100_17683_true",
146
+ "P138_N100_17683_false"
147
+ ],
148
+ "probe_configuration_hash": "667540b0fa890cca",
149
+ "sklearn_version": "1.9.0",
150
+ "n_iter": 18
151
+ }