@crowandraven/evalkeeper 0.17.1 → 0.19.0
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/dist/decisions.js +1 -1
- package/dist/decisions.js.map +1 -1
- package/dist/drafts.d.ts +2 -0
- package/dist/drafts.js +1 -1
- package/dist/drafts.js.map +1 -1
- package/dist/glossary.d.ts +25 -14
- package/dist/glossary.js +25 -14
- package/dist/glossary.js.map +1 -1
- package/dist/health.js +2 -2
- package/dist/health.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/memoryStore.d.ts +2 -1
- package/dist/memoryStore.js +9 -0
- package/dist/memoryStore.js.map +1 -1
- package/dist/next/actions.js +58 -3
- package/dist/next/actions.js.map +1 -1
- package/dist/prisma/contracts.d.ts +5 -2
- package/dist/prisma/contracts.js +7 -1
- package/dist/prisma/contracts.js.map +1 -1
- package/dist/prisma/index.d.ts +40 -1
- package/dist/prisma/index.js +37 -1
- package/dist/prisma/index.js.map +1 -1
- package/dist/prune.d.ts +43 -10
- package/dist/prune.js +42 -13
- package/dist/prune.js.map +1 -1
- package/dist/react/AddCase.js +11 -5
- package/dist/react/AddCase.js.map +1 -1
- package/dist/react/AnswerKey.js +7 -4
- package/dist/react/AnswerKey.js.map +1 -1
- package/dist/react/CaseMenu.d.ts +2 -2
- package/dist/react/CaseMenu.js +10 -31
- package/dist/react/CaseMenu.js.map +1 -1
- package/dist/react/CompareView.js +3 -3
- package/dist/react/CompareView.js.map +1 -1
- package/dist/react/ConfirmAnswer.js +1 -1
- package/dist/react/ConfirmAnswer.js.map +1 -1
- package/dist/react/Drawer.d.ts +32 -0
- package/dist/react/Drawer.js +60 -0
- package/dist/react/Drawer.js.map +1 -0
- package/dist/react/HubSections.d.ts +34 -30
- package/dist/react/HubSections.js +104 -103
- package/dist/react/HubSections.js.map +1 -1
- package/dist/react/Menu.d.ts +37 -0
- package/dist/react/Menu.js +51 -0
- package/dist/react/Menu.js.map +1 -0
- package/dist/react/ModelMenu.d.ts +1 -1
- package/dist/react/ModelMenu.js +8 -32
- package/dist/react/ModelMenu.js.map +1 -1
- package/dist/react/RunView.js +24 -4
- package/dist/react/RunView.js.map +1 -1
- package/dist/react/Spending.d.ts +25 -0
- package/dist/react/Spending.js +51 -0
- package/dist/react/Spending.js.map +1 -0
- package/dist/react/SuiteSections.d.ts +27 -14
- package/dist/react/SuiteSections.js +227 -61
- package/dist/react/SuiteSections.js.map +1 -1
- package/dist/react/app.d.ts +18 -0
- package/dist/react/app.js.map +1 -1
- package/dist/react/format.d.ts +13 -0
- package/dist/react/format.js +13 -0
- package/dist/react/format.js.map +1 -1
- package/dist/react/index.d.ts +3 -0
- package/dist/react/index.js +3 -0
- package/dist/react/index.js.map +1 -1
- package/dist/react/pieces.d.ts +21 -8
- package/dist/react/pieces.js +44 -14
- package/dist/react/pieces.js.map +1 -1
- package/dist/runner.d.ts +18 -8
- package/dist/runner.js +148 -12
- package/dist/runner.js.map +1 -1
- package/dist/settings.d.ts +12 -0
- package/dist/settings.js +18 -0
- package/dist/settings.js.map +1 -1
- package/dist/spending.d.ts +100 -0
- package/dist/spending.js +133 -0
- package/dist/spending.js.map +1 -0
- package/dist/stats.d.ts +3 -1
- package/dist/stats.js +6 -2
- package/dist/stats.js.map +1 -1
- package/dist/store.d.ts +5 -0
- package/dist/suggest.js +17 -12
- package/dist/suggest.js.map +1 -1
- package/dist/suiteSettings.d.ts +78 -0
- package/dist/suiteSettings.js +142 -0
- package/dist/suiteSettings.js.map +1 -0
- package/dist/suites/crisisRisk.js +3 -3
- package/dist/suites/crisisRisk.js.map +1 -1
- package/dist/suites/hopelessness.js +6 -6
- package/dist/suites/hopelessness.js.map +1 -1
- package/dist/suites/injection.js +2 -2
- package/dist/suites/injection.js.map +1 -1
- package/dist/summary.d.ts +41 -4
- package/dist/summary.js +46 -8
- package/dist/summary.js.map +1 -1
- package/dist/testing.d.ts +19 -0
- package/dist/testing.js +61 -0
- package/dist/testing.js.map +1 -1
- package/dist/todo.d.ts +146 -0
- package/dist/todo.js +198 -0
- package/dist/todo.js.map +1 -0
- package/dist/types.d.ts +46 -7
- package/dist/types.js +28 -4
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
- package/schema/evalkeeper.prisma +13 -0
- package/src/decisions.ts +1 -1
- package/src/drafts.ts +3 -1
- package/src/glossary.ts +35 -14
- package/src/health.ts +3 -2
- package/src/index.ts +3 -0
- package/src/memoryStore.ts +15 -1
- package/src/next/actions.ts +67 -2
- package/src/prisma/contracts.ts +16 -1
- package/src/prisma/index.ts +68 -1
- package/src/prune.ts +71 -14
- package/src/react/AddCase.tsx +13 -11
- package/src/react/AnswerKey.tsx +17 -5
- package/src/react/CaseMenu.tsx +23 -77
- package/src/react/CompareView.tsx +4 -10
- package/src/react/ConfirmAnswer.tsx +1 -1
- package/src/react/Drawer.tsx +130 -0
- package/src/react/HubSections.tsx +180 -414
- package/src/react/Menu.tsx +155 -0
- package/src/react/ModelMenu.tsx +23 -74
- package/src/react/RunView.tsx +46 -3
- package/src/react/Spending.tsx +200 -0
- package/src/react/SuiteSections.tsx +591 -148
- package/src/react/app.ts +18 -0
- package/src/react/format.ts +15 -0
- package/src/react/index.ts +3 -0
- package/src/react/pieces.tsx +57 -18
- package/src/runner.ts +199 -13
- package/src/settings.ts +20 -0
- package/src/spending.ts +209 -0
- package/src/stats.ts +8 -2
- package/src/store.ts +5 -0
- package/src/suggest.ts +21 -14
- package/src/suiteSettings.ts +201 -0
- package/src/suites/crisisRisk.ts +3 -3
- package/src/suites/hopelessness.ts +6 -6
- package/src/suites/injection.ts +2 -2
- package/src/summary.ts +59 -8
- package/src/testing.ts +77 -0
- package/src/todo.ts +318 -0
- package/src/types.ts +63 -9
- package/starter/index.ts +7 -0
- package/templates/lib/evalkeeper/actions.ts +20 -0
package/src/summary.ts
CHANGED
|
@@ -70,17 +70,40 @@ export type Confidence = {
|
|
|
70
70
|
sentence: string;
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
+
/**
|
|
74
|
+
* Fewer cases than this can't be judged at all: a score could be off by
|
|
75
|
+
* more than 20 points. A suite whose own target is smaller (cases that cost
|
|
76
|
+
* real money) uses its target instead, so a suite at its target is never
|
|
77
|
+
* "too few".
|
|
78
|
+
*/
|
|
79
|
+
export const TOO_FEW_CASES = 20;
|
|
80
|
+
|
|
81
|
+
/** How many cases are too few to judge, for a suite aiming at `target`. */
|
|
82
|
+
export function tooFewBelow(target: number = TARGET_CASES): number {
|
|
83
|
+
return Math.min(TOO_FEW_CASES, target);
|
|
84
|
+
}
|
|
85
|
+
|
|
73
86
|
/**
|
|
74
87
|
* How far to trust scores on this many cases. The margin is the 95% range
|
|
75
88
|
* of a pass rate (at the given rate, or 50%, the widest), in points.
|
|
89
|
+
*
|
|
90
|
+
* @param cases - Cases in use.
|
|
91
|
+
* @param rate - The score to judge the margin at; 50% (the widest) by default.
|
|
92
|
+
* @param target - The suite's target number of cases (`targetCasesOf`):
|
|
93
|
+
* "too few" is below it or 20, whichever is smaller, and the sentence
|
|
94
|
+
* asks for more only while the suite is under it.
|
|
76
95
|
*/
|
|
77
|
-
export function confidenceFor(
|
|
96
|
+
export function confidenceFor(
|
|
97
|
+
cases: number,
|
|
98
|
+
rate = 0.5,
|
|
99
|
+
target: number = TARGET_CASES,
|
|
100
|
+
): Confidence {
|
|
78
101
|
const p = Math.min(Math.max(rate, 0.05), 0.95);
|
|
79
102
|
const margin = cases
|
|
80
103
|
? Math.round(1.96 * Math.sqrt((p * (1 - p)) / cases) * 100)
|
|
81
104
|
: 100;
|
|
82
105
|
const level =
|
|
83
|
-
cases <
|
|
106
|
+
cases < tooFewBelow(target)
|
|
84
107
|
? "too-few"
|
|
85
108
|
: cases < 50
|
|
86
109
|
? "rough"
|
|
@@ -93,17 +116,45 @@ export function confidenceFor(cases: number, rate = 0.5): Confidence {
|
|
|
93
116
|
good: "good",
|
|
94
117
|
strong: "strong",
|
|
95
118
|
}[level];
|
|
119
|
+
const aim = cases < target ? ` Aim for ${target}.` : "";
|
|
96
120
|
const sentence =
|
|
97
121
|
level === "too-few"
|
|
98
|
-
? `With ${cases} cases a score could be off by about ${margin} points: only big problems show
|
|
99
|
-
: `With ${cases} cases a score could be off by about ${margin} points either way, so models closer than that can't be told apart.${
|
|
122
|
+
? `With ${cases} cases a score could be off by about ${margin} points: only big problems show.${aim}`
|
|
123
|
+
: `With ${cases} cases a score could be off by about ${margin} points either way, so models closer than that can't be told apart.${aim}`;
|
|
100
124
|
return { level, label, margin, sentence };
|
|
101
125
|
}
|
|
102
126
|
|
|
103
|
-
/**
|
|
127
|
+
/**
|
|
128
|
+
* The answer key size to aim for when a suite sets none (see
|
|
129
|
+
* confidenceFor). A suite sets its own with `targetCases`, and a person can
|
|
130
|
+
* change it in the suite's settings.
|
|
131
|
+
*/
|
|
104
132
|
export const TARGET_CASES = 50;
|
|
105
133
|
|
|
106
|
-
/**
|
|
107
|
-
|
|
108
|
-
|
|
134
|
+
/**
|
|
135
|
+
* A suite's target number of cases: what a person saved in its settings,
|
|
136
|
+
* else the suite's `targetCases`, else TARGET_CASES.
|
|
137
|
+
*
|
|
138
|
+
* @param suite - The suite, for its `targetCases`.
|
|
139
|
+
* @param saved - The suite's saved settings, when there are any.
|
|
140
|
+
*/
|
|
141
|
+
export function targetCasesOf(
|
|
142
|
+
suite: { targetCases?: number | undefined },
|
|
143
|
+
saved?: { targetCases?: number | null | undefined } | null,
|
|
144
|
+
): number {
|
|
145
|
+
return saved?.targetCases ?? suite.targetCases ?? TARGET_CASES;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* How many drafts get the key to its target: at least 10 a batch (or the
|
|
150
|
+
* whole target, when that's smaller), at most 30.
|
|
151
|
+
*
|
|
152
|
+
* @param casesNotRetired - Cases in the answer key, drafts included.
|
|
153
|
+
* @param target - The suite's target number of cases.
|
|
154
|
+
*/
|
|
155
|
+
export function draftsToTarget(
|
|
156
|
+
casesNotRetired: number,
|
|
157
|
+
target: number = TARGET_CASES,
|
|
158
|
+
): number {
|
|
159
|
+
return Math.min(30, Math.max(Math.min(10, target), target - casesNotRetired));
|
|
109
160
|
}
|
package/src/testing.ts
CHANGED
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
type SettingsStore,
|
|
24
24
|
} from "./settings.js";
|
|
25
25
|
import type { EvalStore, NewCase } from "./store.js";
|
|
26
|
+
import type { SuiteSettingsStore } from "./suiteSettings.js";
|
|
26
27
|
import { suiteContractProblems } from "./suiteContract.js";
|
|
27
28
|
import type { AnySuite, Suite } from "./types.js";
|
|
28
29
|
import { readCheckSummary, type ReadCheckReport } from "./readCheck.js";
|
|
@@ -565,6 +566,82 @@ export function describeStoreContract(
|
|
|
565
566
|
});
|
|
566
567
|
}
|
|
567
568
|
|
|
569
|
+
/**
|
|
570
|
+
* The contract every SuiteSettingsStore must meet: nothing saved reads as
|
|
571
|
+
* the suite's own values, a save replaces what was there, and each suite
|
|
572
|
+
* keeps its own. With `opts.scope`, every suite it writes starts with the
|
|
573
|
+
* scope (see `describeStoreContract`).
|
|
574
|
+
*
|
|
575
|
+
* @param name - What the tests are called, e.g. "prismaSuiteSettingsStore".
|
|
576
|
+
* @param make - Returns the store to test (an empty one, unless scoped).
|
|
577
|
+
* @param opts - A scope and cleanup, and test functions.
|
|
578
|
+
*
|
|
579
|
+
* @example
|
|
580
|
+
* ```ts
|
|
581
|
+
* describeSuiteSettingsStoreContract("our database", () =>
|
|
582
|
+
* prismaSuiteSettingsStore(prisma),
|
|
583
|
+
* );
|
|
584
|
+
* ```
|
|
585
|
+
*/
|
|
586
|
+
export function describeSuiteSettingsStoreContract(
|
|
587
|
+
name: string,
|
|
588
|
+
make: () => SuiteSettingsStore | Promise<SuiteSettingsStore>,
|
|
589
|
+
opts: ScopedContractOptions = {},
|
|
590
|
+
) {
|
|
591
|
+
const t = testFunctions(opts.test);
|
|
592
|
+
const { describe, it, expect } = t;
|
|
593
|
+
const names = scopeNames(opts.scope);
|
|
594
|
+
describe(`SuiteSettingsStore contract: ${name}`, () => {
|
|
595
|
+
registerCleanup(t, opts);
|
|
596
|
+
|
|
597
|
+
it("reads nothing saved as the suite's own values", async () => {
|
|
598
|
+
const store = await make();
|
|
599
|
+
const suite = names()("triage");
|
|
600
|
+
expect(await store.getSuiteSettings(suite)).toEqual({
|
|
601
|
+
targetCases: null,
|
|
602
|
+
checks: {},
|
|
603
|
+
});
|
|
604
|
+
});
|
|
605
|
+
|
|
606
|
+
it("replaces what was saved, and keeps each suite apart", async () => {
|
|
607
|
+
const store = await make();
|
|
608
|
+
const name = names();
|
|
609
|
+
const [a, b] = [name("triage"), name("summary")];
|
|
610
|
+
const levels = {
|
|
611
|
+
category: { severity: "minor" as const },
|
|
612
|
+
tone: { severity: "moderate" as const, aim: 0.8 },
|
|
613
|
+
};
|
|
614
|
+
await store.saveSuiteSettings(
|
|
615
|
+
a,
|
|
616
|
+
{ targetCases: 10, checks: levels },
|
|
617
|
+
"person-1",
|
|
618
|
+
);
|
|
619
|
+
expect(await store.getSuiteSettings(a)).toEqual({
|
|
620
|
+
targetCases: 10,
|
|
621
|
+
checks: levels,
|
|
622
|
+
});
|
|
623
|
+
expect(await store.getSuiteSettings(b)).toEqual({
|
|
624
|
+
targetCases: null,
|
|
625
|
+
checks: {},
|
|
626
|
+
});
|
|
627
|
+
await store.saveSuiteSettings(
|
|
628
|
+
a,
|
|
629
|
+
{ targetCases: 12, checks: {} },
|
|
630
|
+
"person-2",
|
|
631
|
+
);
|
|
632
|
+
expect(await store.getSuiteSettings(a)).toEqual({
|
|
633
|
+
targetCases: 12,
|
|
634
|
+
checks: {},
|
|
635
|
+
});
|
|
636
|
+
await store.saveSuiteSettings(a, { targetCases: null, checks: {} }, null);
|
|
637
|
+
expect(await store.getSuiteSettings(a)).toEqual({
|
|
638
|
+
targetCases: null,
|
|
639
|
+
checks: {},
|
|
640
|
+
});
|
|
641
|
+
});
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
|
|
568
645
|
/** The columns a thumbs table may lack, for `FeedbackStoreContractOptions`. */
|
|
569
646
|
export type FeedbackColumn =
|
|
570
647
|
"reason" | "excerpt" | "input" | "output" | "status" | "caseId";
|
package/src/todo.ts
ADDED
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import type { BoardRow } from "./board.js";
|
|
2
|
+
import type { ModelCatalog } from "./models.js";
|
|
3
|
+
import { stableJson } from "./stableJson.js";
|
|
4
|
+
import { suggest, type AttackResults } from "./suggest.js";
|
|
5
|
+
import { tooFewBelow } from "./summary.js";
|
|
6
|
+
import {
|
|
7
|
+
checkBar,
|
|
8
|
+
pctBeside,
|
|
9
|
+
type CheckDef,
|
|
10
|
+
type SuitePriority,
|
|
11
|
+
} from "./types.js";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A suite's to-do list: what to do next, in the order to do it, each with
|
|
15
|
+
* why. The suite's page shows it at the top, where each item is done; the
|
|
16
|
+
* hub shows only whether there is one (`suiteStatus`). Pure, from the same
|
|
17
|
+
* board the page reads, so the two always agree.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/** One thing to do on a suite, with what the page needs to act on it. */
|
|
21
|
+
export type Todo =
|
|
22
|
+
| {
|
|
23
|
+
kind: "testAll";
|
|
24
|
+
/** Models with a current test now. */
|
|
25
|
+
tested: number;
|
|
26
|
+
}
|
|
27
|
+
| {
|
|
28
|
+
kind: "retest";
|
|
29
|
+
/** Why, when it isn't a change since the last test (live's answers failed). */
|
|
30
|
+
why?: string;
|
|
31
|
+
}
|
|
32
|
+
| {
|
|
33
|
+
kind: "makeLive";
|
|
34
|
+
/** The model to make live, or the fallback to set. */
|
|
35
|
+
model: string;
|
|
36
|
+
label: string;
|
|
37
|
+
/** True: the fallback changes, live stays. */
|
|
38
|
+
fallback: boolean;
|
|
39
|
+
/** The suggestion's first reason, as the item's why. */
|
|
40
|
+
why: string;
|
|
41
|
+
}
|
|
42
|
+
| {
|
|
43
|
+
kind: "fixCheck";
|
|
44
|
+
check: string;
|
|
45
|
+
label: string;
|
|
46
|
+
/** The live model's pass rate on it (or the best tested one's). */
|
|
47
|
+
rate: number;
|
|
48
|
+
/** The rate it should reach. */
|
|
49
|
+
aim: number;
|
|
50
|
+
/** Cases every tested model misses it on, when the page counted them. */
|
|
51
|
+
missed: number | null;
|
|
52
|
+
/** The live model's test, for the cases it misses. */
|
|
53
|
+
runId: string | null;
|
|
54
|
+
}
|
|
55
|
+
| { kind: "confirm"; answers: number }
|
|
56
|
+
| { kind: "addCases"; add: number; cases: number; target: number }
|
|
57
|
+
| { kind: "makeAttacks"; suites: { key: string; label: string }[] }
|
|
58
|
+
| { kind: "retireStarters"; cases: number }
|
|
59
|
+
| { kind: "reviewSplit"; cases: number };
|
|
60
|
+
|
|
61
|
+
/** What a suite's to-do list is made from. */
|
|
62
|
+
export type TodoInput = {
|
|
63
|
+
/** The suite's board rows (`runner.board`). */
|
|
64
|
+
rows: readonly BoardRow[];
|
|
65
|
+
checks: readonly CheckDef[];
|
|
66
|
+
priority: SuitePriority;
|
|
67
|
+
models?: ModelCatalog;
|
|
68
|
+
/** The feature's injection suites (`attacksFrom`), for the suggestion. */
|
|
69
|
+
attacks?: AttackResults[];
|
|
70
|
+
/** Cases in use: confirmed or provisional answers, not retired. */
|
|
71
|
+
cases: number;
|
|
72
|
+
/** Of those, answers still provisional. */
|
|
73
|
+
provisional: number;
|
|
74
|
+
/** The suite's target number of cases (`targetCasesOf`). */
|
|
75
|
+
target: number;
|
|
76
|
+
/** Attack suites set up for this feature with no attack cases yet. */
|
|
77
|
+
unmadeAttacks?: { key: string; label: string }[];
|
|
78
|
+
/** Starter cases a starter update replaced (`replacedStarters`). */
|
|
79
|
+
replacedStarters?: number;
|
|
80
|
+
/** Cases models split on (`answerKeyHealth(...).split`). */
|
|
81
|
+
splitCases?: number;
|
|
82
|
+
/**
|
|
83
|
+
* Per must-pass check, cases every tested model misses it on. Only the
|
|
84
|
+
* suite's page counts them (it reads the answers); the hub leaves it out.
|
|
85
|
+
*/
|
|
86
|
+
missedByCheck?: Readonly<Record<string, number>>;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
/** Rows with a current, complete-enough test to count as tested. */
|
|
90
|
+
function testedRows(rows: readonly BoardRow[]) {
|
|
91
|
+
return rows.filter((r) => !r.baseline && r.test && !r.test.stale);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* A suite's to-do list, in the order to do it: test every model (or
|
|
96
|
+
* retest), make a better model live, fix must-pass checks every model
|
|
97
|
+
* misses, confirm provisional answers, add cases toward the target, make
|
|
98
|
+
* attack cases, then retire replaced starters and review split cases.
|
|
99
|
+
* Empty when there's nothing to do.
|
|
100
|
+
*
|
|
101
|
+
* @param input - The suite's board, checks, cases, and target.
|
|
102
|
+
*/
|
|
103
|
+
export function suiteTodos(input: TodoInput): Todo[] {
|
|
104
|
+
const { rows, checks, cases, provisional, target } = input;
|
|
105
|
+
const out: Todo[] = [];
|
|
106
|
+
const testing = rows.some((r) => r.testing);
|
|
107
|
+
const models = rows.filter((r) => !r.baseline && !r.variant);
|
|
108
|
+
const tested = testedRows(rows);
|
|
109
|
+
const stale = rows.some((r) => !r.baseline && r.test?.stale);
|
|
110
|
+
|
|
111
|
+
// 1. Tests first: nothing else can be judged without them.
|
|
112
|
+
if (!testing) {
|
|
113
|
+
if (stale) out.push({ kind: "retest" });
|
|
114
|
+
else if (tested.length < Math.min(2, models.length))
|
|
115
|
+
out.push({ kind: "testAll", tested: tested.length });
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// 2. A better model, by the same rules as the suggestion; not while a
|
|
119
|
+
// test runs, when it would weigh half a board.
|
|
120
|
+
const s =
|
|
121
|
+
!testing && tested.length
|
|
122
|
+
? suggest(
|
|
123
|
+
rows as BoardRow[],
|
|
124
|
+
[...checks],
|
|
125
|
+
input.priority,
|
|
126
|
+
input.models ?? {},
|
|
127
|
+
{ attacks: input.attacks ?? [] },
|
|
128
|
+
)
|
|
129
|
+
: null;
|
|
130
|
+
// Live's test has failed answers: test it again before comparing.
|
|
131
|
+
if (s?.retestLive && !out.some((t) => t.kind === "retest"))
|
|
132
|
+
out.push({ kind: "retest", why: s.reasons[0] ?? "" });
|
|
133
|
+
if (s && !s.same && !s.retestLive) {
|
|
134
|
+
const fallback = s.keepLive;
|
|
135
|
+
const to = fallback ? s.fallback : s.live;
|
|
136
|
+
if (to)
|
|
137
|
+
out.push({
|
|
138
|
+
kind: "makeLive",
|
|
139
|
+
model: to.model,
|
|
140
|
+
label: to.label,
|
|
141
|
+
fallback,
|
|
142
|
+
why: s.reasons[0] ?? "",
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// 3. Must-pass checks every tested model misses: the fix is in the
|
|
147
|
+
// instructions or the answers, not the model.
|
|
148
|
+
if (tested.length) {
|
|
149
|
+
const live = tested.find((r) => r.live) ?? null;
|
|
150
|
+
for (const c of checks) {
|
|
151
|
+
if (c.severity !== "serious") continue;
|
|
152
|
+
const aim = checkBar(c);
|
|
153
|
+
const rates = tested.map((r) => r.test?.byCheck[c.key]?.rate ?? null);
|
|
154
|
+
if (!rates.every((x) => x !== null && x < aim)) continue;
|
|
155
|
+
const shown =
|
|
156
|
+
live?.test?.byCheck[c.key]?.rate ??
|
|
157
|
+
Math.max(...rates.filter((x): x is number => x !== null));
|
|
158
|
+
out.push({
|
|
159
|
+
kind: "fixCheck",
|
|
160
|
+
check: c.key,
|
|
161
|
+
label: c.label,
|
|
162
|
+
rate: shown,
|
|
163
|
+
aim,
|
|
164
|
+
missed: input.missedByCheck?.[c.key] ?? null,
|
|
165
|
+
runId: live?.test?.runId ?? null,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// 4–7. The answer key.
|
|
171
|
+
if (provisional) out.push({ kind: "confirm", answers: provisional });
|
|
172
|
+
if (cases < target)
|
|
173
|
+
out.push({ kind: "addCases", add: target - cases, cases, target });
|
|
174
|
+
if (input.unmadeAttacks?.length && cases > 0)
|
|
175
|
+
out.push({ kind: "makeAttacks", suites: input.unmadeAttacks });
|
|
176
|
+
if (input.replacedStarters)
|
|
177
|
+
out.push({ kind: "retireStarters", cases: input.replacedStarters });
|
|
178
|
+
if (input.splitCases)
|
|
179
|
+
out.push({ kind: "reviewSplit", cases: input.splitCases });
|
|
180
|
+
return out;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const n = (count: number, word: string, plural = `${word}s`) =>
|
|
184
|
+
`${count} ${count === 1 ? word : plural}`;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* A to-do item in words: what to do, and why, as the suite's page shows
|
|
188
|
+
* it ("Add 10 cases", "40 of 50, so scores firm up").
|
|
189
|
+
*
|
|
190
|
+
* @param t - The item.
|
|
191
|
+
*/
|
|
192
|
+
export function todoText(t: Todo): { what: string; why: string } {
|
|
193
|
+
switch (t.kind) {
|
|
194
|
+
case "testAll":
|
|
195
|
+
return {
|
|
196
|
+
what: "Test every model",
|
|
197
|
+
why:
|
|
198
|
+
t.tested === 0
|
|
199
|
+
? "none has been tested yet."
|
|
200
|
+
: "only one has been tested, so there's nothing to compare it with.",
|
|
201
|
+
};
|
|
202
|
+
case "retest":
|
|
203
|
+
return {
|
|
204
|
+
what: "Test again",
|
|
205
|
+
why:
|
|
206
|
+
t.why ||
|
|
207
|
+
"the instructions, answers, or cases changed since the last test.",
|
|
208
|
+
};
|
|
209
|
+
case "makeLive":
|
|
210
|
+
return {
|
|
211
|
+
what: t.fallback
|
|
212
|
+
? `Make ${t.label} the fallback`
|
|
213
|
+
: `Make ${t.label} live`,
|
|
214
|
+
// The suggestion's sentence as it is: it starts with a model's name.
|
|
215
|
+
why: t.why,
|
|
216
|
+
};
|
|
217
|
+
case "fixCheck":
|
|
218
|
+
return {
|
|
219
|
+
what: `Fix "${t.label}"`,
|
|
220
|
+
why: `passes ${pctBeside(t.rate, t.aim)} of the time (aim: ${Math.round(t.aim * 100)}%)${
|
|
221
|
+
t.missed
|
|
222
|
+
? `; every model tested misses it on ${n(t.missed, "case")}`
|
|
223
|
+
: "; every model tested misses it"
|
|
224
|
+
}. The fix is in the instructions or the answers, not the model.`,
|
|
225
|
+
};
|
|
226
|
+
case "confirm":
|
|
227
|
+
return {
|
|
228
|
+
what: `Confirm ${n(t.answers, "answer")}`,
|
|
229
|
+
why: `${t.answers === 1 ? "it's" : "they're"} provisional, so scores rest on answers nobody reviewed.`,
|
|
230
|
+
};
|
|
231
|
+
case "addCases":
|
|
232
|
+
return {
|
|
233
|
+
what: `Add ${n(t.add, "case")}`,
|
|
234
|
+
why: `${t.cases} of ${t.target}, so a score could still be well off.`,
|
|
235
|
+
};
|
|
236
|
+
case "makeAttacks":
|
|
237
|
+
return {
|
|
238
|
+
what: "Make attack cases",
|
|
239
|
+
why: "attacks are set up, but none are made, so nobody knows if a model follows text it can't trust.",
|
|
240
|
+
};
|
|
241
|
+
case "retireStarters":
|
|
242
|
+
return {
|
|
243
|
+
what: `Retire ${n(t.cases, "replaced starter")}`,
|
|
244
|
+
why: `the suite's starter cases changed, and ${t.cases === 1 ? "this one is" : "these are"} no longer among them.`,
|
|
245
|
+
};
|
|
246
|
+
case "reviewSplit":
|
|
247
|
+
return {
|
|
248
|
+
what: `Review ${n(t.cases, "case")} models split on`,
|
|
249
|
+
why: "often the answer is wrong or the case unclear, and either makes every score less trustworthy.",
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/** Where a suite stands on the hub, in one word. */
|
|
255
|
+
export type SuiteStatus = "attention" | "unknown" | "healthy";
|
|
256
|
+
|
|
257
|
+
/** The order the hub lists suites in: what needs you first. */
|
|
258
|
+
export const SUITE_STATUS_ORDER: readonly SuiteStatus[] = [
|
|
259
|
+
"attention",
|
|
260
|
+
"unknown",
|
|
261
|
+
"healthy",
|
|
262
|
+
];
|
|
263
|
+
|
|
264
|
+
/** What each status is called on the hub and the suite's page. */
|
|
265
|
+
export const SUITE_STATUS_LABEL: Readonly<Record<SuiteStatus, string>> = {
|
|
266
|
+
attention: "Needs attention",
|
|
267
|
+
unknown: "Can't tell yet",
|
|
268
|
+
healthy: "Healthy",
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Where a suite stands: Can't tell yet when no model has a current test or
|
|
273
|
+
* there are too few cases to judge (against the suite's own target),
|
|
274
|
+
* unless a must-pass check is already missed; otherwise Needs attention
|
|
275
|
+
* when its to-do list has anything on it, and Healthy when it doesn't.
|
|
276
|
+
*
|
|
277
|
+
* @param input - What the to-do list is made from.
|
|
278
|
+
* @param todos - The list, when already made (`suiteTodos(input)`).
|
|
279
|
+
*/
|
|
280
|
+
export function suiteStatus(
|
|
281
|
+
input: TodoInput,
|
|
282
|
+
todos: readonly Todo[] = suiteTodos(input),
|
|
283
|
+
): SuiteStatus {
|
|
284
|
+
if (todos.some((t) => t.kind === "fixCheck")) return "attention";
|
|
285
|
+
if (
|
|
286
|
+
testedRows(input.rows).length === 0 ||
|
|
287
|
+
input.cases < tooFewBelow(input.target)
|
|
288
|
+
)
|
|
289
|
+
return "unknown";
|
|
290
|
+
return todos.length ? "attention" : "healthy";
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Starter cases a starter update replaced: added from the suite's
|
|
295
|
+
* `starter` (`sourceRef` "starter:<suite>#<key>") and not retired, whose
|
|
296
|
+
* input no longer matches any current starter. A case with no `sourceRef`
|
|
297
|
+
* is never listed, even when it matches nothing: it may be hand-made.
|
|
298
|
+
*
|
|
299
|
+
* @param suite - The suite: its key and current `starter` cases.
|
|
300
|
+
* @param cases - The suite's cases.
|
|
301
|
+
*/
|
|
302
|
+
export function replacedStarters<
|
|
303
|
+
C extends { status: string; sourceRef: string | null; input: unknown },
|
|
304
|
+
>(
|
|
305
|
+
suite: { key: string; starter?: readonly { input: unknown }[] | undefined },
|
|
306
|
+
cases: readonly C[],
|
|
307
|
+
): C[] {
|
|
308
|
+
const prefix = `starter:${suite.key}#`;
|
|
309
|
+
const current = new Set(
|
|
310
|
+
(suite.starter ?? []).map((s) => stableJson(s.input)),
|
|
311
|
+
);
|
|
312
|
+
return cases.filter(
|
|
313
|
+
(c) =>
|
|
314
|
+
c.status !== "RETIRED" &&
|
|
315
|
+
c.sourceRef?.startsWith(prefix) === true &&
|
|
316
|
+
!current.has(stableJson(c.input)),
|
|
317
|
+
);
|
|
318
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -34,6 +34,19 @@ export type CheckResult = {
|
|
|
34
34
|
* `brier`, `logLoss`, `confidence`, and `correct` (see decisionCheck).
|
|
35
35
|
*/
|
|
36
36
|
measures?: Record<string, number> | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Set by Evalkeeper when it grades: the check's level then (the suite's,
|
|
39
|
+
* or a person's from Suite settings). A nice-to-have (`minor`) miss
|
|
40
|
+
* never fails an answer (`allPassed`). Absent on answers graded before
|
|
41
|
+
* levels were kept: those count every check.
|
|
42
|
+
*/
|
|
43
|
+
level?: CheckDef["severity"] | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Set by Evalkeeper on checks from a suite's `gradeTogether`: they grade
|
|
46
|
+
* this answer against others (a ranking), so the case matters to other
|
|
47
|
+
* cases' results too, and is never retired as easy.
|
|
48
|
+
*/
|
|
49
|
+
together?: boolean | undefined;
|
|
37
50
|
};
|
|
38
51
|
|
|
39
52
|
/**
|
|
@@ -48,18 +61,51 @@ export type CheckDef = {
|
|
|
48
61
|
/** "code": needs no label. "label": compares with a confirmed label. */
|
|
49
62
|
kind: "code" | "label";
|
|
50
63
|
/**
|
|
51
|
-
* Serious: changes what the product does (which
|
|
52
|
-
* in, what a summary claims)
|
|
53
|
-
*
|
|
64
|
+
* Its level. Serious (must pass): changes what the product does (which
|
|
65
|
+
* queue a ticket lands in, what a summary claims); models are ranked on
|
|
66
|
+
* these misses first. Moderate (should pass): matters, but less. Minor
|
|
67
|
+
* (nice to have): a fair difference of judgment (a category, how finely
|
|
68
|
+
* to split); tracked against its aim, but never fails an answer. A
|
|
69
|
+
* person can change any check's level in the suite's settings.
|
|
70
|
+
*/
|
|
71
|
+
severity: "serious" | "moderate" | "minor";
|
|
72
|
+
/**
|
|
73
|
+
* The pass rate it aims for, shown as its aim; default by severity
|
|
74
|
+
* (checkBar).
|
|
54
75
|
*/
|
|
55
|
-
severity: "serious" | "minor";
|
|
56
|
-
/** Pass rate it should reach; default by severity (checkBar). */
|
|
57
76
|
bar?: number;
|
|
58
77
|
};
|
|
59
78
|
|
|
60
|
-
/**
|
|
79
|
+
/**
|
|
80
|
+
* Each level's aim when a check sets none: must pass 95%, should pass 85%,
|
|
81
|
+
* nice to have 75%.
|
|
82
|
+
*/
|
|
83
|
+
export const DEFAULT_AIM: Readonly<Record<CheckDef["severity"], number>> = {
|
|
84
|
+
serious: 0.95,
|
|
85
|
+
moderate: 0.85,
|
|
86
|
+
minor: 0.75,
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
/** The levels in order, most important first, for sorting checks. */
|
|
90
|
+
export const SEVERITY_ORDER: readonly CheckDef["severity"][] = [
|
|
91
|
+
"serious",
|
|
92
|
+
"moderate",
|
|
93
|
+
"minor",
|
|
94
|
+
];
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* What the pages call each level: a serious check must pass, a moderate
|
|
98
|
+
* one should pass, a minor one is nice to have.
|
|
99
|
+
*/
|
|
100
|
+
export const SEVERITY_LABEL: Readonly<Record<CheckDef["severity"], string>> = {
|
|
101
|
+
serious: "Must pass",
|
|
102
|
+
moderate: "Should pass",
|
|
103
|
+
minor: "Nice to have",
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
/** The pass rate a check should reach: its own, else its level's (DEFAULT_AIM). */
|
|
61
107
|
export function checkBar(c: CheckDef): number {
|
|
62
|
-
return c.bar ??
|
|
108
|
+
return c.bar ?? DEFAULT_AIM[c.severity];
|
|
63
109
|
}
|
|
64
110
|
|
|
65
111
|
/**
|
|
@@ -74,7 +120,7 @@ export function pctBeside(rate: number, bar: number): string {
|
|
|
74
120
|
: `${whole}%`;
|
|
75
121
|
}
|
|
76
122
|
|
|
77
|
-
/** Meets the bar, is within 10 points of it, or is further below. */
|
|
123
|
+
/** Meets the aim (bar), is within 10 points of it, or is further below. */
|
|
78
124
|
export function barStatus(
|
|
79
125
|
rate: number,
|
|
80
126
|
bar: number,
|
|
@@ -100,7 +146,7 @@ export const FAVOR_TEXT: Record<SuitePriority["favor"], string> = {
|
|
|
100
146
|
"speed: someone waits on this, so a model that scores as well and answers clearly faster is worth switching to, and so is one about as accurate (within 10 points) in half the time",
|
|
101
147
|
cost: "cost: this runs in the background, often, so a model that scores as well and is clearly cheaper is worth switching to, and so is one about as accurate (within 10 points) at half the cost",
|
|
102
148
|
quality:
|
|
103
|
-
"quality: people read and act on this, so only clearly better accuracy or fewer
|
|
149
|
+
"quality: people read and act on this, so only clearly better accuracy or fewer must-pass misses is worth switching for",
|
|
104
150
|
};
|
|
105
151
|
|
|
106
152
|
/**
|
|
@@ -114,6 +160,14 @@ export type Suite<Input, Output, Label> = {
|
|
|
114
160
|
priority: SuitePriority;
|
|
115
161
|
label: string;
|
|
116
162
|
description: string;
|
|
163
|
+
/**
|
|
164
|
+
* How many cases this suite's answer key should have (default 50). Lower
|
|
165
|
+
* it for a suite whose every case costs real money (a billed web search,
|
|
166
|
+
* say), where about 10 is the sensible size. A person can change it on
|
|
167
|
+
* the suite's page (Suite settings) when the runner has a
|
|
168
|
+
* `suiteSettings` store; theirs wins.
|
|
169
|
+
*/
|
|
170
|
+
targetCases?: number;
|
|
117
171
|
/** Bump when checks change, so runs say which grading they used. */
|
|
118
172
|
graderVersion: string;
|
|
119
173
|
input: z.ZodType<Input>;
|
package/starter/index.ts
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
prismaFeedbackStore,
|
|
16
16
|
prismaSettingsStore,
|
|
17
17
|
prismaStore,
|
|
18
|
+
prismaSuiteSettingsStore,
|
|
18
19
|
} from "@crowandraven/evalkeeper/prisma";
|
|
19
20
|
// TODO: your app's Prisma client, with Evalkeeper's models added to the
|
|
20
21
|
// schema (node_modules/@crowandraven/evalkeeper/schema/evalkeeper.prisma).
|
|
@@ -88,6 +89,9 @@ export const runner = createRunner({
|
|
|
88
89
|
instructionTexts: (operation) => INSTRUCTION_TEXTS[operation] ?? [],
|
|
89
90
|
route: routeFor,
|
|
90
91
|
candidates: (operation) => ({ models: modelsFor(operation) }),
|
|
92
|
+
// Lets people change a suite's target number of cases on its page
|
|
93
|
+
// (the EvalSuiteSetting table). Leave it out to keep the targets in code.
|
|
94
|
+
suiteSettings: prismaSuiteSettingsStore(prisma),
|
|
91
95
|
});
|
|
92
96
|
|
|
93
97
|
/**
|
|
@@ -116,4 +120,7 @@ export const wiring = {
|
|
|
116
120
|
routeFor,
|
|
117
121
|
answerEditors,
|
|
118
122
|
requireAdmin,
|
|
123
|
+
// TODO, optional: `spending` (an EvalSpending), if your app keeps daily
|
|
124
|
+
// spending limits for eval tests. The pages then show what tests spent
|
|
125
|
+
// and save the limits, with a stop.
|
|
119
126
|
} satisfies Omit<EvalWiring, "basePath">;
|
|
@@ -101,6 +101,26 @@ export async function keepAnswer(form: FormData) {
|
|
|
101
101
|
return actions.keepAnswer(form);
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
export async function retireReplacedStarters(form: FormData) {
|
|
105
|
+
return actions.retireReplacedStarters(form);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export async function saveSuiteSettings(form: FormData) {
|
|
109
|
+
return actions.saveSuiteSettings(form);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export async function saveLimits(form: FormData) {
|
|
113
|
+
return actions.saveLimits(form);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export async function stopTests(form: FormData) {
|
|
117
|
+
return actions.stopTests(form);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export async function allowTests(form: FormData) {
|
|
121
|
+
return actions.allowTests(form);
|
|
122
|
+
}
|
|
123
|
+
|
|
104
124
|
export async function runWeeklyNow() {
|
|
105
125
|
return actions.runWeeklyNow();
|
|
106
126
|
}
|