Skip to main content

Data Utilities

Utility functions for loading and formatting common benchmark datasets.
These utilities are designed for example datasets and quick prototyping, not core functionality. For production use, load datasets directly using HuggingFace datasets library.

Overview

The verifiers.utils.data_utils module provides:
  • Pre-configured loaders for common benchmarks (GSM8K, MATH, GPQA, etc.)
  • Dataset formatting helpers
  • Answer extraction utilities
  • System prompts for math tasks

Dataset Loaders

load_example_dataset

Load a preprocessed benchmark dataset.
str
default:"gsm8k"
Dataset name. Supported: "aime2024", "aime2025", "amc2023", "gpqa_diamond", "gpqa_main", "gsm8k", "math", "math500", "mmlu", "mmlu_pro", "openbookqa", "openrs", "openrs_easy", "openrs_hard", "prime_code".
str | None
default:"None"
Dataset split. If None, uses the default split for that dataset (usually “test” or “train”).
int | None
default:"None"
Number of examples to load. If None, loads all examples.
int
default:"0"
Random seed for shuffling when n is specified.
Returns: HuggingFace Dataset with question and answer columns. Example:

Formatting Functions

format_dataset

Add example_id and prompt columns to a dataset.
Dataset
required
Input dataset to format.
str | None
System prompt to prepend to all prompts.
Messages | None
Few-shot examples to include before each question.
str
default:"question"
Column name containing questions.
str
default:"answer"
Column name containing answers.
dict
Additional arguments passed to dataset.map().
Returns: Dataset with example_id and prompt columns. Example:

Answer Extraction

extract_boxed_answer

Extract content from LaTeX \boxed{} commands. Finds the last occurrence of \boxed{...} in the text and returns the content between matching braces. If no boxed answer is found or braces don’t match, returns the original text.
str
required
Text containing LaTeX boxed answer (e.g., "\boxed{42}").
Returns: str - Extracted answer content, or original text if no valid boxed answer found. Example:

extract_hash_answer

Extract answer after #### delimiter (GSM8K format). Returns the text after the first #### marker, stripped of leading/trailing whitespace. If no delimiter is found, returns the original text.
str
required
Text containing hash-delimited answer (e.g., "Solution here\n#### 42").
Returns: str - Answer after #### delimiter, or original text if no delimiter found. Example:

strip_non_numeric

Remove all non-numeric characters except periods. Example:

System Prompts

BOXED_SYSTEM_PROMPT

Standard prompt for math problems requiring boxed answers.

THINK_BOXED_SYSTEM_PROMPT

Prompt encouraging explicit reasoning in XML tags. Example:

Supported Datasets

AIME 2024 math competition (15 problems)
AIME 2025 math competition (30 problems, AIME I + II)
AMC 2023 math competition
GPQA Diamond subset (high-quality questions)
GPQA Main dataset
Grade School Math 8K dataset
MATH competition dataset
MATH-500 subset
Massive Multitask Language Understanding
MMLU-Pro (harder variant)
OpenBookQA question answering
OpenRS reasoning problems
Prime verifiable coding problems

Preprocessing Functions

Internal preprocessing functions used by load_example_dataset():
Returns a preprocessing function for the named dataset. Each preprocessor:
  • Extracts question and answer fields
  • Normalizes format (e.g., strips #### delimiters)
  • Handles dataset-specific quirks
These are internal functions. Use load_example_dataset() instead of calling preprocessors directly.

Custom Dataset Example

See Also