指南
切片
整體比率可能維持穩定,而測試套件的某一部分卻已崩潰。切片是測試套件中經過宣告、單獨量測的一部分,讓這種崩潰變得可見。切片附帶兩條紀律,因為同時檢視測試套件的許多部分,正是評估把雜訊誤當成發現的方式。
宣告切片
切片在 oloproof.yaml 中命名。最常見的一類會讀取每個案例 metadata 中的某個鍵:
slices: [metadata.lang, metadata.topic]
min_slice_support: 30{"id": "c000", "input": {"lang": "en", "topic": "billing", "hard": false, "n": 0}, "expected": {"label": "yes"}, "metadata": {"lang": "en", "topic": "billing"}}設定檔接受的所有切片類型:
| 切片 | 依據什麼將案例分組 | 需要 |
|---|---|---|
| metadata.<key> | 該鍵在案例 metadata 中的值 | 案例上有該鍵 |
| relevant_position | 第一個相關段落被檢索到的位置:top_k、beyond_top_k 或 not_retrieved | RAG 系統與 expected.relevant |
| context_truncated | token 預算是否從上下文中捨棄了段落 | 設有 token_budget 的 RAG 系統 |
| first_tool | 代理第一個呼叫的工具 | agent_trajectory/v1 紀錄 |
| repeated_action | 代理是否重複了完全相同的呼叫 | agent_trajectory/v1 紀錄 |
| route | 曾握有控制權的代理,寫成 triage>billing | 步驟中標明代理名稱的 agent_trajectory/v1 紀錄 |
| trajectory_length:4,8 | 步驟數,依您宣告的邊界分組 | agent_trajectory/v1 紀錄 |
| confidence:0.5 | 模型給該列的分數,依您宣告的邊界分段 | predictive: 區塊 |
設定檔無法辨識的名稱會在任何執行開始前被拒絕:
Configuration error: unknown slice 'lang'; declare metadata.<key>, relevant_position, context_truncated, first_tool, repeated_action, route, trajectory_length:<bounds> or confidence:<bounds>切片只做報告,永不把關
執行會在自己的標題下列出切片。以下是一個修好了英文卻弄壞了法文的候選版本:
│ metadata.lang=de │ ok │ 100.0% │ [95.4%, 100.0%] │ 80 / 80 observed · 0 missing · 0 excluded · exploratory · support 80 │
│ metadata.lang=en │ ok │ 100.0% │ [95.4%, 100.0%] │ 80 / 80 observed · 0 missing · 0 excluded · exploratory · support 80 │
│ metadata.lang=fr │ ok │ 32.5% │ [22.4%, 43.9%] │ 26 / 80 observed · 0 missing · 0 excluded · exploratory · support 80 │
│ metadata.topic=account │ ok │ 88.3% │ [81.2%, 93.5%] │ 106 / 120 observed · 0 missing · 0 excluded · exploratory · support 120 │
│ metadata.topic=billing │ ok │ 66.7% │ [57.4%, 75.1%] │ 80 / 120 observed · 0 missing · 0 excluded · exploratory · support 120 │表格標題寫著 Slices (exploratory; never gated),而且說到做到。該次執行的整體比率為 77.5%,它的關卡也放行了發布,而法文只有其三分之一。針對執行的發布規則指定的是整體指標,範圍限定於單次執行某個切片的規則會被拒絕:
Configuration error: release rule 'fr-floor' targets slice/metadata.lang=fr; a run's slice results are exploratory, and only a comparison rule gates a slice, inside a family with a correction這是第一條紀律。以十種方式切分的測試套件,就有十次偶然顯示出差異的機會,而讀取切片的關卡會因雜訊而阻擋發布。切片的用途是找出該看哪裡。
哪些切片特別突出
執行也會將各切片與執行本身的比率相比較並排序,標記出有差異的切片,所用的是 Benjamini-Yekutieli 程序,因此無論切片如何重疊,錯誤標記的比例都受到控制。終端機的切片表在 BY mark 欄中顯示每個切片的結果——marked、not marked,或對於太稀疏而無法檢定的切片留白——並附上用於排序的 p 值。這些結果也會儲存在執行中,並匯出到其證據包的 run.json:
jq -c '.run.slice_metrics[] | {scope, estimate, fdr_marked, fdr_p_value}' .oloproof/bundles/RUN_ID/run.json{"scope":"slice/metadata.lang=de","estimate":1.0,"fdr_marked":true,"fdr_p_value":0.0001}
{"scope":"slice/metadata.lang=en","estimate":1.0,"fdr_marked":true,"fdr_p_value":0.0001}
{"scope":"slice/metadata.lang=fr","estimate":0.325,"fdr_marked":true,"fdr_p_value":0.0001}
{"scope":"slice/metadata.topic=account","estimate":0.8833333333333333,"fdr_marked":true,"fdr_p_value":0.0037003540039062493}
{"scope":"slice/metadata.topic=billing","estimate":0.6666666666666666,"fdr_marked":true,"fdr_p_value":0.008582189941406249}未被標記的切片並不代表已證明與執行一致;它只是沒有被標示出來。標記用來引導注意力,不會影響任何關卡。
支持數
min_slice_support 是切片取得區間所需的最少案例數。低於此數時,會顯示估計值,但不提供區間。以下來自一個將其設為 4 的專案:
│ metadata.topic=account │ answer_correct │ 100.0% │ │ 1 / 1 observed · 0 missing · 0 excluded · exploratory · support 1 │
│ │ │ │ │ < 4, no interval │預設值為 30。調低此值的小型測試套件會在稀疏切片上得到區間,而這些區間寬到足以自行說明這一點。
在比較中對切片把關
當某個切片確實不得退步時,可以將比較規則的範圍限定在該切片。範圍是切片名稱加上 slice/ 前綴,而規則會在讀取任何證據之前聲明它需要的支持數:
version: 1
rules:
- {id: overall, metric: ok, kind: non_inferiority, margin: 0.05}
- {id: fr-not-worse, metric: ok, kind: non_inferiority, margin: 0.05, scope: slice/metadata.lang=fr, min_support: 30}
- {id: en-not-worse, metric: ok, kind: non_inferiority, margin: 0.05, scope: slice/metadata.lang=en, min_support: 30}
- {id: de-not-worse, metric: ok, kind: non_inferiority, margin: 0.05, scope: slice/metadata.lang=de, min_support: 30}
families:
- {id: languages, correction: holm, rules: [fr-not-worse, en-not-worse, de-not-worse]}若省略前綴,範圍會被拒絕:
Configuration error: rule 'fr-not-worse' has unknown scope 'metadata.lang=fr'; a comparison rule decides on the global scope or on slice/<name>=<value>加上前綴後,將上述候選版本與其基準比較:
oloproof compare CANDIDATE_RUN_ID BASELINE_RUN_ID --policy compare.yamlComparison sha256:cd2693b505e645919d397e8d7a87eaf0a841ab0c11c0b95484912363381b72e0 of run_01M3C46CYA163JSMSA5QZ6KAZA against run_01M3C46B3PSNP1ZTC8X05AG0GE · 240 paired cases
ok: -5.0 points [-15.2, +4.9] · 240 paired · 0 missing · 0 excluded
ok [slice/metadata.lang=de]: +8.8 points [-0.5, +21.5] · 80 paired · 0 missing · 0 excluded · exploratory · support 80
ok [slice/metadata.lang=en]: +18.8 points [+7.0, +34.4] · 80 paired · 0 missing · 0 excluded · exploratory · support 80
ok [slice/metadata.lang=fr]: -42.5 points [-60.3, -26.8] · 80 paired · 0 missing · 0 excluded · exploratory · support 80
ok [slice/metadata.topic=account]: +7.5 points [+0.9, +17.1] · 120 paired · 0 missing · 0 excluded · exploratory · support 120
ok [slice/metadata.topic=billing]: -17.5 points [-35.0, -0.1] · 120 paired · 0 missing · 0 excluded · exploratory · support 120
Decisions
overall ok non-inferiority, margin 5.0 points INSUFFICIENT_EVIDENCE interval_overlaps_margin
no sample size would make this PASS: the difference itself (-5.0 points) is outside the margin, so more cases would move it toward FAIL
fr-not-worse ok non-inferiority, margin 5.0 points FAIL upper_bound_below_margin
en-not-worse ok non-inferiority, margin 5.0 points PASS lower_bound_above_margin
de-not-worse ok non-inferiority, margin 5.0 points PASS lower_bound_above_margin
Family languages: Holm over 3 rules; adjusted levels 0.01667
Gate: BLOCK (exit 1)這是第二條紀律。範圍限定於切片的規則只在 families: 項目內把關,該項目列出一組共同控制錯誤失敗的規則。holm 是校正方法:家族中失敗的規則會以更嚴格的水準重新檢定,其嚴格程度取決於家族包含多少條規則,因此三次偶然失敗的機會不會累加成三倍的風險。在信賴水準 0.95、三條規則的情況下,最強的失敗以 0.05 / 3 重新檢定,下一個以 0.05 / 2,最後一個以 0.05。只有失敗會被重新檢定:通過並不是拒絕,不需要校正。此例中有一條規則失敗,以 0.01667 重新檢定後,法文仍然失敗。整體規則無法做出判定,其下方的建議指出,更多案例只會讓它更趨向 FAIL。
不屬於任何家族的切片規則會被拒絕:
Configuration error: slice rule 'fr-not-worse' belongs to no family; slice rules multiply the chances of a false FAIL, so they gate only inside a family with a correction下一步
分類器與迴歸器 會使用非 metadata 的切片。