text stringlengths 0 59.1k |
|---|
- **For Viteval Users**: [View Available Viteval Scorers](https://viteval.dev/api/scorers?ref=voltagent) |
- **Recommended**: [VoltAgent CLI Reference](/evaluation-docs/cli-reference) - Use native VoltAgent evaluations |
- **Recommended**: [Experiments Guide](/evaluation-docs/experiments) - Learn about VoltAgent's evaluation system |
- **Coming Soon**: VoltOps integration for enhanced evaluation management |
<|endoftext|> |
# source: VoltAgent__voltagent/website/evaluation-docs/offline-evaluations.md type: docs |
--- |
title: Offline Evaluations |
sidebar_position: 2 |
--- |
# Offline Evaluations |
Offline evaluations run against a fixed dataset and produce deterministic results. Use them for regression testing, CI gates, and comparing model or prompt changes before deployment. |
This guide walks you through building an evaluation experiment step-by-step, from a basic setup to advanced configurations. |
## Where offline runs show up |
When you run an experiment with a `voltOpsClient`, each execution is stored as an Eval Run in VoltOps. You can inspect items, scores, pass criteria, and summaries in the Console. Threshold failures also participate in annotation automation for human review. If you omit `voltOpsClient`, the run executes locally and resu... |
## Step 1: Create a Basic Experiment |
Start with the simplest possible experiment using `createExperiment`. You need three things: an `id`, a `dataset` with inline items, and a `runner` function. |
```ts |
import { createExperiment } from "@voltagent/evals"; |
import { Agent } from "@voltagent/core"; |
import { openai } from "@ai-sdk/openai"; |
export default createExperiment({ |
id: "offline-smoke", |
dataset: { |
items: [ |
{ |
id: "1", |
input: "The color of the sky", |
expected: "blue", |
}, |
{ |
id: "2", |
input: "2+2", |
expected: "4", |
}, |
], |
}, |
runner: async ({ item }) => { |
const supportAgent = new Agent({ |
name: "offline-evals-support", |
instructions: "You are a helpful assistant. Answer questions very short.", |
model: openai("gpt-4o-mini"), |
}); |
const result = await supportAgent.generateText(item.input); |
return { |
output: result.text, |
}; |
}, |
}); |
``` |
The `runner` function receives each dataset item and returns an output. The runner can return the output directly or wrap it in an object with additional metadata. |
At this point, your experiment runs but doesn't evaluate anything. Let's add scoring. |
## Step 2: Add a Scorer |
Add a scorer to evaluate the runner's output against the expected value. Start with a basic heuristic scorer like `levenshtein`, which measures string similarity. |
```ts |
import { createExperiment } from "@voltagent/evals"; |
import { Agent } from "@voltagent/core"; |
import { openai } from "@ai-sdk/openai"; |
import { scorers } from "@voltagent/scorers"; |
export default createExperiment({ |
id: "offline-smoke", |
dataset: { |
items: [ |
{ |
id: "1", |
input: "The color of the sky", |
expected: "blue", |
}, |
{ |
id: "2", |
input: "2+2", |
expected: "4", |
}, |
], |
}, |
runner: async ({ item }) => { |
const supportAgent = new Agent({ |
name: "offline-evals-support", |
instructions: "You are a helpful assistant. Answer questions very short.", |
model: openai("gpt-4o-mini"), |
}); |
const result = await supportAgent.generateText(item.input); |
return { |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.