Skip to main content
Evaluation lets you systematically score your model’s outputs against a dataset. This is essential for catching regressions, comparing model versions, and building confidence before deploying changes.

Core concepts

  • Dataset — A JSON file containing test cases. Each case has an input, an optional output (the model’s response), an optional reference (expected answer), and optional context (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

Use ai.defineEvaluator() to create an evaluator. The runner function receives a data point and returns an EvalResponse with one or more scores:

Score schema

The evaluation 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 the BaseDataPoint schema:

Running evaluations with the CLI

Use genkit eval:run to run a dataset through all registered evaluators:
After the run completes, the CLI prints a link to view results in the Dev UI:
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:
Available metrics:

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:
For RAG evaluations, include the retrieved 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.
  • StatusPASS, FAIL, or UNKNOWN.
  • Reasoning — The evaluator’s explanation (for LLM-based evaluators).
Use the results to:
  • 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 using ai.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.