dsh-eval 0.4.0 → 0.5.1
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.
- package/README.md +214 -13
- package/README.zh.md +99 -10
- package/lib/agreement.js +46 -0
- package/lib/argv.js +66 -0
- package/lib/atomic-write.js +38 -0
- package/lib/benchmark.js +116 -19
- package/lib/calibration.js +90 -0
- package/lib/command.js +202 -10
- package/lib/compare.js +310 -31
- package/lib/dashboard.js +260 -0
- package/lib/digest.js +118 -0
- package/lib/export.js +50 -0
- package/lib/gate.js +293 -0
- package/lib/import.js +17 -6
- package/lib/index.js +174 -12
- package/lib/judge.js +30 -7
- package/lib/leaderboard.js +222 -0
- package/lib/precision.js +50 -0
- package/lib/rejudge.js +107 -0
- package/lib/reliability.js +107 -0
- package/lib/report.js +285 -11
- package/lib/runner.js +189 -33
- package/lib/safe-regex.js +74 -0
- package/lib/segments.js +15 -0
- package/lib/stats.js +63 -0
- package/lib/trace.js +19 -2
- package/lib/types/agreement.d.ts +33 -0
- package/lib/types/argv.d.ts +19 -0
- package/lib/types/atomic-write.d.ts +15 -0
- package/lib/types/benchmark.d.ts +9 -2
- package/lib/types/calibration.d.ts +45 -0
- package/lib/types/command.d.ts +58 -0
- package/lib/types/compare.d.ts +82 -2
- package/lib/types/dashboard.d.ts +24 -0
- package/lib/types/digest.d.ts +38 -0
- package/lib/types/export.d.ts +17 -0
- package/lib/types/gate.d.ts +87 -0
- package/lib/types/index.d.ts +8 -4
- package/lib/types/judge.d.ts +4 -1
- package/lib/types/leaderboard.d.ts +70 -0
- package/lib/types/precision.d.ts +44 -0
- package/lib/types/rejudge.d.ts +22 -0
- package/lib/types/reliability.d.ts +85 -0
- package/lib/types/report.d.ts +18 -5
- package/lib/types/runner.d.ts +8 -1
- package/lib/types/safe-regex.d.ts +24 -0
- package/lib/types/segments.d.ts +12 -0
- package/lib/types/stats.d.ts +56 -0
- package/lib/types/trace.d.ts +7 -0
- package/lib/types/types.d.ts +55 -6
- package/lib/types/validate.d.ts +57 -0
- package/lib/validate.js +155 -0
- package/package.json +2 -2
- package/src/agreement.ts +60 -0
- package/src/argv.ts +63 -0
- package/src/atomic-write.ts +38 -0
- package/src/benchmark.ts +139 -13
- package/src/calibration.ts +113 -0
- package/src/command.ts +297 -10
- package/src/compare.ts +392 -37
- package/src/dashboard.ts +287 -0
- package/src/digest.ts +144 -0
- package/src/export.ts +57 -0
- package/src/gate.ts +383 -0
- package/src/import.ts +18 -6
- package/src/index.ts +192 -12
- package/src/judge.ts +30 -6
- package/src/leaderboard.ts +272 -0
- package/src/precision.ts +85 -0
- package/src/rejudge.ts +112 -0
- package/src/reliability.ts +166 -0
- package/src/report.ts +303 -11
- package/src/runner.ts +182 -35
- package/src/safe-regex.ts +79 -0
- package/src/segments.ts +16 -0
- package/src/stats.ts +104 -0
- package/src/trace.ts +19 -2
- package/src/types.ts +56 -6
- package/src/validate.ts +177 -0
package/lib/types/benchmark.d.ts
CHANGED
|
@@ -12,10 +12,17 @@ import type { Benchmark } from './types.ts';
|
|
|
12
12
|
* @param baseDir - absolute directory used to resolve prompt and workspace paths.
|
|
13
13
|
* @returns the validated benchmark.
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
/** Trusted caller options; the benchmark document itself cannot set these. */
|
|
16
|
+
export interface BenchmarkLoadOptions {
|
|
17
|
+
/** Permit referenced paths outside the benchmark directory. */
|
|
18
|
+
allowExternalPaths?: boolean;
|
|
19
|
+
/** Output artifacts to omit from the provenance digest. */
|
|
20
|
+
excludeFromDigest?: readonly string[];
|
|
21
|
+
}
|
|
22
|
+
export declare function parseBenchmark(text: string, baseDir: string, options?: BenchmarkLoadOptions): Promise<Benchmark>;
|
|
16
23
|
/**
|
|
17
24
|
* Load and validate a benchmark document from disk.
|
|
18
25
|
* @param path - path to the benchmark YAML file.
|
|
19
26
|
* @returns the validated benchmark.
|
|
20
27
|
*/
|
|
21
|
-
export declare function loadBenchmark(path: string): Promise<Benchmark>;
|
|
28
|
+
export declare function loadBenchmark(path: string, options?: BenchmarkLoadOptions): Promise<Benchmark>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Judge calibration diagnostics for dsh-eval.
|
|
3
|
+
*
|
|
4
|
+
* Agreement and kappa say whether the judge and the scripted check reach the
|
|
5
|
+
* same verdict, but a judge can be perfectly calibrated on an all-pass run and
|
|
6
|
+
* still useless for ranking. This module also measures how well the judge's
|
|
7
|
+
* numeric score separates scripted passes from failures, and surfaces the
|
|
8
|
+
* concrete cases where the two views disagree so a rubric can be improved.
|
|
9
|
+
* A normalized score >= 0.5 counts as a judge pass; the hallucination flag is
|
|
10
|
+
* only a fallback for trials whose score is missing, so the disagreement list
|
|
11
|
+
* can explain the score-based separation and ranking figures.
|
|
12
|
+
*
|
|
13
|
+
* @module dsh-eval/calibration
|
|
14
|
+
*/
|
|
15
|
+
import type { EvalRun } from './types.ts';
|
|
16
|
+
/** A case x trial where the judge and the scripted check disagree. */
|
|
17
|
+
export interface CalibrationDisagreement {
|
|
18
|
+
caseId: string;
|
|
19
|
+
trial: number;
|
|
20
|
+
scriptPassed: boolean;
|
|
21
|
+
score: number | null;
|
|
22
|
+
hallucination: boolean | null;
|
|
23
|
+
}
|
|
24
|
+
/** Calibration statistics over trials carrying both signals. */
|
|
25
|
+
export interface CalibrationSummary {
|
|
26
|
+
pairs: number;
|
|
27
|
+
/** Mean normalized judge score on scripted passes, or null when none. */
|
|
28
|
+
passedMean: number | null;
|
|
29
|
+
/** Mean normalized judge score on scripted failures, or null when none. */
|
|
30
|
+
failedMean: number | null;
|
|
31
|
+
/** passedMean - failedMean; positive means the judge ranks passes higher. */
|
|
32
|
+
separation: number | null;
|
|
33
|
+
/** P(random pass scores above random fail), ties count as half. Null when one side is empty. */
|
|
34
|
+
rankingAccuracy: number | null;
|
|
35
|
+
/** Mean squared error of normalized score against the scripted verdict; lower is better. */
|
|
36
|
+
brier: number | null;
|
|
37
|
+
/** Up to five disagreements, ordered by case id and trial. */
|
|
38
|
+
disagreements: readonly CalibrationDisagreement[];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Compute judge calibration for a run.
|
|
42
|
+
* @param run - a persisted run record.
|
|
43
|
+
* @returns the summary, or null when no trial has both a scripted result and a usable judge verdict.
|
|
44
|
+
*/
|
|
45
|
+
export declare function computeCalibration(run: EvalRun): CalibrationSummary | null;
|
package/lib/types/command.d.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import { Command } from 'commander';
|
|
10
10
|
import type { Context } from '@deepseek-ai/cordis';
|
|
11
11
|
import type { ImportFormat } from './import.ts';
|
|
12
|
+
import type { BenchmarkJudge } from './types.ts';
|
|
12
13
|
/** What the eval app resolved from its command line. */
|
|
13
14
|
export type EvalStartupValues = {
|
|
14
15
|
kind: 'run';
|
|
@@ -16,15 +17,72 @@ export type EvalStartupValues = {
|
|
|
16
17
|
outPath: string;
|
|
17
18
|
trials?: number;
|
|
18
19
|
concurrency?: number;
|
|
20
|
+
seed?: number;
|
|
19
21
|
dshCommand?: readonly string[];
|
|
20
22
|
profile?: string;
|
|
23
|
+
quiet?: boolean;
|
|
24
|
+
allowExternalPaths?: boolean;
|
|
21
25
|
} | {
|
|
22
26
|
kind: 'report';
|
|
23
27
|
runPath: string;
|
|
28
|
+
/** Print a compact terminal summary instead of the full markdown report. */
|
|
29
|
+
brief?: boolean;
|
|
30
|
+
/** Emit machine-readable JSON instead of markdown. */
|
|
31
|
+
json?: boolean;
|
|
32
|
+
/** Optional output path; the report goes to stdout when omitted. */
|
|
33
|
+
outPath?: string;
|
|
24
34
|
} | {
|
|
25
35
|
kind: 'compare';
|
|
26
36
|
runPathA: string;
|
|
27
37
|
runPathB: string;
|
|
38
|
+
json?: boolean;
|
|
39
|
+
outPath?: string;
|
|
40
|
+
} | {
|
|
41
|
+
kind: 'export';
|
|
42
|
+
runPath: string;
|
|
43
|
+
/** Optional output path; CSV goes to stdout when omitted. */
|
|
44
|
+
outPath?: string;
|
|
45
|
+
} | {
|
|
46
|
+
kind: 'validate';
|
|
47
|
+
benchmarkPath: string;
|
|
48
|
+
json?: boolean;
|
|
49
|
+
outPath?: string;
|
|
50
|
+
allowExternalPaths?: boolean;
|
|
51
|
+
} | {
|
|
52
|
+
kind: 'provenance';
|
|
53
|
+
runPath: string;
|
|
54
|
+
benchmarkPath: string;
|
|
55
|
+
json?: boolean;
|
|
56
|
+
outPath?: string;
|
|
57
|
+
allowExternalPaths?: boolean;
|
|
58
|
+
} | {
|
|
59
|
+
kind: 'leaderboard';
|
|
60
|
+
runPaths: readonly string[];
|
|
61
|
+
json?: boolean;
|
|
62
|
+
outPath?: string;
|
|
63
|
+
metric?: 'taskSuccess' | 'strictPassAt1';
|
|
64
|
+
} | {
|
|
65
|
+
kind: 'gate';
|
|
66
|
+
candidatePath: string;
|
|
67
|
+
baselinePath: string;
|
|
68
|
+
maxDrop: number;
|
|
69
|
+
maxCostIncrease?: number;
|
|
70
|
+
maxLatencyIncrease?: number;
|
|
71
|
+
allowIncomplete: boolean;
|
|
72
|
+
requireSignificance?: boolean;
|
|
73
|
+
json?: boolean;
|
|
74
|
+
outPath?: string;
|
|
75
|
+
} | {
|
|
76
|
+
kind: 'dashboard';
|
|
77
|
+
runPaths: readonly string[];
|
|
78
|
+
outPath: string;
|
|
79
|
+
metric?: 'taskSuccess' | 'strictPassAt1';
|
|
80
|
+
} | {
|
|
81
|
+
kind: 'rejudge';
|
|
82
|
+
runPath: string;
|
|
83
|
+
outPath: string;
|
|
84
|
+
/** Optional judge configuration overriding the one stored in the run. */
|
|
85
|
+
judge?: BenchmarkJudge;
|
|
28
86
|
} | {
|
|
29
87
|
kind: 'import';
|
|
30
88
|
format: ImportFormat;
|
package/lib/types/compare.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @module dsh-eval/compare
|
|
6
6
|
*/
|
|
7
7
|
import type { EvalRun } from './types.ts';
|
|
8
|
-
import { type PairedDelta, type SignTestOutcome } from './stats.ts';
|
|
8
|
+
import { type FamilyWiseCorrection, type PairedDelta, type SignTestOutcome, type SignTestPower } from './stats.ts';
|
|
9
9
|
/** One compared metric row. */
|
|
10
10
|
export interface CompareRow {
|
|
11
11
|
/** Metric label. */
|
|
@@ -16,6 +16,8 @@ export interface CompareRow {
|
|
|
16
16
|
b: string;
|
|
17
17
|
/** Signed delta (`b - a`) for numeric rows, or a dash for text rows. */
|
|
18
18
|
delta: string;
|
|
19
|
+
/** Inference about a paired comparison, rendered in a separate table. */
|
|
20
|
+
inference?: string;
|
|
19
21
|
}
|
|
20
22
|
/** Paired same-case statistics over two runs. */
|
|
21
23
|
export interface PairedStats {
|
|
@@ -29,8 +31,12 @@ export interface PairedStats {
|
|
|
29
31
|
ties: number;
|
|
30
32
|
/** The metric used for win/lose/tie classification. */
|
|
31
33
|
primaryMetric: 'task success' | 'tool selection accuracy' | 'final answer score';
|
|
32
|
-
/** Exact two-sided sign test over the discordant pairs of the primary metric. */
|
|
34
|
+
/** Exact two-sided sign test over the discordant pairs of the primary metric (raw p-value). */
|
|
33
35
|
test: SignTestOutcome;
|
|
36
|
+
/** Bonferroni correction shared by the printed p-value and delta intervals. */
|
|
37
|
+
correction: FamilyWiseCorrection;
|
|
38
|
+
/** Whether the discordant sample can reach the corrected alpha at all. */
|
|
39
|
+
power: SignTestPower;
|
|
34
40
|
/** Paired step delta (`b - a`) with its bootstrap interval, or null when no pair is numeric. */
|
|
35
41
|
stepsDelta: PairedDelta | null;
|
|
36
42
|
/** Paired token delta (`b - a`) with its bootstrap interval, or null when no pair is numeric. */
|
|
@@ -38,6 +44,26 @@ export interface PairedStats {
|
|
|
38
44
|
/** Paired judge-score delta (`b - a`) with its bootstrap interval, or null without verdicts. */
|
|
39
45
|
scoreDelta: PairedDelta | null;
|
|
40
46
|
}
|
|
47
|
+
/** Render an exact p-value, collapsing anything below the print precision. */
|
|
48
|
+
export declare function formatPValue(pValue: number): string;
|
|
49
|
+
/** A metric that can classify a paired winner. */
|
|
50
|
+
export type PairedMetric = 'task success' | 'tool selection accuracy' | 'final answer score';
|
|
51
|
+
/** Win/loss/tie counts for one metric over completed, paired trials. */
|
|
52
|
+
export interface PairedSignCounts {
|
|
53
|
+
/** Pairs with both outcomes present for the metric. */
|
|
54
|
+
pairs: number;
|
|
55
|
+
wins: number;
|
|
56
|
+
losses: number;
|
|
57
|
+
ties: number;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Count paired wins/losses/ties for one metric, ignoring pairs missing it.
|
|
61
|
+
* @param a - the baseline run.
|
|
62
|
+
* @param b - the candidate run.
|
|
63
|
+
* @param metric - the metric to classify.
|
|
64
|
+
* @returns paired sign counts for that metric alone.
|
|
65
|
+
*/
|
|
66
|
+
export declare function pairedSigns(a: EvalRun, b: EvalRun, metric: PairedMetric): PairedSignCounts;
|
|
41
67
|
/**
|
|
42
68
|
* Pair both runs' trials by case id and trial index and compute win/lose/tie
|
|
43
69
|
* plus mean deltas. Trials are paired as-is; the runs' `seed` is recorded
|
|
@@ -47,6 +73,53 @@ export interface PairedStats {
|
|
|
47
73
|
* @returns paired statistics, or null when no trial is completed in both runs.
|
|
48
74
|
*/
|
|
49
75
|
export declare function pairedCompare(a: EvalRun, b: EvalRun): PairedStats | null;
|
|
76
|
+
/** One paired case x trial classified on the same primary metric as the sign test. */
|
|
77
|
+
export interface PairedCase {
|
|
78
|
+
caseId: string;
|
|
79
|
+
trial: number;
|
|
80
|
+
a: boolean | number | null;
|
|
81
|
+
b: boolean | number | null;
|
|
82
|
+
outcome: 'B better' | 'A better' | 'tie';
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Classify every paired case x trial, using the same metric selection as
|
|
86
|
+
* {@link pairedCompare} so the case list explains its win/lose/tie counts.
|
|
87
|
+
* @param a - the baseline run.
|
|
88
|
+
* @param b - the candidate run.
|
|
89
|
+
* @returns one row per completed pair with a measured value, or null when
|
|
90
|
+
* there are no comparable pairs. Ungraded pairs must not inflate the per-case
|
|
91
|
+
* Bonferroni family.
|
|
92
|
+
*/
|
|
93
|
+
export declare function pairedCases(a: EvalRun, b: EvalRun, metricOverride?: PairedMetric): PairedCase[] | null;
|
|
94
|
+
/** Aggregated paired evidence for one case across its trial pairs. */
|
|
95
|
+
export interface CaseSignificance {
|
|
96
|
+
caseId: string;
|
|
97
|
+
pairs: number;
|
|
98
|
+
wins: number;
|
|
99
|
+
losses: number;
|
|
100
|
+
ties: number;
|
|
101
|
+
adjustedP: number;
|
|
102
|
+
detectable: boolean;
|
|
103
|
+
/** Discordant pairs needed to clear this case's family-wise threshold. */
|
|
104
|
+
requiredPairs: number;
|
|
105
|
+
verdict: 'significantly-better' | 'significantly-worse' | 'not-significant' | 'underpowered';
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Per-case exact sign tests with Bonferroni correction across the cases.
|
|
109
|
+
* This is a separate inference family from the pooled paired metrics.
|
|
110
|
+
*/
|
|
111
|
+
export declare function pairedCaseSignificance(a: EvalRun, b: EvalRun, metricOverride?: PairedMetric): CaseSignificance[] | null;
|
|
112
|
+
/** Render per-case paired significance as a markdown block. */
|
|
113
|
+
export declare function renderCaseSignificance(rows: readonly CaseSignificance[]): string;
|
|
114
|
+
/** Format a paired case value for reports and dashboards. */
|
|
115
|
+
export declare function formatCaseValue(value: boolean | number | null): string;
|
|
116
|
+
/**
|
|
117
|
+
* Render the most actionable paired case outcomes: candidate wins first, then
|
|
118
|
+
* candidate losses, capped at 20 rows so a large benchmark still fits a screen.
|
|
119
|
+
* @param cases - rows from {@link pairedCases}.
|
|
120
|
+
* @returns a markdown block ending in a newline.
|
|
121
|
+
*/
|
|
122
|
+
export declare function renderPairedCases(cases: readonly PairedCase[]): string;
|
|
50
123
|
/**
|
|
51
124
|
* Build the comparison rows between two runs.
|
|
52
125
|
* @param a - the baseline run.
|
|
@@ -60,3 +133,10 @@ export declare function compareRuns(a: EvalRun, b: EvalRun): CompareRow[];
|
|
|
60
133
|
* @returns the markdown text.
|
|
61
134
|
*/
|
|
62
135
|
export declare function renderCompareMarkdown(rows: readonly CompareRow[]): string;
|
|
136
|
+
/**
|
|
137
|
+
* Render a two-run comparison as machine-readable JSON.
|
|
138
|
+
* @param a - the baseline run.
|
|
139
|
+
* @param b - the candidate run.
|
|
140
|
+
* @returns a JSON string ending in a newline.
|
|
141
|
+
*/
|
|
142
|
+
export declare function renderCompareJson(a: EvalRun, b: EvalRun): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Self-contained HTML dashboard for a persisted eval run.
|
|
3
|
+
*
|
|
4
|
+
* The output has no external assets or scripts, so it can be opened from a CI
|
|
5
|
+
* artifact, a local temp directory, or an offline machine. Every value that
|
|
6
|
+
* came from the benchmark or the agent is HTML-escaped: a benchmark id or an
|
|
7
|
+
* error string is data, never markup.
|
|
8
|
+
*
|
|
9
|
+
* @module dsh-eval/dashboard
|
|
10
|
+
*/
|
|
11
|
+
import { type LeaderboardMetric } from './leaderboard.ts';
|
|
12
|
+
import type { EvalRun } from './types.ts';
|
|
13
|
+
/**
|
|
14
|
+
* Write the dashboard as a standalone HTML file, creating parent directories.
|
|
15
|
+
* @param runs - one run, two for a comparison table, or three+ for a leaderboard.
|
|
16
|
+
* @param path - output path.
|
|
17
|
+
*/
|
|
18
|
+
export declare function writeDashboard(runs: readonly EvalRun[], path: string, metric?: LeaderboardMetric): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Render a standalone HTML dashboard for one, two, or three+ runs.
|
|
21
|
+
* @param runs - one run, two for a comparison table, or three+ for a leaderboard.
|
|
22
|
+
* @returns a complete HTML document.
|
|
23
|
+
*/
|
|
24
|
+
export declare function renderDashboard(runs: readonly EvalRun[], metric?: LeaderboardMetric): string;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic content hashing for benchmark provenance.
|
|
3
|
+
*
|
|
4
|
+
* A YAML digest alone misses prompt files, workspace fixtures and replay logs,
|
|
5
|
+
* so the stored benchmark fingerprint folds every resolved input into one
|
|
6
|
+
* SHA-256. Directory entries use code-point ordering (never locale ordering)
|
|
7
|
+
* so the digest is identical on every machine, and symlinks are followed to
|
|
8
|
+
* their real content so an in-directory link cannot hide a changed fixture.
|
|
9
|
+
*
|
|
10
|
+
* @module dsh-eval/digest
|
|
11
|
+
*/
|
|
12
|
+
import type { Benchmark } from './types.ts';
|
|
13
|
+
/** CLI overrides that change the effective benchmark configuration. */
|
|
14
|
+
export interface BenchmarkOverrides {
|
|
15
|
+
trials?: number;
|
|
16
|
+
concurrency?: number;
|
|
17
|
+
seed?: number;
|
|
18
|
+
profile?: string;
|
|
19
|
+
dshCommand?: readonly string[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Fold CLI overrides into a benchmark digest so provenance cannot report a
|
|
23
|
+
* match for a run whose effective configuration differed from the YAML.
|
|
24
|
+
*/
|
|
25
|
+
export declare function hashBenchmarkOverrides(baseSha256: string, overrides: BenchmarkOverrides): string;
|
|
26
|
+
/** Options that affect only the digest, not the benchmark itself. */
|
|
27
|
+
export interface BenchmarkDigestOptions {
|
|
28
|
+
/** Absolute paths to omit, e.g. the run report written into a `workspace: .` tree. */
|
|
29
|
+
excludePaths?: readonly string[];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Hash the benchmark YAML plus every resolved input it reads at run time.
|
|
33
|
+
* @param text - raw benchmark YAML source.
|
|
34
|
+
* @param benchmark - the parsed benchmark with resolved paths.
|
|
35
|
+
* @param options - digest-only exclusions for output artifacts.
|
|
36
|
+
* @returns a stable 64-character hex digest.
|
|
37
|
+
*/
|
|
38
|
+
export declare function hashBenchmarkInputs(text: string, benchmark: Benchmark, options?: BenchmarkDigestOptions): Promise<string>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flat trial-level CSV export for dsh-eval runs.
|
|
3
|
+
*
|
|
4
|
+
* Reports are the source of truth for aggregate analysis, but spreadsheet and
|
|
5
|
+
* notebook workflows usually want one row per trial. This module derives that
|
|
6
|
+
* view without changing the persisted JSON, and escapes every agent-controlled
|
|
7
|
+
* string so a case id or error message cannot inject a spreadsheet formula.
|
|
8
|
+
*
|
|
9
|
+
* @module dsh-eval/export
|
|
10
|
+
*/
|
|
11
|
+
import type { EvalRun } from './types.ts';
|
|
12
|
+
/**
|
|
13
|
+
* Render a persisted run as trial-level CSV.
|
|
14
|
+
* @param run - a validated run report.
|
|
15
|
+
* @returns CSV text ending in a newline, with a header row even for empty runs.
|
|
16
|
+
*/
|
|
17
|
+
export declare function renderTrialsCsv(run: EvalRun): string;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CI quality gate for dsh-eval: compare a candidate run against a baseline and
|
|
3
|
+
* fail when a quality metric regresses beyond an allowed tolerance.
|
|
4
|
+
*
|
|
5
|
+
* All quality metrics are expressed on a 0..1 scale, so one `--max-drop`
|
|
6
|
+
* threshold applies uniformly to pass rates and judge scores. Judge scores are
|
|
7
|
+
* normalized by each run's configured `maxScore` before comparison.
|
|
8
|
+
*
|
|
9
|
+
* @module dsh-eval/gate
|
|
10
|
+
*/
|
|
11
|
+
import { type PairedMetric } from './compare.ts';
|
|
12
|
+
import type { EvalRun } from './types.ts';
|
|
13
|
+
/** One gate criterion. */
|
|
14
|
+
export interface GateCheck {
|
|
15
|
+
metric: string;
|
|
16
|
+
baseline: number | null;
|
|
17
|
+
candidate: number | null;
|
|
18
|
+
delta: number | null;
|
|
19
|
+
passed: boolean;
|
|
20
|
+
/** Count checks print integers; rates print percentages; budgets print money/time. */
|
|
21
|
+
unit?: 'count' | 'usd' | 'ms' | 'p';
|
|
22
|
+
note?: string;
|
|
23
|
+
}
|
|
24
|
+
/** A single case x trial that got worse between the two runs. */
|
|
25
|
+
export interface CaseRegression {
|
|
26
|
+
caseId: string;
|
|
27
|
+
trial: number;
|
|
28
|
+
metric: 'task success' | 'tool selection' | 'judge score';
|
|
29
|
+
before: number;
|
|
30
|
+
after: number;
|
|
31
|
+
}
|
|
32
|
+
/** Aggregated gate decision. */
|
|
33
|
+
export interface GateResult {
|
|
34
|
+
checks: readonly GateCheck[];
|
|
35
|
+
passed: boolean;
|
|
36
|
+
maxDrop: number;
|
|
37
|
+
/** Optional for callers that only need the aggregate verdict. */
|
|
38
|
+
regressions?: readonly CaseRegression[];
|
|
39
|
+
/** Enabled relative cost budget, if any. */
|
|
40
|
+
maxCostIncrease?: number;
|
|
41
|
+
/** Enabled relative latency budget, if any. */
|
|
42
|
+
maxLatencyIncrease?: number;
|
|
43
|
+
/** Cases with a family-corrected, statistically confirmed paired regression. */
|
|
44
|
+
confirmedCaseRegressions?: readonly ConfirmedCaseRegression[];
|
|
45
|
+
}
|
|
46
|
+
/** A regression that survives per-case multiple-comparison correction. */
|
|
47
|
+
export interface ConfirmedCaseRegression {
|
|
48
|
+
caseId: string;
|
|
49
|
+
metric: PairedMetric;
|
|
50
|
+
adjustedP: number;
|
|
51
|
+
}
|
|
52
|
+
/** Optional resource budgets for a gate run. */
|
|
53
|
+
export interface GateBudgets {
|
|
54
|
+
maxCostIncrease?: number | null;
|
|
55
|
+
maxLatencyIncrease?: number | null;
|
|
56
|
+
}
|
|
57
|
+
/** Optional significance mode for a gate run. */
|
|
58
|
+
export interface GateOptions {
|
|
59
|
+
/**
|
|
60
|
+
* Only treat quality drops as failures when the paired sign test confirms a
|
|
61
|
+
* regression. Insufficient or underpowered evidence fails closed.
|
|
62
|
+
*/
|
|
63
|
+
requireSignificance?: boolean;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Evaluate a candidate run against a baseline.
|
|
67
|
+
* @param baseline - the trusted reference run.
|
|
68
|
+
* @param candidate - the run under test.
|
|
69
|
+
* @param maxDrop - largest tolerated regression on the 0..1 scale.
|
|
70
|
+
* @param allowIncomplete - skip the trial-coverage checks when true.
|
|
71
|
+
* @param budgets - optional relative cost and latency increase limits.
|
|
72
|
+
* @param options - optional significance mode for quality regressions.
|
|
73
|
+
* @returns the per-metric checks and the overall decision.
|
|
74
|
+
*/
|
|
75
|
+
export declare function evaluateGate(baseline: EvalRun, candidate: EvalRun, maxDrop: number, allowIncomplete?: boolean, budgets?: GateBudgets, options?: GateOptions): GateResult;
|
|
76
|
+
/**
|
|
77
|
+
* Render a gate decision as machine-readable JSON for CI consumers.
|
|
78
|
+
* @param result - the evaluated gate.
|
|
79
|
+
* @returns a JSON string ending in a newline.
|
|
80
|
+
*/
|
|
81
|
+
export declare function renderGateJson(result: GateResult): string;
|
|
82
|
+
/**
|
|
83
|
+
* Render a gate decision as markdown.
|
|
84
|
+
* @param result - the evaluated gate.
|
|
85
|
+
* @returns a compact table ending in a newline.
|
|
86
|
+
*/
|
|
87
|
+
export declare function renderGate(result: GateResult): string;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -6,14 +6,16 @@
|
|
|
6
6
|
* headless dsh subprocess per case x trial, harvests each persisted session
|
|
7
7
|
* log as a trace, folds automatic metrics, scripted grading (task success,
|
|
8
8
|
* tool-selection accuracy), and cross-run comparison, and writes a JSON run
|
|
9
|
-
* report. LLM-judge metrics (final-answer score, hallucination)
|
|
10
|
-
* same-seed
|
|
9
|
+
* report. LLM-judge metrics (final-answer score, hallucination), offline
|
|
10
|
+
* rejudging, paired same-seed inference, calibration and statistical gates
|
|
11
|
+
* are implemented and available from the same CLI.
|
|
11
12
|
*
|
|
12
13
|
* @module dsh-eval
|
|
13
14
|
*/
|
|
14
15
|
import type { Context } from '@deepseek-ai/cordis';
|
|
15
16
|
import { type EvalStartupValues } from './command.ts';
|
|
16
17
|
import { type JudgeChat } from './judge.ts';
|
|
18
|
+
import type { EvalTrialResult } from './types.ts';
|
|
17
19
|
/** Stable Cordis plugin name. */
|
|
18
20
|
export declare const name = "eval";
|
|
19
21
|
/** The launcher-provided command line is the only required service. */
|
|
@@ -36,13 +38,15 @@ export declare const internals: EvalIo;
|
|
|
36
38
|
* @returns a chat seam over the llm stream, or undefined without llm.
|
|
37
39
|
*/
|
|
38
40
|
export declare function resolveJudgeChat(ctx: Context): JudgeChat | undefined;
|
|
41
|
+
/** One bounded progress line; agent-controlled text must not inject newlines or terminal control codes. */
|
|
42
|
+
export declare function renderProgress(result: EvalTrialResult, finished: number, total: number, startedAtMs?: number, nowMs?: number): string;
|
|
39
43
|
/**
|
|
40
44
|
* Execute one eval invocation to completion.
|
|
41
45
|
* @param values - the resolved command-line invocation.
|
|
42
46
|
* @param io - output streams for the report and diagnostics.
|
|
43
47
|
* @param services - injected runtime seams, e.g. the LLM-judge chat.
|
|
44
|
-
* @returns the process exit code; nonzero
|
|
45
|
-
* completed
|
|
48
|
+
* @returns the process exit code; nonzero when any trial failed or no trial
|
|
49
|
+
* completed, so a partially failing run cannot be mistaken for a green CI.
|
|
46
50
|
*/
|
|
47
51
|
export declare function executeEval(values: EvalStartupValues, io: EvalIo, services?: {
|
|
48
52
|
judgeChat?: JudgeChat | undefined;
|
package/lib/types/judge.d.ts
CHANGED
|
@@ -22,6 +22,8 @@ export interface JudgeChatRequest {
|
|
|
22
22
|
}
|
|
23
23
|
/** The injected chat seam; returns the model's raw text reply. */
|
|
24
24
|
export type JudgeChat = (request: JudgeChatRequest) => Promise<string>;
|
|
25
|
+
/** The last assistant text message in a trace, used as the final answer. */
|
|
26
|
+
export declare function finalAnswerOf(trace: EvalTrace): string;
|
|
25
27
|
/**
|
|
26
28
|
* Summarize a trace for the judge: final assistant answer, the distinct tool
|
|
27
29
|
* names called, and the failure counters a hallucination call needs.
|
|
@@ -64,7 +66,8 @@ export declare function judgeTrial(caseValue: BenchmarkCase, trace: EvalTrace, j
|
|
|
64
66
|
* @param trace - the merged trial trace.
|
|
65
67
|
* @param judge - the judge configuration.
|
|
66
68
|
* @param chat - the injected chat seam.
|
|
67
|
-
* @returns the parsed verdict, or all-null when the
|
|
69
|
+
* @returns the parsed verdict, or all-null plus `judgeError` when the call
|
|
70
|
+
* failed or the reply could not be parsed.
|
|
68
71
|
*/
|
|
69
72
|
export declare function tryJudgeTrial(caseValue: BenchmarkCase, trace: EvalTrace, judge: BenchmarkJudge, chat: JudgeChat): Promise<EvalJudgeVerdict>;
|
|
70
73
|
/**
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multi-run leaderboard for dsh-eval.
|
|
3
|
+
*
|
|
4
|
+
* `compare` answers a two-run question with paired inference; a leaderboard
|
|
5
|
+
* answers the wider "which of these runs is currently best" question. Ranks
|
|
6
|
+
* use pooled task success with deterministic tie-breakers, and every row shows
|
|
7
|
+
* how far it trails the leader. This is a screening view, not a significance
|
|
8
|
+
* test, but each non-leader row carries a Bonferroni-corrected paired verdict
|
|
9
|
+
* against the leader so a one-point lead is not mistaken for a real gap.
|
|
10
|
+
*
|
|
11
|
+
* @module dsh-eval/leaderboard
|
|
12
|
+
*/
|
|
13
|
+
import type { EvalRun } from './types.ts';
|
|
14
|
+
/** Primary ranking metric for a leaderboard. */
|
|
15
|
+
export type LeaderboardMetric = 'taskSuccess' | 'strictPassAt1';
|
|
16
|
+
/** Paired evidence that a row really trails the current leader. */
|
|
17
|
+
export interface LeaderboardSignificance {
|
|
18
|
+
/** p-value adjusted for the leaderboard comparison family. */
|
|
19
|
+
adjustedP: number;
|
|
20
|
+
/** Whether the smallest attainable p-value can reach alpha at this sample size. */
|
|
21
|
+
detectable: boolean;
|
|
22
|
+
/** Whether the paired primary metric moved against the row. */
|
|
23
|
+
worse: boolean;
|
|
24
|
+
/** The paired metric the verdict is based on. */
|
|
25
|
+
primaryMetric: string | null;
|
|
26
|
+
/** Machine-readable interpretation of the comparison. */
|
|
27
|
+
verdict: 'significantly-behind' | 'behind-not-significant' | 'ahead-or-tied' | 'underpowered' | 'unpaired';
|
|
28
|
+
}
|
|
29
|
+
/** One ranked run. */
|
|
30
|
+
export interface LeaderboardEntry {
|
|
31
|
+
label: string;
|
|
32
|
+
benchmark: string;
|
|
33
|
+
model: string;
|
|
34
|
+
rank: number;
|
|
35
|
+
completed: number;
|
|
36
|
+
total: number;
|
|
37
|
+
taskSuccess: number | null;
|
|
38
|
+
strictPassAt1: number | null;
|
|
39
|
+
toolSelection: number | null;
|
|
40
|
+
judgeScore: number | null;
|
|
41
|
+
costUsd: number | null;
|
|
42
|
+
latencyMs: number | null;
|
|
43
|
+
gapFromBest: number | null;
|
|
44
|
+
/** Paired verdict against the leader; null for the leader itself. */
|
|
45
|
+
significance: LeaderboardSignificance | null;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Rank persisted runs by task success or strict pass@1.
|
|
49
|
+
* @param runs - labelled run records; labels are usually `benchmark — model`.
|
|
50
|
+
* @param metric - primary ranking metric; default is pooled task success.
|
|
51
|
+
* @returns ranked rows with ties sharing a rank.
|
|
52
|
+
*/
|
|
53
|
+
export declare function buildLeaderboard(runs: readonly {
|
|
54
|
+
label: string;
|
|
55
|
+
run: EvalRun;
|
|
56
|
+
}[], metric?: LeaderboardMetric): LeaderboardEntry[];
|
|
57
|
+
/**
|
|
58
|
+
* Render leaderboard rows as machine-readable JSON.
|
|
59
|
+
* @param rows - rows from {@link buildLeaderboard}.
|
|
60
|
+
* @returns a JSON string ending in a newline.
|
|
61
|
+
*/
|
|
62
|
+
export declare function renderLeaderboardJson(rows: readonly LeaderboardEntry[], metric?: LeaderboardMetric): string;
|
|
63
|
+
/** Format the paired verdict against the leader. */
|
|
64
|
+
export declare function formatLeaderboardSignificance(value: LeaderboardSignificance | null): string;
|
|
65
|
+
/**
|
|
66
|
+
* Render a leaderboard as markdown.
|
|
67
|
+
* @param rows - rows from {@link buildLeaderboard}.
|
|
68
|
+
* @returns markdown ending in a newline.
|
|
69
|
+
*/
|
|
70
|
+
export declare function renderLeaderboard(rows: readonly LeaderboardEntry[], metric?: LeaderboardMetric): string;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single-run precision for dsh-eval: percentile-bootstrap intervals for graded
|
|
3
|
+
* rates and latency percentiles, derived from the stored trials at render time.
|
|
4
|
+
*
|
|
5
|
+
* A pooled rate alone hides how little evidence a small run carries. Reusing
|
|
6
|
+
* the paired bootstrap machinery on the zero/one trial outcomes gives a
|
|
7
|
+
* distribution-free interval with no extra assumption, and seeding it with the
|
|
8
|
+
* run's `seed` keeps a re-rendered report byte-identical.
|
|
9
|
+
*
|
|
10
|
+
* @module dsh-eval/precision
|
|
11
|
+
*/
|
|
12
|
+
import { type BootstrapOptions } from './stats.ts';
|
|
13
|
+
import type { EvalRun } from './types.ts';
|
|
14
|
+
/** A rate with a seeded percentile-bootstrap interval. */
|
|
15
|
+
export interface RateInterval {
|
|
16
|
+
/** Number of graded trials contributing. */
|
|
17
|
+
trials: number;
|
|
18
|
+
/** Observed rate over those trials. */
|
|
19
|
+
rate: number;
|
|
20
|
+
/** Lower interval bound, or null with a single trial. */
|
|
21
|
+
lower: number | null;
|
|
22
|
+
/** Upper interval bound, or null with a single trial. */
|
|
23
|
+
upper: number | null;
|
|
24
|
+
}
|
|
25
|
+
/** Precision figures for one run. */
|
|
26
|
+
export interface RunPrecision {
|
|
27
|
+
/** Task-success interval, or null when no trial carried the check. */
|
|
28
|
+
task: RateInterval | null;
|
|
29
|
+
/** Tool-selection interval, or null when no trial carried the expectation. */
|
|
30
|
+
toolSelection: RateInterval | null;
|
|
31
|
+
/** Strict pass@1 interval over every trial, keeping errors in the denominator. */
|
|
32
|
+
strictPassAt1: RateInterval | null;
|
|
33
|
+
/** Median trial latency in milliseconds, or null without metrics. */
|
|
34
|
+
latencyP50: number | null;
|
|
35
|
+
/** 95th-percentile trial latency in milliseconds, or null without metrics. */
|
|
36
|
+
latencyP95: number | null;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Derive single-run precision from a persisted run.
|
|
40
|
+
* @param run - the run to summarize.
|
|
41
|
+
* @param options - bootstrap overrides; the run's seed is used by default.
|
|
42
|
+
* @returns the precision figures, all null when no trial carries data.
|
|
43
|
+
*/
|
|
44
|
+
export declare function computePrecision(run: EvalRun, options?: BootstrapOptions): RunPrecision;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Offline re-judging for dsh-eval: rebuild judge verdicts from a stored run's
|
|
3
|
+
* harvested traces and persisted case inputs, then re-aggregate grading.
|
|
4
|
+
*
|
|
5
|
+
* This enables a keyless two-phase workflow: record a run with replay (which
|
|
6
|
+
* cannot coexist with a live judge), then judge the recorded traces later with
|
|
7
|
+
* an LLM seam. Only the judge verdicts and the grading summary change; metrics,
|
|
8
|
+
* scripted grades, and trial outcomes are preserved.
|
|
9
|
+
*
|
|
10
|
+
* @module dsh-eval/rejudge
|
|
11
|
+
*/
|
|
12
|
+
import { type JudgeChat } from './judge.ts';
|
|
13
|
+
import type { BenchmarkJudge, EvalRun } from './types.ts';
|
|
14
|
+
/**
|
|
15
|
+
* Re-judge every completed trial of a persisted run.
|
|
16
|
+
* @param run - a validated run report carrying `caseInputs`.
|
|
17
|
+
* @param judgeChat - the injected chat seam for the judge model.
|
|
18
|
+
* @param judgeOverride - judge config to use instead of the one stored in the run.
|
|
19
|
+
* @returns a new run with fresh verdicts and a re-aggregated grading summary.
|
|
20
|
+
* @throws when the report lacks the data a judge prompt needs.
|
|
21
|
+
*/
|
|
22
|
+
export declare function rejudgeRun(run: EvalRun, judgeChat: JudgeChat, judgeOverride?: BenchmarkJudge): Promise<EvalRun>;
|