grpo-rl-training

Implements GRPO reinforcement learning fine-tuning of language models with TRL and custom reward functions.

14|5|Updated Apr 9, 2026
One-click install
npx skills add https://github.com/MLT-OSS/hermes-agent-go --skill grpo-rl-training-mlt-oss
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: grpo-rl-training
Source: https://github.com/MLT-OSS/hermes-agent-go/tree/main/skills/mlops/training/grpo-rl-training
Command: npx skills add https://github.com/MLT-OSS/hermes-agent-go --skill grpo-rl-training-mlt-oss

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires transformers, trl, datasets, peft, torch.

What problem does it solve? Fine-tuning language models to follow strict output formats or excel at verifiable tasks like math and code is difficult without preference data. This Skill provides a complete workflow for Group Relative Policy Optimization (GRPO) training with TRL, covering dataset preparation, reward function design, training configuration, and debugging. ## Core Features & Use Cases - Reward Function Library: 20+ ready-made reward functions for correctness, format compliance, length control, and style, with preset collections for math reasoning, code generation, summarization, and Q&A. - Production Training Template: A fully documented training script using Qwen 2.5 1.5B with LoRA, three composed reward functions, and memory-optimized GRPOConfig settings. - Training Diagnostics: Guidance on interpreting GRPO-specific metrics (reward, reward_std, KL divergence), expected loss behavior, and fixes for mode collapse, OOM errors, and format non-compliance. - Use Case: Train a model to always respond with <reasoning> and <answer> XML tags while maximizing math answer correctness on GSM8K, monitoring reward progression instead of loss. ## Quick Start Ask the agent to set up GRPO training on the GSM8K dataset using the basic training template with format and correctness reward functions.

Frequently Asked Questions about grpo-rl-training

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I train a model with GRPO using TRL?

Prepare a dataset with chat-formatted prompts, define 3-5 reward functions returning float scores per completion, configure GRPOConfig with num_generations of 8-16, and pass everything to GRPOTrainer. The included template shows a complete working setup with Qwen 2.5 1.5B and LoRA.

What reward functions should I use for GRPO training?

Combine 3-5 reward functions covering correctness (weight 2.0), format compliance (0.5-1.0), and length or style (0.1-0.5). Test each function independently before training, and use incremental partial-credit rewards for format enforcement.

Why does loss increase during GRPO training?

Rising loss is expected in GRPO because it measures KL divergence from the initial policy as the model diverges to optimize rewards. Monitor reward, reward_std, and KL metrics instead of loss to judge training progress.

When should I use GRPO instead of DPO or SFT?

Use GRPO for verifiable tasks with objective reward signals like math or code, or to enforce output formats without preference pairs. Use SFT for simple supervised tasks and DPO or PPO when you already have high-quality preference data.

How do I fix mode collapse in GRPO training?

Mode collapse appears when reward_std drops toward zero and completions become identical. Increase num_generations for more within-group diversity, add a diversity or repetition penalty reward, and verify reward functions are not overly harsh.

Can GRPO training run on a small GPU?

Yes, use per_device_train_batch_size of 1 with gradient accumulation, LoRA with rank 16, the adamw_8bit optimizer, and bf16 precision. Unsloth provides 2-3x speedup with 4-bit loading, and reducing num_generations lowers memory usage.