Skip to main content
This example demonstrates the simplest type of Verifiers environment: single-turn question answering with symbolic verification. Models solve grade school math word problems using natural language reasoning.

Overview

The GSM8K environment provides:
  • Dataset: 8.5K grade school math word problems
  • Format: Single-turn response (no tools or code execution)
  • Evaluation: Symbolic math verification of final answers
  • Difficulty: Elementary to middle school level

Complete Implementation

Here’s the full working implementation from environments/gsm8k/gsm8k.py:

How It Works

1. Dataset Loading

GSM8K contains grade school math word problems:
Dataset size:
  • Training: 7,473 problems
  • Test: 1,319 problems
Dataset format:

2. System Prompt

The default system prompt uses the standard BOXED_SYSTEM_PROMPT:
This encourages:
  • Step-by-step reasoning (chain of thought)
  • Clear final answer formatting using \boxed{}

3. Evaluation with MathRubric

MathRubric handles answer extraction and verification:
Features:
  • Extracts answers from \boxed{} notation
  • Symbolic equivalence checking (handles different representations)
  • Numerical tolerance for floating-point answers
  • Returns 1.0 for correct, 0.0 for incorrect

4. Single-Turn Environment

SingleTurnEnv is the simplest environment type:
  • Model receives question
  • Model generates single response
  • Response is evaluated
  • No multi-turn interaction or tools

Example Interactions

Question: Janet’s ducks lay 16 eggs per day. She eats three for breakfast every morning and bakes muffins for her friends every day with four. She sells the remainder at the farmers’ market daily for $2 per fresh duck egg. How much in dollars does she make every day at the farmers’ market?Model Response: Let me work through this step-by-step:
  1. Janet’s ducks lay 16 eggs per day
  2. She eats 3 eggs for breakfast
  3. She uses 4 eggs for muffins
  4. Eggs remaining: 16 - 3 - 4 = 9 eggs
  5. She sells each egg for $2
  6. Total earnings: 9 × 2=2 = 18
Therefore, Janet makes 18\boxed{18} dollars every day at the farmers’ market.Result: ✓ Correct (reward = 1.0)

Running the Environment

Installation

Quick Evaluation

Training Dataset

Custom Configuration

Configuration Options

Key Features

Separate Train/Eval Datasets

GSM8K demonstrates proper train/eval split:
When running prime eval run, the eval dataset is used by default.

Answer Format Flexibility

MathRubric handles various answer formats:

Symbolic Verification

MathRubric uses symbolic math verification:

Metrics Tracked

  • correct_answer: 1.0 if answer matches ground truth, 0.0 otherwise
  • reward: Same as correct_answer for this simple environment

Advanced Usage

Custom System Prompts

Experiment with different prompting strategies:

Filtering Dataset

Create custom dataset subsets:

Adding Metrics

Track additional metrics beyond correctness:

Comparison with Math Python

Next Steps