forked from chrishayuk/larql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhistory.txt
More file actions
62 lines (62 loc) · 12.6 KB
/
Copy pathhistory.txt
File metadata and controls
62 lines (62 loc) · 12.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#V2
SELECT count() FROM embeddings GROUP ALL;
exit
quit
exit
bye
SELECT count() FROM embeddings GROUP ALL;\nSELECT count() FROM ffn_gate GROUP ALL;\nSELECT count() FROM ffn_down GROUP ALL;\nSELECT count() FROM attn_ov GROUP ALL;
SELECT token_id, token, c_score FROM embeddings WHERE token = 'France';
LET $v = (SELECT vector FROM embeddings WHERE token = 'France' LIMIT 1);\nSELECT token, vector::distance::knn() AS dist FROM embeddings WHERE vector <|10, COSINE|> $v.vector ORDER BY dist;
SELECT * FROM embeddings LIMIT 3;
clear
-- If you know the token ID (check your tokenizer)\nSELECT id, top_token, c_score FROM embeddings:T6342;
SELECT id, top_token, c_score FROM embeddings WHERE top_token = 'France' LIMIT 5;
LET $v = (SELECT vector FROM embeddings:T7001);\nSELECT id, top_token, vector::distance::knn() AS dist FROM embeddings WHERE vector <|10, COSINE|> $v.vector ORDER BY dist;
SELECT id, top_token, vector::distance::knn() AS dist \nFROM embeddings \nWHERE vector <|10, COSINE|> (SELECT VALUE vector FROM embeddings:T7001) \nORDER BY dist;
LET $v = (SELECT VALUE vector FROM embeddings:T7001);\nSELECT id, top_token, vector::distance::knn() AS dist \nFROM embeddings \nWHERE vector <|10, COSINE|> $v \nORDER BY dist;
LET $v = (SELECT vector FROM ONLY embeddings:T7001).vector;\nSELECT id, top_token, vector::distance::knn() AS dist \nFROM embeddings \nWHERE vector <|10, COSINE|> $v \nORDER BY dist;
LET $v = (SELECT vector FROM ONLY embeddings:T7001).vector; \n SELECT id, feature, top_token, c_score, vector::distance::knn() AS dist \n FROM ffn_gate\n WHERE layer = 26 AND vector <|10, COSINE|> $v \n ORDER BY dist;
SELECT id, top_token, c_score FROM ffn_down:L26_F5140;\nSELECT id, top_token, c_score FROM ffn_down:L26_F2384;\nSELECT id, top_token, c_score FROM ffn_down:L26_F9348;\nSELECT id, top_token, c_score FROM ffn_down:L26_F5040;\nSELECT id, top_token, c_score FROM ffn_down:L26_F943;
LET $v = (SELECT vector FROM ONLY embeddings WHERE top_token = 'Toulouse' LIMIT 1).vector;\nSELECT id, feature, top_token, c_score, vector::distance::knn() AS dist \nFROM ffn_gate \nWHERE layer = 26 AND vector <|10, COSINE|> $v \nORDER BY dist;
LET $v = (SELECT vector FROM ONLY embeddings WHERE top_token = 'Paris' LIMIT 1).vector;\nSELECT id, feature, top_token, c_score, vector::distance::knn() AS dist \nFROM ffn_gate \nWHERE layer = 26 AND vector <|10, COSINE|> $v \nORDER BY dist;
SELECT id, top_token, c_score FROM ffn_down:L26_F2398;\nSELECT id, top_token, c_score FROM ffn_down:L26_F3315;\nSELECT id, top_token, c_score FROM ffn_down:L26_F9604;\nSELECT id, top_token, c_score FROM ffn_down:L26_F1789;\nSELECT id, top_token, c_score FROM ffn_down:L26_F8114;
LET $g = (SELECT vector FROM ONLY ffn_gate:L26_F67).vector; \n LET $d = (SELECT vector FROM ONLY ffn_down:L26_F67).vector;\n RETURN { \n feature: 67, \n gate_token: (SELECT top_token FROM ONLY ffn_gate:L26_F67).top_token, \n down_token: (SELECT top_token FROM ONLY ffn_down:L26_F67).top_token, \n cosine: vector::similarity::cosine($g, $d) \n };
LET $g = (SELECT vector FROM ONLY ffn_gate:L26_F5040).vector;\nLET $d = (SELECT vector FROM ONLY ffn_down:L26_F5040).vector;\nRETURN {\n feature: 5040,\n gate_token: (SELECT top_token FROM ONLY ffn_gate:L26_F5040).top_token,\n down_token: (SELECT top_token FROM ONLY ffn_down:L26_F5040).top_token,\n cosine: vector::similarity::cosine($g, $d)\n};
LET $g = (SELECT vector FROM ONLY ffn_gate:L26_F943).vector;\nLET $d = (SELECT vector FROM ONLY ffn_down:L26_F943).vector;\nRETURN {\n feature: 943,\n gate_token: (SELECT top_token FROM ONLY ffn_gate:L26_F943).top_token,\n down_token: (SELECT top_token FROM ONLY ffn_down:L26_F943).top_token,\n cosine: vector::similarity::cosine($g, $d)\n};
LET $g = (SELECT vector FROM ONLY ffn_gate:L26_F9348).vector;\nLET $d = (SELECT vector FROM ONLY ffn_down:L26_F9348).vector;\nRETURN {\n feature: 9348,\n gate_token: (SELECT top_token FROM ONLY ffn_gate:L26_F9348).top_token,\n down_token: (SELECT top_token FROM ONLY ffn_down:L26_F9348).top_token,\n cosine: vector::similarity::cosine($g, $d)\n};
LET $g = (SELECT vector FROM ONLY ffn_gate:L26_F5140).vector;\nLET $d = (SELECT vector FROM ONLY ffn_down:L26_F5140).vector;\nRETURN {\n feature: 5140,\n gate_token: (SELECT top_token FROM ONLY ffn_gate:L26_F5140).top_token,\n down_token: (SELECT top_token FROM ONLY ffn_down:L26_F5140).top_token,\n cosine: vector::similarity::cosine($g, $d)\n};
SELECT id, feature, top_token, c_score \nFROM ffn_gate \nWHERE layer = 26 AND c_score > 0.3 \nORDER BY c_score DESC \nLIMIT 20;
SELECT id, feature, top_token, c_score \nFROM ffn_gate \nWHERE layer = 26 \n AND top_token = /^[A-Z]/ \n AND c_score > 0.05\nORDER BY c_score DESC \nLIMIT 30;
LET $g = (SELECT vector FROM ONLY ffn_gate:L26_F9348).vector;\nLET $d = (SELECT vector FROM ONLY ffn_down:L26_F9348).vector;\nRETURN { f: 9348, gate: 'Italy', down: (SELECT top_token FROM ONLY ffn_down:L26_F9348).top_token, cos: vector::similarity::cosine($g, $d) };
LET $g = (SELECT vector FROM ONLY ffn_gate:L26_F7915).vector;\nLET $d = (SELECT vector FROM ONLY ffn_down:L26_F7915).vector;\nRETURN { f: 7915, gate: 'Ireland', down: (SELECT top_token FROM ONLY ffn_down:L26_F7915).top_token, cos: vector::similarity::cosine($g, $d) };
LET $g = (SELECT vector FROM ONLY ffn_gate:L26_F918).vector;\nLET $d = (SELECT vector FROM ONLY ffn_down:L26_F918).vector;\nRETURN { f: 918, gate: 'Rome', down: (SELECT top_token FROM ONLY ffn_down:L26_F918).top_token, cos: vector::similarity::cosine($g, $d) };
LET $g = (SELECT vector FROM ONLY ffn_gate:L26_F2230).vector;\nLET $d = (SELECT vector FROM ONLY ffn_down:L26_F2230).vector;\nRETURN { f: 2230, gate: 'Dutch', down: (SELECT top_token FROM ONLY ffn_down:L26_F2230).top_token, cos: vector::similarity::cosine($g, $d) };
LET $g = (SELECT vector FROM ONLY ffn_gate:L26_F5759).vector;\nLET $d = (SELECT vector FROM ONLY ffn_down:L26_F5759).vector;\nRETURN { f: 5759, gate: 'Ethiopia', down: (SELECT top_token FROM ONLY ffn_down:L26_F5759).top_token, cos: vector::similarity::cosine($g, $d) };
SELECT id, feature, top_token, c_score \n FROM ffn_gate \n WHERE layer = 26 AND c_score > 0.15 \n ORDER BY c_score DESC \n LIMIT 20;
-- What does L26-F5040 (Toulouse→French) feed into at L27?\nLET $d = (SELECT vector FROM ONLY ffn_down:L26_F5040).vector;\nSELECT id, feature, top_token, c_score, vector::distance::knn() AS dist\nFROM ffn_gate\nWHERE layer = 27 AND vector <|5, COSINE|> $d.vector\nORDER BY dist;
SELECT id, top_token, c_score FROM ffn_down:L26_F5040;
SELECT * FROM ffn_down:L26_F5040 LIMIT 1;
SELECT meta::id(id), top_token, c_score FROM ffn_down WHERE layer = 26 AND feature = 5040;
SELECT * FROM ffn_down LIMIT 1;
LET $d = (SELECT vector FROM ONLY ffn_down:L26_F5040).vector;\nSELECT id, feature, top_token, c_score, vector::distance::knn() AS dist\nFROM ffn_gate\nWHERE layer = 27 AND vector <|5, COSINE|> $d\nORDER BY dist;
-- What does F5040's down vector land near in embedding space?\nLET $d = (SELECT vector FROM ONLY ffn_down:L26_F5040).vector;\nSELECT id, top_token, vector::distance::knn() AS dist\nFROM embeddings\nWHERE vector <|10, COSINE|> $d\nORDER BY dist;
LET $d = (SELECT vector FROM ONLY ffn_down:L26_F943).vector;\nSELECT id, top_token, vector::distance::knn() AS dist\nFROM embeddings WHERE vector <|10, COSINE|> $d ORDER BY dist;
LET $d = (SELECT vector FROM ONLY ffn_down:L26_F918).vector;\nSELECT id, top_token, vector::distance::knn() AS dist\nFROM embeddings WHERE vector <|10, COSINE|> $d ORDER BY dist;
LET $d = (SELECT vector FROM ONLY ffn_down:L26_F2230).vector;\nSELECT id, top_token, vector::distance::knn() AS dist\nFROM embeddings WHERE vector <|10, COSINE|> $d ORDER BY dist;
LET $d = (SELECT vector FROM ONLY ffn_down:L26_F5140).vector; \n SELECT id, top_token, vector::distance::knn() AS dist \n FROM embeddings WHERE vector <|10, COSINE|> $d ORDER BY dist;
LET $d = (SELECT vector FROM ONLY ffn_down:L26_F2384).vector;\n SELECT id, top_token, vector::distance::knn() AS dist \n FROM embeddings WHERE vector <|10, COSINE|> $d ORDER BY dist;
LET $d = (SELECT vector FROM ONLY ffn_down:L26_F5040).vector; \n SELECT id, feature, top_token, c_score, vector::distance::knn() AS dist \n FROM ffn_down \n WHERE layer = 26 AND vector <|20, COSINE|> $d \n ORDER BY dist;
exit
LET $d = (SELECT vector FROM ONLY ffn_down:L26_F5040).vector; \n SELECT id, feature, top_token, c_score, vector::distance::knn() AS dist \n FROM ffn_down \n WHERE layer = 26 AND vector <|20, COSINE|> $d \n ORDER BY dist;
LET $v = (SELECT vector FROM ONLY ffn_up:L26_F5040).vector;\nSELECT id, top_token, vector::distance::knn() AS dist\nFROM embeddings WHERE vector <|10, COSINE|> $v ORDER BY dist;
LET $france = (SELECT vector FROM ONLY embeddings:T7001).vector;\nLET $neighbours = (SELECT vector FROM embeddings WHERE vector <|10, COSINE|> $france);
-- What does F3593's down vector look like against OTHER down vectors that DID resolve?\nLET $d = (SELECT vector FROM ONLY ffn_down:L26_F3593).vector;\nSELECT id, feature, top_token, vector::distance::knn() AS dist\nFROM ffn_down WHERE layer = 26 AND vector <|5, COSINE|> $d ORDER BY dist;
SELECT top_k FROM ffn_down:L26_F3593;
-- What do L26 attention heads write? (OV vectors against embeddings)\nLET $v = (SELECT vector FROM ONLY attn_ov:L26_H0).vector;\nSELECT id, top_token, vector::distance::knn() AS dist\nFROM embeddings WHERE vector <|10, COSINE|> $v ORDER BY dist;
exit
-- What do L26 attention heads write? (OV vectors against embeddings)\nLET $v = (SELECT vector FROM ONLY attn_ov:L26_H0).vector;\nSELECT id, top_token, vector::distance::knn() AS dist\nFROM embeddings WHERE vector <|10, COSINE|> $v ORDER BY dist;
-- What does head 0 at L26 respond to? (QK vectors against embeddings)\nLET $v = (SELECT vector FROM ONLY attn_qk:L26_H0).vector;\nSELECT id, top_token, vector::distance::knn() AS dist\nFROM embeddings WHERE vector <|10, COSINE|> $v ORDER BY dist;
-- Which attention heads' OV vectors are nearest to "Germany"?\nLET $v = (SELECT vector FROM ONLY embeddings WHERE top_token = 'Germany' LIMIT 1).vector;\nSELECT id, layer, feature AS head, top_token, vector::distance::knn() AS dist\nFROM attn_ov WHERE vector <|5, COSINE|> $v ORDER BY dist;
-- Which attention heads' OV vectors are nearest to "German"?\nLET $v = (SELECT vector FROM ONLY embeddings WHERE top_token = 'German' LIMIT 1).vector;\nSELECT id, layer, feature AS head, top_token, vector::distance::knn() AS dist\nFROM attn_ov WHERE vector <|5, COSINE|> $v ORDER BY dist;
exit
clear