quantcheck 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- quantcheck/__init__.py +3 -0
- quantcheck/auth/__init__.py +6 -0
- quantcheck/auth/base.py +74 -0
- quantcheck/auth/callback.py +73 -0
- quantcheck/auth/fake.py +40 -0
- quantcheck/auth/service.py +49 -0
- quantcheck/auth/store.py +63 -0
- quantcheck/auth/supabase.py +168 -0
- quantcheck/bench.py +38 -0
- quantcheck/candidates.py +138 -0
- quantcheck/cli.py +251 -0
- quantcheck/config.py +63 -0
- quantcheck/executors/__init__.py +0 -0
- quantcheck/hardware.py +52 -0
- quantcheck/limits.py +19 -0
- quantcheck/pipeline.py +172 -0
- quantcheck/prompt.py +67 -0
- quantcheck/recommend.py +131 -0
- quantcheck/report/__init__.py +0 -0
- quantcheck/report/html.py +38 -0
- quantcheck/report/templates/report.html.j2 +272 -0
- quantcheck/report/terminal.py +90 -0
- quantcheck/report/tokens.py +41 -0
- quantcheck/report/view.py +161 -0
- quantcheck/runners/__init__.py +3 -0
- quantcheck/runners/base.py +87 -0
- quantcheck/runners/fake.py +68 -0
- quantcheck/runners/llamacpp_runner.py +185 -0
- quantcheck/runners/mlx_runner.py +153 -0
- quantcheck/runners/toolparse.py +107 -0
- quantcheck/scoring/__init__.py +0 -0
- quantcheck/scoring/checks.py +342 -0
- quantcheck/scoring/fake_judge.py +50 -0
- quantcheck/scoring/judge.py +171 -0
- quantcheck/scoring/language.py +99 -0
- quantcheck/scoring/models.py +92 -0
- quantcheck/scoring/score.py +167 -0
- quantcheck/scoring/stats.py +60 -0
- quantcheck/settings.py +14 -0
- quantcheck/store.py +88 -0
- quantcheck/tests_io.py +169 -0
- quantcheck/ui/__init__.py +1 -0
- quantcheck/ui/app.py +534 -0
- quantcheck/ui/catalog.py +47 -0
- quantcheck/ui/chat.py +211 -0
- quantcheck/ui/compare.py +63 -0
- quantcheck/ui/downloads.py +172 -0
- quantcheck/ui/jobs.py +173 -0
- quantcheck/ui/modeldetail.py +97 -0
- quantcheck/ui/reviews.py +59 -0
- quantcheck/ui/security.py +45 -0
- quantcheck/ui/static/chat.js +312 -0
- quantcheck/ui/static/fonts/JetBrainsMono-latin-b87346.woff2 +0 -0
- quantcheck/ui/static/fonts/JetBrainsMono-latin-ext-9326b4.woff2 +0 -0
- quantcheck/ui/static/fonts/NotoSansDevanagari-devanagari-3819bb.woff2 +0 -0
- quantcheck/ui/static/fonts/NotoSansDevanagari-latin-ext-542103.woff2 +0 -0
- quantcheck/ui/static/fonts/NotoSansDevanagari-latin-f3aaed.woff2 +0 -0
- quantcheck/ui/static/fonts/NotoSansTamil-latin-17e6dc.woff2 +0 -0
- quantcheck/ui/static/fonts/NotoSansTamil-latin-ext-027c12.woff2 +0 -0
- quantcheck/ui/static/fonts/NotoSansTamil-tamil-a57d5e.woff2 +0 -0
- quantcheck/ui/static/fonts/Outfit-latin-ebadd8.woff2 +0 -0
- quantcheck/ui/static/fonts/Outfit-latin-ext-744997.woff2 +0 -0
- quantcheck/ui/static/fonts/README.md +14 -0
- quantcheck/ui/static/fonts.css +228 -0
- quantcheck/ui/static/index.html +24 -0
- quantcheck/ui/static/lab.css +768 -0
- quantcheck/ui/static/lab.js +896 -0
- quantcheck/ui/static/logo.svg +5 -0
- quantcheck/ui/static/review.js +127 -0
- quantcheck/ui/static/setup.js +132 -0
- quantcheck/ui/static/testsets.js +527 -0
- quantcheck/ui/summary.py +104 -0
- quantcheck/ui/system.py +101 -0
- quantcheck/ui/testsets.py +243 -0
- quantcheck-0.0.1.dist-info/METADATA +115 -0
- quantcheck-0.0.1.dist-info/RECORD +79 -0
- quantcheck-0.0.1.dist-info/WHEEL +4 -0
- quantcheck-0.0.1.dist-info/entry_points.txt +2 -0
- quantcheck-0.0.1.dist-info/licenses/LICENSE +202 -0
quantcheck/recommend.py
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"""The recommendation: the smallest version that is still safe, and how sure we are.
|
|
2
|
+
|
|
3
|
+
Safe means the lower end of the 95% interval on (version quality / reference quality) stays
|
|
4
|
+
at or above ``quality_limit``, with at least ``MIN_PROMPTS_FOR_VERDICT`` prompts scored.
|
|
5
|
+
Otherwise the version is "unsafe" (the whole interval is below the limit) or "uncertain",
|
|
6
|
+
and we say so instead of declaring a winner inside the noise.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from quantcheck import limits
|
|
12
|
+
from quantcheck.scoring.models import CandidateScore, CandidateVerdict, Recommendation
|
|
13
|
+
from quantcheck.scoring.stats import needed_prompts, paired_ratio_ci
|
|
14
|
+
from quantcheck.store import CandidateRun, RunResult
|
|
15
|
+
|
|
16
|
+
CHANGE = 0.05 # a per-prompt quality move bigger than this counts as better/worse
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _paired(cand: CandidateScore, ref: CandidateScore) -> tuple[list[float], list[float]]:
|
|
20
|
+
ref_q = {a.case_id: a.quality for a in ref.answers if a.quality is not None}
|
|
21
|
+
pairs = [(a.quality, ref_q[a.case_id]) for a in cand.answers if a.quality is not None
|
|
22
|
+
and a.case_id in ref_q] # fmt: skip
|
|
23
|
+
return [p[0] for p in pairs], [p[1] for p in pairs]
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _size_order(runs: dict[str, CandidateRun]) -> list[str]:
|
|
27
|
+
"""Smallest first: by file size if every version has one, else by bits."""
|
|
28
|
+
labels = list(runs)
|
|
29
|
+
if all(runs[x].file_size_mb is not None for x in labels):
|
|
30
|
+
return sorted(labels, key=lambda x: runs[x].file_size_mb)
|
|
31
|
+
return sorted(labels, key=lambda x: (runs[x].candidate.bits or 99) if runs[x].candidate else 99)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _verdict(
|
|
35
|
+
cs: CandidateScore, ref: CandidateScore, run: CandidateRun, ref_run: CandidateRun, limit: float,
|
|
36
|
+
min_n: int,
|
|
37
|
+
) -> tuple[CandidateVerdict, tuple[list[float], list[float]]]: # fmt: skip
|
|
38
|
+
cand_q, ref_q = _paired(cs, ref)
|
|
39
|
+
saving = None
|
|
40
|
+
if run.file_size_mb and ref_run.file_size_mb:
|
|
41
|
+
saving = round(1 - run.file_size_mb / ref_run.file_size_mb, 4)
|
|
42
|
+
v = CandidateVerdict(label=cs.label, verdict="uncertain", n=len(cand_q), size_saving=saving)
|
|
43
|
+
v.n_worse = sum(c < r - CHANGE for c, r in zip(cand_q, ref_q, strict=True))
|
|
44
|
+
v.n_better = sum(c > r + CHANGE for c, r in zip(cand_q, ref_q, strict=True))
|
|
45
|
+
ci = paired_ratio_ci(cand_q, ref_q)
|
|
46
|
+
if ci is None:
|
|
47
|
+
v.note = "cannot compare: the reference scored 0 or nothing was scored"
|
|
48
|
+
return v, (cand_q, ref_q)
|
|
49
|
+
v.relative, v.ci_low, v.ci_high = (round(x, 4) for x in ci)
|
|
50
|
+
if v.n < min_n:
|
|
51
|
+
v.note = f"only {v.n} prompts scored; at least {min_n} needed for a verdict"
|
|
52
|
+
elif v.ci_low >= limit:
|
|
53
|
+
v.verdict, v.note = "safe", "stays above the limit even in the pessimistic case"
|
|
54
|
+
elif v.ci_high < limit:
|
|
55
|
+
v.verdict, v.note = "unsafe", "below the limit even in the optimistic case"
|
|
56
|
+
else:
|
|
57
|
+
v.note = "too close to the limit to call with this many prompts"
|
|
58
|
+
return v, (cand_q, ref_q)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def _pct(x: float) -> str:
|
|
62
|
+
return f"{x:.1%}".replace(".0%", "%")
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def recommend(
|
|
66
|
+
result: RunResult, limit: float, min_n: int = limits.MIN_PROMPTS_FOR_VERDICT
|
|
67
|
+
) -> Recommendation:
|
|
68
|
+
"""Recommend a version from a scored run."""
|
|
69
|
+
sc = result.scoring
|
|
70
|
+
if sc is None or sc.reference_label is None:
|
|
71
|
+
return Recommendation(
|
|
72
|
+
status="no_data", limit=limit, message="Nothing to recommend: the run is not scored."
|
|
73
|
+
)
|
|
74
|
+
runs = {c.label: c for c in result.candidates if c.status == "ok"}
|
|
75
|
+
scores = {c.label: c for c in sc.candidates}
|
|
76
|
+
ref_label = sc.reference_label
|
|
77
|
+
ref, ref_run = scores[ref_label], runs[ref_label]
|
|
78
|
+
verdicts: dict[str, CandidateVerdict] = {
|
|
79
|
+
ref_label: CandidateVerdict(
|
|
80
|
+
label=ref_label,
|
|
81
|
+
verdict="reference",
|
|
82
|
+
relative=1.0,
|
|
83
|
+
ci_low=1.0,
|
|
84
|
+
ci_high=1.0,
|
|
85
|
+
n=ref.n_scored,
|
|
86
|
+
note="what the others are compared to",
|
|
87
|
+
) # fmt: skip
|
|
88
|
+
}
|
|
89
|
+
samples: dict[str, tuple[list[float], list[float]]] = {}
|
|
90
|
+
for label, cs in scores.items():
|
|
91
|
+
if label != ref_label:
|
|
92
|
+
verdicts[label], samples[label] = _verdict(cs, ref, runs[label], ref_run, limit, min_n)
|
|
93
|
+
|
|
94
|
+
order = _size_order(runs)
|
|
95
|
+
chosen = next((x for x in order if verdicts[x].verdict in ("safe", "reference")), ref_label)
|
|
96
|
+
smaller = order[: order.index(chosen)]
|
|
97
|
+
unsure = [x for x in smaller if verdicts[x].verdict == "uncertain"]
|
|
98
|
+
needed = None
|
|
99
|
+
if unsure:
|
|
100
|
+
guesses = [needed_prompts(*samples[x], limit) for x in unsure]
|
|
101
|
+
needed = max((g for g in guesses if g is not None), default=None)
|
|
102
|
+
status, message = _message(chosen, ref_label, verdicts, unsure, needed, limit, min_n)
|
|
103
|
+
return Recommendation(
|
|
104
|
+
status=status, limit=limit, reference_label=ref_label, recommended=chosen,
|
|
105
|
+
message=message, needed_prompts=needed, verdicts=[verdicts[x] for x in order],
|
|
106
|
+
) # fmt: skip
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def _message(chosen, ref_label, verdicts, unsure, needed, limit, min_n):
|
|
110
|
+
v = verdicts[chosen]
|
|
111
|
+
if chosen == ref_label:
|
|
112
|
+
base = (
|
|
113
|
+
f"Keep {ref_label}: no smaller version is proven safe at {_pct(limit)} of its quality."
|
|
114
|
+
)
|
|
115
|
+
if not unsure:
|
|
116
|
+
return "keep_reference", base
|
|
117
|
+
names = ", ".join(unsure)
|
|
118
|
+
if needed is not None and needed >= limits.MAX_PROMPTS:
|
|
119
|
+
more = " It is too close to call with any practical number of prompts: your decision."
|
|
120
|
+
else:
|
|
121
|
+
more = f" Use about {max(needed or 0, min_n)} prompts to settle it."
|
|
122
|
+
return "inconclusive", f"{base} {names} may be fine but cannot be proven yet.{more}"
|
|
123
|
+
saving = f", {_pct(v.size_saving)} smaller" if v.size_saving else ""
|
|
124
|
+
text = (
|
|
125
|
+
f"Use {chosen}: {_pct(v.relative)} of {ref_label} quality (95% sure it is at least "
|
|
126
|
+
f"{_pct(v.ci_low)}) over {v.n} prompts{saving}. "
|
|
127
|
+
f"{v.n_worse} {'answer' if v.n_worse == 1 else 'answers'} got worse."
|
|
128
|
+
)
|
|
129
|
+
if unsure:
|
|
130
|
+
text += f" Smaller {', '.join(unsure)} could not be proven safe with this many prompts."
|
|
131
|
+
return "recommended", text
|
|
File without changes
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""Single-file HTML report (F8). Opens offline: all CSS and JS are inline, no network."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
from jinja2 import Environment, PackageLoader
|
|
8
|
+
|
|
9
|
+
from quantcheck import __version__
|
|
10
|
+
from quantcheck.report import tokens
|
|
11
|
+
from quantcheck.report.terminal import num, pct
|
|
12
|
+
from quantcheck.report.view import ReportView, build_view
|
|
13
|
+
from quantcheck.store import RunResult
|
|
14
|
+
|
|
15
|
+
_env = Environment(
|
|
16
|
+
loader=PackageLoader("quantcheck.report", "templates"), autoescape=True, trim_blocks=True,
|
|
17
|
+
lstrip_blocks=True,
|
|
18
|
+
) # fmt: skip
|
|
19
|
+
_env.filters["pct"] = pct
|
|
20
|
+
_env.filters["num"] = num
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def render_html(view: ReportView) -> str:
|
|
24
|
+
"""The full report as one HTML string."""
|
|
25
|
+
return _env.get_template("report.html.j2").render(
|
|
26
|
+
v=view,
|
|
27
|
+
version=__version__,
|
|
28
|
+
light_css=tokens.css_vars(tokens.LIGHT),
|
|
29
|
+
dark_css=tokens.css_vars(tokens.DARK),
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def write_report(result: RunResult, path: str | Path) -> Path:
|
|
34
|
+
"""Write ``report.html`` for a run and return its path."""
|
|
35
|
+
p = Path(path)
|
|
36
|
+
p.parent.mkdir(parents=True, exist_ok=True)
|
|
37
|
+
p.write_text(render_html(build_view(result)), encoding="utf-8")
|
|
38
|
+
return p
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
<title>quantcheck report · {{ v.model }}</title>
|
|
7
|
+
<style>
|
|
8
|
+
:root {
|
|
9
|
+
{{ light_css }}
|
|
10
|
+
color-scheme: light;
|
|
11
|
+
}
|
|
12
|
+
@media (prefers-color-scheme: dark) {
|
|
13
|
+
:root:not([data-theme="light"]) {
|
|
14
|
+
{{ dark_css }}
|
|
15
|
+
color-scheme: dark;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
:root[data-theme="dark"] {
|
|
19
|
+
{{ dark_css }}
|
|
20
|
+
color-scheme: dark;
|
|
21
|
+
}
|
|
22
|
+
* { box-sizing: border-box; }
|
|
23
|
+
body {
|
|
24
|
+
margin: 0; background: var(--page); color: var(--body); line-height: 1.55;
|
|
25
|
+
font-family: Outfit, "Noto Sans", "Noto Sans Devanagari", "Noto Sans Tamil", "Noto Sans Telugu",
|
|
26
|
+
"Noto Sans Bengali", system-ui, -apple-system, "Segoe UI", sans-serif;
|
|
27
|
+
}
|
|
28
|
+
.mono, pre, code, td.num, .stat b {
|
|
29
|
+
font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
30
|
+
font-variant-numeric: tabular-nums;
|
|
31
|
+
}
|
|
32
|
+
.wrap { max-width: 1120px; margin: 0 auto; padding: 24px 16px 64px; }
|
|
33
|
+
h1, h2, h3 { color: var(--ink); font-weight: 600; letter-spacing: -0.02em; margin: 0; }
|
|
34
|
+
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; margin: 40px 0 12px; } h3 { font-size: 1rem; }
|
|
35
|
+
a { color: var(--link); }
|
|
36
|
+
header.top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
|
|
37
|
+
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 600;
|
|
38
|
+
font-size: 1.1rem; letter-spacing: -0.02em; }
|
|
39
|
+
.spacer { flex: 1; }
|
|
40
|
+
.theme { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; padding: 2px; }
|
|
41
|
+
.theme button { border: 0; background: none; color: var(--muted); font: inherit; font-size: .8rem;
|
|
42
|
+
padding: 4px 12px; border-radius: 999px; cursor: pointer; }
|
|
43
|
+
.theme button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }
|
|
44
|
+
.meta { color: var(--muted); font-size: .9rem; margin: 6px 0 0; }
|
|
45
|
+
.card { background: var(--card); border: 1px solid var(--border); border-radius: 20px;
|
|
46
|
+
padding: 20px 24px; }
|
|
47
|
+
.reco { margin-top: 24px; background: var(--tint); border-color: var(--primary); }
|
|
48
|
+
.reco.inconclusive { background: var(--warn-tint); border-color: var(--warn); }
|
|
49
|
+
.reco.no_data { background: var(--card); border-color: var(--border); }
|
|
50
|
+
.reco .kicker { font-size: .8rem; letter-spacing: .06em; text-transform: uppercase;
|
|
51
|
+
color: var(--primary); font-weight: 600; }
|
|
52
|
+
.reco.inconclusive .kicker { color: var(--warn); }
|
|
53
|
+
.reco p { margin: 8px 0 0; font-size: 1.15rem; color: var(--ink); }
|
|
54
|
+
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px;
|
|
55
|
+
margin-top: 16px; }
|
|
56
|
+
.stat { border: 1px solid var(--border); border-radius: 16px; padding: 12px 16px; background: var(--card); }
|
|
57
|
+
.stat span { display: block; color: var(--muted); font-size: .8rem; }
|
|
58
|
+
.stat b { color: var(--ink); font-size: 1.1rem; font-weight: 500; }
|
|
59
|
+
.scroll { overflow-x: auto; }
|
|
60
|
+
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
|
|
61
|
+
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
|
|
62
|
+
th { color: var(--muted); font-weight: 500; font-size: .8rem; }
|
|
63
|
+
td.num { text-align: right; } th.num { text-align: right; }
|
|
64
|
+
tr.refrow td { background: var(--tint); }
|
|
65
|
+
td small { color: var(--muted); display: block; font-size: .75rem; }
|
|
66
|
+
.badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 2px 10px;
|
|
67
|
+
font-size: .72rem; font-weight: 600; letter-spacing: .05em; border: 1px solid currentColor; }
|
|
68
|
+
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
|
|
69
|
+
.b-safe, .b-reference { color: var(--primary); }
|
|
70
|
+
.b-unsafe, .b-check_failed, .b-error { color: var(--fail); }
|
|
71
|
+
.b-uncertain, .b-worse, .b-skipped { color: var(--warn); }
|
|
72
|
+
details { border: 1px solid var(--border); border-radius: 16px; margin: 12px 0; background: var(--card); }
|
|
73
|
+
details > summary { cursor: pointer; padding: 14px 20px; color: var(--ink); font-weight: 600; list-style: none; }
|
|
74
|
+
details > summary::-webkit-details-marker { display: none; }
|
|
75
|
+
details > summary::before { content: "▸ "; color: var(--muted); }
|
|
76
|
+
details[open] > summary::before { content: "▾ "; }
|
|
77
|
+
.change { border-top: 1px solid var(--border); padding: 16px 20px; }
|
|
78
|
+
.change header { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
|
|
79
|
+
.why { color: var(--muted); font-size: .9rem; }
|
|
80
|
+
.prompt { margin: 8px 0; color: var(--ink); white-space: pre-wrap; }
|
|
81
|
+
.tag { border: 1px solid var(--border); border-radius: 999px; padding: 0 8px; font-size: .75rem;
|
|
82
|
+
color: var(--muted); }
|
|
83
|
+
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; }
|
|
84
|
+
.col { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
|
|
85
|
+
.col h4 { margin: 0; padding: 6px 12px; font-size: .78rem; font-weight: 600; color: var(--muted);
|
|
86
|
+
background: var(--tint); border-bottom: 1px solid var(--border); }
|
|
87
|
+
.col.bad h4 { color: var(--fail); background: var(--fail-tint); }
|
|
88
|
+
pre.ans { margin: 0; padding: 12px; white-space: pre-wrap; word-break: break-word; font-size: .85rem;
|
|
89
|
+
color: var(--ink); max-height: 360px; overflow: auto; }
|
|
90
|
+
.docs { margin-top: 8px; } .docs summary { padding: 6px 12px; font-weight: 500; font-size: .85rem; }
|
|
91
|
+
.docs li { font-size: .85rem; }
|
|
92
|
+
.note { color: var(--muted); font-size: .9rem; }
|
|
93
|
+
.warnbox { background: var(--warn-tint); border: 1px solid var(--warn); color: var(--ink);
|
|
94
|
+
border-radius: 16px; padding: 12px 16px; margin-top: 16px; }
|
|
95
|
+
footer { margin-top: 48px; color: var(--muted); font-size: .85rem; }
|
|
96
|
+
@media (max-width: 720px) { .pair { grid-template-columns: 1fr; } .card { padding: 16px; } }
|
|
97
|
+
</style>
|
|
98
|
+
</head>
|
|
99
|
+
<body>
|
|
100
|
+
<div class="wrap">
|
|
101
|
+
<header class="top">
|
|
102
|
+
<div class="brand">
|
|
103
|
+
<svg width="32" height="32" viewBox="0 0 40 40" role="img" aria-label="quantcheck logo">
|
|
104
|
+
<rect width="40" height="40" rx="10" fill="#047857"/>
|
|
105
|
+
<circle cx="19" cy="19" r="9" fill="none" stroke="#fff" stroke-width="3.2"/>
|
|
106
|
+
<path d="M21 22 L25.5 26.5 L34 16" fill="none" stroke="#6EE7B7" stroke-width="3.6"
|
|
107
|
+
stroke-linecap="round" stroke-linejoin="round"/>
|
|
108
|
+
</svg>
|
|
109
|
+
quantcheck
|
|
110
|
+
</div>
|
|
111
|
+
<div class="spacer"></div>
|
|
112
|
+
<div class="theme" role="group" aria-label="Theme">
|
|
113
|
+
<button type="button" data-set="system">System</button>
|
|
114
|
+
<button type="button" data-set="light">Light</button>
|
|
115
|
+
<button type="button" data-set="dark">Dark</button>
|
|
116
|
+
</div>
|
|
117
|
+
</header>
|
|
118
|
+
|
|
119
|
+
<h1 style="margin-top:24px">{{ v.model }}</h1>
|
|
120
|
+
<p class="meta mono">run {{ v.run_id }} · {{ v.created_at }} · {{ v.runtime }} · {{ v.hardware }}</p>
|
|
121
|
+
|
|
122
|
+
{% if v.recommendation %}
|
|
123
|
+
<section class="card reco {{ v.recommendation.status }}">
|
|
124
|
+
<div class="kicker">
|
|
125
|
+
{% if v.recommendation.status == "recommended" %}Recommendation
|
|
126
|
+
{% elif v.recommendation.status == "keep_reference" %}Recommendation: keep the reference
|
|
127
|
+
{% elif v.recommendation.status == "inconclusive" %}Not proven yet
|
|
128
|
+
{% else %}No recommendation{% endif %}
|
|
129
|
+
</div>
|
|
130
|
+
<p>{{ v.recommendation.message }}</p>
|
|
131
|
+
</section>
|
|
132
|
+
{% elif not v.scored %}
|
|
133
|
+
<div class="warnbox"><b>Not scored.</b> The judge did not run, so there is no quality score or
|
|
134
|
+
recommendation. Speed, memory and size are measured.</div>
|
|
135
|
+
{% endif %}
|
|
136
|
+
|
|
137
|
+
<div class="stats">
|
|
138
|
+
<div class="stat"><span>Prompts</span><b>{{ v.n_prompts }}</b></div>
|
|
139
|
+
<div class="stat"><span>Versions tested</span><b>{{ v.rows | selectattr("status", "equalto", "ok") | list | length }}</b></div>
|
|
140
|
+
<div class="stat"><span>Reference</span><b>{{ v.reference_label or "-" }}</b></div>
|
|
141
|
+
<div class="stat"><span>Quality limit</span><b>{{ v.quality_limit | pct }}</b></div>
|
|
142
|
+
</div>
|
|
143
|
+
|
|
144
|
+
<h2>Versions</h2>
|
|
145
|
+
<div class="card scroll" style="padding:8px 12px">
|
|
146
|
+
<table>
|
|
147
|
+
<thead><tr>
|
|
148
|
+
<th>Version</th><th>Verdict</th><th class="num">Quality</th><th class="num">vs reference</th>
|
|
149
|
+
<th class="num">Tokens/s</th><th class="num">First token (s)</th><th class="num">Peak memory (MB)</th>
|
|
150
|
+
<th class="num">Size (MB)</th><th class="num">Answers worse</th>
|
|
151
|
+
</tr></thead>
|
|
152
|
+
<tbody>
|
|
153
|
+
{% for r in v.rows %}
|
|
154
|
+
{% if r.status != "ok" %}
|
|
155
|
+
<tr><td class="mono">{{ r.label }}</td><td><span class="badge b-skipped">SKIPPED</span></td>
|
|
156
|
+
<td colspan="7" class="note" style="white-space:normal">{{ r.reason }}</td></tr>
|
|
157
|
+
{% else %}
|
|
158
|
+
<tr class="{{ 'refrow' if r.is_reference }}">
|
|
159
|
+
<td class="mono">{{ r.label }}</td>
|
|
160
|
+
<td><span class="badge b-{{ r.verdict }}">{{ r.verdict | upper if r.verdict != "-" else "NOT SCORED" }}</span></td>
|
|
161
|
+
<td class="num">{{ r.quality | pct }}</td>
|
|
162
|
+
<td class="num">{{ r.relative | pct }}{% if r.ci_low is not none and not r.is_reference %}
|
|
163
|
+
<small>95% sure ≥ {{ r.ci_low | pct }}</small>{% endif %}</td>
|
|
164
|
+
<td class="num">{{ r.bench.tokens_per_s | num }}</td>
|
|
165
|
+
<td class="num">{{ r.bench.ttft_s | num }}</td>
|
|
166
|
+
<td class="num">{{ r.bench.peak_memory_mb | num }}</td>
|
|
167
|
+
<td class="num">{{ r.bench.file_size_mb | num }}{% if r.size_saving %}<small>{{ r.size_saving | pct }} smaller</small>{% endif %}</td>
|
|
168
|
+
<td class="num">{{ "-" if r.is_reference else r.n_worse }}</td>
|
|
169
|
+
</tr>
|
|
170
|
+
{% endif %}
|
|
171
|
+
{% endfor %}
|
|
172
|
+
</tbody>
|
|
173
|
+
</table>
|
|
174
|
+
</div>
|
|
175
|
+
|
|
176
|
+
{% if v.tags and v.tag_quality %}
|
|
177
|
+
<h2>Quality by tag</h2>
|
|
178
|
+
<div class="card scroll" style="padding:8px 12px">
|
|
179
|
+
<table>
|
|
180
|
+
<thead><tr><th>Version</th>{% for t in v.tags %}<th class="num">{{ t }}</th>{% endfor %}</tr></thead>
|
|
181
|
+
<tbody>
|
|
182
|
+
{% for r in v.rows if r.status == "ok" and r.label in v.tag_quality %}
|
|
183
|
+
<tr><td class="mono">{{ r.label }}</td>
|
|
184
|
+
{% for t in v.tags %}<td class="num">{{ v.tag_quality[r.label].get(t) | pct }}</td>{% endfor %}</tr>
|
|
185
|
+
{% endfor %}
|
|
186
|
+
</tbody>
|
|
187
|
+
</table>
|
|
188
|
+
</div>
|
|
189
|
+
<p class="note">Each cell is the mean over the prompts with that tag. Small groups are noisy: check how many prompts a tag has before trusting a gap.</p>
|
|
190
|
+
{% endif %}
|
|
191
|
+
|
|
192
|
+
{% macro change(c, label) %}
|
|
193
|
+
<article class="change">
|
|
194
|
+
<header>
|
|
195
|
+
<span class="badge b-{{ c.kind }}">{{ {"check_failed": "CHECK FAILED", "error": "ERROR", "worse": "WORSE"}[c.kind] }}</span>
|
|
196
|
+
<b class="mono">{{ c.case_id }}</b>
|
|
197
|
+
{% for t in c.tags %}<span class="tag">{{ t }}</span>{% endfor %}
|
|
198
|
+
<span class="why">{{ c.why }}</span>
|
|
199
|
+
</header>
|
|
200
|
+
<div class="prompt">{{ c.prompt }}</div>
|
|
201
|
+
{% if c.documents %}
|
|
202
|
+
<details class="docs"><summary>Documents sent with this prompt ({{ c.documents | length }})</summary>
|
|
203
|
+
<ol>{% for d in c.documents %}<li>{{ d }}</li>{% endfor %}</ol></details>
|
|
204
|
+
{% endif %}
|
|
205
|
+
<div class="pair">
|
|
206
|
+
<div class="col"><h4>{{ c.reference_name }}</h4><pre class="ans">{{ c.reference_text or "(empty)" }}</pre></div>
|
|
207
|
+
<div class="col bad"><h4>{{ label }}</h4><pre class="ans">{{ c.answer_text or "(empty)" }}</pre></div>
|
|
208
|
+
</div>
|
|
209
|
+
{% if c.judge_reason %}<p class="why">Judge: {{ c.judge_reason }}</p>{% endif %}
|
|
210
|
+
</article>
|
|
211
|
+
{% endmacro %}
|
|
212
|
+
|
|
213
|
+
<h2>What broke</h2>
|
|
214
|
+
{% if not v.scored %}
|
|
215
|
+
<p class="note">Answers are not compared because the run was not scored.</p>
|
|
216
|
+
{% else %}
|
|
217
|
+
{% set shown = namespace(any=false) %}
|
|
218
|
+
{% for r in v.rows if r.status == "ok" and not r.is_reference %}
|
|
219
|
+
{% set items = v.changes.get(r.label, []) %}
|
|
220
|
+
{% if items %}{% set shown.any = true %}
|
|
221
|
+
<details {{ "open" if loop.first }}>
|
|
222
|
+
<summary>{{ r.label }} · {{ v.changes_total[r.label] }} answer{{ "" if v.changes_total[r.label] == 1 else "s" }} failed or got worse</summary>
|
|
223
|
+
{% for c in items %}{{ change(c, r.label) }}{% endfor %}
|
|
224
|
+
{% if v.changes_total[r.label] > items | length %}
|
|
225
|
+
<p class="note" style="padding:0 20px 16px">Showing the first {{ items | length }} of {{ v.changes_total[r.label] }}. All answers are in results.json.</p>
|
|
226
|
+
{% endif %}
|
|
227
|
+
</details>
|
|
228
|
+
{% endif %}
|
|
229
|
+
{% endfor %}
|
|
230
|
+
{% if not shown.any %}<p class="note">No answer failed or got clearly worse than the reference.</p>{% endif %}
|
|
231
|
+
{% if v.reference_failures %}
|
|
232
|
+
<h2>Failed on the reference too</h2>
|
|
233
|
+
<p class="note">These answers fail even on {{ v.reference_label }}, so they say more about the test or the model than about quantization.</p>
|
|
234
|
+
<details><summary>{{ v.reference_label }} · {{ v.reference_failures | length }} failed</summary>
|
|
235
|
+
{% for c in v.reference_failures %}{{ change(c, v.reference_label) }}{% endfor %}
|
|
236
|
+
</details>
|
|
237
|
+
{% endif %}
|
|
238
|
+
{% for label, n in v.unscored.items() if n %}
|
|
239
|
+
<p class="note">{{ label }}: {{ n }} answer{{ "" if n == 1 else "s" }} could not be scored (the judge failed or there was no reference) and are left out of its quality.</p>
|
|
240
|
+
{% endfor %}
|
|
241
|
+
{% endif %}
|
|
242
|
+
|
|
243
|
+
<h2>How this was scored</h2>
|
|
244
|
+
<div class="card note" style="color:var(--body)">
|
|
245
|
+
<p style="margin-top:0">Every prompt went through every version with the same settings (temperature 0, fixed seed, same answer length), using the model's own chat template.
|
|
246
|
+
An answer scores 0 if any check fails; otherwise the judge's 0–10 score ÷ 10, compared with the test's expected answer when it has one, otherwise with the reference version's answer.</p>
|
|
247
|
+
<p>The reference is {{ v.reference_label or "not available" }}, the largest version that ran. A version is called <b>safe</b> only when it is at least {{ v.quality_limit | pct }} of the reference's quality even in the pessimistic end of a 95% interval, over at least 20 prompts. Otherwise it is <b>uncertain</b> or <b>unsafe</b>.</p>
|
|
248
|
+
<p style="margin-bottom:0">Judge: {{ v.judge or "none" }}{% if v.judge_model %} ({{ v.judge_model }}){% endif %}. A model judge is itself imperfect; read the answers above, not only the scores.</p>
|
|
249
|
+
</div>
|
|
250
|
+
|
|
251
|
+
<footer>Generated by quantcheck {{ version }} · this file works offline and nothing in it was sent anywhere.</footer>
|
|
252
|
+
</div>
|
|
253
|
+
<script>
|
|
254
|
+
(function () {
|
|
255
|
+
var root = document.documentElement, KEY = "qc-theme";
|
|
256
|
+
function get() { try { return localStorage.getItem(KEY) || "system"; } catch (e) { return "system"; } }
|
|
257
|
+
function set(v) { try { localStorage.setItem(KEY, v); } catch (e) {} apply(v); }
|
|
258
|
+
function apply(v) {
|
|
259
|
+
if (v === "light" || v === "dark") root.setAttribute("data-theme", v);
|
|
260
|
+
else root.removeAttribute("data-theme");
|
|
261
|
+
document.querySelectorAll(".theme button").forEach(function (b) {
|
|
262
|
+
b.setAttribute("aria-pressed", String(b.dataset.set === v));
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
document.querySelectorAll(".theme button").forEach(function (b) {
|
|
266
|
+
b.addEventListener("click", function () { set(b.dataset.set); });
|
|
267
|
+
});
|
|
268
|
+
apply(get());
|
|
269
|
+
})();
|
|
270
|
+
</script>
|
|
271
|
+
</body>
|
|
272
|
+
</html>
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"""Terminal summary (F8): recommendation, version table, tag table, where the full report is."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
from rich import box
|
|
8
|
+
from rich.console import Console
|
|
9
|
+
from rich.panel import Panel
|
|
10
|
+
from rich.table import Table
|
|
11
|
+
|
|
12
|
+
from quantcheck.report.view import ReportView
|
|
13
|
+
|
|
14
|
+
_VERDICT = {
|
|
15
|
+
"reference": "[cyan]REFERENCE[/cyan]",
|
|
16
|
+
"safe": "[green]SAFE[/green]",
|
|
17
|
+
"unsafe": "[red]UNSAFE[/red]",
|
|
18
|
+
"uncertain": "[yellow]UNCERTAIN[/yellow]",
|
|
19
|
+
"-": "-",
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def pct(value: float | None) -> str:
|
|
24
|
+
"""0.9731 -> '97.3%'; None -> '-'."""
|
|
25
|
+
return "-" if value is None else f"{value:.1%}".replace(".0%", "%")
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def num(value: float | None) -> str:
|
|
29
|
+
"""A measurement, or '-' when not measured."""
|
|
30
|
+
if value is None:
|
|
31
|
+
return "-"
|
|
32
|
+
return (
|
|
33
|
+
f"{value:.0f}"
|
|
34
|
+
if abs(value) >= 100
|
|
35
|
+
else f"{value:.1f}"
|
|
36
|
+
if abs(value) >= 10
|
|
37
|
+
else f"{value:.2f}"
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def render(view: ReportView, console: Console, report_path: Path | None = None) -> None:
|
|
42
|
+
"""Print the summary for a run."""
|
|
43
|
+
console.print(
|
|
44
|
+
f"[bold]{view.model}[/bold] on {view.runtime} · {view.n_prompts} prompts · {view.hardware}"
|
|
45
|
+
)
|
|
46
|
+
rec = view.recommendation
|
|
47
|
+
if rec:
|
|
48
|
+
style = {"recommended": "green", "keep_reference": "cyan", "inconclusive": "yellow"}.get(
|
|
49
|
+
rec.status, "white"
|
|
50
|
+
)
|
|
51
|
+
console.print(Panel(rec.message, title=rec.status.replace("_", " "), border_style=style))
|
|
52
|
+
elif not view.scored:
|
|
53
|
+
console.print("[yellow]Not scored: the judge did not run. Speed and memory only.[/yellow]")
|
|
54
|
+
|
|
55
|
+
table = Table(
|
|
56
|
+
title=f"Run {view.run_id}", box=box.SIMPLE_HEAD, pad_edge=False, collapse_padding=True
|
|
57
|
+
)
|
|
58
|
+
for col in ("version", "quality", "vs ref", "verdict", "tok/s", "ttft s",
|
|
59
|
+
"mem MB", "size MB", "worse"): # fmt: skip
|
|
60
|
+
table.add_column(
|
|
61
|
+
col, no_wrap=True, justify="left" if col in ("version", "verdict") else "right"
|
|
62
|
+
)
|
|
63
|
+
for r in view.rows:
|
|
64
|
+
if r.status != "ok":
|
|
65
|
+
table.add_row(r.label, f"[yellow]skipped: {r.reason}[/yellow]")
|
|
66
|
+
continue
|
|
67
|
+
b = r.bench
|
|
68
|
+
table.add_row(
|
|
69
|
+
r.label, pct(r.quality), pct(r.relative), _VERDICT.get(r.verdict, r.verdict),
|
|
70
|
+
num(b.tokens_per_s), num(b.ttft_s), num(b.peak_memory_mb), num(b.file_size_mb),
|
|
71
|
+
"-" if r.is_reference else str(r.n_worse),
|
|
72
|
+
) # fmt: skip
|
|
73
|
+
console.print(table)
|
|
74
|
+
|
|
75
|
+
if view.tags and view.tag_quality:
|
|
76
|
+
# One row per tag, one column per version: stays readable on an 80-column terminal.
|
|
77
|
+
tag_table = Table(title="Quality by tag")
|
|
78
|
+
tag_table.add_column("tag")
|
|
79
|
+
ok_rows = [r for r in view.rows if r.status == "ok" and r.label in view.tag_quality]
|
|
80
|
+
for r in ok_rows:
|
|
81
|
+
tag_table.add_column(r.label, justify="right")
|
|
82
|
+
for t in view.tags:
|
|
83
|
+
tag_table.add_row(t, *(pct(view.tag_quality[r.label].get(t)) for r in ok_rows))
|
|
84
|
+
console.print(tag_table)
|
|
85
|
+
|
|
86
|
+
shown = sum(view.changes_total.values())
|
|
87
|
+
if shown:
|
|
88
|
+
console.print(f"{shown} answers failed or got worse than the reference. See the report.")
|
|
89
|
+
if report_path:
|
|
90
|
+
console.print(f"Report: {report_path}")
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"""Design tokens for reports: the one place colors live (light and dark).
|
|
2
|
+
|
|
3
|
+
Values come from the QuantCheck design system (see CLAUDE.md section 8a). Templates and CSS
|
|
4
|
+
use the variable names, never hex codes. ``fail-tint`` and ``warn-tint`` are derived, soft
|
|
5
|
+
backgrounds for status blocks. Status colors are always paired with a text label.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
LIGHT = {
|
|
9
|
+
"page": "#FFFFFF", "card": "#FFFFFF", "border": "#E5E7EB",
|
|
10
|
+
"ink": "#0B1220", "body": "#374151", "muted": "#6B7280",
|
|
11
|
+
"primary": "#047857", "primary-hover": "#065F46", "on-primary": "#FFFFFF", "link": "#047857",
|
|
12
|
+
"tint": "#ECFDF5", "bright": "#10B981", "mint": "#6EE7B7", "deep": "#0B3D2E",
|
|
13
|
+
"warn": "#B45309", "fail": "#B91C1C", "warn-tint": "#FFFBEB", "fail-tint": "#FEF2F2",
|
|
14
|
+
# lab surfaces (from the design canvas): off-white page, hairlines, hover and tile fills
|
|
15
|
+
"surface": "#F7F8FA", "hair": "#F3F4F6", "track": "#EEF0F2", "border-strong": "#D1D5DB",
|
|
16
|
+
"hover": "#F3F4F6", "tint-border": "#D1FAE5", "dots": "#D5DAE1", "primary-deep": "#065F46",
|
|
17
|
+
} # fmt: skip
|
|
18
|
+
|
|
19
|
+
DARK = {
|
|
20
|
+
# neutral cool grey (no green cast): green is only used for accents, never for backgrounds
|
|
21
|
+
"page": "#0E1116", "card": "#151A21", "border": "#262C35",
|
|
22
|
+
"ink": "#F3F5F7", "body": "#C9D0D8", "muted": "#8C97A3",
|
|
23
|
+
"primary": "#10B981", "primary-hover": "#34D399", "on-primary": "#052E22", "link": "#34D399",
|
|
24
|
+
"tint": "#0F2A21", "bright": "#10B981", "mint": "#6EE7B7", "deep": "#0B3D2E",
|
|
25
|
+
"warn": "#FBBF24", "fail": "#F87171", "warn-tint": "#2A2210", "fail-tint": "#2A1514",
|
|
26
|
+
"surface": "#0E1116", "hair": "#1C222A", "track": "#232A33", "border-strong": "#333B46",
|
|
27
|
+
"hover": "#1B212A", "tint-border": "#1B3A2E", "dots": "#262C35", "primary-deep": "#6EE7B7",
|
|
28
|
+
} # fmt: skip
|
|
29
|
+
|
|
30
|
+
# Text-on-background pairs that must reach 4.5:1 in both themes (checked in tests).
|
|
31
|
+
CONTRAST_PAIRS = [
|
|
32
|
+
("ink", "page"), ("body", "page"), ("muted", "page"), ("muted", "card"), ("link", "page"),
|
|
33
|
+
("primary", "page"), ("primary", "tint"), ("body", "tint"), ("muted", "tint"),
|
|
34
|
+
("warn", "warn-tint"), ("fail", "fail-tint"), ("fail", "page"), ("warn", "page"),
|
|
35
|
+
("on-primary", "primary"),
|
|
36
|
+
] # fmt: skip
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def css_vars(tokens: dict[str, str], indent: str = " ") -> str:
|
|
40
|
+
"""``--page: #FFF;`` lines for one theme."""
|
|
41
|
+
return "\n".join(f"{indent}--{k}: {v};" for k, v in tokens.items())
|