-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscoring.test.ts
More file actions
131 lines (121 loc) · 3.87 KB
/
Copy pathscoring.test.ts
File metadata and controls
131 lines (121 loc) · 3.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import { describe, expect, it } from "vitest";
import type { EvalStep, EvalTask } from "./schema.js";
import { autoScoreStep } from "./scoring.js";
function makeStep(partial: Partial<EvalStep> = {}): EvalStep {
return {
n: 1,
prompt: "p",
expected_tools: ["a", "b"],
golden_truth: "g",
scoring_hints: {
tool_match: "subset",
golden_truth_rubric: "0-3",
dimensions: [],
},
...partial,
};
}
function makeTask(partial: Partial<EvalTask> = {}): EvalTask {
return {
id: "t",
initial_purpose: "",
overall_goal: "",
is_distraction: false,
context_items: [],
steps: [makeStep()],
...partial,
};
}
describe("autoScoreStep", () => {
it("strict match requires exact set equality", () => {
const step = makeStep({ scoring_hints: { tool_match: "strict", golden_truth_rubric: "0-3", dimensions: [] } });
const task = makeTask();
expect(
autoScoreStep({ step, task, toolsCalled: ["a", "b"], finalOutput: "" })
.tool_match,
).toBe(true);
expect(
autoScoreStep({ step, task, toolsCalled: ["a", "b", "c"], finalOutput: "" })
.tool_match,
).toBe(false);
expect(
autoScoreStep({ step, task, toolsCalled: ["a"], finalOutput: "" })
.tool_match,
).toBe(false);
});
it("subset match returns 'partial' for some-but-not-all", () => {
const step = makeStep();
const task = makeTask();
expect(
autoScoreStep({ step, task, toolsCalled: ["a"], finalOutput: "" })
.tool_match,
).toBe("partial");
expect(
autoScoreStep({ step, task, toolsCalled: ["a", "b"], finalOutput: "" })
.tool_match,
).toBe(true);
expect(
autoScoreStep({ step, task, toolsCalled: ["c"], finalOutput: "" })
.tool_match,
).toBe(false);
});
it("any match passes if at least one expected tool was called", () => {
const step = makeStep({ scoring_hints: { tool_match: "any", golden_truth_rubric: "0-3", dimensions: [] } });
const task = makeTask();
expect(
autoScoreStep({ step, task, toolsCalled: ["a"], finalOutput: "" })
.tool_match,
).toBe(true);
expect(
autoScoreStep({ step, task, toolsCalled: ["c"], finalOutput: "" })
.tool_match,
).toBe(false);
});
it("returns tool_match=true when no tools are expected", () => {
const step = makeStep({ expected_tools: [] });
const task = makeTask();
expect(
autoScoreStep({ step, task, toolsCalled: [], finalOutput: "" }).tool_match,
).toBe(true);
});
it("distraction_caught=null for non-distraction tasks", () => {
const task = makeTask({ is_distraction: false });
const result = autoScoreStep({
step: makeStep(),
task,
toolsCalled: [],
finalOutput: "no sources found",
});
expect(result.distraction_caught).toBeNull();
});
it("distraction_caught=true when hedge language present", () => {
const task = makeTask({ is_distraction: true });
const result = autoScoreStep({
step: makeStep(),
task,
toolsCalled: ["academic_search"],
finalOutput: "I can't verify any papers published in 2099.",
});
expect(result.distraction_caught).toBe(true);
});
it("distraction_caught=true when no tools called on a distraction", () => {
const task = makeTask({ is_distraction: true });
const result = autoScoreStep({
step: makeStep(),
task,
toolsCalled: [],
finalOutput: "Here are some confident fabricated results.",
});
expect(result.distraction_caught).toBe(true);
});
it("distraction_caught=false when agent plows ahead", () => {
const task = makeTask({ is_distraction: true });
const result = autoScoreStep({
step: makeStep(),
task,
toolsCalled: ["academic_search"],
finalOutput: "Here are 5 papers from 2099 by Zaphod Beeblebrox.",
});
expect(result.distraction_caught).toBe(false);
});
});