{
 "schema_version": 1,
 "generated": "2026-10-31",
 "id": "huggingface-trl--train-a-reasoning-model-with-trl-grpo",
 "repo": "huggingface/trl",
 "repo_url": "https://github.com/huggingface/trl",
 "repo_slug": "huggingface-trl",
 "title": "Train math reasoning with GRPO",
 "page_title": "How to train math reasoning with GRPO with TRL",
 "summary": "Use GRPOTrainer with the built-in accuracy_reward on a math dataset, the method behind DeepSeek R1.",
 "who": "A researcher who wants to try reinforcement learning on a small instruct model.",
 "problem": "RL training setups are complex and memory hungry.",
 "outcome": "A GRPO-trained checkpoint and a feel for reward-driven training.",
 "steps": [
  "Install TRL with math support using `pip install trl[math_verify]`",
  "Load trl-lib/DeepMath-103K and create a GRPOTrainer with model Qwen/Qwen2.5-0.5B-Instruct and reward_funcs=accuracy_reward",
  "Call trainer.train()",
  "For reasoning models, switch to the reasoning_accuracy_reward function as the README notes"
 ],
 "agent_prompt": "Using huggingface/trl, install `pip install trl[math_verify]`, write a GRPOTrainer script on trl-lib/DeepMath-103K with accuracy_reward and Qwen/Qwen2.5-0.5B-Instruct, and add logging so I can watch the reward climb.",
 "agents": [
  "claude-code",
  "codex",
  "cursor",
  "gemini-cli"
 ],
 "difficulty": "Advanced",
 "time": "half a day",
 "basis": "readme",
 "caveat": "GRPO is more memory efficient than PPO per the README, but still needs a capable GPU.",
 "category": "Software and DevOps",
 "tags": [
  "Software and DevOps"
 ],
 "lang": "python",
 "requirements": [
  "Python with pip",
  "A GPU is strongly recommended; the README covers NVIDIA, AMD and AWS Trainium setups",
  "Access to Hugging Face Hub models and datasets"
 ],
 "risk": "none",
 "seen_in_the_wild": false,
 "mentioned_publicly": false,
 "risks": [
  {
   "tag": "cost",
   "notice": "RL runs are long; budget GPU hours before starting."
  }
 ],
 "best": false,
 "score": 0.8,
 "evidence": [],
 "url": "https://dedupedai.com/use-cases/huggingface-trl/train-a-reasoning-model-with-trl-grpo/",
 "md": "https://dedupedai.com/use-cases/huggingface-trl/train-a-reasoning-model-with-trl-grpo/index.md",
 "disclaimer": "Deduped lists open-source repositories that belong to other people. We do not own, maintain, audit, or vouch for any of them, and a repo appearing here is not an endorsement or a safety check. The use cases, steps, and prompts are written by AI and may be incomplete, outdated, or just wrong. Where a use case is marked \"Seen in the wild\", we link to public posts where someone described something similar, but we have not verified those posts and the use case itself is still our AI's own write-up. Use all of this at your own risk. Only run code, commands, or agents on systems and accounts you are authorized to use, and read the code and every command before you run it, especially anything that touches credentials, files, or the network. Nothing here is professional, security, legal, or financial advice. All trademarks and project names belong to their respective owners, and their use here does not imply affiliation. Content is provided as is, without warranties of any kind. Found a mistake, a safety problem, or something you want removed? Email hello@dedupedai.com and we will look at it promptly.",
 "api": "https://dedupedai.com/api/v1/usecases/huggingface-trl--train-a-reasoning-model-with-trl-grpo.json",
 "api_version": "v1"
}
