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 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
# BCS、BES、ISS 与 KTS 评测规范

## 0. 目的

本规范用于在固定事实知识数据集上评测大语言模型的:

1. **外部行为一致性**2. **内部事实状态稳定性**3. **整体知识拓扑稳定性**。

最终报告四个核心指标:

\[
\boxed{
\mathrm{BCS},\quad
\mathrm{BES},\quad
\mathrm{ISS},\quad
\mathrm{KTS}
}
\]

其中:

| 指标 | 全称 | 分析层级 | 核心问题 |
|---|---|---|---|
| BCS | Behavioral Consistency Score | 单事实、外部行为 | 不同检索条件下是否主要表达同一个答案? |
| BES | Behavioral Entropy Stability | 单事实、外部行为 | 回答分布是否集中,还是分散到多个答案? |
| ISS | Internal State Stability | 单事实、内部表示 | 同一事实跨条件是否形成一致且可区分的内部状态? |
| KTS | Knowledge Topology Stability | 数据集、内部空间 | 不同条件下事实身份与整体知识几何是否保持? |

本规范默认使用固定主事实集:

\[
\mathcal D=\{f_1,\ldots,f_N\},\qquad N=2,592.
\]

所有被测模型使用完全相同的事实和 query bank。模型在 anchor 条件下是否回答正确,只作为标签,不改变评测分母。

---

# 1. 评测条件

## 1.1 主前向检索条件

以下条件保持检索目标为:

\[
(s,r)\rightarrow o.
\]

记主条件集合为:

\[
\mathcal T=
\{
\text{anchor},
\text{paraphrase},
\text{format},
\text{context},
\text{multilingual}
\}.
\]

这些条件进入 BCS、BES、ISS 和 KTS 的主要计算。

## 1.2 独立诊断条件

以下条件不混入主指标:

- `recognition`:正确答案已经出现在候选中,属于辅助识别;
- `reverse`:检索目标从 object 改为 subject,单独报告 structural retrieval;
- `reverse_illposed`:反向映射不唯一,只用于数据诊断。

## 1.3 覆盖不完整时的处理

当前数据中:

- anchor:覆盖 2,592 条事实;
- paraphrase:覆盖 2,592 条事实;
- format:覆盖 2,592 条事实;
- context:覆盖 2,591 条事实;
- multilingual:覆盖 2,402 条事实。

推荐优先补齐缺失条件。

在未补齐前,应同时报告:

### Complete-family 主结果

仅使用具备全部五个主条件的事实集合:

\[
\mathcal D_{\cap}
=
\bigcap_{t\in\mathcal T}\mathcal D_t.
\]

这是最严格、最可比的主结果。

### Full-set 补充结果

对每条事实使用其实际存在的条件集合:

\[
\mathcal T_f
=
\{t\in\mathcal T:f\in\mathcal D_t\}.
\]

所有平均都按可用 condition family 等权计算,并报告每个指标的有效样本数。

不能为缺失条件伪造零分,也不能把不同模型的有效事实集设为不同集合。

---

# 2. 必要输入

## 2.1 Fact 文件

每条事实至少包含:

```json
{
  "fact_id": "fact_000001",
  "subject": "France",
  "relation": "capital",
  "object": "Paris",
  "gold_aliases": ["Paris", "City of Paris"],
  "answer_type": "city",
  "answer_granularity": "entity"
}
```

## 2.2 Query 文件

每条 query 至少包含:

```json
{
  "query_id": "query_00000001",
  "fact_id": "fact_000001",
  "condition_family": "paraphrase",
  "variant_id": "para_02",
  "language": "en",
  "query": "Which city serves as the capital of France?",
  "target_slot": "object",
  "use_for_main_forward": true
}
```

## 2.3 模型输出文件

```json
{
  "model": "model_name",
  "query_id": "query_00000001",
  "fact_id": "fact_000001",
  "condition_family": "paraphrase",
  "raw_response": "The answer is Paris.",
  "generation_config": {
    "do_sample": false,
    "temperature": 0,
    "max_new_tokens": 24
  }
}
```

## 2.4 内部表示文件

ISS 和 KTS 需要在模型尚未生成第一个答案 token 时,提取问题末位位置的 residual state:

```json
{
  "model": "model_name",
  "query_id": "query_00000001",
  "fact_id": "fact_000001",
  "condition_family": "paraphrase",
  "layer": 16,
  "position": "query_end",
  "hidden_state_path": "..."
}
```

必须保证所有 query 使用同一种位置定义:

> 输入 prompt 的最后一个有效 token,即模型读完问题但尚未开始生成答案的位置。

---

# 3. AI Judge 输出协议

BCS 和 BES 不直接比较原始字符串,而基于 AI Judge 得到的语义答案 cluster。

整个过程分为两步。

## 3.1 Reference-blind 答案抽取与聚类

Judge 不看 gold answer,只完成:

1. 提取回答最终主张的核心答案;
2. 忽略句式、语言、标点和解释性文字;
3. 将语义等价答案归为同一 cluster;
4. 标记拒答、多答案和无法解析输出。

例如:

```text
Paris
The answer is Paris.
Paris, France.
巴黎
```

应归入同一个语义 cluster。

建议特殊 cluster:

- `ABSTAIN`:拒答或明确表示不知道;
- `MULTIPLE`:给出多个冲突答案且未选择;
- `UNPARSEABLE`:无法提取明确答案;
- 具体实体或命题 cluster,如 `ENTITY_Q90``SEMANTIC_PARIS`。

Judge 输出:

```json
{
  "query_id": "query_00000001",
  "fact_id": "fact_000001",
  "cluster_id": "ENTITY_Q90",
  "canonical_meaning": "Paris",
  "status": "ANSWER",
  "confidence": 0.98
}
```

同一事实的所有主条件输出应一次性或全局一致地聚类,避免两两判断产生非传递关系。

## 3.2 Reference-aware 正确性判断

第二步再向 Judge 提供:

- gold answer;
- accepted aliases;
- answer type;
- answer granularity。

对每个语义 cluster 标记:

- `CORRECT`- `INCORRECT`- `ABSTAIN`- `AMBIGUOUS`- `REVIEW_REQUIRED`。

该步骤用于区分 Stable Correct 和 Stable Wrong,但不参与答案 cluster 的形成。

---

# 4. BCS:Behavioral Consistency Score

## 4.1 为什么需要 family-balanced 计算

不同 condition family 的 query 数量差异很大。例如:

- paraphrase 可能有 3–5 个版本;
- multilingual 可能有多个语言版本;
- anchor 通常只有 1 条。

如果直接按全部 query 计数,query 更多的 family 会支配结果。

因此必须先在每个 family 内计算答案分布,再对 family 等权聚合。

## 4.2 Family 内答案分布

设事实 \(f\) 在 family \(t\) 下的 query 集为:

\[
Q_{f,t}.
\]

AI Judge 给 query \(q\) 分配语义 cluster:

\[
\kappa_{m,f,q}.
\]

对于答案 cluster \(a\),定义:

\[
p_{m,f,t}(a)
=
\frac{1}{|Q_{f,t}|}
\sum_{q\in Q_{f,t}}
\mathbb I[
\kappa_{m,f,q}=a
].
\]

每个 family 的总概率满足:

\[
\sum_a p_{m,f,t}(a)=1.
\]

## 4.3 跨 family 等权聚合

对事实 \(f\) 的有效主条件集合 \(\mathcal T_f\),定义:

\[
p_{m,f}(a)
=
\frac{1}{|\mathcal T_f|}
\sum_{t\in\mathcal T_f}
p_{m,f,t}(a).
\]

这样每个 condition family 权重相同,不受该 family 中 query 数量影响。

## 4.4 BCS 定义

\[
\boxed{
\mathrm{BCS}_{m,f}
=
\max_a p_{m,f}(a)
}
\]

取最大概率的 cluster:

\[
a^*_{m,f}
=
\arg\max_a p_{m,f}(a).
\]

解释:

- \(\mathrm{BCS}=1\):所有有效条件都只支持同一个语义答案;
- \(\mathrm{BCS}=0.8\):主要答案获得 80% 的 family-balanced 概率;
- BCS 较低:输出分散到多个答案。

BCS 不判断主答案是否正确。

例如,gold 是 `Canberra`,但所有条件都回答 `Sydney`:

\[
\mathrm{BCS}=1.
\]

这是高度稳定但错误的行为。

## 4.5 模型级 BCS

\[
\boxed{
\mathrm{BCS}_m
=
\frac{1}{|\mathcal D_{\mathrm{eval}}|}
\sum_{f\in\mathcal D_{\mathrm{eval}}}
\mathrm{BCS}_{m,f}
}
\]

其中:

- 主结果使用 \(\mathcal D_{\cap}\);
- 补充结果可使用完整可用集合。

---

# 5. BES:Behavioral Entropy Stability

BCS 只关注最大答案 cluster,可能忽略剩余概率如何分布。

例如以下两种情况的 BCS 都是 0.6:

```text
A: 0.6, B: 0.4
```

和:

```text
A: 0.6, B: 0.1, C: 0.1, D: 0.1, E: 0.1
```

第二种回答明显更加分散,因此需要 BES。

## 5.1 答案熵

基于 family-balanced 分布 \(p_{m,f}(a)\),定义:

\[
H_{m,f}
=
-\sum_{a:p_{m,f}(a)>0}
p_{m,f}(a)\log p_{m,f}(a).
\]

设实际观察到的非零答案 cluster 数为:

\[
A_{m,f}
=
\left|
\{a:p_{m,f}(a)>0\}
\right|.
\]

## 5.2 BES 定义

当 \(A_{m,f}=1\) 时:

\[
\mathrm{BES}_{m,f}=1.
\]

当 \(A_{m,f}>1\) 时:

\[
\boxed{
\mathrm{BES}_{m,f}
=
1-
\frac{H_{m,f}}{\log A_{m,f}}
}
\]

解释:

- \(\mathrm{BES}=1\):回答完全集中于一个 cluster;
- \(\mathrm{BES}=0\):回答在所有已观察 cluster 上均匀分布;
- 值越高,回答分布越集中。

BCS 和 BES 的区别:

- BCS 衡量最大 cluster 的占比;
- BES 衡量完整答案分布的集中程度。

建议将 BCS 作为主外部稳定性指标,BES 作为补充指标。

## 5.3 模型级 BES

\[
\boxed{
\mathrm{BES}_m
=
\frac{1}{|\mathcal D_{\mathrm{eval}}|}
\sum_{f\in\mathcal D_{\mathrm{eval}}}
\mathrm{BES}_{m,f}
}
\]

---

# 6. 外部行为类型

设置预注册的行为稳定阈值:

\[
\tau_B=0.8.
\]

根据主答案 cluster \(a^*_{m,f}\) 的正确性,将事实划分为:

## 6.1 Stable Correct

\[
\mathrm{BCS}_{m,f}\ge \tau_B
\]

且:

\[
a^*_{m,f}\text{ 被 Judge 标记为 CORRECT}.
\]

## 6.2 Stable Wrong

\[
\mathrm{BCS}_{m,f}\ge \tau_B
\]

且主 cluster 是明确的错误答案。

## 6.3 Stable Abstention

\[
\mathrm{BCS}_{m,f}\ge \tau_B
\]

且:

\[
a^*_{m,f}=\mathrm{ABSTAIN}.
\]

## 6.4 Unstable

\[
\mathrm{BCS}_{m,f}<\tau_B.
\]

建议额外做阈值敏感性分析:

\[
\tau_B\in\{0.7,0.8,0.9\}.
\]

模型级比例:

\[
\mathrm{SCR}_m
=
\frac{\#\text{Stable Correct}}{|\mathcal D_{\mathrm{eval}}|},
\]

\[
\mathrm{SWR}_m
=
\frac{\#\text{Stable Wrong}}{|\mathcal D_{\mathrm{eval}}|},
\]

\[
\mathrm{SAR}_m
=
\frac{\#\text{Stable Abstention}}{|\mathcal D_{\mathrm{eval}}|},
\]

\[
\mathrm{UR}_m
=
\frac{\#\text{Unstable}}{|\mathcal D_{\mathrm{eval}}|}.
\]

四者应满足:

\[
\mathrm{SCR}_m+
\mathrm{SWR}_m+
\mathrm{SAR}_m+
\mathrm{UR}_m
=1.
\]

---

# 7. ISS:Internal State Stability

## 7.1 测量目标

ISS 衡量:

> 同一事实在不同主检索条件下,是否形成一致且具有事实区分性的内部状态。

ISS 不依赖模型最终答案是否正确,也不依赖 gold answer 是单 token 还是多 token。

## 7.2 Query-end hidden state

对于模型 \(m\)、事实 \(f\)、query \(q\) 和层 \(\ell\),提取:

\[
h^\ell_{m,f,q}\in\mathbb R^{d_m}.
\]

位置固定为 query 最后一个有效输入 token。

## 7.3 J-Lens Jacobian transport

对每一层估计平均 Jacobian transport:

\[
J^\ell_m
=
\mathbb E_x
\left[
\frac{\partial h^L_m}{\partial h^\ell_m}
\right].
\]

将第 \(\ell\) 层状态运输到 final-layer residual basis:

\[
\boxed{
z^\ell_{m,f,q}
=
J^\ell_m h^\ell_{m,f,q}
}
\]

这里只使用运输后的 hidden representation,不乘 unembedding matrix,因此不进入 vocabulary space。

如果暂时无法实现 Jacobian transport,可以用 raw hidden state 计算一个 `Raw-ISS` 作为消融,但主指标应使用 transported state。

## 7.4 去除 relation 和 condition family 主效应

对每个模型和层计算:

\[
\mu^\ell_m
=
\mathbb E_{f,q}[z^\ell_{m,f,q}],
\]

\[
\mu^\ell_{m,r}
=
\mathbb E_{f,q:r_f=r}[z^\ell_{m,f,q}],
\]

\[
\mu^\ell_{m,t}
=
\mathbb E_{f,q:t(q)=t}[z^\ell_{m,f,q}].
\]

双重残差化:

\[
\bar z^\ell_{m,f,q}
=
z^\ell_{m,f,q}
-
\mu^\ell_{m,r_f}
-
\mu^\ell_{m,t(q)}
+
\mu^\ell_m.
\]

该步骤用于减少:

- relation 类型共有方向;
- query 格式共有方向;
- 语言 family 共有方向;
- residual stream 公共均值。

## 7.5 正则化白化

估计协方差:

\[
\Sigma^\ell_m
=
\operatorname{Cov}
\left(
\bar z^\ell_{m,f,q}
\right).
\]

定义:

\[
\tilde z^\ell_{m,f,q}
=
\left(
\Sigma^\ell_m+\lambda I
\right)^{-1/2}
\bar z^\ell_{m,f,q}.
\]

实践建议:

- 使用 shrinkage covariance;
- 或使用 PCA whitening;
- PCA 维度固定为 \(\min(512,d_m)\);
- 所有 query 使用同一个模型、同一层的变换;
- 不允许为不同 condition family 单独拟合白化矩阵。

随后进行 L2 归一化:

\[
\hat z^\ell_{m,f,q}
=
\frac{\tilde z^\ell_{m,f,q}}
{\|\tilde z^\ell_{m,f,q}\|_2+\epsilon}.
\]

## 7.6 Family centroid

一个 family 内可能有多个 query。为了避免 query 数量多的 family 获得更高权重,先计算 family centroid:

\[
v^\ell_{m,f,t}
=
\operatorname{Normalize}
\left(
\frac{1}{|Q_{f,t}|}
\sum_{q\in Q_{f,t}}
\hat z^\ell_{m,f,q}
\right).
\]

每条事实在每个 condition family 下只保留一个表示。

## 7.7 同事实跨 family 相似度

设事实 \(f\) 的有效 family pair 集为:

\[
\mathcal P_f
=
\{(t,t'):t,t'\in\mathcal T_f,\ t<t'\}.
\]

定义正样本相似度:

\[
S^+_{m,f,\ell}
=
\frac{1}{|\mathcal P_f|}
\sum_{(t,t')\in\mathcal P_f}
\cos
\left(
v^\ell_{m,f,t},
v^\ell_{m,f,t'}
\right).
\]

## 7.8 同 relation 背景相似度

为每个事实选择同 relation、不同事实的负样本集合:

\[
\mathcal N_f
=
\{g:g\neq f,\ r_g=r_f\}.
\]

对于每个 family pair,使用对称背景:

\[
B_{m,f,\ell}(t,t')
=
\frac{1}{2|\mathcal N_f|}
\sum_{g\in\mathcal N_f}
\left[
\cos(v^\ell_{m,f,t},v^\ell_{m,g,t'})
+
\cos(v^\ell_{m,f,t'},v^\ell_{m,g,t})
\right].
\]

再定义:

\[
S^-_{m,f,\ell}
=
\frac{1}{|\mathcal P_f|}
\sum_{(t,t')\in\mathcal P_f}
B_{m,f,\ell}(t,t').
\]

如果同 relation 事实过多,可以固定随机采样最多 100 个负事实,并对所有模型使用同一采样列表。

## 7.9 ISS 定义

\[
\boxed{
\mathrm{ISS}_{m,f,\ell}
=
\frac{
S^+_{m,f,\ell}
-
S^-_{m,f,\ell}
}{
1-S^-_{m,f,\ell}+\epsilon
}
}
\]

解释:

- 接近 1:同一事实跨条件高度一致;
- 接近 0:同一事实的相似性不高于同 relation 背景;
- 小于 0:跨条件表示比其他事实背景还不一致。

该值理论上可能小于 \(-1\)。统计分析应保留原始值;如果用于图表展示,可额外报告裁剪版本:

\[
\mathrm{ISS}^{\mathrm{clip}}
=
\operatorname{clip}(\mathrm{ISS},-1,1).
\]

不要用裁剪值替代原始统计值。

## 7.10 跨层 ISS

将相对层深定义为:

\[
d_\ell
=
\frac{\ell}{L_m-1}.
\]

预注册主分析窗口:

\[
\mathcal W_m
=
\{\ell:0.4\le d_\ell\le1.0\}.
\]

单事实 ISS:

\[
\boxed{
\mathrm{ISS}_{m,f}
=
\frac{1}{|\mathcal W_m|}
\sum_{\ell\in\mathcal W_m}
\mathrm{ISS}_{m,f,\ell}
}
\]

模型级 ISS:

\[
\boxed{
\mathrm{ISS}_m
=
\frac{1}{|\mathcal D_{\mathrm{eval}}|}
\sum_{f\in\mathcal D_{\mathrm{eval}}}
\mathrm{ISS}_{m,f}
}
\]

同时建议报告:

### Peak ISS

\[
\mathrm{ISS}^{\mathrm{peak}}_{m,f}
=
\max_{\ell\in\mathcal W_m}
\mathrm{ISS}_{m,f,\ell}.
\]

表示模型是否曾形成过一致事实状态。

### Late ISS

\[
\mathrm{ISS}^{\mathrm{late}}_{m,f}
=
\frac{1}{|\mathcal W^{\mathrm{late}}_m|}
\sum_{\ell:d_\ell\ge0.8}
\mathrm{ISS}_{m,f,\ell}.
\]

表示一致状态是否保持到靠近输出的阶段。

---

# 8. KTS:Knowledge Topology Stability

## 8.1 测量目标

KTS 衡量:

> 不同 condition family 下,整个事实表示空间的相对几何和事实身份是否保持。

KTS 不要求不同问法触发相同的计算路径。

它允许:

- 整体空间旋转;
- 平移;
- 各向同性缩放;
- 不同语言使用不同内部实现。

只要事实间相对结构和事实身份仍可保持,KTS 就可以较高。

## 8.2 Condition-specific knowledge space

对 condition family \(t\)、层 \(\ell\),将所有有效事实的 family centroid 组成:

\[
V^\ell_{m,t}
=
\begin{bmatrix}
v^\ell_{m,1,t}\\
v^\ell_{m,2,t}\\
\vdots\\
v^\ell_{m,N_t,t}
\end{bmatrix}.
\]

对 family pair \((t,t')\),只使用共同覆盖事实:

\[
\mathcal D_{t,t'}
=
\mathcal D_t\cap\mathcal D_{t'}.
\]

不同模型必须使用完全相同的 \(\mathcal D_{t,t'}\)。

---

# 9. KTS-Geo:全局几何稳定性

## 9.1 Relation 内距离矩阵

为减少 relation 不平衡和 relation 间宏观差异的支配作用,KTS-Geo 按 relation 计算后再宏平均。

对于 relation \(r\),定义:

\[
\mathcal D_{r,t,t'}
=
\{f\in\mathcal D_{t,t'}:r_f=r\}.
\]

仅保留至少包含 5 条事实的 relation。

在 family \(t\) 下构造 relation 内距离:

\[
D^\ell_{m,t,r}(f,g)
=
1-
\cos
\left(
v^\ell_{m,f,t},
v^\ell_{m,g,t}
\right).
\]

在 family \(t'\) 下类似构造:

\[
D^\ell_{m,t',r}(f,g).
\]

## 9.2 Relation 内几何相关性

\[
\rho^\ell_{m,r}(t,t')
=
\operatorname{Spearman}
\left(
\operatorname{vec}_{f<g}D^\ell_{m,t,r},
\operatorname{vec}_{f<g}D^\ell_{m,t',r}
\right).
\]

## 9.3 Relation-macro KTS-Geo

\[
\boxed{
\mathrm{KTS}^{\mathrm{geo}}_{m,\ell}(t,t')
=
\frac{1}{|\mathcal R_{t,t'}|}
\sum_{r\in\mathcal R_{t,t'}}
\rho^\ell_{m,r}(t,t')
}
\]

该值范围为:

\[
[-1,1].
\]

解释:

- 1:事实距离排序完全保持;
- 0:两个条件下的事实几何无显著对应;
- 负值:事实距离结构发生反向重排。

为了与 KTS-ID 合成,需要映射到 \([0,1]\):

\[
\widetilde{\mathrm{KTS}}^{\mathrm{geo}}
=
\frac{
\mathrm{KTS}^{\mathrm{geo}}+1
}{2}.
\]

---

# 10. KTS-ID:事实身份稳定性

全局距离结构可能看起来类似,但局部事实身份仍可能交换,因此需要 cross-condition fact identification。

## 10.1 跨条件最近邻检索

对于事实 \(f\) 在 family \(t\) 下的表示,在 family \(t'\) 的同 relation 事实中检索最近邻:

\[
\hat f_{t\rightarrow t'}
=
\arg\max_{
g\in\mathcal D_{r_f,t,t'}
}
\cos
\left(
v^\ell_{m,f,t},
v^\ell_{m,g,t'}
\right).
\]

反向同样计算:

\[
\hat f_{t'\rightarrow t}.
\]

## 10.2 Relation 内 Top-1 身份准确率

\[
\mathrm{ID}_{m,\ell,r}(t\rightarrow t')
=
\frac{1}{|\mathcal D_{r,t,t'}|}
\sum_{f\in\mathcal D_{r,t,t'}}
\mathbb I[
\hat f_{t\rightarrow t'}=f
].
\]

进行双向平均:

\[
\mathrm{ID}^{\mathrm{sym}}_{m,\ell,r}(t,t')
=
\frac{
\mathrm{ID}_{m,\ell,r}(t\rightarrow t')
+
\mathrm{ID}_{m,\ell,r}(t'\rightarrow t)
}{2}.
\]

## 10.3 Chance correction

若 relation \(r\) 有 \(n_r\) 条事实,随机 Top-1 命中的概率为:

\[
b_r=\frac{1}{n_r}.
\]

定义 chance-corrected identity:

\[
\mathrm{ID}^{\mathrm{adj}}_{m,\ell,r}
=
\frac{
\mathrm{ID}^{\mathrm{sym}}_{m,\ell,r}-b_r
}{
1-b_r+\epsilon
}.
\]

用于合成时裁剪到:

\[
[0,1].
\]

## 10.4 Relation-macro KTS-ID

\[
\boxed{
\mathrm{KTS}^{\mathrm{id}}_{m,\ell}(t,t')
=
\frac{1}{|\mathcal R_{t,t'}|}
\sum_{r\in\mathcal R_{t,t'}}
\operatorname{clip}
\left(
\mathrm{ID}^{\mathrm{adj}}_{m,\ell,r},
0,1
\right)
}
\]

建议同时报告原始:

- Top-1 accuracy;
- Top-5 accuracy;
- mean reciprocal rank;
- chance-corrected Top-1。

主 KTS 使用 chance-corrected Top-1。

---

# 11. KTS 合成

对于 family pair \((t,t')\) 和层 \(\ell\),定义:

\[
g
=
\widetilde{\mathrm{KTS}}^{\mathrm{geo}}_{m,\ell}(t,t'),
\]

\[
i
=
\mathrm{KTS}^{\mathrm{id}}_{m,\ell}(t,t').
\]

使用调和平均:

\[
\boxed{
\mathrm{KTS}_{m,\ell}(t,t')
=
\frac{
2gi
}{
g+i+\epsilon
}
}
\]

使用调和平均的原因是:

- 只有几何稳定但事实身份无法匹配,不应获得高 KTS;
- 只有身份匹配但整体邻域结构严重扭曲,也不应获得高 KTS。

## 11.1 跨 family pair 平均

主 family pair 集:

\[
\mathcal P_{\mathcal T}
=
\{(t,t'):t,t'\in\mathcal T,\ t<t'\}.
\]

每个 pair 等权:

\[
\mathrm{KTS}_{m,\ell}
=
\frac{1}{|\mathcal P_{\mathcal T}|}
\sum_{(t,t')\in\mathcal P_{\mathcal T}}
\mathrm{KTS}_{m,\ell}(t,t').
\]

不能按 pair 中 query 数或事实数加权,否则覆盖更大的 family 会支配结果。

## 11.2 跨层 KTS

\[
\boxed{
\mathrm{KTS}_m
=
\frac{1}{|\mathcal W_m|}
\sum_{\ell\in\mathcal W_m}
\mathrm{KTS}_{m,\ell}
}
\]

建议主表同时展示:

- KTS-Geo;
- KTS-ID;
- KTS composite。

不要只报告 composite 而隐藏两个组成部分。

---

# 12. 四个指标的联合解释

| BCS/BES | ISS | KTS | 解释 |
|---|---:|---:|---|
| 高 | 高 | 高 | 输出、单事实状态和整体知识结构均稳定 |
| 高 | 低 | 低 | 表面答案一致,但内部状态和知识组织不稳定 |
| 高 | 高 | 低 | 单事实局部状态一致,但整体空间可能坍缩或重排 |
| 低 | 高 | 高 | 内部知识较稳定,失败更可能发生在后期选择或表达 |
| 低 | 低 | 高 | 不同条件引起统一坐标变化,但知识拓扑仍保持 |
| 低 | 低 | 低 | 外部行为、单事实状态和知识空间均不稳定 |

对于 Stable Wrong:

- BCS/BES 高;
- 主 cluster 被判为错误;
- ISS 和 KTS 高;

表示模型可能稳定形成并组织了一个错误事实关联。

这不应称为“正确知识稳定”,而应称为:

> stable internal misalignment 或 stable wrong association。

---

# 13. 推荐主结果表

## 13.1 模型总体结果

| Model | Anchor Acc. | BCS | BES | Stable Correct | Stable Wrong | Stable Abstention | ISS | KTS-Geo | KTS-ID | KTS |
|---|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|
| Model A |  |  |  |  |  |  |  |  |  |  |
| Model B |  |  |  |  |  |  |  |  |  |  |

## 13.2 按行为类型分析内部稳定性

| Behavior group | Facts | ISS | KTS-Geo | KTS-ID | KTS |
|---|---:|---:|---:|---:|---:|
| Stable Correct |  |  |  |  |  |
| Stable Wrong |  |  |  |  |  |
| Stable Abstention |  |  |  |  |  |
| Unstable |  |  |  |  |  |

## 13.3 按 condition pair 报告 KTS

| Pair | Shared facts | KTS-Geo | KTS-ID | KTS |
|---|---:|---:|---:|---:|
| Anchor–Paraphrase |  |  |  |  |
| Anchor–Format |  |  |  |  |
| Anchor–Context |  |  |  |  |
| Anchor–Multilingual |  |  |  |  |
| Paraphrase–Format |  |  |  |  |
| ... |  |  |  |  |

---

# 14. 推荐统计协议

## 14.1 Relation-clustered bootstrap

由于 21 个 relation 的事实数量不均衡,不能只对所有事实进行普通独立 bootstrap。

推荐:

1. 有放回采样 relation;
2. 在每个采样 relation 内有放回采样事实;
3. 重复 1,000 次;
4. 报告 95% percentile confidence interval。

对 KTS-Geo 和 KTS-ID,应在每次 bootstrap 内重新计算关系宏平均。

## 14.2 模型间比较

比较模型 A 和 B 时使用 paired bootstrap:

- 每次使用相同的 relation 和 fact 重采样;
- 计算指标差:
  \[
  \Delta=\mathrm{Metric}_A-\mathrm{Metric}_B;
  \]
- 报告 \(\Delta\) 的 95% CI。

## 14.3 随机性控制

必须固定:

- 模型 revision;
- tokenizer revision;
- generation 参数;
- Judge 模型和 revision;
- Judge temperature;
- negative fact sampling;
- PCA 或 randomized SVD seed;
- bootstrap seed。

---

# 15. 评测流程

```text
固定 2,592 条事实和 query bank
          |
          v
对每个模型运行全部 query 的贪婪生成
          |
          v
Reference-blind AI Judge 抽取与语义聚类
          |
          +--> Reference-aware Judge 标记正确性
          |
          +--> 计算 BCS、BES 和行为类别
          |
          v
提取主前向 query 的 query-end hidden states
          |
          v
计算 J-Lens Jacobian transport
          |
          v
relation/condition 残差化 + whitening
          |
          v
构造每个 fact-family 的 centroid
          |
          +--> 计算 ISS
          |
          +--> 构建 condition-specific knowledge spaces
                    |
                    +--> KTS-Geo
                    +--> KTS-ID
                    +--> KTS composite
```

---

# 16. Python 风格伪代码

## 16.1 BCS 和 BES

```python
from collections import defaultdict
import math


def compute_bcs_bes(records, main_families):
    family_cluster_counts = defaultdict(lambda: defaultdict(int))
    family_totals = defaultdict(int)

    for item in records:
        family = item["condition_family"]
        if family not in main_families:
            continue
        cluster = item["cluster_id"]
        family_cluster_counts[family][cluster] += 1
        family_totals[family] += 1

    valid_families = sorted(family_totals)
    if not valid_families:
        raise ValueError("No valid main-family queries.")

    clusters = {
        cluster
        for family in valid_families
        for cluster in family_cluster_counts[family]
    }

    p = {}
    for cluster in clusters:
        p[cluster] = sum(
            family_cluster_counts[family].get(cluster, 0)
            / family_totals[family]
            for family in valid_families
        ) / len(valid_families)

    modal_cluster = max(p, key=p.get)
    bcs = p[modal_cluster]

    positive_probs = [value for value in p.values() if value > 0]
    if len(positive_probs) == 1:
        bes = 1.0
    else:
        entropy = -sum(value * math.log(value) for value in positive_probs)
        bes = 1.0 - entropy / math.log(len(positive_probs))

    return {
        "bcs": bcs,
        "bes": bes,
        "modal_cluster": modal_cluster,
        "cluster_distribution": p,
        "valid_families": valid_families,
    }
```

## 16.2 Family centroid

```python
import numpy as np


def l2_normalize(x, eps=1e-12):
    return x / max(np.linalg.norm(x), eps)


def family_centroid(query_vectors):
    normalized = [l2_normalize(x) for x in query_vectors]
    return l2_normalize(np.mean(normalized, axis=0))
```

## 16.3 单层 ISS

```python
def compute_iss_for_fact(
    family_vectors,
    same_relation_fact_vectors,
    eps=1e-12,
):
    families = sorted(family_vectors)
    positive = []
    negative = []

    for i, family_a in enumerate(families):
        for family_b in families[i + 1:]:
            va = family_vectors[family_a]
            vb = family_vectors[family_b]
            positive.append(float(np.dot(va, vb)))

            pair_negatives = []
            for other in same_relation_fact_vectors:
                if family_a not in other or family_b not in other:
                    continue
                pair_negatives.append(
                    0.5 * (
                        float(np.dot(va, other[family_b]))
                        + float(np.dot(vb, other[family_a]))
                    )
                )
            if pair_negatives:
                negative.append(float(np.mean(pair_negatives)))

    s_pos = float(np.mean(positive))
    s_neg = float(np.mean(negative))
    iss = (s_pos - s_neg) / (1.0 - s_neg + eps)

    return {
        "s_positive": s_pos,
        "s_background": s_neg,
        "iss": iss,
    }
```

## 16.4 KTS-ID

```python
def cross_condition_top1(vectors_a, vectors_b, fact_ids):
    vectors_a = np.asarray([l2_normalize(x) for x in vectors_a])
    vectors_b = np.asarray([l2_normalize(x) for x in vectors_b])

    sim_ab = vectors_a @ vectors_b.T
    sim_ba = vectors_b @ vectors_a.T

    pred_ab = np.argmax(sim_ab, axis=1)
    pred_ba = np.argmax(sim_ba, axis=1)
    gold = np.arange(len(fact_ids))

    acc_ab = np.mean(pred_ab == gold)
    acc_ba = np.mean(pred_ba == gold)
    acc_sym = 0.5 * (acc_ab + acc_ba)

    chance = 1.0 / len(fact_ids)
    adjusted = (acc_sym - chance) / max(1.0 - chance, 1e-12)

    return {
        "top1_symmetric": acc_sym,
        "chance": chance,
        "chance_corrected": float(np.clip(adjusted, 0.0, 1.0)),
    }
```

---

# 17. 输出文件建议

```text
metrics/
├── behavioral_per_query.jsonl
├── behavioral_per_fact.jsonl
├── behavioral_model_summary.json
├── hidden_family_centroids/
├── iss_per_fact_layer.jsonl
├── iss_per_fact.jsonl
├── iss_model_summary.json
├── kts_per_pair_layer.jsonl
├── kts_model_summary.json
├── bootstrap_intervals.json
└── evaluation_manifest.json
```

## 17.1 behavioral_per_fact.jsonl

```json
{
  "model": "model_name",
  "fact_id": "fact_000001",
  "bcs": 0.95,
  "bes": 0.82,
  "modal_cluster": "ENTITY_Q90",
  "modal_correctness": "CORRECT",
  "behavior_group": "Stable Correct",
  "valid_families": [
    "anchor",
    "paraphrase",
    "format",
    "context",
    "multilingual"
  ]
}
```

## 17.2 iss_per_fact.jsonl

```json
{
  "model": "model_name",
  "fact_id": "fact_000001",
  "relation": "capital",
  "iss": 0.61,
  "iss_peak": 0.79,
  "iss_late": 0.65,
  "layers_used": [12, 13, 14, 15, 16]
}
```

## 17.3 kts_model_summary.json

```json
{
  "model": "model_name",
  "kts_geo": 0.54,
  "kts_id": 0.68,
  "kts": 0.60,
  "family_pairs": {
    "anchor__paraphrase": {
      "shared_facts": 2592,
      "kts_geo": 0.62,
      "kts_id": 0.76,
      "kts": 0.68
    }
  }
}
```

---

# 18. 必做 sanity checks

## 18.1 Query shuffle test

随机打乱 fact_id 与 hidden representation 的对应关系后:

- ISS 应明显下降;
- KTS-ID 应接近 chance;
- KTS-Geo 应接近 0。

## 18.2 Duplicate-query test

同一个 query 与自身比较时:

- hidden cosine 应接近 1;
- ISS 正样本部分应达到上界附近。

## 18.3 Condition-label shuffle

随机打乱 condition family 标签后,family residualization 和 family centroid 不应产生虚假的高稳定性。

## 18.4 Relation-matched negative test

使用同 relation negatives 得到的 ISS 应比随机跨 relation negatives 更严格。主结果必须使用同 relation negatives。

## 18.5 Raw versus transported ablation

报告:

- Raw-ISS;
- J-transported ISS。

如果两者完全相同,需要检查 Jacobian transport 是否实际生效。

## 18.6 Judge consistency

对至少 300–500 条回答进行人工校验,报告:

- answer extraction accuracy;
- cluster equivalence accuracy;
- correctness accuracy;
- Cohen's \(\kappa\) 或 Krippendorff's \(\alpha\)。

---

# 19. 推荐论文定义

可以在论文中将四个指标概括为:

> **Behavioral Consistency Score (BCS)** measures the family-balanced mass assigned to a model's modal semantic answer across retrieval conditions. **Behavioral Entropy Stability (BES)** measures the concentration of the complete semantic answer distribution. **Internal State Stability (ISS)** measures whether the same fact forms a consistent and fact-discriminative Jacobian-transported representation across retrieval conditions. **Knowledge Topology Stability (KTS)** measures whether fact identity and the relative geometry of the overall knowledge representation space are preserved across conditions.

中文:

> BCS 衡量不同检索条件下主语义答案所占的等条件权重;BES 衡量完整答案分布的集中程度;ISS 衡量同一事实是否跨条件形成一致且具有事实区分性的 Jacobian 运输表示;KTS 衡量不同条件下事实身份及整体知识空间相对几何是否保持。

---

# 20. 最终最小报告集合

每个模型至少报告:

```text
Anchor Accuracy
BCS
BES
Stable Correct Rate
Stable Wrong Rate
Stable Abstention Rate
Unstable Rate
ISS
KTS-Geo
KTS-ID
KTS
```

同时提供:

- 按 relation 的 macro 结果;
- 按 behavior group 的 ISS/KTS;
- 按 condition pair 的 KTS;
- 95% relation-clustered bootstrap confidence intervals;
- complete-family 和 full-set 两种覆盖口径。