kaminocorp/hermes-alpha/grpo-rl-training
Claude Code and agent skill by kaminocorp/hermes-alpha
- community
Checking that the SKILL.md file is still in the repository.
Expert guidance for GRPO/RL fine-tuning with TRL for reasoning and task-specific model training
Install
npx vskill@latest install kaminocorp/hermes-alpha/grpo-rl-trainingSKILL.md
The same SKILL.md was published earlier as kaminocorp/hermes-alpha/grpo-rl-training.
GRPO/RL Training with TRL
Expert-level guidance for implementing Group Relative Policy Optimization (GRPO) using the Transformer Reinforcement Learning (TRL) library. This skill provides battle-tested patterns, critical insights, and production-ready workflows for fine-tuning language models with custom reward functions.
When to Use This Skill
Use GRPO training when you need to:
- Enforce specific output formats (e.g., XML tags, JSON, structured reasoning)
- Teach verifiable tasks with objective correctness metrics (math, coding, fact-checking)
- Improve reasoning capabilities by rewarding chain-of-thought patterns
- Align models to domain-specific behaviors without labeled preference data
- Optimize for multiple objectives simultaneously (format + correctness + style)
Do NOT use GRPO for:
- Simple supervised fine-tuning tasks (use SFT instead)
- Tasks without clear reward signals
- When you already have high-quality preference pairs (use DPO/PPO instead)
Core Concepts
1. GRPO Algorithm Fundamentals
Key Mechanism:
- Generates multiple completions for each prompt (group size: 4-16)
- Compares completions within each group using reward functions
- Updates policy to favor higher-rewarded responses relative to the group
Critical Difference from PPO:
- No separate reward model needed
- More sample-efficient (learns from within-group comparisons)
- Simpler to implement and debug
Mathematical Intuition:
2. Reward Function Design Philosophy
Golden Rules:
- Compose multiple reward functions - Each handles one aspect (format, correctness, style)
- Scale rewards appropriately - Higher weight = stronger signal
- Use incremental rewards - Partial credit for partial compliance
- Test rewards independently - Debug each reward function in isolation
Reward Function Types:
| Type | Use Case | Example Weight | |
|---|---|---|---|
| Correctness | Verifiable tasks (math, code) | 2.0 (highest) | |
| Format | Strict structure enforcement | 0.5-1.0 | |
| Length | Encourage verbosity/conciseness | 0.1-0.5 | |
| Style | Penalize unwanted patterns | -0.5 to 0.5 |
Implementation Workflow
Step 1: Dataset Preparation
Critical Requirements:
- Prompts in chat format (list of dicts with 'role' and 'content')
- Include system prompts to set expectations
- For verifiable tasks, include ground truth answers as additional columns
Example Structure:
Pro Tips:
- Use one-shot or few-shot examples in system prompt for complex formats
- Keep prompts concise (max_prompt_length: 256-512 tokens)
- Validate data quality before training (garbage in = garbage out)
Step 2: Reward Function Implementation
Template Structure:
Example 1: Correctness Reward (Math/Coding)
Example 2: Format Reward (Structured Output)
Example 3: Incremental Format Reward (Partial Credit)
Critical Insight: Combine 3-5 reward functions for robust training. Order matters less than diversity of signals.
Step 3: Training Configuration
Memory-Optimized Config (Small GPU)
High-Performance Config (Large GPU)
Critical Hyperparameters:
| Parameter | Impact | Tuning Advice | |
|---|---|---|---|
num_generations | Group size for comparison | Start with 8, increase to 16 if GPU allows | |
learning_rate | Convergence speed/stability | 5e-6 (safe), 1e-5 (faster, riskier) | |
max_completion_length | Output verbosity | Match your task (512 for reasoning, 256 for short answers) | |
gradient_accumulation_steps | Effective batch size | Increase if GPU memory limited |
Step 4: Model Setup and Training
Standard Setup (Transformers)
Unsloth Setup (2-3x Faster)
Critical Training Insights
1. Loss Behavior (EXPECTED PATTERN)
- Loss starts near 0 and INCREASES during training
- This is CORRECT - loss measures KL divergence from initial policy
- Model is learning (diverging from original behavior to optimize rewards)
- Monitor reward metrics instead of loss for progress
2. Reward Tracking
Key metrics to watch:
reward: Average across all completionsreward_std: Diversity within groups (should remain > 0)kl: KL divergence from reference (should grow moderately)
Healthy Training Pattern:
Warning Signs:
- Reward std → 0 (model collapsing to single response)
- KL exploding (> 0.5) (diverging too much, reduce LR)
- Reward stuck (reward functions too harsh or model capacity issue)
3. Common Pitfalls and Solutions
| Problem | Symptom | Solution | |
|---|---|---|---|
| Mode collapse | All completions identical | Increase num_generations, add diversity penalty | |
| No learning | Flat rewards | Check reward function logic, increase LR | |
| OOM errors | GPU memory exceeded | Reduce num_generations, enable gradient checkpointing | |
| Slow training | < 1 it/s | Enable use_vllm=True, use Unsloth, reduce seq length | |
| Format ignored | Model doesn't follow structure | Increase format reward weight, add incremental rewards |
Advanced Patterns
1. Multi-Stage Training
For complex tasks, train in stages:
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckinghermes-agent/skills/mlops/training/grpo-rl-training/SKILL.md
Popularity
- Repository stars
- 228
- Repository forks
- 34
- 7-day trend score
- 27
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/kaminocorp/hermes-alpha/grpo-rl-training)