| # 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 两种覆盖口径。 |
| |