Datasets:
The dataset viewer is not available for this dataset.
Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.
GSM8K GRPO Dataset for Qwen3-4B Post-Training
A clean, GRPO-ready dataset derived from GSM8K for post-training the Qwen3-4B base model using Group Relative Policy Optimization (GRPO).
Dataset Purpose
This dataset is designed for the GRPO stage of post-training, where the model learns to produce correct mathematical reasoning through reward-based optimization. The key design principles are:
- Verifiable answers: Every example has a single, unambiguous numeric answer
- Clean reward extraction: The
#### <answer>format makes automated answer checking trivial - Moderate difficulty: Balanced to provide useful learning signal (not too easy, not too hard)
- Format consistency: Standardized prompt templates teach the model the exact output format
Dataset Splits
| Split | Size | Description |
|---|---|---|
v1_clean |
7,473 | All GSM8K train examples with clean numeric answers (full baseline) |
v2_medium |
6,100 | Difficulty-balanced: 20% easy / 65% medium / 15% hard |
v3_augmented |
18,300 | v2 examples x 3 prompt template variants (format robustness) |
Recommended for GRPO training: Use v2_medium as the primary training set.
Column Descriptions
| Column | Type | Description |
|---|---|---|
prompt |
string | The formatted prompt including question and answer-format instruction |
question |
string | The original GSM8K question text |
gold_solution |
string | The original GSM8K step-by-step solution (for debugging, not for training) |
gold_answer |
string | The correct final answer as a string (e.g., "72") |
gold_answer_float |
float | The correct final answer as a float (for reward computation) |
difficulty |
string | Difficulty bucket: "easy", "medium", or "hard" |
num_numbers_in_question |
int | Count of numeric values in the question |
num_solution_steps |
int | Number of reasoning steps in the gold solution |
prompt_template |
string | Which prompt template was used: "standard", "variant_a", or "variant_b" |
source |
string | Always "gsm8k" |
Usage with TRL GRPOTrainer
from datasets import load_dataset
from trl import GRPOTrainer, GRPOConfig
import re
# Load the recommended split
dataset = load_dataset("TeamClaude/GRPO-Fine-Tuned", split="v2_medium")
# Define reward function
def math_reward_func(completions, gold_answer, **kwargs):
"""Check if model's final answer matches the gold answer."""
rewards = []
for completion, answer in zip(completions, gold_answer):
# Extract the model's answer from #### format
match = re.search(r"####\s*(.+)", completion)
if match:
model_answer = match.group(1).strip()
model_answer = model_answer.replace(",", "").replace("$", "")
try:
model_val = float(model_answer)
gold_val = float(answer)
rewards.append(1.0 if abs(model_val - gold_val) < 0.01 else 0.0)
except ValueError:
rewards.append(0.0)
else:
rewards.append(0.0)
return rewards
# Optional: format reward to encourage #### output
def format_reward_func(completions, **kwargs):
"""Reward completions that contain the #### format."""
return [0.5 if "####" in c else 0.0 for c in completions]
# Train
trainer = GRPOTrainer(
model="your-sft-checkpoint",
reward_funcs=[math_reward_func, format_reward_func],
train_dataset=dataset,
args=GRPOConfig(
per_device_train_batch_size=4,
num_generations=8,
max_completion_length=512,
),
)
trainer.train()
Filtering Methodology
Answer Filtering
- Extracted final answer from GSM8K's
#### <answer>format - Normalized: removed
$,,,%symbols; converted fractions to decimals - Rejected: answers with units, dates, times, ratios, mixed numbers, or non-numeric text
- Result: 100% of GSM8K train passed (GSM8K is already very clean)
Difficulty Classification
Based on three features:
- Easy: <=2 solution steps, <=3 numbers in question, <=40 word question
- Hard: >=6 solution steps, >=7 numbers, or >=120 word question
- Medium: Everything else
Difficulty Rebalancing (v2_medium)
Target distribution: 20% easy / 65% medium / 15% hard. Medium examples subsampled to match proportions. Easy and hard examples kept in full.
Format Augmentation (v3_augmented)
Each v2 example is replicated with 3 prompt instruction variants:
- standard: "Solve the problem step by step..."
- variant_a: "Work through the arithmetic carefully..."
- variant_b: "Answer the question step by step..."
Source
Built from the train split of openai/gsm8k (7,473 examples).
License
This dataset inherits the MIT license from GSM8K.
- Downloads last month
- 17