teff.eval¶
teff.eval
¶
Evaluation harness: run a workflow over a dataset and score the outputs.
A dataset is a list of examples; each example seeds the workflow state
and optionally carries an expected answer. Outputs are scored by
exact match, by a similarity heuristic, or by an LLM judge.
dataset.jsonl (one JSON object per line)::
{"id": "q1", "query": "What is the mascot of Teff?",
"expected": "a rocket", "input": "You are a helper."}
every key except ``id`` / ``expected`` is merged into the workflow
state as an initial override (on top of the workflow's own
``state.initial``).
Functions:
| Name | Description |
|---|---|
extract_output |
Pick the answer from the final state. |
format_report |
Render an eval report as human-readable lines. |
item_state |
The state overrides contributed by a dataset item. |
judge_with_llm |
Ask an LLM whether actual satisfies expected. |
load_dataset |
Load a dataset from a |
run_eval |
Evaluate dataset against a loaded workflow. |
write_dataset_examples |
Write dataset examples to a JSONL file (helper for authors). |
extract_output
¶
extract_output(state, output_key=None)
Pick the answer from the final state.
Uses output_key when given; otherwise falls back to a heuristic list of common answer keys and finally the whole state as JSON.
Source code in teff/eval.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | |
format_report
¶
format_report(report)
Render an eval report as human-readable lines.
Source code in teff/eval.py
208 209 210 211 212 213 214 215 216 217 218 219 | |
item_state
¶
item_state(item)
The state overrides contributed by a dataset item.
Source code in teff/eval.py
77 78 79 | |
judge_with_llm
async
¶
judge_with_llm(harness, question, expected, actual)
Ask an LLM whether actual satisfies expected.
Returns (verdict, reason) where verdict is "PASS" or "FAIL".
Source code in teff/eval.py
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 | |
load_dataset
¶
load_dataset(path)
Load a dataset from a .json, .jsonl, or .csv file.
Source code in teff/eval.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
run_eval
async
¶
run_eval(
workflow,
dataset,
*,
judge_model=None,
judge_provider=None,
exact=False,
max_examples=None,
output_key=None,
)
Evaluate dataset against a loaded workflow.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workflow
|
tuple[Any, list, dict, dict]
|
A |
required |
dataset
|
list[dict]
|
List of example dicts. |
required |
judge_model
|
str | None
|
Model name for LLM judging (when exact is False). |
None
|
judge_provider
|
str | None
|
Provider key for the judge model. |
None
|
exact
|
bool
|
Score by exact (normalised) string match instead of an LLM. |
False
|
max_examples
|
int | None
|
Cap the number of examples evaluated. |
None
|
output_key
|
str | None
|
State key holding the answer; defaults to a heuristic. |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
A report dict: ``{total, passed, failed, errors, interrupted, |
dict
|
cases, judge}``. |
Source code in teff/eval.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | |
write_dataset_examples
¶
write_dataset_examples(dataset, path)
Write dataset examples to a JSONL file (helper for authors).
Source code in teff/eval.py
222 223 224 225 226 | |