Skip to main content

Overview

Verifiers uses the HuggingFace datasets library for loading and manipulating training and evaluation data. Each dataset row becomes a rollout during generation or evaluation.

Dataset Schema

Required Columns

Datasets are automatically processed by the environment to include:
  • example_id - Integer ID for grouping rollouts (auto-generated if missing)
  • prompt - Messages to send to the model (list of chat messages)
  • task - Task identifier for routing in EnvGroup (defaults to env_id)

Optional Columns

  • answer - Ground truth for scoring (string)
  • info - Structured metadata (dict or JSON string)
When using info, prefer JSON strings if rows have different schemas (different fields or nested structures). The environment automatically parses JSON strings into dicts during rollout initialization.

Building Prompts

Direct Prompt Construction

Provide a prompt column with pre-formatted chat messages:

Question-Based Construction

Use a question column and let the environment wrap it:

System Prompts and Few-Shot Examples

Add system prompts and few-shot examples via environment parameters:
Result:
Behavior:
  • If dataset has prompt column: system_prompt is prepended (if not already present), few_shot is ignored
  • If dataset has question column: both system_prompt and few_shot are applied

Dataset Builders (Lazy Loading)

For large datasets or when running multiple environment replicas, defer dataset loading using a DatasetBuilder - a callable that returns a Dataset:
When to use builders:
  • Dataset loading is expensive (e.g., downloading from HuggingFace Hub)
  • Multiple environment replicas don’t all need to own the dataset
  • You want to parameterize dataset creation without loading immediately
Lazy loading behavior:
When a raw Dataset is passed (not a builder), it’s loaded eagerly during environment initialization for backwards compatibility.

Training vs Evaluation Datasets

Environments support separate datasets for training and evaluation:
Fallback behavior:
  • If eval_dataset is not provided, evaluate() falls back to dataset
  • If neither is provided, environment initialization raises ValueError

Dataset Access Methods

get_dataset()

Retrieve the training dataset with optional sampling:
Type signature:

get_eval_dataset()

Retrieve the evaluation dataset:
Type signature:

Dataset Formatting

The environment automatically formats datasets during initialization:

Example ID Assignment

Prompt Construction

Task Assignment

Loading Example Datasets

Verifiers includes built-in example datasets:

Creating Datasets Programmatically

From Lists

From HuggingFace Hub

From Pandas DataFrame

Using make_dataset()

Static helper for creating datasets from rollout inputs:

Dataset Transformations

Use the datasets library’s .map() for preprocessing:
Configure mapping parallelism:

Info Column Patterns

Simple Metadata

Heterogeneous Schemas (JSON Strings)

Tool Definitions in Info

Store per-example tool definitions:
The environment automatically extracts and normalizes info["tool_defs"] during state initialization.

Dataset Persistence

Saving to Disk

Pushing to HuggingFace Hub

Rollouts Per Example

Generate multiple rollouts per dataset row for best-of-N sampling or diversity:
Implementation:

Example: Complete Dataset Pipeline

When using DatasetBuilder, ensure the builder function is deterministic if you need reproducible dataset ordering across runs. Use fixed seeds for shuffling operations.