post-training-grpo-rl-training 是什么?
Expert guidance for GRPO/RL fine-tuning with TRL for reasoning and task-specific model training
以上为来源原文,中文用途说明尚待整理。
怎么接入你的 Agent?
- 定位完整 Skill 目录
打开本项目来源,核对
SKILL.md及其引用的脚本和资料。 - 交给你正在用的 Agent
在下面选择客户端,展开并复制安装指令,让 Agent 读取来源后选择安装方式。
- 确认识别,再做具体任务
让 Agent 回报安装目录和识别到的名称
post-training-grpo-rl-training,然后告诉 Agent 你的任务和实际输入,让它先核对触发条件。
展开并复制给 Codex 的安装指令
安装并检查 post-training-grpo-rl-training
请在 Codex 的当前工作环境中安装并检查 post-training-grpo-rl-training 这个 Skill。
项目身份:davila7/claude-code-templates / post-training-grpo-rl-training
来源:https://github.com/davila7/claude-code-templates/blob/c1bc5c1df4ff0bffb9a04d8f7790543681232423/cli-tool/components/skills/ai-research/post-training-grpo-rl-training/SKILL.md
已定位的源文件:cli-tool/components/skills/ai-research/post-training-grpo-rl-training/SKILL.md
1. 先阅读真实 SKILL.md 和它引用的必要文件,确认触发条件、安装方式、依赖与权限;尊重源文件要求的审批步骤。
2. 按当前客户端支持的方式安装完整 Skill 目录,保留已有配置,不只复制一段提示词。涉及缺失凭证、目标目录或权限时先列出缺项并向我确认。
3. 安装后回读实际目录、Skill 名称和识别结果,说明哪些步骤已完成,哪些只是文档检查,不得把安装成功当作任务已经实测。
4. 如来源提供了可安全验证的示例,在我提供所需输入后做一个最小任务;创建、修改、删除、部署或发送内容前,按源文件和我的授权执行。展开并复制给 Claude Code 的安装指令
安装并检查 post-training-grpo-rl-training
请在 Claude Code 的当前工作环境中安装并检查 post-training-grpo-rl-training 这个 Skill。
项目身份:davila7/claude-code-templates / post-training-grpo-rl-training
来源:https://github.com/davila7/claude-code-templates/blob/c1bc5c1df4ff0bffb9a04d8f7790543681232423/cli-tool/components/skills/ai-research/post-training-grpo-rl-training/SKILL.md
已定位的源文件:cli-tool/components/skills/ai-research/post-training-grpo-rl-training/SKILL.md
1. 先阅读真实 SKILL.md 和它引用的必要文件,确认触发条件、安装方式、依赖与权限;尊重源文件要求的审批步骤。
2. 按当前客户端支持的方式安装完整 Skill 目录,保留已有配置,不只复制一段提示词。涉及缺失凭证、目标目录或权限时先列出缺项并向我确认。
3. 安装后回读实际目录、Skill 名称和识别结果,说明哪些步骤已完成,哪些只是文档检查,不得把安装成功当作任务已经实测。
4. 如来源提供了可安全验证的示例,在我提供所需输入后做一个最小任务;创建、修改、删除、部署或发送内容前,按源文件和我的授权执行。展开并复制给 Cursor 的安装指令
安装并检查 post-training-grpo-rl-training
请在 Cursor Agent 的当前工作环境中安装并检查 post-training-grpo-rl-training 这个 Skill。
项目身份:davila7/claude-code-templates / post-training-grpo-rl-training
来源:https://github.com/davila7/claude-code-templates/blob/c1bc5c1df4ff0bffb9a04d8f7790543681232423/cli-tool/components/skills/ai-research/post-training-grpo-rl-training/SKILL.md
已定位的源文件:cli-tool/components/skills/ai-research/post-training-grpo-rl-training/SKILL.md
1. 先阅读真实 SKILL.md 和它引用的必要文件,确认触发条件、安装方式、依赖与权限;尊重源文件要求的审批步骤。
2. 按当前客户端支持的方式安装完整 Skill 目录,保留已有配置,不只复制一段提示词。涉及缺失凭证、目标目录或权限时先列出缺项并向我确认。
3. 安装后回读实际目录、Skill 名称和识别结果,说明哪些步骤已完成,哪些只是文档检查,不得把安装成功当作任务已经实测。
4. 如来源提供了可安全验证的示例,在我提供所需输入后做一个最小任务;创建、修改、删除、部署或发送内容前,按源文件和我的授权执行。展开并复制给 当前 Agent 的安装指令
安装并检查 post-training-grpo-rl-training
请在 当前 Agent 的当前工作环境中安装并检查 post-training-grpo-rl-training 这个 Skill。
项目身份:davila7/claude-code-templates / post-training-grpo-rl-training
来源:https://github.com/davila7/claude-code-templates/blob/c1bc5c1df4ff0bffb9a04d8f7790543681232423/cli-tool/components/skills/ai-research/post-training-grpo-rl-training/SKILL.md
已定位的源文件:cli-tool/components/skills/ai-research/post-training-grpo-rl-training/SKILL.md
1. 先阅读真实 SKILL.md 和它引用的必要文件,确认触发条件、安装方式、依赖与权限;尊重源文件要求的审批步骤。
2. 按当前客户端支持的方式安装完整 Skill 目录,保留已有配置,不只复制一段提示词。涉及缺失凭证、目标目录或权限时先列出缺项并向我确认。
3. 安装后回读实际目录、Skill 名称和识别结果,说明哪些步骤已完成,哪些只是文档检查,不得把安装成功当作任务已经实测。
4. 如来源提供了可安全验证的示例,在我提供所需输入后做一个最小任务;创建、修改、删除、部署或发送内容前,按源文件和我的授权执行。来源原文与资料状态
- 源文件
- 已保存 SKILL.md,抓取于 2026-11-23T04:29:48.865Z
- 中文使用说明
- 尚待整理,保留英文来源内容
- 安装与任务测试
- 本站未执行安装或任务测试
- 来源复核
- 已保留来源记录;当前完整用法未逐项人工复核
展开 SKILL.md 原文、章节与历史收录资料
cli-tool/components/skills/ai-research/post-training-grpo-rl-training/SKILL.md · 抓取时间 2026-11-23T04:29:48.865Z
以下保留源文件的 description、章节及摘录,供核对中文说明;完整文件通过上方链接打开。
抓取成功不代表已完成安装或任务测试。
Expert guidance for GRPO/RL fine-tuning with TRL for reasoning and task-specific model training
查看源文件章节 / Source sections
- 原文:GRPO/RL Training with TRL
- 原文:When to Use This Skill
- 原文:Core Concepts
- 原文:1. GRPO Algorithm Fundamentals
- 原文:2. Reward Function Design Philosophy
- 原文:Implementation Workflow
- 原文:Step 1: Dataset Preparation
- 原文:Step 2: Reward Function Implementation
- 原文:Step 3: Training Configuration
- 原文:Step 4: Model Setup and Training
- 原文:Critical Training Insights
- 原文:1. Loss Behavior (EXPECTED PATTERN)
- 原文:2. Reward Tracking
- 原文:3. Common Pitfalls and Solutions
- 原文:Advanced Patterns
- 原文:1. Multi-Stage Training
- 原文:2. Adaptive Reward Scaling
- 原文:3. Custom Dataset Integration
- 原文:Deployment and Inference
- 原文:Save and Merge LoRA
- 原文:Inference Example
- 原文:Best Practices Checklist
- 原文:Troubleshooting Guide
- 原文:Debugging Workflow
- 原文:Quick Fixes
- 原文:References and Resources
- 原文:Usage Instructions for Agents
原文: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) ---
原文: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:** ``` For each prompt p: 1. Generate N completions: {c₁, c₂, ..., cₙ} 2. Compute rewards: {r₁, r₂, ..., rₙ} 3. Learn to increase probability of high-reward completions relative to low-reward ones in the same group ```
原文:2. Reward Function Design Philosophy
**Golden Rules:** 1. **Compose multiple reward functions** - Each handles one aspect (format, correctness, style) 2. **Scale rewards appropriately** - Higher weight = stronger signal 3. **Use incremental rewards** - Partial credit for partial compliance 4. **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 | ---
原文: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:** ```python from datasets import load_dataset, Dataset SYSTEM_PROMPT = """ Respond in the following format: <reasoning> [Your step-by-step thinking] </reasoning> <answer> [Final answer] </answer> """ def prepare_dataset(raw_data): """ Transform raw data into GRPO-compatible format. Returns: Dataset with columns: - 'prompt': List[Dict] with role/content (system + user messages) - 'answer': str (ground truth, optional but recommended) """ return raw_data.map(lambda x: { 'prompt': [ {'role': 'system', 'content': SYSTEM_PROMPT}, {'role': 'user', 'content': x['question']} ], 'answer': extract_answer(x['raw_answer']) }) ``` **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:** ```python def reward_function_name( prompts, # List[List[Dict]]: Original prompts completions, # List[List[Dict]]: Model generations answer=None, # Optional: Ground truth from dataset **kwargs # Additional dataset columns ) -> list[float]: """ Evaluate completions and return rewards. Returns: List of floats (one per completion) """ # Extract completion text responses = [comp[0]['content'] for comp in completions] # Compute rewards rewards = [] for response in responses: score = compute_score(response) rewards.append(score) return rewards ``` **Example 1: Correctness Reward (Math/Coding)** ```python def correctness_reward(prompts, completions, answer, **kwargs): """Reward correct answers with high score.""" responses = [comp[0]['content'] for comp in completions] extracted = [extract_final_answer(r) for r in responses] return [2.0 if ans == gt else 0.0 for ans, gt in zip(extracted, answer)] ``` **Example 2: Format Reward (Structured Output)** ```python import re def format_reward(completions, **kwargs): """Reward XML-like structured format.""" pattern = r'<reasoning>.*?</reasoning>\s*<answer>.*?</answer>' responses = [comp[0]['content'] for comp in completions] return [1.0 if re.search(pattern, r, re.DOTALL) else 0.0 for r in responses] ``` **Example 3: Incremental Format Reward (Partial Credit)** ```python def incremental_format_reward(completions, **kwargs): """Award partial credit for format compliance.""" responses = [comp[0]['content'] for comp in completions] rewards = [] for r in responses: score = 0.0 if '<reasoning>' in r: score += 0.25 if '</reasoning>' in r: score += 0.25 if '<answer>' in r: score += 0.25 if '</answer>' in r: score += 0.25 # Penalize extra text after closing tag if r.count('</answer>') == 1: extra_text = r.split('</answer>')[-1].strip() score -= len(extra_text) * 0.001 rewards.append(score)
本段为节选,完整内容见源文件。
文件 SHA256:9cf0d6df20b46c8d2709a4e5976983098fca4142202c31960c4f6ddd64065255
仓库许可证记录:MIT;skill-declaration-captured-not-interpreted,查看来源。
Expert guidance for GRPO/RL fine-tuning with TRL for reasoning and task-specific model training
历史收录数据
| 来源仓库 | davila7/claude-code-templates |
|---|---|
| Skill源路径 | cli-tool/components/skills/ai-research/post-training-grpo-rl-training/SKILL.md |
安装前请让使用的Agent先读取这个SKILL.md及其所在目录,确认依赖和所需权限。此页不生成未经来源验证的安装命令。
