Skip to main content
You are evaluating a SQL generation feature and have 80 “question + expected result” samples. The check logic is the same for each: send the question, run the SQL, compare the result. If you write one file per sample, changing the check logic once means changing it in 80 places. Data-driven tests let you write the logic once and generate many evals from a dataset. Large sets of same-shaped tests such as intent classification, retrieval QA, and tool selection are a good fit.

Export a set of evals from one file

Put the samples in an array, use map to generate a defineEval for each row, and default-export the whole array. The check logic is written once, and changing it applies to every sample:

Confirm each eval’s ID

When you export an array, NiceEval numbers each eval by position. If the file is evals/sql.eval.ts, the generated IDs are:
The numbers are zero-padded to a fixed width, which makes them easy to reference and filter by prefix. Note that when the array order changes, the same sample’s ID changes with it. When the data source already has stable case, issue, or benchmark IDs, export an object instead and use those IDs as keys:
When the file is evals/swelancer.eval.ts and the key is 15193, the ID is swelancer/15193. A key must be one non-empty path segment: it cannot be . or .., and cannot contain /, \\, or control characters. NiceEval sorts keys lexicographically, so when the data source returns them in a different order, the run order and IDs stay the same. Before running, use pnpm exec niceeval exp local sql --dry to confirm which IDs were generated and how many there are.

Read a dataset from YAML or JSON

As samples grow, a separate data file is easier to maintain. Read it with loadYaml or loadJson, passing a validation function:
loadYaml and loadJson require a validation function (decoder). The file content only appears as an unknown type inside the validation function; once validation passes, the return value is typed data you can use directly. When the data file has the wrong format, the validation function throws, and this eval file fails to load.

Run only part of the dataset

Write an eval ID prefix after the Experiment to run only some of them:
After the run, view results in the terminal with pnpm exec niceeval show, or in the browser with pnpm exec niceeval view. Each sample is an independent eval, and the failing ones are listed separately.

Choose a dataset or separate files

Every sample follows exactly the same flow; only the input and expected output differ.
A dataset suits covering one feature with many similar samples; separate eval files suit scenarios with complex flows.