Skip to main content
An evaluation is a test suite for your AI capability. It runs your capability against a of test cases and scores the results using . This page explains how to write evaluation functions using Axiom’s Eval API.

Anatomy of an evaluation

The Eval function defines a complete test suite for your capability. Here’s the basic structure:

Key parameters

  • data: An array of test cases, or a function that returns an array of test cases. Each test case has an input (what you send to your capability) and an expected output (the ground truth).
  • task: An async function that executes your capability for a given input and returns the output.
  • scorers: An array of scorer functions that evaluate the output against the expected result.
  • metadata: Optional metadata like a description or tags.

Creating collections

The data parameter defines your collection of test cases. Start with a small set of examples and grow it over time as you discover edge cases.

Inline collections

For small collections, define test cases directly in the evaluation:

External collections

For larger collections, load test cases from external files or databases:
We recommend storing collections in version control alongside your code. This makes it easy to track how your test suite evolves and ensures evaluations are reproducible.

Defining the task

The task function executes your AI capability for each test case. It receives the input from the test case and should return the output your capability produces.
The task function should generally be the same code you use in your actual capability. This ensures your evaluations accurately reflect real-world behavior.

Creating scorers

Scorers evaluate your capability’s output. They receive the input, output, and expected values, and return a score (a number between 0-1, or boolean).

Custom scorers

Create custom scorers using the Scorer wrapper:
Scorers can return just a score, or an object with a score and metadata:

Using autoevals

The autoevals library provides prebuilt scorers for common tasks:
Use multiple scorers to evaluate different aspects of your capability. For example, check both exact accuracy and semantic similarity to get a complete picture of performance.

Complete example

Here’s a complete evaluation for a support ticket classification system:
src/lib/capabilities/classify-ticket/evaluations/spam-classification.eval.ts

File naming conventions

Name your evaluation files with the .eval.ts extension so they’re automatically discovered by the Axiom CLI:
The CLI will find all files matching **/*.eval.{ts,js,mts,mjs,cts,cjs} based on your axiom.config.ts configuration.

What’s next?