Core concepts
- Dataset — A JSON file containing test cases. Each case has an
input, an optionaloutput(the model’s response), an optionalreference(expected answer), and optionalcontext(retrieved documents for RAG). - Evaluator — A function that scores a test case and returns a numeric, boolean, or string score.
- Eval run — The result of running a dataset through one or more evaluators.
Defining a custom evaluator
Useai.defineEvaluator() to create an evaluator. The runner function receives a data point and returns an EvalResponse with one or more scores:
Score schema
Theevaluation field of an EvalResponse follows the Score schema:
LLM-based evaluators
Evaluators can themselves use an LLM to score outputs — commonly called “LLM-as-judge”. This is useful for qualities that are hard to measure programmatically, such as coherence, factuality, or helpfulness:Dataset format
Datasets are JSON files containing an array of data points. Each data point matches theBaseDataPoint schema:
Running evaluations with the CLI
Usegenkit eval:run to run a dataset through all registered evaluators:
Evaluators marked
isBilled: true use LLM calls and may incur API charges. The CLI prompts you to confirm before running billed evaluators. Use --force to skip the confirmation.Built-in evaluators
The@genkit-ai/evaluators plugin provides a set of ready-to-use evaluators:
- TypeScript
- Python
RAGAS evaluators for RAG quality
For Retrieval-Augmented Generation (RAG) pipelines, the@genkit-ai/evaluators package includes RAGAS-based metrics that measure both retrieval and generation quality:
context in your dataset:
Interpreting results
Evaluation results appear in the Dev UI under the Evaluate tab. Each row shows:- Test case — The input and output being scored.
- Score — The numeric or boolean score from each evaluator.
- Status —
PASS,FAIL, orUNKNOWN. - Reasoning — The evaluator’s explanation (for LLM-based evaluators).
- Identify which test cases consistently fail and improve the relevant prompt or retrieval logic.
- Track metrics over time by re-running evaluations after each change.
- Compare two model versions by running both against the same dataset.
Programmatic evaluation
You can also run evaluations programmatically from your code usingai.evaluate():
Developer tools
View evaluation results in the Dev UI.
RAG
Build retrieval-augmented generation pipelines.
Flows
Wrap model calls in observable flows for easier eval.
Plugins overview
Find evaluator plugins in the plugin ecosystem.
