Update gliclass-std-base-v3-daecore-5facet-qint8-v2 documentation
Browse files- evaluation/figures.py +32 -13
- evaluation/metrics.py +139 -27
- publication-manifest.json +11 -11
evaluation/figures.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
"""Regenerate
|
| 2 |
|
| 3 |
Run with Python 3.11+: python figures.py --output ../figures
|
| 4 |
The repository shares its renderer from eval/lib; HF packages include that
|
|
@@ -27,8 +27,7 @@ spec.loader.exec_module(svg)
|
|
| 27 |
UPSTREAM, FIT, REFERENCE = '#0072B2', '#D55E00', '#777777'
|
| 28 |
|
| 29 |
|
| 30 |
-
def classifier(
|
| 31 |
-
summary = metrics.summarize_classifier(data)
|
| 32 |
facets = [*metrics.FACETS, 'macro']
|
| 33 |
def values(model):
|
| 34 |
result = summary['models'][model]
|
|
@@ -45,8 +44,8 @@ def classifier(data: dict) -> str:
|
|
| 45 |
)
|
| 46 |
|
| 47 |
|
| 48 |
-
def reranker(
|
| 49 |
-
|
| 50 |
definitions = [('hit', 'At least one useful passage'), ('precision', 'Useful passages / returned passages'), ('ndcg', 'Graded ranking quality')]
|
| 51 |
panels = []
|
| 52 |
legend = [('Upstream', UPSTREAM, None), ('Daecore fine-tune', FIT, None), ('Random pool order', REFERENCE, '5 3')]
|
|
@@ -54,12 +53,31 @@ def reranker(data: dict) -> str:
|
|
| 54 |
series = []
|
| 55 |
for model, (label, color, dash) in zip(('upstream', 'finetuned', 'random'), legend, strict=True):
|
| 56 |
values = summary['models'][model]['answerable']
|
| 57 |
-
series.append(svg.Series(label, list(range(
|
| 58 |
panels.append(svg.Panel(title, series, xlabel='rank cutoff',
|
| 59 |
ylabel={'hit': 'Hit@k', 'precision': 'Precision@k', 'ndcg': 'nDCG@k'}[field],
|
| 60 |
-
xlim=(0,
|
| 61 |
return svg.render_grid(panels, columns=3, title='Ettin: identical candidates, different ordering',
|
| 62 |
-
subtitle='873 answerable pools
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
legend=legend, panel_width=300, panel_height=270)
|
| 64 |
|
| 65 |
|
|
@@ -67,20 +85,21 @@ def main() -> None:
|
|
| 67 |
parser = argparse.ArgumentParser(description=__doc__)
|
| 68 |
parser.add_argument('--directory', type=Path, default=HERE)
|
| 69 |
parser.add_argument('--output', type=Path, required=True)
|
| 70 |
-
parser.add_argument('--model', choices=('classifier', 'reranker'))
|
| 71 |
args = parser.parse_args()
|
| 72 |
args.output.mkdir(parents=True, exist_ok=True)
|
| 73 |
definitions = {'classifier': ('classifier', 'classifier-comparison.svg'),
|
| 74 |
-
'reranker': ('reranker', 'ettin-comparison.svg')
|
|
|
|
| 75 |
names = [args.model] if args.model else [
|
| 76 |
name for name, (record, _) in definitions.items()
|
| 77 |
-
if (args.directory / f'{record}.json').is_file()
|
| 78 |
]
|
| 79 |
if not names:
|
| 80 |
-
parser.error('No model comparison
|
| 81 |
for name in names:
|
| 82 |
record, filename = definitions[name]
|
| 83 |
-
data = json.loads((args.directory / f'{record}.json').read_text(encoding='utf-8'))
|
| 84 |
(args.output / filename).write_text(globals()[name](data), encoding='utf-8', newline='\n')
|
| 85 |
|
| 86 |
|
|
|
|
| 1 |
+
"""Regenerate model comparison SVGs from the published summaries.
|
| 2 |
|
| 3 |
Run with Python 3.11+: python figures.py --output ../figures
|
| 4 |
The repository shares its renderer from eval/lib; HF packages include that
|
|
|
|
| 27 |
UPSTREAM, FIT, REFERENCE = '#0072B2', '#D55E00', '#777777'
|
| 28 |
|
| 29 |
|
| 30 |
+
def classifier(summary: dict) -> str:
|
|
|
|
| 31 |
facets = [*metrics.FACETS, 'macro']
|
| 32 |
def values(model):
|
| 33 |
result = summary['models'][model]
|
|
|
|
| 44 |
)
|
| 45 |
|
| 46 |
|
| 47 |
+
def reranker(summary: dict) -> str:
|
| 48 |
+
cutoffs = list(metrics.CUTOFFS)
|
| 49 |
definitions = [('hit', 'At least one useful passage'), ('precision', 'Useful passages / returned passages'), ('ndcg', 'Graded ranking quality')]
|
| 50 |
panels = []
|
| 51 |
legend = [('Upstream', UPSTREAM, None), ('Daecore fine-tune', FIT, None), ('Random pool order', REFERENCE, '5 3')]
|
|
|
|
| 53 |
series = []
|
| 54 |
for model, (label, color, dash) in zip(('upstream', 'finetuned', 'random'), legend, strict=True):
|
| 55 |
values = summary['models'][model]['answerable']
|
| 56 |
+
series.append(svg.Series(label, list(range(len(cutoffs))), [values[str(k)][field] for k in cutoffs], color, dash=dash))
|
| 57 |
panels.append(svg.Panel(title, series, xlabel='rank cutoff',
|
| 58 |
ylabel={'hit': 'Hit@k', 'precision': 'Precision@k', 'ndcg': 'nDCG@k'}[field],
|
| 59 |
+
xlim=(0, len(cutoffs) - 1), ylim=(0, 1.02), xticks=list(enumerate(map(str, cutoffs)))))
|
| 60 |
return svg.render_grid(panels, columns=3, title='Ettin: identical candidates, different ordering',
|
| 61 |
+
subtitle='873 answerable pools · 3–20 returned in Daecore · 50 is the full candidate pool',
|
| 62 |
+
legend=legend, panel_width=300, panel_height=270)
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
def retriever(summary: dict) -> str:
|
| 66 |
+
cutoffs = [1, 3, 5, 10, 20]
|
| 67 |
+
x = list(range(len(cutoffs)))
|
| 68 |
+
panels = []
|
| 69 |
+
legend = [('Upstream Gemma', UPSTREAM, None), ('Daecore v2', FIT, None)]
|
| 70 |
+
for field, title in [('hit', 'Find at least one useful passage'),
|
| 71 |
+
('precision', 'Useful passages / retained passages'),
|
| 72 |
+
('ndcg', 'Graded ranking quality')]:
|
| 73 |
+
series = [svg.Series(label, x, [summary['models'][name][str(k)][field] for k in cutoffs], color)
|
| 74 |
+
for name, (label, color, _) in zip(('upstream', 'finetuned'), legend, strict=True)]
|
| 75 |
+
panels.append(svg.Panel(title, series, xlabel='rank cutoff',
|
| 76 |
+
ylabel={'hit': 'Hit@k', 'precision': 'Precision@k', 'ndcg': 'nDCG@k'}[field],
|
| 77 |
+
xlim=(0, len(cutoffs) - 1), ylim=(0, 1.02), xticks=list(enumerate(map(str, cutoffs)))))
|
| 78 |
+
return svg.render_grid(panels, columns=3,
|
| 79 |
+
title='Gemma v2: matched dense retrieval on Daecore data',
|
| 80 |
+
subtitle=f"{summary['queries']:,} queries · {summary['corpus_passages']:,} passages · reviewed abstentions excluded",
|
| 81 |
legend=legend, panel_width=300, panel_height=270)
|
| 82 |
|
| 83 |
|
|
|
|
| 85 |
parser = argparse.ArgumentParser(description=__doc__)
|
| 86 |
parser.add_argument('--directory', type=Path, default=HERE)
|
| 87 |
parser.add_argument('--output', type=Path, required=True)
|
| 88 |
+
parser.add_argument('--model', choices=('classifier', 'reranker', 'retriever'))
|
| 89 |
args = parser.parse_args()
|
| 90 |
args.output.mkdir(parents=True, exist_ok=True)
|
| 91 |
definitions = {'classifier': ('classifier', 'classifier-comparison.svg'),
|
| 92 |
+
'reranker': ('reranker', 'ettin-comparison.svg'),
|
| 93 |
+
'retriever': ('retriever', 'gemma-comparison.svg')}
|
| 94 |
names = [args.model] if args.model else [
|
| 95 |
name for name, (record, _) in definitions.items()
|
| 96 |
+
if (args.directory / f'{record}-summary.json').is_file()
|
| 97 |
]
|
| 98 |
if not names:
|
| 99 |
+
parser.error('No model comparison summaries found in the selected directory')
|
| 100 |
for name in names:
|
| 101 |
record, filename = definitions[name]
|
| 102 |
+
data = json.loads((args.directory / f'{record}-summary.json').read_text(encoding='utf-8'))
|
| 103 |
(args.output / filename).write_text(globals()[name](data), encoding='utf-8', newline='\n')
|
| 104 |
|
| 105 |
|
evaluation/metrics.py
CHANGED
|
@@ -11,7 +11,7 @@ import math
|
|
| 11 |
from pathlib import Path
|
| 12 |
from statistics import mean
|
| 13 |
|
| 14 |
-
CUTOFFS = (1, 3, 5, 10, 20)
|
| 15 |
FACETS = ("trap", "decision", "constraint", "mechanism", "procedure")
|
| 16 |
|
| 17 |
|
|
@@ -116,36 +116,82 @@ def summarize_reranker(data: dict) -> dict:
|
|
| 116 |
return output
|
| 117 |
|
| 118 |
|
| 119 |
-
def
|
| 120 |
-
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
|
| 122 |
A null is permitted only for an explicitly excluded judging abstention.
|
| 123 |
Cut first, remove exclusions second, and never backfill from a deeper rank.
|
| 124 |
"""
|
| 125 |
rows = data['rows']
|
| 126 |
if not rows or len({row['id'] for row in rows}) != len(rows):
|
| 127 |
-
raise ValueError('
|
| 128 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
for model in data['model_order']:
|
| 130 |
cutoffs = {}
|
| 131 |
-
for cutoff in
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
per_query = []
|
| 133 |
-
for row in
|
| 134 |
counts = row['reference_grade_counts']
|
| 135 |
-
if set(counts) != {'0', '1', '2', '3'} or any(type(n) is not int or n < 0 for n in counts.values()):
|
| 136 |
-
raise ValueError('Reference grade counts must cover grades zero through three')
|
| 137 |
ranked = row['ranked_grades'][model]
|
| 138 |
excluded = row['excluded'][model]
|
| 139 |
depth = row['selected_depth'][model] if cutoff == 'selected' else cutoff
|
| 140 |
-
if (len(ranked) != 20 or len(excluded) != 20 or type(depth) is not int
|
| 141 |
-
or not 3 <= depth <= 20 or any(type(x) is not bool for x in excluded)):
|
| 142 |
-
raise ValueError('Promotion rows require a bounded original top twenty')
|
| 143 |
-
if any((grade is not None if drop else type(grade) is not int or grade not in range(4))
|
| 144 |
-
for grade, drop in zip(ranked, excluded, strict=True)):
|
| 145 |
-
raise ValueError('Only declared abstentions may lack grades')
|
| 146 |
kept = [grade for grade, drop in zip(ranked[:depth], excluded[:depth], strict=True) if not drop]
|
| 147 |
-
if not kept:
|
| 148 |
-
raise ValueError('Every scored prefix must retain judged passages')
|
| 149 |
ideal_grades = [g for g in (3, 2, 1, 0) for _ in range(min(counts[str(g)], len(kept)))][:len(kept)]
|
| 150 |
useful = sum(g >= 2 for g in kept)
|
| 151 |
positives = counts['2'] + counts['3']
|
|
@@ -160,15 +206,22 @@ def summarize_promotion(data: dict) -> dict:
|
|
| 160 |
retained = sum(row['retained'] for row in per_query)
|
| 161 |
recalls = [row['known_recall'] for row in per_query if row['known_recall'] is not None]
|
| 162 |
cutoffs[str(cutoff)] = {
|
|
|
|
| 163 |
'hit': mean(row['hit'] for row in per_query), 'precision': useful / retained,
|
| 164 |
'macro_precision': mean(row['precision'] for row in per_query),
|
| 165 |
'ndcg': mean(row['ndcg'] for row in per_query),
|
| 166 |
'known_positive_recall': mean(recalls) if recalls else None,
|
| 167 |
'recall_queries': len(recalls), 'useful': useful, 'retained': retained,
|
| 168 |
'excluded_positions': sum(row['excluded'] for row in per_query),
|
| 169 |
-
'mean_useful': useful / len(
|
| 170 |
}
|
| 171 |
output['models'][model] = cutoffs
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 172 |
for dataset, panel in data['public'].items():
|
| 173 |
if not panel['rows'] or len({row['id'] for row in panel['rows']}) != len(panel['rows']):
|
| 174 |
raise ValueError('Public panel requires distinct query identities')
|
|
@@ -187,27 +240,86 @@ def summarize_promotion(data: dict) -> dict:
|
|
| 187 |
return output
|
| 188 |
|
| 189 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
def main() -> None:
|
| 191 |
parser = argparse.ArgumentParser(description=__doc__)
|
| 192 |
parser.add_argument("--directory", type=Path, default=Path(__file__).resolve().parent)
|
| 193 |
parser.add_argument("--output", type=Path)
|
| 194 |
-
parser.add_argument("--model", choices=("classifier", "reranker", "promotion", "serving"), help="Recompute one comparison; default: every record in this package")
|
| 195 |
args = parser.parse_args()
|
| 196 |
-
summarizers = {"classifier": summarize_classifier, "reranker": summarize_reranker,
|
| 197 |
-
"promotion": summarize_promotion, "serving": summarize_promotion}
|
| 198 |
names = [args.model] if args.model else [
|
| 199 |
-
name for name in
|
| 200 |
]
|
| 201 |
if not names:
|
| 202 |
parser.error("No evaluation records found in the selected directory")
|
| 203 |
result = {}
|
| 204 |
for name in names:
|
| 205 |
-
summarize = summarizers[name]
|
| 206 |
data = json.loads((args.directory / f"{name}.json").read_text(encoding="utf-8"))
|
| 207 |
-
|
| 208 |
-
if len(set(ids)) != len(ids):
|
| 209 |
-
raise ValueError(f"Repeated query/passage identity in {name}")
|
| 210 |
-
result[name] = summarize(data)
|
| 211 |
text = json.dumps(result, indent=2, allow_nan=False) + "\n"
|
| 212 |
if args.output:
|
| 213 |
args.output.write_text(text, encoding="utf-8")
|
|
|
|
| 11 |
from pathlib import Path
|
| 12 |
from statistics import mean
|
| 13 |
|
| 14 |
+
CUTOFFS = (1, 3, 5, 10, 20, 50)
|
| 15 |
FACETS = ("trap", "decision", "constraint", "mechanism", "procedure")
|
| 16 |
|
| 17 |
|
|
|
|
| 116 |
return output
|
| 117 |
|
| 118 |
|
| 119 |
+
def summarize_retriever(data: dict) -> dict:
|
| 120 |
+
"""Fully reviewed dense rankings, including queries without known positives."""
|
| 121 |
+
if type(data['corpus_passages']) is not int or data['corpus_passages'] <= 0:
|
| 122 |
+
raise ValueError('Dense comparison requires a positive corpus size')
|
| 123 |
+
return {**_summarize_ranked_grades(data, include_selected=False),
|
| 124 |
+
'corpus_passages': data['corpus_passages']}
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
def summarize_dimensions(data: dict) -> dict:
|
| 128 |
+
"""Average the measured public nDCG values for each embedding width."""
|
| 129 |
+
rows, widths = data['rows'], data['widths']
|
| 130 |
+
if not rows or len({row['id'] for row in rows}) != len(rows):
|
| 131 |
+
raise ValueError('Width comparison requires distinct query identities')
|
| 132 |
+
if not widths or len(set(widths)) != len(widths) or any(type(w) is not int or w <= 0 for w in widths):
|
| 133 |
+
raise ValueError('Embedding widths must be distinct positive integers')
|
| 134 |
+
for row in rows:
|
| 135 |
+
if set(row['ndcg@10']) != {str(w) for w in widths} or any(
|
| 136 |
+
isinstance(v, bool) or not isinstance(v, int | float) or not math.isfinite(v) or not 0 <= v <= 1
|
| 137 |
+
for v in row['ndcg@10'].values()
|
| 138 |
+
):
|
| 139 |
+
raise ValueError('Every query must have a finite nDCG value for every width')
|
| 140 |
+
panels = {}
|
| 141 |
+
for name in sorted({row['dataset'] for row in rows}):
|
| 142 |
+
panel = [row for row in rows if row['dataset'] == name]
|
| 143 |
+
panels[name] = {'queries': len(panel), 'ndcg@10': {
|
| 144 |
+
str(w): mean(row['ndcg@10'][str(w)] for row in panel) for w in widths
|
| 145 |
+
}}
|
| 146 |
+
return {'queries': len(rows), 'vector_bytes_fp32': {str(w): w * 4 for w in widths}, 'public': panels}
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
def _summarize_ranked_grades(data: dict, *, include_selected: bool) -> dict:
|
| 150 |
+
"""Reviewed exclusions inside each original dense or hybrid prefix.
|
| 151 |
|
| 152 |
A null is permitted only for an explicitly excluded judging abstention.
|
| 153 |
Cut first, remove exclusions second, and never backfill from a deeper rank.
|
| 154 |
"""
|
| 155 |
rows = data['rows']
|
| 156 |
if not rows or len({row['id'] for row in rows}) != len(rows):
|
| 157 |
+
raise ValueError('Ranked rows require unique nonempty query identities')
|
| 158 |
+
# Validate before excluding fully abstained prefixes. An omitted query
|
| 159 |
+
# must never conceal a malformed grade, model map or selected depth.
|
| 160 |
+
for row in rows:
|
| 161 |
+
counts = row['reference_grade_counts']
|
| 162 |
+
if set(counts) != {'0', '1', '2', '3'} or any(type(n) is not int or n < 0 for n in counts.values()):
|
| 163 |
+
raise ValueError('Reference grade counts must cover grades zero through three')
|
| 164 |
+
for model in data['model_order']:
|
| 165 |
+
ranked, excluded = row['ranked_grades'][model], row['excluded'][model]
|
| 166 |
+
if (len(ranked) != 20 or len(excluded) != 20
|
| 167 |
+
or any(type(x) is not bool for x in excluded)):
|
| 168 |
+
raise ValueError('Ranked rows require a bounded original top twenty')
|
| 169 |
+
if include_selected:
|
| 170 |
+
depth = row['selected_depth'][model]
|
| 171 |
+
if type(depth) is not int or not 3 <= depth <= 20:
|
| 172 |
+
raise ValueError('Selected depth must be between three and twenty')
|
| 173 |
+
if any((grade is not None if drop else type(grade) is not int or grade not in range(4))
|
| 174 |
+
for grade, drop in zip(ranked, excluded, strict=True)):
|
| 175 |
+
raise ValueError('Only declared abstentions may lack grades')
|
| 176 |
+
output = {'queries': len(rows), 'models': {}}
|
| 177 |
+
requested_cutoffs = (1, 3, 5, 10, 20, 'selected') if include_selected else (1, 3, 5, 10, 20)
|
| 178 |
for model in data['model_order']:
|
| 179 |
cutoffs = {}
|
| 180 |
+
for cutoff in requested_cutoffs:
|
| 181 |
+
eligible = [row for row in rows if all(
|
| 182 |
+
any(not drop for drop in row['excluded'][arm][:(
|
| 183 |
+
row['selected_depth'][arm] if cutoff == 'selected' else cutoff)])
|
| 184 |
+
for arm in data['model_order']
|
| 185 |
+
)]
|
| 186 |
+
if not eligible:
|
| 187 |
+
raise ValueError('No shared judged queries at this cutoff')
|
| 188 |
per_query = []
|
| 189 |
+
for row in eligible:
|
| 190 |
counts = row['reference_grade_counts']
|
|
|
|
|
|
|
| 191 |
ranked = row['ranked_grades'][model]
|
| 192 |
excluded = row['excluded'][model]
|
| 193 |
depth = row['selected_depth'][model] if cutoff == 'selected' else cutoff
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
kept = [grade for grade, drop in zip(ranked[:depth], excluded[:depth], strict=True) if not drop]
|
|
|
|
|
|
|
| 195 |
ideal_grades = [g for g in (3, 2, 1, 0) for _ in range(min(counts[str(g)], len(kept)))][:len(kept)]
|
| 196 |
useful = sum(g >= 2 for g in kept)
|
| 197 |
positives = counts['2'] + counts['3']
|
|
|
|
| 206 |
retained = sum(row['retained'] for row in per_query)
|
| 207 |
recalls = [row['known_recall'] for row in per_query if row['known_recall'] is not None]
|
| 208 |
cutoffs[str(cutoff)] = {
|
| 209 |
+
'scored_queries': len(eligible), 'excluded_queries': len(rows) - len(eligible),
|
| 210 |
'hit': mean(row['hit'] for row in per_query), 'precision': useful / retained,
|
| 211 |
'macro_precision': mean(row['precision'] for row in per_query),
|
| 212 |
'ndcg': mean(row['ndcg'] for row in per_query),
|
| 213 |
'known_positive_recall': mean(recalls) if recalls else None,
|
| 214 |
'recall_queries': len(recalls), 'useful': useful, 'retained': retained,
|
| 215 |
'excluded_positions': sum(row['excluded'] for row in per_query),
|
| 216 |
+
'mean_useful': useful / len(eligible), 'mean_retained': retained / len(eligible),
|
| 217 |
}
|
| 218 |
output['models'][model] = cutoffs
|
| 219 |
+
return output
|
| 220 |
+
|
| 221 |
+
|
| 222 |
+
def summarize_promotion(data: dict) -> dict:
|
| 223 |
+
"""Hybrid rankings and the separately measured public dense panels."""
|
| 224 |
+
output = {**_summarize_ranked_grades(data, include_selected=True), 'public': {}}
|
| 225 |
for dataset, panel in data['public'].items():
|
| 226 |
if not panel['rows'] or len({row['id'] for row in panel['rows']}) != len(panel['rows']):
|
| 227 |
raise ValueError('Public panel requires distinct query identities')
|
|
|
|
| 240 |
return output
|
| 241 |
|
| 242 |
|
| 243 |
+
SUMMARIZERS = {
|
| 244 |
+
'classifier': summarize_classifier, 'reranker': summarize_reranker,
|
| 245 |
+
'retriever': summarize_retriever, 'dimensions': summarize_dimensions,
|
| 246 |
+
'promotion': summarize_promotion, 'serving': summarize_promotion,
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
|
| 250 |
+
def summarize_record(name: str, data: dict) -> dict:
|
| 251 |
+
"""Check anonymous publication records before recomputing their summary."""
|
| 252 |
+
fields = {
|
| 253 |
+
'classifier': {'id', 'group', 'labels', 'scores'},
|
| 254 |
+
'reranker': {'id', 'group', 'grades', 'scores'},
|
| 255 |
+
'retriever': {'id', 'group', 'reference_grade_counts', 'ranked_grades', 'excluded'},
|
| 256 |
+
'dimensions': {'id', 'dataset', 'ndcg@10'},
|
| 257 |
+
'promotion': {'id', 'group', 'reference_grade_counts', 'ranked_grades', 'excluded', 'selected_depth'},
|
| 258 |
+
'serving': {'id', 'group', 'reference_grade_counts', 'ranked_grades', 'excluded', 'selected_depth'},
|
| 259 |
+
}[name]
|
| 260 |
+
rows = data['rows']
|
| 261 |
+
if not rows or any(set(row) != fields for row in rows):
|
| 262 |
+
raise ValueError(f'Unexpected evaluation row fields in {name}')
|
| 263 |
+
ids = [row['id'] for row in rows]
|
| 264 |
+
if len(set(ids)) != len(ids):
|
| 265 |
+
raise ValueError(f'Repeated query/passage identity in {name}')
|
| 266 |
+
for row in rows:
|
| 267 |
+
identity = row['id']
|
| 268 |
+
if not isinstance(identity, str) or identity[:1] not in ('p', 'q') or not identity[1:].isdigit():
|
| 269 |
+
raise ValueError(f'Non-anonymous row identity in {name}')
|
| 270 |
+
if 'group' in row and (not isinstance(row['group'], str) or not row['group'].startswith('g') or not row['group'][1:].isdigit()):
|
| 271 |
+
raise ValueError(f'Non-anonymous group identity in {name}')
|
| 272 |
+
if name != 'dimensions' and set(data['model_order']) != set(data['models']):
|
| 273 |
+
raise ValueError(f'Model identities do not match in {name}')
|
| 274 |
+
models = set(data.get('model_order', ()))
|
| 275 |
+
for row in rows:
|
| 276 |
+
for field in ('scores', 'ranked_grades', 'excluded', 'selected_depth'):
|
| 277 |
+
if field in row and set(row[field]) != models:
|
| 278 |
+
raise ValueError(f'Unexpected model fields in {name}.{field}')
|
| 279 |
+
if name == 'classifier':
|
| 280 |
+
required = {facet for facet, label in row['labels'].items() if label is not None}
|
| 281 |
+
if set(row['labels']) != set(FACETS) or any(not required <= set(scores) <= set(FACETS) for scores in row['scores'].values()):
|
| 282 |
+
raise ValueError('Unexpected classifier facet fields')
|
| 283 |
+
if any(type(value) not in (int, float) or not math.isfinite(value)
|
| 284 |
+
for scores in row['scores'].values() for value in scores.values()):
|
| 285 |
+
raise ValueError('Classifier scores must be finite numbers, including unresolved facets')
|
| 286 |
+
for panel in data.get('public', {}).values():
|
| 287 |
+
if set(panel) != {'model_order', 'rows'} or not panel['rows']:
|
| 288 |
+
raise ValueError('Unexpected public-panel fields')
|
| 289 |
+
panel_models = set(panel['model_order'])
|
| 290 |
+
panel_ids = []
|
| 291 |
+
for row in panel['rows']:
|
| 292 |
+
if set(row) != {'id', 'ndcg@10'} or set(row['ndcg@10']) != panel_models:
|
| 293 |
+
raise ValueError('Unexpected public-panel row fields')
|
| 294 |
+
identity = row['id']
|
| 295 |
+
if not isinstance(identity, str) or identity[:1] != 'q' or not identity[1:].isdigit():
|
| 296 |
+
raise ValueError('Non-anonymous public-panel row identity')
|
| 297 |
+
if any(type(value) not in (int, float) or not math.isfinite(value) or not 0 <= value <= 1 for value in row['ndcg@10'].values()):
|
| 298 |
+
raise ValueError('Invalid public-panel score')
|
| 299 |
+
panel_ids.append(identity)
|
| 300 |
+
if len(panel_ids) != len(set(panel_ids)):
|
| 301 |
+
raise ValueError('Repeated public-panel query identity')
|
| 302 |
+
text = json.dumps(data).lower()
|
| 303 |
+
if any(value in text for value in ('c:\\', 'eval/private', 'qrel_target_id', 'query_text', 'passage_text')):
|
| 304 |
+
raise ValueError(f'Private payload in {name}')
|
| 305 |
+
return SUMMARIZERS[name](data)
|
| 306 |
+
|
| 307 |
+
|
| 308 |
def main() -> None:
|
| 309 |
parser = argparse.ArgumentParser(description=__doc__)
|
| 310 |
parser.add_argument("--directory", type=Path, default=Path(__file__).resolve().parent)
|
| 311 |
parser.add_argument("--output", type=Path)
|
| 312 |
+
parser.add_argument("--model", choices=("classifier", "reranker", "retriever", "dimensions", "promotion", "serving"), help="Recompute one comparison; default: every record in this package")
|
| 313 |
args = parser.parse_args()
|
|
|
|
|
|
|
| 314 |
names = [args.model] if args.model else [
|
| 315 |
+
name for name in SUMMARIZERS if (args.directory / f"{name}.json").is_file()
|
| 316 |
]
|
| 317 |
if not names:
|
| 318 |
parser.error("No evaluation records found in the selected directory")
|
| 319 |
result = {}
|
| 320 |
for name in names:
|
|
|
|
| 321 |
data = json.loads((args.directory / f"{name}.json").read_text(encoding="utf-8"))
|
| 322 |
+
result[name] = summarize_record(name, data)
|
|
|
|
|
|
|
|
|
|
| 323 |
text = json.dumps(result, indent=2, allow_nan=False) + "\n"
|
| 324 |
if args.output:
|
| 325 |
args.output.write_text(text, encoding="utf-8")
|
publication-manifest.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"schema": "daecore.classifier-publication-manifest",
|
| 3 |
-
"tool_sha256": "
|
| 4 |
"public_repo": "Daecore/gliclass-std-base-v3-5facet-qint8-v2",
|
| 5 |
"classifier_version": "gliclass-std-base-v3-daecore-5facet-qint8-v2",
|
| 6 |
"upstream": {
|
|
@@ -10,7 +10,7 @@
|
|
| 10 |
"nominee_receipt_sha256": "d463fc167b2a26f8f5b56e03c18e4c604b231eb25b5093064dd8a9bd7ffa6373",
|
| 11 |
"derivation_preparation_sha256": "bfd902e06b7a984348283dc279f5e46d76398ff59633a9b5b426f33d872a67d3",
|
| 12 |
"source_nominee_binding": "unchanged learned model and calibration; graph bytes separately derived",
|
| 13 |
-
"staged_at": "2026-09-
|
| 14 |
"files": {
|
| 15 |
"classifier-metadata.json": {
|
| 16 |
"sha256": "736d8b615fb8c4bd7cc36d1c2e0e86bbe096d63dc373d047ca75af9cc6119a11",
|
|
@@ -68,13 +68,8 @@
|
|
| 68 |
"binding": "packaging record"
|
| 69 |
},
|
| 70 |
"evaluation/metrics.py": {
|
| 71 |
-
"sha256": "
|
| 72 |
-
"size":
|
| 73 |
-
"binding": "packaging record"
|
| 74 |
-
},
|
| 75 |
-
"evaluation/classifier.json": {
|
| 76 |
-
"sha256": "5498bb3f5f15f587bc93fc77c9a56308e6ccbc85976bd8e38530b643614628bc",
|
| 77 |
-
"size": 721988,
|
| 78 |
"binding": "packaging record"
|
| 79 |
},
|
| 80 |
"evaluation/classifier-summary.json": {
|
|
@@ -82,9 +77,14 @@
|
|
| 82 |
"size": 4799,
|
| 83 |
"binding": "packaging record"
|
| 84 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
"evaluation/figures.py": {
|
| 86 |
-
"sha256": "
|
| 87 |
-
"size":
|
| 88 |
"binding": "packaging record"
|
| 89 |
},
|
| 90 |
"evaluation/svg_figures.py": {
|
|
|
|
| 1 |
{
|
| 2 |
"schema": "daecore.classifier-publication-manifest",
|
| 3 |
+
"tool_sha256": "3ea615c62866883f911899f1e131d73ca8cc9701eea3540a3a016345ac5650f8",
|
| 4 |
"public_repo": "Daecore/gliclass-std-base-v3-5facet-qint8-v2",
|
| 5 |
"classifier_version": "gliclass-std-base-v3-daecore-5facet-qint8-v2",
|
| 6 |
"upstream": {
|
|
|
|
| 10 |
"nominee_receipt_sha256": "d463fc167b2a26f8f5b56e03c18e4c604b231eb25b5093064dd8a9bd7ffa6373",
|
| 11 |
"derivation_preparation_sha256": "bfd902e06b7a984348283dc279f5e46d76398ff59633a9b5b426f33d872a67d3",
|
| 12 |
"source_nominee_binding": "unchanged learned model and calibration; graph bytes separately derived",
|
| 13 |
+
"staged_at": "2026-09-29T16:51:23+00:00",
|
| 14 |
"files": {
|
| 15 |
"classifier-metadata.json": {
|
| 16 |
"sha256": "736d8b615fb8c4bd7cc36d1c2e0e86bbe096d63dc373d047ca75af9cc6119a11",
|
|
|
|
| 68 |
"binding": "packaging record"
|
| 69 |
},
|
| 70 |
"evaluation/metrics.py": {
|
| 71 |
+
"sha256": "72e7452766b491c247514df8ad1c8f52c8023e1e305d779655a9e1f3159ce52d",
|
| 72 |
+
"size": 17556,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
"binding": "packaging record"
|
| 74 |
},
|
| 75 |
"evaluation/classifier-summary.json": {
|
|
|
|
| 77 |
"size": 4799,
|
| 78 |
"binding": "packaging record"
|
| 79 |
},
|
| 80 |
+
"evaluation/classifier.json": {
|
| 81 |
+
"sha256": "5498bb3f5f15f587bc93fc77c9a56308e6ccbc85976bd8e38530b643614628bc",
|
| 82 |
+
"size": 721988,
|
| 83 |
+
"binding": "packaging record"
|
| 84 |
+
},
|
| 85 |
"evaluation/figures.py": {
|
| 86 |
+
"sha256": "53819eb947c3c5c25f6331b0e384e6e27f7b5da750c84f8bdf6fd6e7790c9d94",
|
| 87 |
+
"size": 5378,
|
| 88 |
"binding": "packaging record"
|
| 89 |
},
|
| 90 |
"evaluation/svg_figures.py": {
|