본문으로 건너뛰기
Skillpedia
에이전트41k · #6732

grpo-rlvr-training

하는 일

이 기능은 수학 문제를 푸는 것이나 코드를 쓰는 것처럼 자동으로 확인할 수 있는 작업을 위해 AI를 학습시킵니다. GRPO라는 방법과 강화 학습을 사용해 AI가 정답을 맞히도록 배우게 합니다.

사용하는 경우

  • ✓AI가 수학 문제를 풀어야 할 때.
  • ✓AI가 제대로 작동하는 코드를 쓰기를 원할 때.
  • ✓AI의 작업에 명확한 '맞음' 또는 '틀림' 답이 있을 때.

스킬 링크

https://github.com/wshobson/agents/blob/main/plugins/llm-finetuning/skills/grpo-rlvr-training/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/wshobson/agents/blob/main/plugins/llm-finetuning/skills/grpo-rlvr-training/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“AI가 수학 방정식을 풀고 답이 맞는지 확인하도록 학습시켜 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

AI에게 작업을 주면 AI가 풀어 봅니다. 시스템이 자동으로 답이 맞는지 확인합니다. 맞으면 AI는 보상을 받고 더 잘하도록 배웁니다. 틀리면 다시 시도합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

GRPO & RLVR Training

This skill assumes finetuning-method-selection already routed here because the target behavior has a verifiable pass/fail signal — not demonstrations (lora-qlora-recipes) or preference pairs (preference-optimization). What follows is when RL is the right tool, the reference recipe, the mandatory reward-inspection gate, and how to pick a GRPO variant when the base recipe misbehaves.

Input: a routing decision (RLVR via GRPO) plus a verifier (code executor, test suite, schema checker, or grader) for the target task. Output format: a validated GRPO config — the kwarg values in references/grpo-memory.md and the reward functions in references/reward-functions.md, not free-form advice — that llm-finetuning-training-engineer consumes directly.

When RL Applies

GRPO+RLVR only pays off when task success is algorithmically checkable — a unit test passes, a parser accepts the output, a tool call matches an expected schema, a math answer matches a ground truth. If grading the output requires human judgment or a subjective rubric, that's an eval-harness and judge-calibration problem first — see eval-harness-first — not a reason to skip straight to RL.

Before opening a GRPO run, confirm the model can sometimes succeed on the target task already. RL sharpens an existing capability by reweighting toward the samples that already work; it does not install a capability from zero.

  • The model never succeeds, even at low temperature across many samples: the gap is format or task understanding, not policy refinement. Route back to SFT first (lora-qlora-recipes) and only return to this skill once the base success rate is nonzero.
  • The model succeeds sometimes, inconsistently: this is the GRPO sweet spot — proceed to The Recipe below.

The standing rule for the whole plugin: DPO for taste, GRPO for reasoning. If the signal is a preference between two acceptable outputs, that's preference-optimization, not this skill.

The Recipe

The reference recipe is TRL's GRPOTrainer with vLLM-backed generation:

from trl import GRPOConfig, GRPOTrainer

grpo_args = GRPOConfig(
    output_dir="./outputs-grpo",
    use_vllm=True,
    vllm_mode="colocate",       # single GPU; "server" for multi-GPU
    num_generations=8,          # floor — fewer starves the group-relative baseline
    learning_rate=5e-7,         # settled range for GRPO
    beta=0.01,                  # KL coefficient vs the reference policy
    per_device_train_batch_size=8,
    gradient_accumulation_steps=4,
    bf16=True,
    logging_steps=10,
    seed=3407,
)

trainer = GRPOTrainer(
    model=SFT_CHECKPOINT,
    args=grpo_args,
    reward_funcs=[format_reward, correctness_reward],   # references/reward-functions.md
    train_dataset=prompts,       # prompt-only — GRPO generates its own completions
    processing_class=tokenizer,
)

trainer.train()
  • vllm_mode="colocate" runs generation and training on the same GPU — the default for a single-GPU box.
  • vllm_mode="server" points at a separate vLLM server process and is the multi-GPU path — generation and training don't compete for the same device.
  • num_generations ≥ 8 is a floor, not a suggestion: GRPO's advantage estimate is relative to the group mean, and fewer than 8 samples per prompt produces a noisy baseline.
  • Reward is composite — a format reward (did the output parse / match the required structure) plus a correctness reward (did the answer verify). A well-formed-but-wrong answer and a malformed one should not score identically; correctness alone loses that signal.
  • learning_rate=5e-7 and beta=0.01 are the settled starting point; deviate only after the base run is stable and reward-inspected (below).

Memory sizing for this recipe by target size class: references/grpo-memory.md.

The Inspection Rule

Run the reward function against 50–100 sampled outputs and manually read the results before starting the actual training run. This is a gate, not a one-time sanity check.

If the reward function's judgment disagrees with a human reading of that sample, fix the reward function first. Training against an uninspected reward, or tuning hyperparameters to compensate for one silently scoring the wrong thing, is how a run reward-hacks: the model optimizes cleanly toward the wrong target, and that doesn't surface as a training-loop bug.

…

자주 묻는 질문

'검증 가능하다'는 무슨 뜻인가요?

사람이 판단하지 않아도 컴퓨터가 답이 맞는지 틀린지 확실히 알 수 있다는 뜻입니다.

이 기능을 쓰지 말아야 하는 경우는 언제인가요?

시를 쓰거나 조언을 하는 것처럼 사람의 의견이 필요한 작업이라면 이 기능은 적합하지 않습니다. 객관적인 답이 있는 작업에 가장 잘 맞습니다.

AI가 아무것도 맞히지 못하면 어떻게 하나요?

조정을 해도 계속 맞히지 못한다면 기초 학습이 더 필요할 수 있습니다. 이 기능은 AI가 이미 조금 할 줄 아는 기술을 향상시키는 데 쓰며, 처음부터 가르치는 용도가 아닙니다.

상세 정보

작성자의 원본 설명

Train reasoning and verifiable-task behavior with GRPO and reinforcement learning from verifiable rewards (RLVR). Use when task success is algorithmically checkable (math, code, tool calls, structured output), when designing GRPO reward functions, or when a GRPO run diverges or reward-hacks.

repo: wshobson/agents

인기도

GitHub 스타
41k
순위
#6732
라이선스
MIT
업데이트
2026. 10. 15.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬