lietzsche;perron

updated 2026-11-26·5 min read

Evaluation Metrics Specification

Definitions for Function Acc@K, File Acc@K, Context Coverage@4k, HSI@10, Bamber discrimination bounds, and GoldPatchParser interval resolution.

Every score reported in Perron comes out of perron.metrics and gets pinned down by tests/test_evaluation_invariants.py. Keeping the metric code strict sounds pedantic until a subtle tie-break shifts your numbers behind your back: during the SWE-bench Verified audit, standalone BM25 printed 175 / 344 (50.87%) in one table and 176 / 344 (51.16%) in another on the exact same split.

The culprit turned out to be astropy__astropy-14182, where overloaded methods tied right at rank 10. Canonical AST sorting (file_path::qualified_name) pushed the gold target to rank 11, whereas raw token ordering kept it at rank 10. Ever since catching that, every runner uses deterministic kind="stable" sorting preserving symbol declaration order so paired McNemar tests don’t drift.

What the Four Metrics Track

  • Function Acc@K (K∈{1,5,10,25}K \in \{1, 5, 10, 25\}): 1.0 if at least one gold modified function appears inside the top-KK retrieved symbols, 0.0 otherwise.
  • File Acc@K (K∈{1,3,5}K \in \{1, 3, 5\}): Same check at the file level after normalizing Windows/POSIX separators (\ vs /) and comparing exact paths or relative suffixes.
  • Coverage@4k: Packs ranked AST breadcrumbs one by one until adding the next symbol would cross B=4,096B = 4,096 tokens, then reports the fraction of gold functions that actually fit inside that budget.
  • HSI@10 (Hub Suppression Index): Measures how much of the top-10 list is not clogged by the repository’s top-25 highest in-degree hubs (1.01.0 means zero hub congestion; 0.00.0 means all 10 slots went to utility hubs).
Formal Set Definitions

Given ranked symbols R=(s1,s2,…,sN)R = (s_1, s_2, \dots, s_N), gold modified functions GG, ranked files FRF_R, gold files FGF_G, and the top-25 global in-degree hubs H25H_{25}:

Function Acc@K={1.0if ∃ s∈R[:K] such that s∈G0.0otherwise\text{Function Acc}@K = \begin{cases} 1.0 & \text{if } \exists\, s \in R[:K] \text{ such that } s \in G \\ 0.0 & \text{otherwise} \end{cases}File Acc@K={1.0if ∃ f∈FR[:K] such that f matches any g∈FG0.0otherwise\text{File Acc}@K = \begin{cases} 1.0 & \text{if } \exists\, f \in F_R[:K] \text{ such that } f \text{ matches any } g \in F_G \\ 0.0 & \text{otherwise} \end{cases}Rpacked=(s1,…,sm  |  ∑i=1mc(si)≤B and ∑i=1m+1c(si)>B),Coverage@4k=∣{s∈Rpacked∣s∈G}∣∣G∣R_{\text{packed}} = \left(s_1, \dots, s_m \;\middle|\; \sum_{i=1}^m c(s_i) \le B \text{ and } \sum_{i=1}^{m+1} c(s_i) > B\right), \quad \text{Coverage}@4\text{k} = \frac{|\{s \in R_{\text{packed}} \mid s \in G\}|}{|G|}HSI@10=1.0−∣R[:10]∩H25∣10.0\text{HSI}@10 = 1.0 - \frac{|R[:10] \cap H_{25}|}{10.0}

Why Larger Candidate Pools Hurt Small Rerankers

Expanding the graph from 10 seeds to 50 candidates adds recall, yet downstream Top-5 accuracy barely budges. Bamber’s theorem explains why in one line: keeping an expected rank E[Rank]≤k\mathbb{E}[\text{Rank}] \le k out of MM candidates forces the scorer’s ROC-AUC to stay above:

AUC∗≥1−k−1M−1\text{AUC}^\ast \ge 1 - \frac{k - 1}{M - 1}

At mean pool size M=24.5M = 24.5 and target k=5k = 5, the break-even bar is AUC∗≥0.830\text{AUC}^\ast \ge 0.830. On non-seed graph neighbors (where surface keyword overlap is low), Gemma 4 E2B’s discrimination drops from 0.7966 to 0.6596, pushing the expected rank out to ~9.00 (17.68 at M=50M = 50) instead of inside the top 5.

Three-panel plot illustrating the break-even discrimination bound AUC*, topological disambiguation deficit from selection conditioning, and cross-architecture scaling surface
break-even discrimination bound auc*, selection conditioning deficit (0.7966 to 0.6596), and gemma 4 / phi-4 / deepseek scaling surface.
Continuous effective sample size n_eff GLMM dose-response surface and damping sensitivity across beta and gamma = 0.70
continuous n_eff glmm dose-response surface and damping sensitivity (gamma = 0.70) relative to standard ppr.

Extracting Gold Targets from Unified Diffs

Ground-truth modified symbols come from human patches parsed by benchmarks.gold_patch_parser.GoldPatchParser:

  1. Unified Diff Hunk Parsing

    Extract (file_path, old_start_line, old_line_count) tuples and form pre-image line intervals [old_start_line, old_start_line + max(0, old_line_count - 1)].

  2. AST Interval Intersection

    Intersect each hunk interval against every symbol span [L_start(s), L_end(s)] registered under file_path in the repository AST symbol table.

  3. Innermost Symbol Resolution

    Prefer function and method nodes over class or module containers by picking the narrowest span (L_end - L_start); pure additions resolve to the enclosing scope.

Edge-Case Handling

Edge CaseMetric BehaviorRationale
Empty Gold (G=∅G = \emptyset)Acc=0.0\text{Acc} = 0.0, Cov=0.0\text{Cov} = 0.0, HSI=1.0\text{HSI} = 1.0No defect exists to localize.
Duplicate IDs in RetrievedEvaluated on slice; deduplicated for set hitsPreserves exact rank position without double-counting hits.
K>Candidate Pool SizeK > \text{Candidate Pool Size}Evaluates all available candidatesHandles compact modules without index errors.
Gold Absent from CatalogAcc=0.0\text{Acc} = 0.0, Cov=0.0\text{Cov} = 0.0Treated safely as an unretrieved miss rather than raising.
Zero Token Budget (B≤0B \le 0)Coverage=0.0\text{Coverage} = 0.0Zero context can be delivered within budget.

For how these metrics partition hub and non-hub defects, see Hub-Gold & SWE-bench Benchmarks.

Search wiki and portfolio

type to search across all entries.