Quick Start
1
Load a task set
Read a JSONL file into
EvalCase objects.2
Run the suite on the loaded cases
Run the cases and get an
EvalReport.3
Export what passed
Write the passing runs as chat-format training data.
Input Format
Each line is one JSON object describing a task. The minimal shape carries aname, an input, and an expected answer.
metadata.
// comments are skipped.
Output Format
Export writes one chat-format JSON object per line — the shape OpenAI’s fine-tuning API expects.system_prompt to prepend a system message to every row.
result.record["input"]; the completion is result.actual_output.
How It Works
load_cases maps aliases, folds extra columns into metadata, and auto-names rows; export_sft keeps only passing runs at or above min_score.
Aliases map friendly column names onto the case fields.
Behaviour Worth Knowing
The loader is forgiving where it costs nothing and strict where it matters.- Unrecognised columns fold into
metadatainstead of being dropped, sosource/difficulty/idsurvive into the report. - Missing
nameauto-populates ascase_1,case_2, … by position among data rows. - Blank lines and
//comment lines are skipped; the physical file line is preserved, sofile:900really is line 900 in the editor. - A malformed line is reported by
file:line, not a generic “invalid JSON”. - A non-object line (e.g.
[1, 2, 3]) is refused with “must be a JSON object”. - An empty file raises
DatasetError— an empty task set would otherwise report a perfect pass rate over nothing. - Only
passed=Trueruns withscore >= min_scoreare exported. - A run missing either a prompt or a completion is skipped, never silently shrinking the set.
- A zero-record export raises
DatasetErrorrather than writing an empty file that looks like success. DatasetErrorsubclassesValueError, so existingexcept ValueErrorhandlers still catch it.
Python API
Import the five public helpers from the top-level eval package.load_cases
load_cases(path, *, case_cls=None) -> List[EvalCase] reads a JSONL task set into EvalCase objects.
Raises:
DatasetError on missing file, malformed line, non-object line, or empty file — with file:line when the fault is inside the file.
iter_jsonl
iter_jsonl(path) -> Iterator[Dict[str, Any]] yields one dict per data line, with the same error handling but no aliasing or metadata folding.
export_sft
export_sft(report, path, *, min_score=1.0, system_prompt=None) -> int writes passing runs to path and returns the count written.
Raises:
DatasetError if no run scored high enough, or if report is not an EvalReport / list.
sft_records
sft_records(report, *, min_score=1.0, system_prompt=None) -> List[Dict[str, Any]] applies the same selection logic but returns the records in memory instead of writing them.
DatasetError
DatasetError(ValueError) is raised for every dataset read or write failure. As a ValueError subclass, existing except ValueError handlers still catch it.
Common Patterns
Portable in, portable out
Load a Hugging Face-exported JSONL withprompt / answer columns and export a file OpenAI’s fine-tuning API accepts unchanged.
Lower the bar for a small dataset
Keep more attempts when the suite is small by loweringmin_score — a deliberate trade against SFT quality.
Persist a system prompt with each training row
Passsystem_prompt= so the fine-tuned model learns the same persona the eval was scored under.
Best Practices
Fold provenance columns into metadata, don't strip them
Fold provenance columns into metadata, don't strip them
The loader keeps
source / difficulty / id automatically — leave them in your JSONL so the report carries where each case came from.Set min_score above your CI gate, not equal to it
Set min_score above your CI gate, not equal to it
A run that barely passed is a fragile teacher. Export above your gate so training data reflects confident wins, not marginal ones.
Never edit a training file by hand
Never edit a training file by hand
Regenerate
train.jsonl from the eval report instead of editing it, so provenance stays honest and reproducible.Keep // comment lines in the source dataset
Keep // comment lines in the source dataset
Comment lines are skipped at load time and make the file self-documenting — describe each section inline without breaking the loader.
Related
Evaluation Suite
Run every evaluator you enable as one CI gate
Train Package
Fine-tune on the JSONL that export_sft produces
Dataset Tooling
Prepare and inspect training datasets

