Spaces:
Running
Running
Deploy eval-card-registry service
Browse files- packages/eval-entity-resolver/src/eval_entity_resolver/eee.py +20 -0
- packages/eval-entity-resolver/src/eval_entity_resolver/resolver.py +203 -17
- src/eval_card_registry/api/schemas.py +23 -0
- src/eval_card_registry/cli.py +148 -20
- src/eval_card_registry/store/hf_store.py +4 -0
- src/eval_card_registry/store/schemas.py +17 -4
packages/eval-entity-resolver/src/eval_entity_resolver/eee.py
CHANGED
|
@@ -143,6 +143,26 @@ _METRIC_KEYWORDS: list[tuple[str, str]] = [
|
|
| 143 |
# Class-averaged F1 (before generic F1, which would swallow both)
|
| 144 |
(r"macro[\s_-]*f1", "Macro F1"),
|
| 145 |
(r"micro[\s_-]*f1", "Micro F1"),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
# Single-word patterns (generic, checked last by position)
|
| 147 |
(r"\baccuracy\b", "Accuracy"),
|
| 148 |
(r"\bacc\b", "Accuracy"),
|
|
|
|
| 143 |
# Class-averaged F1 (before generic F1, which would swallow both)
|
| 144 |
(r"macro[\s_-]*f1", "Macro F1"),
|
| 145 |
(r"micro[\s_-]*f1", "Micro F1"),
|
| 146 |
+
# Benchmark-scoped safety rubrics. Each is its own canonical with its own
|
| 147 |
+
# rubric and direction, so the generic tail ("Score", "Harmlessness") must
|
| 148 |
+
# not swallow them onto `score` / `harmlessness`.
|
| 149 |
+
(r"harmbench[\s_-]*refusal[\s_-]*score",
|
| 150 |
+
"HarmBench Refusal Score"),
|
| 151 |
+
(r"xstest[\s_-]*appropriateness[\s_-]*score",
|
| 152 |
+
"XSTest Appropriateness Score"),
|
| 153 |
+
(r"simple[\s_-]*safety[\s_-]*tests?[\s_-]*safety[\s_-]*score",
|
| 154 |
+
"SimpleSafetyTests Safety Score"),
|
| 155 |
+
(r"anthropic[\s_-]*red[\s_-]*team(?:ing)?[\s_-]*harmlessness[\s_-]*score",
|
| 156 |
+
"Anthropic Red Team Harmlessness Score"),
|
| 157 |
+
# Model-scored generation metrics whose variant tail ("F1", "Accuracy")
|
| 158 |
+
# the single-word patterns below would otherwise swallow onto the plain
|
| 159 |
+
# f1 / accuracy canonicals.
|
| 160 |
+
(r"bertscore[\s_-]*f1?\b", "BERTScore-F"),
|
| 161 |
+
(r"bertscore[\s_-]*p(?:recision)?\b", "BERTScore-P"),
|
| 162 |
+
(r"bertscore[\s_-]*r(?:ecall)?\b", "BERTScore-R"),
|
| 163 |
+
(r"bleurt[\s_-]*acc(?:uracy)?\b", "BLEURT_acc"),
|
| 164 |
+
(r"bleurt[\s_-]*diff\b", "BLEURT_diff"),
|
| 165 |
+
(r"bleurt[\s_-]*max\b", "BLEURT_max"),
|
| 166 |
# Single-word patterns (generic, checked last by position)
|
| 167 |
(r"\baccuracy\b", "Accuracy"),
|
| 168 |
(r"\bacc\b", "Accuracy"),
|
packages/eval-entity-resolver/src/eval_entity_resolver/resolver.py
CHANGED
|
@@ -37,6 +37,7 @@ _NORMALIZED_CONFIDENCE = 0.95
|
|
| 37 |
# benchmark, and the registry does hold a handful of two-letter canonicals
|
| 38 |
# (`if`, `mc`, `nq`) a bare segment would otherwise collide with.
|
| 39 |
_MIN_BENCHMARK_SEGMENT_LEN = 3
|
|
|
|
| 40 |
|
| 41 |
# A trailing version token on a harness string (`lm_eval 0.4.12`,
|
| 42 |
# `inspect_ai inspect_ai:0.3.80.dev25+g91a50728.d20250331`). Whitespace-
|
|
@@ -74,11 +75,64 @@ class StructuredBenchmark:
|
|
| 74 |
"""One dotted `evaluation_name` resolved against the benchmark
|
| 75 |
vocabulary. `benchmark_raw` is the surface form to record downstream:
|
| 76 |
the winning segment plus any subset segments, which is what the
|
| 77 |
-
producer's slice machinery reads.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
canonical_id: str
|
| 80 |
benchmark_raw: str
|
| 81 |
subset: Optional[str]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
|
| 84 |
class Resolver:
|
|
@@ -329,6 +383,39 @@ class Resolver:
|
|
| 329 |
(no hits, only catch-all hits, or conflicting hits) — callers fall
|
| 330 |
back to their existing description/name path unchanged.
|
| 331 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 332 |
if not raw_id or not isinstance(raw_id, str):
|
| 333 |
return None
|
| 334 |
raw_id = raw_id.strip()
|
|
@@ -346,18 +433,28 @@ class Resolver:
|
|
| 346 |
# normalized whole-id lookup could equate distinct ids.
|
| 347 |
whole = exact_match(raw_id, "metric", source_config, self.store)
|
| 348 |
if whole is not None and whole not in catch_all_ids:
|
| 349 |
-
return whole
|
| 350 |
-
hits: list[str] = []
|
| 351 |
-
for segment in segments[1:]
|
|
|
|
| 352 |
canonical = exact_match(
|
| 353 |
segment, "metric", source_config, self.store
|
| 354 |
) or normalized_match(segment, "metric", self.store, source_config)
|
| 355 |
if canonical is not None:
|
| 356 |
-
hits.append(canonical)
|
| 357 |
-
specific = {
|
| 358 |
-
if len(specific) =
|
| 359 |
-
return
|
| 360 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 361 |
|
| 362 |
def resolve_structured_benchmark(
|
| 363 |
self,
|
|
@@ -408,9 +505,12 @@ class Resolver:
|
|
| 408 |
`paperswithcode` (64) sit in that position and stay unresolved only
|
| 409 |
because neither is a benchmark alias.
|
| 410 |
|
| 411 |
-
`subset` is only
|
| 412 |
-
hit itself; when the
|
| 413 |
-
the identity and `subset` is informational.
|
|
|
|
|
|
|
|
|
|
| 414 |
|
| 415 |
Returns None when no segment resolves, so callers fall back to
|
| 416 |
`clean_eval_name` unchanged.
|
|
@@ -496,15 +596,94 @@ class Resolver:
|
|
| 496 |
benchmark_raw, "benchmark", source_config, check_hf=False
|
| 497 |
)
|
| 498 |
if joined.canonical_id is not None:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 499 |
return StructuredBenchmark(
|
| 500 |
-
joined.canonical_id, benchmark_raw,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 501 |
)
|
| 502 |
|
| 503 |
index, canonical = hits[-1]
|
|
|
|
| 504 |
return StructuredBenchmark(
|
| 505 |
-
canonical, _spell(segments[index:]),
|
|
|
|
| 506 |
)
|
| 507 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 508 |
def _is_namespace_segment(
|
| 509 |
self, segment: str, next_segment: Optional[str], source_config: Optional[str]
|
| 510 |
) -> bool:
|
|
@@ -527,9 +706,16 @@ class Resolver:
|
|
| 527 |
resolves as a metric or reads as one to the metric extractor, so a
|
| 528 |
metric tail is never mistaken for a subset."""
|
| 529 |
spelled = segment.replace("_", " ")
|
| 530 |
-
if exact_match(segment, "metric", source_config, self.store)
|
| 531 |
-
|
| 532 |
-
):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 533 |
return True
|
| 534 |
return _keyword_extract(spelled.lower()) is not None
|
| 535 |
|
|
|
|
| 37 |
# benchmark, and the registry does hold a handful of two-letter canonicals
|
| 38 |
# (`if`, `mc`, `nq`) a bare segment would otherwise collide with.
|
| 39 |
_MIN_BENCHMARK_SEGMENT_LEN = 3
|
| 40 |
+
_MIN_METRIC_SEGMENT_LEN = 3
|
| 41 |
|
| 42 |
# A trailing version token on a harness string (`lm_eval 0.4.12`,
|
| 43 |
# `inspect_ai inspect_ai:0.3.80.dev25+g91a50728.d20250331`). Whitespace-
|
|
|
|
| 75 |
"""One dotted `evaluation_name` resolved against the benchmark
|
| 76 |
vocabulary. `benchmark_raw` is the surface form to record downstream:
|
| 77 |
the winning segment plus any subset segments, which is what the
|
| 78 |
+
producer's slice machinery reads.
|
| 79 |
+
|
| 80 |
+
`subset_is_identity` says whether `subset` names a PART of the benchmark
|
| 81 |
+
or merely spells the benchmark itself at greater length. The two look
|
| 82 |
+
identical in `subset` and mean opposite things to a consumer deciding
|
| 83 |
+
what a row measured:
|
| 84 |
+
|
| 85 |
+
* `mmlu.mmlu.anatomy` — the registry knows `mmlu`, not
|
| 86 |
+
`mmlu anatomy`, so `anatomy` is a real subset. The row measured one
|
| 87 |
+
subject, a PART of MMLU. `subset_is_identity` False.
|
| 88 |
+
* `polyglotoxicityprompts.polyglotoxicityprompts.small_overall` — the
|
| 89 |
+
registry aliases the whole joined spelling to the benchmark, so the
|
| 90 |
+
trailing segments belong to the identity, not to a subset of it. The
|
| 91 |
+
row measured the benchmark. `subset_is_identity` True.
|
| 92 |
+
|
| 93 |
+
`subset` is kept in both cases because the producer's slice machinery
|
| 94 |
+
spells its display axis from it either way."""
|
| 95 |
|
| 96 |
canonical_id: str
|
| 97 |
benchmark_raw: str
|
| 98 |
subset: Optional[str]
|
| 99 |
+
subset_is_identity: bool = False
|
| 100 |
+
|
| 101 |
+
@property
|
| 102 |
+
def observation_role(self) -> str:
|
| 103 |
+
"""What this match VERIFIED the row observed, relative to the
|
| 104 |
+
benchmark it resolved to: `"whole"` or `"part"`.
|
| 105 |
+
|
| 106 |
+
There is a third answer this class cannot express — `"unknown"`,
|
| 107 |
+
the row whose name the structured path could not read at all
|
| 108 |
+
(flat/spaced names such as HELM's `MMLU All Subjects`, which
|
| 109 |
+
`prepare_eval_name_segments` declines). That answer is the ABSENCE
|
| 110 |
+
of a `StructuredBenchmark`, and callers must map `None` to it
|
| 111 |
+
rather than assuming a whole: a name nobody parsed is not a
|
| 112 |
+
verified observation of anything, and labelling it `whole` is the
|
| 113 |
+
claim that made a page pool 34 subjects into their own total."""
|
| 114 |
+
return "part" if (self.subset and not self.subset_is_identity) else "whole"
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
@dataclass
|
| 118 |
+
class StructuredMetric:
|
| 119 |
+
"""One namespaced `metric_config.metric_id` resolved against the metric
|
| 120 |
+
vocabulary. `matched_segment` is the surface form that carried the
|
| 121 |
+
identity (the whole id when a whole-id alias won); `qualifier` is the
|
| 122 |
+
tail spelled after it, which narrows the same metric to a scoring
|
| 123 |
+
variant (`gpqa.accuracy.strict`, `squadv2.f1.has_ans`) and is None when
|
| 124 |
+
the tail carries no information."""
|
| 125 |
+
|
| 126 |
+
canonical_id: str
|
| 127 |
+
matched_segment: str
|
| 128 |
+
qualifier: Optional[str]
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
def _is_aggregate_marker(segment: str) -> bool:
|
| 132 |
+
"""`overall` and `<group>_overall` mark an aggregation level, not a
|
| 133 |
+
variant of the metric, so they never become a qualifier."""
|
| 134 |
+
lowered = segment.lower()
|
| 135 |
+
return lowered == "overall" or lowered.endswith("_overall")
|
| 136 |
|
| 137 |
|
| 138 |
class Resolver:
|
|
|
|
| 383 |
(no hits, only catch-all hits, or conflicting hits) — callers fall
|
| 384 |
back to their existing description/name path unchanged.
|
| 385 |
"""
|
| 386 |
+
match = self.resolve_structured_metric(raw_id, source_config, catch_all_ids)
|
| 387 |
+
return match.canonical_id if match is not None else None
|
| 388 |
+
|
| 389 |
+
def resolve_structured_metric(
|
| 390 |
+
self,
|
| 391 |
+
raw_id: Optional[str],
|
| 392 |
+
source_config: Optional[str] = None,
|
| 393 |
+
catch_all_ids: frozenset = frozenset(),
|
| 394 |
+
) -> Optional["StructuredMetric"]:
|
| 395 |
+
"""`resolve_structured_metric_id` with the match span reported.
|
| 396 |
+
|
| 397 |
+
Same identity decision, plus the two pieces a consumer needs to keep
|
| 398 |
+
distinct observations apart: `matched_segment`, the surface form that
|
| 399 |
+
disclosed the metric, and `qualifier`, the tail spelled after it.
|
| 400 |
+
|
| 401 |
+
The tail is what narrows one metric to a scoring variant the source
|
| 402 |
+
reports separately — `gpqa.accuracy.strict` next to
|
| 403 |
+
`gpqa.accuracy.diamond`, `squadv2.f1.has_ans` next to
|
| 404 |
+
`squadv2.f1.no_ans` — so a consumer that pools on the canonical id
|
| 405 |
+
alone would median unrelated numbers together. Excluded from the
|
| 406 |
+
tail: aggregate markers (`overall`, `<group>_overall`) and nothing
|
| 407 |
+
else, because those state a level rather than a variant. A numeric
|
| 408 |
+
segment IS a variant and is kept — `bench.accuracy.1` and
|
| 409 |
+
`bench.accuracy.5` are k-shot readings of one metric that a source
|
| 410 |
+
reports separately, exactly the case the tail exists for. Segments
|
| 411 |
+
BEFORE the match are never part of it: those are the adapter
|
| 412 |
+
namespace, the source config and the benchmark. A whole-id alias
|
| 413 |
+
match reports the whole id as the matched segment and no qualifier,
|
| 414 |
+
because the registry has claimed that exact string and there is no
|
| 415 |
+
residue to interpret.
|
| 416 |
+
|
| 417 |
+
Returns None exactly when `resolve_structured_metric_id` returns None.
|
| 418 |
+
"""
|
| 419 |
if not raw_id or not isinstance(raw_id, str):
|
| 420 |
return None
|
| 421 |
raw_id = raw_id.strip()
|
|
|
|
| 433 |
# normalized whole-id lookup could equate distinct ids.
|
| 434 |
whole = exact_match(raw_id, "metric", source_config, self.store)
|
| 435 |
if whole is not None and whole not in catch_all_ids:
|
| 436 |
+
return StructuredMetric(whole, raw_id, None)
|
| 437 |
+
hits: list[tuple[int, str]] = []
|
| 438 |
+
for index, segment in enumerate(segments[1:], start=1):
|
| 439 |
+
# segments[0] is the adapter namespace
|
| 440 |
canonical = exact_match(
|
| 441 |
segment, "metric", source_config, self.store
|
| 442 |
) or normalized_match(segment, "metric", self.store, source_config)
|
| 443 |
if canonical is not None:
|
| 444 |
+
hits.append((index, canonical))
|
| 445 |
+
specific = {c for _, c in hits if c not in catch_all_ids}
|
| 446 |
+
if len(specific) != 1:
|
| 447 |
+
return None
|
| 448 |
+
canonical_id = next(iter(specific))
|
| 449 |
+
# The LAST segment naming the winning metric ends the identity: a
|
| 450 |
+
# later restatement of the same metric is not a qualifier of itself.
|
| 451 |
+
matched_index = max(i for i, c in hits if c == canonical_id)
|
| 452 |
+
tail = [
|
| 453 |
+
s for s in segments[matched_index + 1:] if not _is_aggregate_marker(s)
|
| 454 |
+
]
|
| 455 |
+
return StructuredMetric(
|
| 456 |
+
canonical_id, segments[matched_index], ".".join(tail) or None
|
| 457 |
+
)
|
| 458 |
|
| 459 |
def resolve_structured_benchmark(
|
| 460 |
self,
|
|
|
|
| 505 |
`paperswithcode` (64) sit in that position and stay unresolved only
|
| 506 |
because neither is a benchmark alias.
|
| 507 |
|
| 508 |
+
`subset` is only a real subset when the winning canonical is the
|
| 509 |
+
segment hit itself; when the JOINED form won, the trailing segments
|
| 510 |
+
belong to the identity and `subset` is informational. The two cases
|
| 511 |
+
are told apart by `subset_is_identity`, because a consumer asking
|
| 512 |
+
"did this row measure the whole benchmark or a part of it?" gets
|
| 513 |
+
opposite answers from the same `subset` string.
|
| 514 |
|
| 515 |
Returns None when no segment resolves, so callers fall back to
|
| 516 |
`clean_eval_name` unchanged.
|
|
|
|
| 596 |
benchmark_raw, "benchmark", source_config, check_hf=False
|
| 597 |
)
|
| 598 |
if joined.canonical_id is not None:
|
| 599 |
+
# Resolution is unchanged: the joined spelling wins whenever
|
| 600 |
+
# it resolves at all, fuzzy tier included.
|
| 601 |
+
#
|
| 602 |
+
# The identity flag is stricter, and deliberately so: EXACT
|
| 603 |
+
# alias only. An exact alias is the registry spelling this
|
| 604 |
+
# surface form, as written, as the benchmark — a statement
|
| 605 |
+
# that the trailing segments are part of its name.
|
| 606 |
+
#
|
| 607 |
+
# The looser tiers are not that statement. `mmlu anatomy`
|
| 608 |
+
# reaches `mmlu` through the normalized tier, which is
|
| 609 |
+
# spelling-insensitive and absorbs every subject name; the
|
| 610 |
+
# fuzzy tier reduces further still by stripping
|
| 611 |
+
# run-configuration tokens. Accepting either would turn all
|
| 612 |
+
# 183 MMLU subject rows into whole-benchmark observations and
|
| 613 |
+
# hand the page a median over its own parts — the number this
|
| 614 |
+
# whole workstream exists to stop publishing.
|
| 615 |
+
claimed = exact_match(
|
| 616 |
+
benchmark_raw, "benchmark", source_config, self.store
|
| 617 |
+
)
|
| 618 |
+
joined_subset = _spell(segments[index + 1:]) or None
|
| 619 |
return StructuredBenchmark(
|
| 620 |
+
joined.canonical_id, benchmark_raw, joined_subset,
|
| 621 |
+
subset_is_identity=(
|
| 622 |
+
claimed is not None
|
| 623 |
+
or self._subset_names_the_benchmark(
|
| 624 |
+
joined_subset, joined.canonical_id
|
| 625 |
+
)
|
| 626 |
+
),
|
| 627 |
)
|
| 628 |
|
| 629 |
index, canonical = hits[-1]
|
| 630 |
+
subset = _spell(segments[index + 1:]) or None
|
| 631 |
return StructuredBenchmark(
|
| 632 |
+
canonical, _spell(segments[index:]), subset,
|
| 633 |
+
subset_is_identity=self._subset_names_the_benchmark(subset, canonical),
|
| 634 |
)
|
| 635 |
|
| 636 |
+
@staticmethod
|
| 637 |
+
def _subset_names_the_benchmark(
|
| 638 |
+
subset: Optional[str],
|
| 639 |
+
canonical: str,
|
| 640 |
+
) -> bool:
|
| 641 |
+
"""True when the reported subset is just the benchmark again.
|
| 642 |
+
|
| 643 |
+
A subset only narrows the observation when it names something INSIDE
|
| 644 |
+
the benchmark. When it names the benchmark itself it narrows nothing,
|
| 645 |
+
and treating it as a part excludes the source's own total from its own
|
| 646 |
+
page.
|
| 647 |
+
|
| 648 |
+
`vals_ai.swebench.overall` is the live case. The leading segment names
|
| 649 |
+
the source folder, so the identity path lands on it and reports
|
| 650 |
+
`swebench` as the subset — which is SWE-Bench. Meanwhile the sibling
|
| 651 |
+
time buckets (`vals_ai.swebench.<15 min fix>`) hit exact aliases and
|
| 652 |
+
report no subset at all, so the roles came out exactly backwards: the
|
| 653 |
+
submitted total was excluded from its own cell and the page moved
|
| 654 |
+
0.70731 -> 0.58718.
|
| 655 |
+
|
| 656 |
+
The test is SELF-SPELLING, not resolution. A subset names the
|
| 657 |
+
benchmark when it is the benchmark's own name written differently —
|
| 658 |
+
nothing more. Asking the general resolver "does this subset resolve
|
| 659 |
+
to the same canonical?" answers a different question and answers it
|
| 660 |
+
wrongly: every alias of a benchmark resolves to that benchmark,
|
| 661 |
+
including the aliases that name its PARTS. Vals LegalBench is the
|
| 662 |
+
live case — `conclusion_tasks`, `interpretation_tasks`,
|
| 663 |
+
`issue_tasks`, `rhetoric_tasks` and `rule_tasks` are all registry
|
| 664 |
+
aliases of `legalbench`, so resolution called each of the five
|
| 665 |
+
category aggregates a whole-benchmark reading and left the source's
|
| 666 |
+
own `vals_ai.legal_bench.overall` unable to win its own cell.
|
| 667 |
+
|
| 668 |
+
This is the same line the joined-spelling branch draws (see
|
| 669 |
+
`_probe_benchmark_segments`): an EXACT alias is the registry
|
| 670 |
+
spelling a surface form, as written, as the benchmark; the
|
| 671 |
+
normalized and fuzzy tiers are spelling-insensitive and absorb
|
| 672 |
+
member names. Exact identity of the joined spelling is checked
|
| 673 |
+
there; this predicate adds only self-spelling.
|
| 674 |
+
"""
|
| 675 |
+
if not subset:
|
| 676 |
+
return False
|
| 677 |
+
|
| 678 |
+
def _squash(value: str) -> str:
|
| 679 |
+
# `normalize` maps separators to spaces, so `swe-bench` becomes
|
| 680 |
+
# `swe bench` while the source spells it `swebench`. Squashing to
|
| 681 |
+
# alphanumerics makes the two comparable without loosening
|
| 682 |
+
# `normalize` itself, which other callers depend on.
|
| 683 |
+
return "".join(ch for ch in normalize(value) if ch.isalnum())
|
| 684 |
+
|
| 685 |
+
return _squash(subset) == _squash(canonical)
|
| 686 |
+
|
| 687 |
def _is_namespace_segment(
|
| 688 |
self, segment: str, next_segment: Optional[str], source_config: Optional[str]
|
| 689 |
) -> bool:
|
|
|
|
| 706 |
resolves as a metric or reads as one to the metric extractor, so a
|
| 707 |
metric tail is never mistaken for a subset."""
|
| 708 |
spelled = segment.replace("_", " ")
|
| 709 |
+
if exact_match(segment, "metric", source_config, self.store):
|
| 710 |
+
return True
|
| 711 |
+
if len(segment) < _MIN_METRIC_SEGMENT_LEN:
|
| 712 |
+
# A one- or two-character tail is ambiguous: `mr` is a Marathi
|
| 713 |
+
# language slice (`arc.arc_multilingual.mr`) as much as the
|
| 714 |
+
# case-folded mean-recall alias `mR`. Only a byte-exact alias hit
|
| 715 |
+
# (above) may claim it; the case-insensitive and keyword tiers
|
| 716 |
+
# need a longer token, mirroring `_MIN_BENCHMARK_SEGMENT_LEN`.
|
| 717 |
+
return False
|
| 718 |
+
if normalized_match(segment, "metric", self.store, source_config):
|
| 719 |
return True
|
| 720 |
return _keyword_extract(spelled.lower()) is not None
|
| 721 |
|
src/eval_card_registry/api/schemas.py
CHANGED
|
@@ -163,12 +163,29 @@ class ModelPatch(BaseModel):
|
|
| 163 |
review_status: Optional[str] = None
|
| 164 |
|
| 165 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
class BenchmarkCreate(BaseModel):
|
| 167 |
id: str
|
| 168 |
display_name: str
|
| 169 |
description: Optional[str] = None
|
| 170 |
dataset_repo: Optional[str] = None
|
| 171 |
parent_benchmark_id: Optional[str] = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 172 |
tags: list[str] = []
|
| 173 |
metadata: dict[str, Any] = {}
|
| 174 |
review_status: str = "draft"
|
|
@@ -179,6 +196,12 @@ class BenchmarkPatch(BaseModel):
|
|
| 179 |
description: Optional[str] = None
|
| 180 |
dataset_repo: Optional[str] = None
|
| 181 |
parent_benchmark_id: Optional[str] = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
tags: Optional[list[str]] = None
|
| 183 |
metadata: Optional[dict[str, Any]] = None
|
| 184 |
review_status: Optional[str] = None
|
|
|
|
| 163 |
review_status: Optional[str] = None
|
| 164 |
|
| 165 |
|
| 166 |
+
_PREFERRED_METRIC_DESCRIPTION = (
|
| 167 |
+
"Registry-declared default metric for the merged benchmark view "
|
| 168 |
+
"(canonical_metrics.id). Null = no default declared."
|
| 169 |
+
)
|
| 170 |
+
_PREFERRED_METRIC_JUDGED_DESCRIPTION = (
|
| 171 |
+
"Is preferred_metric_id produced by an LLM judge? true = yes, "
|
| 172 |
+
"false = no, null = unstated. Says nothing about the benchmark's "
|
| 173 |
+
"other metrics."
|
| 174 |
+
)
|
| 175 |
+
|
| 176 |
+
|
| 177 |
class BenchmarkCreate(BaseModel):
|
| 178 |
id: str
|
| 179 |
display_name: str
|
| 180 |
description: Optional[str] = None
|
| 181 |
dataset_repo: Optional[str] = None
|
| 182 |
parent_benchmark_id: Optional[str] = None
|
| 183 |
+
preferred_metric_id: Optional[str] = Field(
|
| 184 |
+
default=None, description=_PREFERRED_METRIC_DESCRIPTION
|
| 185 |
+
)
|
| 186 |
+
preferred_metric_llm_judged: Optional[bool] = Field(
|
| 187 |
+
default=None, description=_PREFERRED_METRIC_JUDGED_DESCRIPTION
|
| 188 |
+
)
|
| 189 |
tags: list[str] = []
|
| 190 |
metadata: dict[str, Any] = {}
|
| 191 |
review_status: str = "draft"
|
|
|
|
| 196 |
description: Optional[str] = None
|
| 197 |
dataset_repo: Optional[str] = None
|
| 198 |
parent_benchmark_id: Optional[str] = None
|
| 199 |
+
preferred_metric_id: Optional[str] = Field(
|
| 200 |
+
default=None, description=_PREFERRED_METRIC_DESCRIPTION
|
| 201 |
+
)
|
| 202 |
+
preferred_metric_llm_judged: Optional[bool] = Field(
|
| 203 |
+
default=None, description=_PREFERRED_METRIC_JUDGED_DESCRIPTION
|
| 204 |
+
)
|
| 205 |
tags: Optional[list[str]] = None
|
| 206 |
metadata: Optional[dict[str, Any]] = None
|
| 207 |
review_status: Optional[str] = None
|
src/eval_card_registry/cli.py
CHANGED
|
@@ -7,8 +7,10 @@ Commands:
|
|
| 7 |
sync Batch sync one or all EEE configs → eval_results table
|
| 8 |
"""
|
| 9 |
import json
|
|
|
|
| 10 |
import re
|
| 11 |
import unicodedata
|
|
|
|
| 12 |
from pathlib import Path
|
| 13 |
from typing import Optional
|
| 14 |
|
|
@@ -16,6 +18,16 @@ import typer
|
|
| 16 |
import yaml
|
| 17 |
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
def seed_collision_key(s: str) -> str:
|
| 20 |
"""The key under which two seed surface forms count as one entity:
|
| 21 |
NFKD + combining-mark strip (so "racé" and "race" collide before the
|
|
@@ -499,22 +511,32 @@ def seed(
|
|
| 499 |
curated_path = seed_path / "benchmarks.yaml"
|
| 500 |
generated_dir = seed_path / "benchmarks_generated"
|
| 501 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 502 |
generated_entries: list[dict] = []
|
| 503 |
if generated_dir.is_dir():
|
| 504 |
for src_path in sorted(generated_dir.glob("*.yaml")):
|
| 505 |
-
|
| 506 |
-
loaded = yaml.safe_load(f) or []
|
| 507 |
-
if not isinstance(loaded, list):
|
| 508 |
-
raise typer.BadParameter(f"{src_path} must be a flat list")
|
| 509 |
-
generated_entries.extend(loaded)
|
| 510 |
|
| 511 |
curated_entries: list[dict] = []
|
| 512 |
if curated_path.exists():
|
| 513 |
-
|
| 514 |
-
loaded = yaml.safe_load(f) or []
|
| 515 |
-
if not isinstance(loaded, list):
|
| 516 |
-
raise typer.BadParameter(f"{curated_path} must be a flat list")
|
| 517 |
-
curated_entries = loaded
|
| 518 |
|
| 519 |
def _merge_benchmark(generated: dict, curated: dict) -> dict:
|
| 520 |
"""Curated wins on every field it specifies; aliases are
|
|
@@ -556,6 +578,17 @@ def seed(
|
|
| 556 |
metric_ids = {m["id"] for m in (yaml.safe_load(f) or [])}
|
| 557 |
for entry in by_id.values():
|
| 558 |
pm = entry.pop("preferred_metric", None)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 559 |
if pm is not None:
|
| 560 |
if pm not in metric_ids:
|
| 561 |
raise typer.BadParameter(
|
|
@@ -815,6 +848,10 @@ def seed(
|
|
| 815 |
]
|
| 816 |
|
| 817 |
alias_count = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
| 818 |
# Track all seed entity IDs and alias keys so we can remove stale ones.
|
| 819 |
# Alias key: (raw_value, entity_type, canonical_id, source_config)
|
| 820 |
seed_snapshot: list[tuple[str, str, set[str], set[tuple[str, str, str, Optional[str]]]]] = []
|
|
@@ -1063,6 +1100,12 @@ def seed(
|
|
| 1063 |
(raw, None) for raw in global_aliases if raw
|
| 1064 |
]
|
| 1065 |
for source_cfg, raw_values in scoped_aliases.items():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1066 |
for raw in raw_values or []:
|
| 1067 |
if raw:
|
| 1068 |
alias_specs.append((raw, source_cfg))
|
|
@@ -1280,14 +1323,17 @@ def seed(
|
|
| 1280 |
raise typer.BadParameter(f"{folds_path} must be a flat list")
|
| 1281 |
bench_ids = {e["id"] for e in _load_benchmarks_merged()}
|
| 1282 |
fold_metrics_path = seed_path / "metrics.yaml"
|
| 1283 |
-
|
| 1284 |
if fold_metrics_path.exists():
|
| 1285 |
with open(fold_metrics_path) as f:
|
| 1286 |
-
|
| 1287 |
-
|
|
|
|
|
|
|
| 1288 |
fold_rows = []
|
| 1289 |
for e in fold_entries:
|
| 1290 |
b, fm, tm = e.get("benchmark"), e.get("from_metric"), e.get("to_metric")
|
|
|
|
| 1291 |
if not (b and fm and tm):
|
| 1292 |
raise typer.BadParameter(f"metric_folds entry needs benchmark/from_metric/to_metric: {e!r}")
|
| 1293 |
if b not in bench_ids:
|
|
@@ -1295,23 +1341,101 @@ def seed(
|
|
| 1295 |
missing = [m for m in (fm, tm) if m not in metric_ids]
|
| 1296 |
if missing:
|
| 1297 |
raise typer.BadParameter(f"metric_folds ({b}): unknown metric id(s) {missing}")
|
| 1298 |
-
if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1299 |
raise typer.BadParameter(f"metric_folds ({b}): self-fold {fm!r}")
|
| 1300 |
-
|
| 1301 |
-
|
| 1302 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1303 |
factor = e.get("scale_factor")
|
| 1304 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1305 |
raise typer.BadParameter(
|
| 1306 |
f"metric_folds ({b}): scale_factor must be a positive number, got {factor!r}"
|
| 1307 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1308 |
fold_rows.append({
|
| 1309 |
"benchmark_id": b, "from_metric_id": fm,
|
| 1310 |
-
"to_metric_id": tm, "
|
|
|
|
|
|
|
| 1311 |
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1312 |
# No chains: a fold target must not itself be folded on the same benchmark.
|
| 1313 |
targets = {(r["benchmark_id"], r["to_metric_id"]) for r in fold_rows}
|
| 1314 |
-
chained = sorted(targets &
|
| 1315 |
if chained:
|
| 1316 |
raise typer.BadParameter(f"metric_folds: chained folds {chained}")
|
| 1317 |
folds_df = pd.DataFrame(
|
|
@@ -1408,6 +1532,10 @@ def seed(
|
|
| 1408 |
store.set_table("aliases", current_aliases.reset_index(drop=True))
|
| 1409 |
|
| 1410 |
typer.echo(f" aliases: {alias_count} added, {removed_aliases} removed")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1411 |
if removed_entities:
|
| 1412 |
typer.echo(f" stale entities removed: {removed_entities}")
|
| 1413 |
|
|
|
|
| 7 |
sync Batch sync one or all EEE configs → eval_results table
|
| 8 |
"""
|
| 9 |
import json
|
| 10 |
+
import math
|
| 11 |
import re
|
| 12 |
import unicodedata
|
| 13 |
+
from numbers import Real
|
| 14 |
from pathlib import Path
|
| 15 |
from typing import Optional
|
| 16 |
|
|
|
|
| 18 |
import yaml
|
| 19 |
|
| 20 |
|
| 21 |
+
# Source scope keys — the `source_config` on a scoped alias or a scoped
|
| 22 |
+
# metric fold. A key is an UPSTREAM DATASET CONFIG NAME exactly as published
|
| 23 |
+
# in the EEE datastore (`data/<config>/`): `openeval`, `llm-stats`,
|
| 24 |
+
# `helm_capabilities`, … Registry ids are never scope keys, and the spelling
|
| 25 |
+
# is not normalised — `llm-stats` and `llm_stats` are different configs. This
|
| 26 |
+
# pattern is the shape the datastore uses, so a typo'd or path-like key fails
|
| 27 |
+
# the seed instead of silently scoping an alias to a config that never calls.
|
| 28 |
+
_SOURCE_SCOPE_KEY_RE = re.compile(r"^[A-Za-z0-9][A-Za-z0-9_.-]*$")
|
| 29 |
+
|
| 30 |
+
|
| 31 |
def seed_collision_key(s: str) -> str:
|
| 32 |
"""The key under which two seed surface forms count as one entity:
|
| 33 |
NFKD + combining-mark strip (so "racé" and "race" collide before the
|
|
|
|
| 511 |
curated_path = seed_path / "benchmarks.yaml"
|
| 512 |
generated_dir = seed_path / "benchmarks_generated"
|
| 513 |
|
| 514 |
+
def _load_benchmarks_yaml(path: Path) -> list[dict]:
|
| 515 |
+
raw_yaml = path.read_text()
|
| 516 |
+
invalid_judge_flag = re.search(
|
| 517 |
+
r"^\s*preferred_metric_llm_judged:\s*(?!true\b|false\b|null\b|~)(?P<value>\S+)",
|
| 518 |
+
raw_yaml,
|
| 519 |
+
re.MULTILINE,
|
| 520 |
+
)
|
| 521 |
+
if invalid_judge_flag:
|
| 522 |
+
raise typer.BadParameter(
|
| 523 |
+
f"{path}: invalid preferred_metric_llm_judged value "
|
| 524 |
+
f"{invalid_judge_flag.group('value')!r}; "
|
| 525 |
+
"use true, false, null, or ~"
|
| 526 |
+
)
|
| 527 |
+
loaded = yaml.safe_load(raw_yaml) or []
|
| 528 |
+
if not isinstance(loaded, list):
|
| 529 |
+
raise typer.BadParameter(f"{path} must be a flat list")
|
| 530 |
+
return loaded
|
| 531 |
+
|
| 532 |
generated_entries: list[dict] = []
|
| 533 |
if generated_dir.is_dir():
|
| 534 |
for src_path in sorted(generated_dir.glob("*.yaml")):
|
| 535 |
+
generated_entries.extend(_load_benchmarks_yaml(src_path))
|
|
|
|
|
|
|
|
|
|
|
|
|
| 536 |
|
| 537 |
curated_entries: list[dict] = []
|
| 538 |
if curated_path.exists():
|
| 539 |
+
curated_entries = _load_benchmarks_yaml(curated_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 540 |
|
| 541 |
def _merge_benchmark(generated: dict, curated: dict) -> dict:
|
| 542 |
"""Curated wins on every field it specifies; aliases are
|
|
|
|
| 578 |
metric_ids = {m["id"] for m in (yaml.safe_load(f) or [])}
|
| 579 |
for entry in by_id.values():
|
| 580 |
pm = entry.pop("preferred_metric", None)
|
| 581 |
+
judged = entry.get("preferred_metric_llm_judged")
|
| 582 |
+
if judged is not None and type(judged) is not bool:
|
| 583 |
+
raise typer.BadParameter(
|
| 584 |
+
f"benchmark {entry['id']!r}: preferred_metric_llm_judged "
|
| 585 |
+
"must be a boolean or null"
|
| 586 |
+
)
|
| 587 |
+
if judged is not None and pm is None:
|
| 588 |
+
raise typer.BadParameter(
|
| 589 |
+
f"benchmark {entry['id']!r}: preferred_metric_llm_judged "
|
| 590 |
+
"requires preferred_metric"
|
| 591 |
+
)
|
| 592 |
if pm is not None:
|
| 593 |
if pm not in metric_ids:
|
| 594 |
raise typer.BadParameter(
|
|
|
|
| 848 |
]
|
| 849 |
|
| 850 |
alias_count = 0
|
| 851 |
+
# Distinct source scope keys (EEE dataset config names) seen across
|
| 852 |
+
# scoped aliases and scoped metric folds — reported in the seed summary
|
| 853 |
+
# so a typo'd config shows up as a new key rather than a silent no-op.
|
| 854 |
+
source_scope_keys: set[str] = set()
|
| 855 |
# Track all seed entity IDs and alias keys so we can remove stale ones.
|
| 856 |
# Alias key: (raw_value, entity_type, canonical_id, source_config)
|
| 857 |
seed_snapshot: list[tuple[str, str, set[str], set[tuple[str, str, str, Optional[str]]]]] = []
|
|
|
|
| 1100 |
(raw, None) for raw in global_aliases if raw
|
| 1101 |
]
|
| 1102 |
for source_cfg, raw_values in scoped_aliases.items():
|
| 1103 |
+
if not isinstance(source_cfg, str) or not _SOURCE_SCOPE_KEY_RE.match(source_cfg):
|
| 1104 |
+
raise typer.BadParameter(
|
| 1105 |
+
f"{label} entry {canonical_id!r}: scoped_aliases key "
|
| 1106 |
+
f"{source_cfg!r} is not a valid EEE dataset config name"
|
| 1107 |
+
)
|
| 1108 |
+
source_scope_keys.add(source_cfg)
|
| 1109 |
for raw in raw_values or []:
|
| 1110 |
if raw:
|
| 1111 |
alias_specs.append((raw, source_cfg))
|
|
|
|
| 1323 |
raise typer.BadParameter(f"{folds_path} must be a flat list")
|
| 1324 |
bench_ids = {e["id"] for e in _load_benchmarks_merged()}
|
| 1325 |
fold_metrics_path = seed_path / "metrics.yaml"
|
| 1326 |
+
metrics_by_id = {}
|
| 1327 |
if fold_metrics_path.exists():
|
| 1328 |
with open(fold_metrics_path) as f:
|
| 1329 |
+
metrics_by_id = {m["id"]: m for m in (yaml.safe_load(f) or [])}
|
| 1330 |
+
metric_ids = set(metrics_by_id)
|
| 1331 |
+
seen_rows: set[tuple[str, str, Optional[str]]] = set()
|
| 1332 |
+
unscoped_pairs: dict[tuple[str, str], str] = {}
|
| 1333 |
fold_rows = []
|
| 1334 |
for e in fold_entries:
|
| 1335 |
b, fm, tm = e.get("benchmark"), e.get("from_metric"), e.get("to_metric")
|
| 1336 |
+
source_config = e.get("source_config")
|
| 1337 |
if not (b and fm and tm):
|
| 1338 |
raise typer.BadParameter(f"metric_folds entry needs benchmark/from_metric/to_metric: {e!r}")
|
| 1339 |
if b not in bench_ids:
|
|
|
|
| 1341 |
missing = [m for m in (fm, tm) if m not in metric_ids]
|
| 1342 |
if missing:
|
| 1343 |
raise typer.BadParameter(f"metric_folds ({b}): unknown metric id(s) {missing}")
|
| 1344 |
+
if source_config is not None and not isinstance(source_config, str):
|
| 1345 |
+
raise typer.BadParameter(
|
| 1346 |
+
f"metric_folds ({b}): source_config must be a string or null"
|
| 1347 |
+
)
|
| 1348 |
+
if source_config is not None and not _SOURCE_SCOPE_KEY_RE.match(source_config):
|
| 1349 |
+
raise typer.BadParameter(
|
| 1350 |
+
f"metric_folds ({b}): source_config {source_config!r} is not a "
|
| 1351 |
+
"valid EEE dataset config name"
|
| 1352 |
+
)
|
| 1353 |
+
if source_config is not None:
|
| 1354 |
+
source_scope_keys.add(source_config)
|
| 1355 |
+
# A scoped row may fold a metric onto ITSELF: that is a pure
|
| 1356 |
+
# published-scale conversion for one source, not a rename. An
|
| 1357 |
+
# unscoped row saying `x is x` carries no information.
|
| 1358 |
+
if fm == tm and source_config is None:
|
| 1359 |
raise typer.BadParameter(f"metric_folds ({b}): self-fold {fm!r}")
|
| 1360 |
+
row_key = (b, fm, source_config)
|
| 1361 |
+
if row_key in seen_rows:
|
| 1362 |
+
raise typer.BadParameter(
|
| 1363 |
+
f"metric_folds: duplicate fold for ({b}, {fm}, {source_config!r})"
|
| 1364 |
+
)
|
| 1365 |
+
seen_rows.add(row_key)
|
| 1366 |
+
if source_config is None:
|
| 1367 |
+
unscoped_pairs[(b, fm)] = tm
|
| 1368 |
factor = e.get("scale_factor")
|
| 1369 |
+
offset = e.get("scale_offset")
|
| 1370 |
+
if source_config is None and (factor is not None or offset is not None):
|
| 1371 |
+
raise typer.BadParameter(
|
| 1372 |
+
f"metric_folds ({b}): scale_factor/scale_offset conversions require source_config"
|
| 1373 |
+
)
|
| 1374 |
+
for name, value in (("scale_factor", factor), ("scale_offset", offset)):
|
| 1375 |
+
if value is not None and (
|
| 1376 |
+
not isinstance(value, Real)
|
| 1377 |
+
or isinstance(value, bool)
|
| 1378 |
+
or not math.isfinite(value)
|
| 1379 |
+
):
|
| 1380 |
+
raise typer.BadParameter(
|
| 1381 |
+
f"metric_folds ({b}): {name} must be a finite real number, got {value!r}"
|
| 1382 |
+
)
|
| 1383 |
+
if factor is not None and factor <= 0:
|
| 1384 |
raise typer.BadParameter(
|
| 1385 |
f"metric_folds ({b}): scale_factor must be a positive number, got {factor!r}"
|
| 1386 |
)
|
| 1387 |
+
if factor is not None or offset is not None:
|
| 1388 |
+
target = metrics_by_id[tm]
|
| 1389 |
+
min_score, max_score = target.get("min_score"), target.get("max_score")
|
| 1390 |
+
if (
|
| 1391 |
+
not isinstance(min_score, Real)
|
| 1392 |
+
or isinstance(min_score, bool)
|
| 1393 |
+
or not math.isfinite(min_score)
|
| 1394 |
+
or not isinstance(max_score, Real)
|
| 1395 |
+
or isinstance(max_score, bool)
|
| 1396 |
+
or not math.isfinite(max_score)
|
| 1397 |
+
or max_score <= min_score
|
| 1398 |
+
):
|
| 1399 |
+
raise typer.BadParameter(
|
| 1400 |
+
f"metric_folds ({b}): {tm!r} must have finite ordered numeric bounds "
|
| 1401 |
+
"when scale_factor or scale_offset is set"
|
| 1402 |
+
)
|
| 1403 |
fold_rows.append({
|
| 1404 |
"benchmark_id": b, "from_metric_id": fm,
|
| 1405 |
+
"to_metric_id": tm, "source_config": source_config,
|
| 1406 |
+
"scale_factor": factor, "scale_offset": offset,
|
| 1407 |
+
"note": e.get("note"),
|
| 1408 |
})
|
| 1409 |
+
# A scoped row is either (a) the per-source conversion attached to a
|
| 1410 |
+
# benchmark-wide naming fold — then it must name that fold's target —
|
| 1411 |
+
# or (b) a standalone published-scale conversion, which renames
|
| 1412 |
+
# nothing (from_metric == to_metric) and must actually carry a
|
| 1413 |
+
# conversion. Naming a DIFFERENT target than the benchmark-wide row
|
| 1414 |
+
# would make one source's metric mean something else, so it is
|
| 1415 |
+
# rejected either way.
|
| 1416 |
+
for row in fold_rows:
|
| 1417 |
+
source_config = row["source_config"]
|
| 1418 |
+
if source_config is None:
|
| 1419 |
+
continue
|
| 1420 |
+
pair = (row["benchmark_id"], row["from_metric_id"])
|
| 1421 |
+
unscoped_target = unscoped_pairs.get(pair)
|
| 1422 |
+
if unscoped_target is not None:
|
| 1423 |
+
if row["to_metric_id"] != unscoped_target:
|
| 1424 |
+
raise typer.BadParameter(
|
| 1425 |
+
f"metric_folds ({pair[0]}): scoped to_metric must match unscoped row"
|
| 1426 |
+
)
|
| 1427 |
+
elif not (
|
| 1428 |
+
row["to_metric_id"] == row["from_metric_id"]
|
| 1429 |
+
and (row["scale_factor"] is not None or row["scale_offset"] is not None)
|
| 1430 |
+
):
|
| 1431 |
+
raise typer.BadParameter(
|
| 1432 |
+
f"metric_folds ({pair[0]}): scoped row requires unscoped row for "
|
| 1433 |
+
f"{pair[1]!r}, unless it is a pure published-scale conversion "
|
| 1434 |
+
"(from_metric == to_metric with scale_factor/scale_offset)"
|
| 1435 |
+
)
|
| 1436 |
# No chains: a fold target must not itself be folded on the same benchmark.
|
| 1437 |
targets = {(r["benchmark_id"], r["to_metric_id"]) for r in fold_rows}
|
| 1438 |
+
chained = sorted(targets & set(unscoped_pairs))
|
| 1439 |
if chained:
|
| 1440 |
raise typer.BadParameter(f"metric_folds: chained folds {chained}")
|
| 1441 |
folds_df = pd.DataFrame(
|
|
|
|
| 1532 |
store.set_table("aliases", current_aliases.reset_index(drop=True))
|
| 1533 |
|
| 1534 |
typer.echo(f" aliases: {alias_count} added, {removed_aliases} removed")
|
| 1535 |
+
typer.echo(
|
| 1536 |
+
" source scope keys: "
|
| 1537 |
+
+ (", ".join(sorted(source_scope_keys)) if source_scope_keys else "(none)")
|
| 1538 |
+
)
|
| 1539 |
if removed_entities:
|
| 1540 |
typer.echo(f" stale entities removed: {removed_entities}")
|
| 1541 |
|
src/eval_card_registry/store/hf_store.py
CHANGED
|
@@ -100,6 +100,10 @@ QUERY_TABLE_NAMES = [
|
|
| 100 |
"canonical_families",
|
| 101 |
"canonical_composites",
|
| 102 |
"canonical_metrics",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
"eval_harnesses",
|
| 104 |
"canonical_inference_platforms",
|
| 105 |
"aliases",
|
|
|
|
| 100 |
"canonical_families",
|
| 101 |
"canonical_composites",
|
| 102 |
"canonical_metrics",
|
| 103 |
+
# Read-only curated dim table: no CRUD route, but the query-only Space
|
| 104 |
+
# loads it so a consumer can read the folds alongside the benchmarks
|
| 105 |
+
# they apply to.
|
| 106 |
+
"benchmark_metric_folds",
|
| 107 |
"eval_harnesses",
|
| 108 |
"canonical_inference_platforms",
|
| 109 |
"aliases",
|
src/eval_card_registry/store/schemas.py
CHANGED
|
@@ -106,6 +106,11 @@ _SCHEMAS: dict[str, dict] = {
|
|
| 106 |
# Registry-declared default metric for the merged benchmark view
|
| 107 |
# (seed key `preferred_metric`). Null → consumer fallback rules.
|
| 108 |
"preferred_metric_id": pd.StringDtype(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
"tags": pd.StringDtype(),
|
| 110 |
"metadata": pd.StringDtype(),
|
| 111 |
"review_status": pd.StringDtype(),
|
|
@@ -183,19 +188,27 @@ _SCHEMAS: dict[str, dict] = {
|
|
| 183 |
"created_at": pd.StringDtype(),
|
| 184 |
"updated_at": pd.StringDtype(),
|
| 185 |
},
|
| 186 |
-
# Curated per-benchmark metric
|
| 187 |
# `from_metric_id` on `benchmark_id` is the same measurement as
|
| 188 |
# `to_metric_id` under a generic name. Naming folds ONLY — protocol
|
| 189 |
# variants (cot-correct vs accuracy) never fold. Consumed by the
|
| 190 |
# producer to compute `metric_id_effective` for the merged view.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
"benchmark_metric_folds": {
|
| 192 |
"benchmark_id": pd.StringDtype(),
|
| 193 |
"from_metric_id": pd.StringDtype(),
|
| 194 |
"to_metric_id": pd.StringDtype(),
|
| 195 |
-
|
| 196 |
-
#
|
| 197 |
-
#
|
|
|
|
|
|
|
| 198 |
"scale_factor": "float64",
|
|
|
|
| 199 |
"note": pd.StringDtype(),
|
| 200 |
},
|
| 201 |
"eval_harnesses": {
|
|
|
|
| 106 |
# Registry-declared default metric for the merged benchmark view
|
| 107 |
# (seed key `preferred_metric`). Null → consumer fallback rules.
|
| 108 |
"preferred_metric_id": pd.StringDtype(),
|
| 109 |
+
# Is `preferred_metric_id` produced by an LLM judge? True = yes,
|
| 110 |
+
# false = no, null = unstated. Non-null only when
|
| 111 |
+
# `preferred_metric_id` is set. Says nothing about the benchmark's
|
| 112 |
+
# other metrics.
|
| 113 |
+
"preferred_metric_llm_judged": pd.BooleanDtype(),
|
| 114 |
"tags": pd.StringDtype(),
|
| 115 |
"metadata": pd.StringDtype(),
|
| 116 |
"review_status": pd.StringDtype(),
|
|
|
|
| 188 |
"created_at": pd.StringDtype(),
|
| 189 |
"updated_at": pd.StringDtype(),
|
| 190 |
},
|
| 191 |
+
# Curated per-benchmark metric folds (seed/metric_folds.yaml):
|
| 192 |
# `from_metric_id` on `benchmark_id` is the same measurement as
|
| 193 |
# `to_metric_id` under a generic name. Naming folds ONLY — protocol
|
| 194 |
# variants (cot-correct vs accuracy) never fold. Consumed by the
|
| 195 |
# producer to compute `metric_id_effective` for the merged view.
|
| 196 |
+
# A naming fold is benchmark-wide (`source_config` null). A scoped row
|
| 197 |
+
# (`source_config` set to an EEE dataset config name) carries the
|
| 198 |
+
# published-scale conversion for that one source, and may leave the
|
| 199 |
+
# metric unchanged (`from_metric_id == to_metric_id`) when the source
|
| 200 |
+
# differs only in scale.
|
| 201 |
"benchmark_metric_folds": {
|
| 202 |
"benchmark_id": pd.StringDtype(),
|
| 203 |
"from_metric_id": pd.StringDtype(),
|
| 204 |
"to_metric_id": pd.StringDtype(),
|
| 205 |
+
"source_config": pd.StringDtype(),
|
| 206 |
+
# Optional curated published-scale -> registry-scale affine conversion:
|
| 207 |
+
# canonical = published * scale_factor + scale_offset (e.g. 1/9 and
|
| 208 |
+
# -1/9 for a raw 1-10 score folding onto a [0,1] metric). Scoped rows
|
| 209 |
+
# only. Null = no curated conversion declared.
|
| 210 |
"scale_factor": "float64",
|
| 211 |
+
"scale_offset": "float64",
|
| 212 |
"note": pd.StringDtype(),
|
| 213 |
},
|
| 214 |
"eval_harnesses": {
|