エージェント技術の習得:AI エージェント強化学習
NVIDIA は、AI エージェントが自律的にタスクを遂行するための強化学習手法に関する技術的アプローチと応用可能性を解説し、次世代エージェント開発の基盤となる重要な知見を示した。
キーポイント
自律型エージェントのための強化学習アプローチ
AI エージェントが複雑な環境下で自律的に意思決定を行いタスクを完遂するための、NVIDIA が提案する強化学習の具体的な技術的枠組みについて解説している。
実用的な応用可能性の提示
理論的な手法だけでなく、実際の業務やシナリオにおける適用事例を示すことで、開発者がどのようにこの技術を現場に落とし込むべきかを示唆している。
次世代 AI エージェントの開発基盤
単なるチャットボットを超えた、自律的な行動が可能になる「Agentic Techniques」の実装において、強化学習が果たす決定的な役割を強調している。
影響分析・編集コメントを表示
影響分析
本記事は、AI エージェントが単なる情報処理ツールから自律的な行動主体へと進化するための技術的転換点を示しており、業界全体における「Agentic AI」の実装基準を高める影響を持つ。特に NVIDIA のプラットフォームを活用した強化学習の具体例は、開発者がより高度な自律システムを構築する際の指針となり、実用化のスピードを加速させる可能性が高い。
編集コメント
「AI エージェント」というホットトピックにおいて、その中核をなす強化学習の具体的な実装手法に焦点を当てた記事は、開発者にとって極めて示唆に富んでいます。NVIDIA の技術的知見が、次世代自律システムの構築における重要な指針となるでしょう。
Reinforcement learning(強化学習)は、AI アシスタント内の人間フィードバックによる強化学習(RLHF)から、推論やエージェントタスク向けの新しい検証可能報酬による強化学習(RLVR)ワークフローに至るまで、言語モデルの整合性を図る上で中心的な役割を果たしています。
現在、強化学習は、企業がドメイン固有のワークフローに対してより正確なエージェントを必要とする 専門特化型 AI において、実用的な技術として普及しつつあります。オープンモデルはデータ、知的財産、および展開における制御性を高めますが、強化学習はドメイン固有の成功基準をトレーニングシグナルへと変換します。
フロンティア研究所では、強化学習が汎用モデルの能力を向上させることができることが示されています。OpenAI は大規模な強化学習を用いて o シリーズモデルを訓練し、DeepSeek-R1 は、グループ相対ポリシー最適化(GRPO)と検証可能報酬が数学、コード、および推論行動をどのように改善するかを示しました。
NVIDIA Nemotron 3 Super は、21 の NVIDIA NeMo Gym ベリファイアと 37 のデータセットにわたるマルチ環境強化学習を用いてポストトレーニングされ、約 120 万の環境ロールアウトを生成しました。
このガイドは、モデル構築者、研究チーム、およびエージェント開発者が、いつ強化学習(RL)を使用すべきかを判断し、長時間実行される agents に対して最初の検証可能な RL トレーニングループを実行する方法を学ぶために役立ちます。
エージェントにとっての RL の重要性
組織は、セキュリティのトリアージ、科学的発見、CLI オートメーション、カスタマーサポート、データ分析、および内部ツールの利用などのワークフローに特化したエージェントを必要としています。Nemotron などのオープンモデルをカスタマイズすることで、これが現実的なものになります。チームは、データ、知的財産(IP)、およびデプロイメントに対するコントロールを保ちながら、精度と速度のために特化することができます。
プロンプティング、RAG(検索拡張生成)、およびツールを使用すれば、ある程度の成果は得られます。モデルをエージェントの脳、エージェントハネスをその体、そしてツールが作用する作業領域と考えるとよいでしょう。ハネスを改善したりツールを追加したりすることは役立ちますが、必ずしもモデルの行動を変えるわけではありません。もしエージェントがツールの呼び出しミスを繰り返す場合や、長時間のワークフローで失敗する場合、出力形式が正しくない場合、あるいは間違った戦略を選択する場合、トレーニングシグナルが必要です。そこが強化学習(RL)の出番です。
RL(強化学習)を用いることで、成功の定義を設定し、試行を生成し、それらを採点してモデルの重みを更新することで、成功した行動がより起こりやすくなります。エージェントシステムにおいては、この報酬は検証者から得られます:テストやツール実行、スキーマ検証、シミュレーター、報酬モデル、LLM-as-judge(大規模言語モデルによる審査)、人間の選好ラベル、またはその他のタスク固有のフィードバックを用いて出力や軌跡を採点するコードです。
image*図 1. 環境ファーストの RL 学習ワークフロー*
Nemotron、NVIDIA NeMo RL、および NVIDIA NeMo Gym は、OpenRLHF、PrimeIntellect、SGLang、Unsloth、veRL、vLLM などのエコシステムツールと連携するオープンモデル、ポストトレーニングのワークフロー、環境インフラストラクチャを提供しています。
RAG、プロンプト、SFT、および RL:いつ何を使うべきか
「どのアルゴリズムを使うべきか?」から始めるのは避けてください。
「どのような行動を増やしたいのか、またそれをどのように測定するのか?」から始めてください。
以下に意思決定マトリックスの例を示します:
問題最初に試すべき技術
モデルがドメインの事実を欠いているRAG またはデータ注入
モデルがフォーマットに従わないプロンプト、その後 SFT(教師あり微調整)
モデルが例を模倣する必要があるSFT *(LoRA や QLoRA を用いた効率的な適応)*
好ましい出力と拒否された出力があるDPO(直接最適化による差分学習)
成功をアルゴリズム的に検証できるRLVR(強化学習による検証)と GRPO
微妙な人間の選好の整合性が必要であるRLHF または報酬モデリング
エージェントは、複数のツール呼び出し、状態更新、または会話ターンを伴う長期ワークフロー全体で失敗します。環境ベースの強化学習における軌道レベル報酬**
SFT と DPO と RLVR と RLHF の比較
SFT を使用するのは、指示の遵守、多回対話、出力スキーマ、ツール呼び出し形式、またはドメインワークフローなど、望ましい行動の実演データがある場合です。
DPO を使用するのは、ある回答が別の回答よりも優れているという好意的なペア(preference pairs)がある場合です。
RLHF を使用するのは、微妙な人間の嗜好をルールで捉えきれず、好意データや報酬モデル、慎重なトレーニングインフラストラクチャをサポートできる場合です。
RLVR を使用するのは、有効な JSON、正しい CLI コマンド、テストの合格、正確な数学的答え、成功したツール呼び出し、またはシミュレータの結果など、正しさがアルゴリズムによって検証可能な場合です。
最適な方法は、利用可能な信号(signal)に依存します。検証可能なツール使用やエージェントワークフローにおいては、一般的な初期アプローチは以下の通りです:必要に応じて SFT → 検証可能な報酬を用いた GRPO → 評価 → 失敗の分析 → 繰り返し。
RLVR や検証可能タスクには GRPO がデフォルトとして適している
RLVR ワークフローにおいて、GRPO は開始する際に実用的な選択肢となることが多いです。これはプロンプトごとに複数の完成文を生成し、検証器(verifier)で採点し、グループ内の相対的なパフォーマンスに基づいてモデルを更新します。PPO スタイルの RLHF と比較して、GRPO は構成要素が少なく、ルールベースの報酬と自然に適合するため、多くのエージェント型強化学習の例においてデフォルトとなっています。
RL 訓練システムが成熟するにつれて、より新しいバリアントも次々と登場しています。例えば、ダイナミック・サンプリング・ポリシー最適化(DAPO)は、GRPO を基盤としつつ、有用な学習シグナルと探索の多様性を維持するために動的サンプリングと非対称クリッピングを採用しています。一方、グループ・シーケンス・ポリシー最適化(GSPO)はトークンレベルではなくシーケンスレベルで最適化を行うことで、特に Mixture-of-Experts(MoE)モデルにおいて訓練の安定性を向上させます。
本ガイドの後半では、GRPO と環境ベースの評価を用いた実用的な RLVR ワークフローに焦点を当てます。
最小限の RL ループ
LLM やエージェント向けの RL 訓練ランには、以下の 7 つの部分があります:
- ポリシーモデル:訓練対象となるモデル
- タスク:モデルが入力として受け取るもの
- アクション:モデルの出力、ツール呼び出し、コードパッチ、コマンド、または多段階の軌跡
- 環境:アクションを実行しフィードバックを提供するシステム
- バリファイア:成功をスコアリングするか、報酬を生成するシグナル
- ロールアウト:現在のモデルからサンプリングされた試行
- ポリシー更新:より良い出力の確率を増加させる訓練ステップ
この RL 101 ギャラリー は、各コンポーネントの詳細な理解と、それらがどのように連携して動作するかを解説しています。
トレーニング前に評価から始めましょう。保持されたタスクセット上で現在のモデルを実行し、失敗箇所を検証し、重みを更新する前に検証器または報酬関数のプロファイルを取得してください。RL は、モデルが時折正しい振る舞いを生成できるが、それを確実に行えない場合に最も効果的です。報酬が間違っている場合、RL は間違った行動を最適化してしまいます。
開発者が RL で直面する一般的な課題は、データ、環境設計、報酬設計、および計算リソースの判断に関するものです。
タスクとトレーニングデータ
SFT(Supervised Fine-Tuning:教師あり微調整)では、モデルに望ましい振る舞いを教えるための入力 - 出力例が必要です。RLVR(Reinforcement Learning with Verifiable Rewards:検証可能な報酬による強化学習)では、タスクと、出力をスコアリングできる検証器やツールを備えた環境ロジックが必要です。Synthetic data generation(合成データ生成)は、実例が不足している場合にカバレッジを拡大するのに役立ちます:タスクのバリエーション、エッジケース、ツール呼び出しシナリオ、および期待される出力を生成し、バリデーター、報酬モデル、または LLM-as-judge によるレビューでフィルタリングします。
NVIDIA NeMo Data Designer は、ゼロから構造化されたタスクデータセットを生成したり、シードデータから開始したりし、フィールド間の関係を制御し、バッチ処理で生成し、仕様に対して出力を検証するのに役立ちます。その後、NeMo Gym を使用して、これらのタスクを環境を通じて実行し、モデルや教師エージェントからのスコア付き軌道(trajectories)を生成できます。これらは SFT のデモンストレーション、好ましいペアの作成、または RL のロールアウトに使用できます。
合成データは真の正解ではありません。人間による高品質なシードセットを少量保持し、重複を徹底的に排除し、評価タスクを保留し、トレーニングデータとして使用する前に失敗事例を検査してください。
エージェント型 RL には環境が必要であり、単なるデータセットだけでは不十分です
単純なシングルターンタスクの場合、静的なデータセットで十分な場合があります:
{"prompt": "このコマンドに対して有効な JSON を返してください...", "answer": "..."}
シングルステップ/ターン、マルチステップ、そしてマルチターンワークフローにわたるエージェント型 RL には、以下の要素を定義する環境が必要です:
- データセット
- エージェントハネス (Agent Harness)
- 検証器 (Verifier)
- 状態 (State)
例えば、長時間実行されるコーディングエージェントは、テストが合格するまでに多くのツール呼び出しが必要になるかもしれません。データ分析エージェントはファイルの検査、クエリの実行、チャートの生成、結果の検証を必要とする可能性があります。科学分野のエージェントは文献検索、シミュレータの呼び出し、仮説の見直しを必要とするかもしれません。
環境は単純なものから複雑なものまで様々です。数学ではパーサーと回答チェッカー、コード生成ではユニットテスト、長時間実行されるエージェントにはツールやファイル、ターン制限、タスク固有の成功基準を備えたサンドボックスなどが挙げられます。
評価 (Evals) と環境は、同じシステムの二面性です。優れた評価はモデルが成功したかどうかを示し、優れた RL 環境はその信号をトレーニングデータに変換します。
NeMo Gym は、エージェント、モデル、外部システム、ツール、検証器を接続する環境を構築するためのスケーラブルで再現性の高い方法を提供しており、シングルステップ、マルチステップ、状態保持型、リアルワールド、LLM-as-judge 環境向けのチュートリアルも用意されています。
image*図 2. NeMo Gym ライブラリのコンポーネント*
リワードと検証器の設計:シンプルに始める
リワード(報酬)設計は、多くの強化学習(Reinforcement Learning: RL)プロジェクトが過度に複雑化してしまう箇所です。
まずはループが機能することを証明する最もシンプルなリワードから始めましょう。RLVR の場合、これは二値(binary)で開始できます:検証器を通過すれば +1、そうでなければ 0 です。
実際の進捗を測定する場合のみ、中間シグナルを追加します。コーディングエージェントの場合、以下のようなものが考えられます。
+0.1 適切なツールを選択した
+0.2 有効な中間成果物を生成した
+0.3 部分的なテストに合格した
+1.0 タスクを完了した
-1.0 不安全な行動を行った
リワードの調整(shaping)をやりすぎると、モデルがタスクそのものではなくチェックリストの最適化を学習してしまうことになります。優れたリワード関数には以下の三つの特性が必要です。
- 実際のタスクを測定するものであること。
- ゲーム(不正行為)やハッキングが困難であること。
- 誤っている場合に明確に失敗すること。
トレーニング前に、50〜100 のモデル出力に対してリワード関数を実行し、スコアを手動で確認してください。リワードの判断とあなたの評価が一致しない場合は、リワードを修正してください。
コンピューティング:トレーニングとロールアウトのための予算
RL のコストは、二つのワークロードに由来します:ロールアウト(推論実行)とトレーニングです。両方ともバッチサイズ、モデルサイズ、シーケンス長の影響を受けます。特にロールアウトのコストは、ツール呼び出しの数、会話のターン数、環境ステップ数に応じてスケーリングします。vLLM などの推論ソフトウェアはロールアウトのレイテンシを改善し、NeMo Gym はツール呼び出しのオーケストレーションを改善します。
あるいは、トレーニングコストはデータセットのサイズとポリシー更新の数に比例して増大します。Megatron や NeMo Automodel などのトレーニングソフトウェアはスループットを向上させます。NeMo RL などの強化学習(Reinforcement Learning: RL)フレームワークはこれらの推論およびトレーニングソフトウェアの上に構築され、最適なモデル学習のための効率的なループを実現します。
GPU の要件はワークロードによって異なります。アダプターベースの約 1B〜8B の小規模実験であれば、単一の現代 GPU または小規模なマルチ GPU ノードから開始できます。大規模モデル、フルファインチューニング、長文コンテキストタスク、高いロールアウト数、または多ステップエージェント環境では複数の GPU が必要です。計算リソースが限られている場合は、まずモデルサイズ、最大トークン数、プロンプトあたりの生成数、並列環境数を削減してください。
初期実験では小さく始めるのが良いでしょう。小規模なモデルは、データのデバッグ、検証器(verifiers)、環境、トレーニングループにおいて特に優れています。複雑なタスクでは、報酬曲線や保留評価で意味のある改善が示されるまで、より能力の高いモデルが必要です。
実践的な最初の RL トレーニング実行は小規模で、検証可能かつ検査可能であるべきです
自然言語の要求から正しい JSON ツール呼び出しを生成する職場アシスタント型エージェントを構築しましょう:
まず、NeMo RL の入門 例を使用してセットアップをクリーンに整えましょう。
次に、プロジェクト管理ワークフロー全体にわたるツール呼び出しのために GRPO で Nemotron Nano 9B v2 をトレーニングする NeMo RL や NeMo Gym の職場アシスタントチュートリアルのような多段階の例に移りましょう。まずは、多段階環境にも拡張可能な単純な 1 ステップのツール使用タスクから始めます。
ステップ 1: 評価対象の行動を 1 つ選択する
自動評価用の行動を 1 つ選びます。
例:自然言語によるリクエストを受け取り、内部 CLI または API に対する正しい JSON ツール呼び出しを生成します。
{
"prompt": "来週の火曜日の午後 2 時にアレックスのためのカレンダーイベントを作成してください。",
"expected_tool": "calendar.create_event",
"expected_args": {
"attendee": "Alex",
"day": "Tuesday",
"time": "14:00"
}
}
ステップ 2: ベースライン評価を実行し、失敗を分類する
トレーニング前に、トレーニング用と検証用のタスクファイルを別々に用意します。検証セット上でベースラインモデルを実行し、有効な JSON の割合、正しいツールまたはコマンドの割合、正しい引数の割合、実行成功率、および不安全なアクションの割合を測定します。
次に出力を検査し、失敗をタイプ別にグループ化します:フォーマットエラー、間違ったツールまたはコマンド、一貫性のない成功、不安全なアクション、あるいは長期ホライズンの失敗です。トレーニング前にモデルに測定可能な失敗パターンがあることを確認してください。
これにより、使用するトレーニング手法が決定されます。
ステップ 3: SFT の必要性を判断する
もしモデルが期待される形式やツールファミリーをほとんど守らない場合は、SFT から始めましょう。時々成功するが不安定な場合は、GRPO を用いた RLVR へ移行します。
実践的なアプローチは以下の通りです:
- 形式とタスク理解のための SFT
- 信頼性向上のための GRPO を用いた RLVR
- デプロイ前のホールドアウト評価(Held-out evals)
ステップ 4: 検証器または報酬関数の構築
RL が次の適切なステップであることが確定したら、評価ロジックを報酬関数に変換します。最初はシンプルで決定論的なものから始めましょう。
def reward(output, expected):
if not is_valid_json(output):
return -1.0
parsed = json.loads(output)
score = 0.0
if parsed["tool"] == expected["expected_tool"]:
score += 0.4
score += 0.4 * argument_match(
parsed["args"],
expected["expected_args"]
)
if executes_safely(parsed):
score += 0.2
return score
トレーニング前にサンプル出力に対してこの検証器を実行してください。報酬があなたが正しいと考える内容と一致しない場合は、まず検証器を修正します。
ステップ 5: 小規模な GRPO ジョブの実行
小規模モデルまたはアダプターベースのランから始めます。最初のランは意図的に範囲を狭く保ちましょう。
model: nvidia/Nemotron-Nano-9B-v2
algorithm: grpo
adapter: lora
num_generations_per_prompt: 8
reward: tool_call_verifier
eval_interval: 10
held_out_eval: tool_call_eval
ステップ 6: 適切な指標の追跡
トレーニング報酬だけでなく、検証用報酬、成功率、無効な出力、不安全なアクション、レイテンシ、コストも追跡してください。モデルが訓練していないタスクにおいて、検証用報酬や精度がベースラインに対して改善されているか確認してください。
ステップ 7: 失敗の調査と慎重なリリース
各チェックポイントでサンプル出力を確認してください。報酬ハッキング、フォーマットの後退、不安全なアクション、あるいは報酬は向上しているものの実際の品質が悪化しているケースがないか探します。安全、レイテンシ、または一般的な能力チェックにおいて後退することなく、未使用の評価セット(held-out evals)上でチューニング済みモデルがベースラインを上回った場合にのみリリースしてください。
長時間稼働するエージェントのための継続的改善
長時間稼働するエージェントはソフトウェアシステムのように改善されるべきです。RL を実践的なループとして用い、本番環境向けのエージェントワークフローを継続的に改善します:
- 実際の軌跡(trajectories)のログ記録:プロンプト、ツール呼び出し、観測結果、出力、失敗事例、人間の介入、および最終結果を記録する。
- 失敗の評価セットへの変換:本番環境でのすべての失敗は、回帰テストまたは環境タスクとして扱うべきである。
- 失敗モードの分類:フォーマットエラー、誤ったツールの選択、不適切な計画、不安全なアクション、検索失敗、ハルシネーション(幻覚)された API、および不完全な実行を分離する。
- 最も軽量な修正の選択:まずプロンプトまたはツールの変更を行う。繰り返し発生するフォーマットやドメイン固有の動作には SFT を使用し、選好品質の向上には DPO を使用する。成功を検証できる場合は RLVR/GRPO を適用する。
- 未使用タスクでのトレーニング:モデルが決して訓練しない固定の評価セットを維持し、新しいタスクを継続的に追加する。
- 行動の改善がある場合のみ推進する
成功確率、安全性の失敗、コスト、レイテンシ、回帰テストにおいて、ベースラインと調整済みモデルを比較してください。
- 調整済みモデルはバージョン管理する
エージェントの専門化のために、各調整済みチェックポイントまたはアダプターにバージョンを割り当てて、行動を比較し、安全にロールバックし、基本モデルを上書きしないようにします。
このループの出力は、エージェントのフライホイールです。生産環境での失敗が評価データとなり、評価データが環境となり、環境が報酬を生成し、報酬がモデルを改善し、次のモデルは展開前にテストされます。
LLM とエージェントのための強化学習の始め方
有用な RL 実行への最短経路は、明確なタスク、信頼できる検証者、小さなベースラインモデル、そしてモデルが実際に向上したかどうかを示す保持された評価セットです。
ご自身のモデルやエージェントに RL を適用する準備はできましたか?NVIDIA NeMo と Nemotron で開発を加速しましょう:
- Nemotron によるオープンモデル、レシピ、およびアジェンティック AI の例
- NeMo RL によるスケーラブルなポストトレーニング
- NeMo Gym による検証可能な報酬環境、ロールアウト、および評価
- NeMo Data Designer による合成データ生成
- カスタムエージェントの異なる手法に関する詳細ガイド
これらのツールは、開発者がゼロから完全な RL スタックを再構築することなく、タスク定義とデータ生成からトレーニング、評価、最適化へと移行できるよう支援します。
原文を表示
Reinforcement learning (RL) is central to aligning language models, from reinforcement learning with human feedback (RLHF) within AI assistants to newer reinforcement learning with verifiable rewards (RLVR) workflows for reasoning and agent tasks.
RL is now becoming a practical technique for specialized AI where enterprises need more accurate agents for domain-specific workflows. Open models provide more control over data, IP, and deployment, while RL turns domain success criteria into training signals.
Frontier labs have shown RL can improve general model capabilities. OpenAI trained their o-series models with large-scale RL, and DeepSeek-R1 showed how group relative policy optimization (GRPO) and verifiable rewards improve math, code, and reasoning behavior.
NVIDIA Nemotron 3 Super was post-trained using multi-environment RL across 21 NVIDIA NeMo Gym verifiers and 37 datasets, generating about 1.2 million environment rollouts.
This guide helps model-builders, research teams, and agent developers decide when to use RL and how to run a first verifiable RL training loop for long-running agents.
Why RL matters for agents
Organizations need specialized agents for workflows such as security triage, scientific discovery, CLI automation, customer support, data analysis, and internal tool use. Customizing open models like Nemotron makes this practical. Teams can specialize for accuracy and speed while keeping control over data, IP, and deployment.
Prompting, RAG, and tools can get you far. Think of the model as the agent’s brain, the agent harness as its body, and tools as the workspace it can act in. Improving the harness or adding tools can help, but it doesn’t always change model behavior. If the agent repeats tool-call mistakes, fails in long workflows, formats outputs incorrectly, or chooses the wrong strategy, you need a training signal. That is where RL fits.
RL lets you define success, generate attempts, score them, and update model weights so successful behavior becomes more likely. In agentic systems, that reward can come from a verifier: code that scores outputs or trajectories using tests, tool execution, schema validation, simulators, reward models, LLM-as-judge review, human preference labels, or other task-specific feedback.

Nemotron, NVIDIA NeMo RL, and NVIDIA NeMo Gym provide open models, post-training workflows, and environment infrastructure that work with ecosystem tools such as OpenRLHF, PrimeIntellect, SGLang, Unsloth, veRL, and vLLM.
RAG, prompting, SFT, and RL: When to use what
Avoid starting with: “Which algorithm should I use?”
Start with: “What behavior do I want to increase, and how will I measure it?”
Here is an example decision matrix:
SFT vs DPO vs RLVR vs RLHF
Use SFT when you have demonstrations of desired behavior, such as instruction following, multi-turn conversations, output schemas, tool-call formats, or domain workflows.
Use DPO when you have preference pairs, where one answer is better than another.
Use RLHF when nuanced human preferences cannot be captured by rules and you can support preference data, reward models, and careful training infrastructure.
Use RLVR when correctness can be checked algorithmically, such as valid JSON, correct CLI commands, passing tests, exact math answers, successful tool calls, or simulator outcomes.
The best method depends on the signal you have. For verifiable tool-use and agent workflows, a common starting path is: SFT if needed → GRPO with verifiable rewards → evaluate → inspect failures → repeat.
GRPO is a good default for RLVR or verifiable tasks
For RLVR workflows, GRPO is often practical to start with. It generates multiple completions per prompt, scores them with a verifier, and updates the model based on relative performance within the group. Compared with PPO-style RLHF, GRPO has fewer moving parts and works naturally with rule-based rewards, becoming a default for many agentic RL examples.
Newer variants continue to emerge as RL training systems mature. For example, dynamic sampling policy optimization (DAPO) builds on GRPO with dynamic sampling and asymmetric clipping to preserve useful learning signal and exploration diversity, while group sequence policy optimization (GSPO) optimizes at the sequence level instead of the token level to improve training stability, especially for Mixture-of-Experts (MoE) models.
The rest of this guide focuses on a practical RLVR workflow using GRPO and environment-based evaluation.
The minimal RL loop
An RL training run for LLMs or agents has seven parts:
- Policy model: the model you are training
- Task: the input the model receives
- Action: the model output, tool call, code patch, command, or multi-step trajectory
- Environment: the system that executes the action and provides feedback
- Verifier: the signal that scores success or produces rewards
- Rollouts: sampled attempts from the current model
- Policy update: the training step that increases the probability of better outputs
This RL 101 Glossary provides a detailed understanding of each component and how they work together.
Start with evaluation before training. Run the current model on a held-out task set, inspect failures, and profile the verifier or reward function before updating weights. RL works best when the model can sometimes produce the right behavior but doesn’t do so reliably. If the reward is wrong, RL will optimize the wrong behavior.
The common challenges that developers face with RL are around data, environment design, reward design, and compute decisions.
Task and training data
For SFT, you need input-output examples that teach the model the desired behavior. For RLVR, you need tasks, environment logic with verifiers and tools that can score outputs. Synthetic data generation helps expand coverage when real examples are sparse: generate task variants, edge cases, tool-call scenarios, and expected outputs, then filter them with validators, reward models, or LLM-as-judge review.
NVIDIA NeMo Data Designer can help generate structured task datasets from scratch or seed data, control relationships between fields, batch generation, and validate outputs against specifications. NeMo Gym can then run those tasks through environments to generate scored trajectories from models or teacher agents, which can be used for SFT demonstrations, preference pairs, or RL rollouts.
Synthetic data is not ground truth. Keep a small human-quality seed set, deduplicate aggressively, hold out eval tasks, and inspect failure cases before using as training data.
Agentic RL needs environments, not just datasets
For simpler single-turn tasks, a static dataset may be enough:
{"prompt": "Return valid JSON for this command...", "answer": "..."}
For agentic RL spanning across single-step/turn, multi-step, and multi-turn workflows, you need an environment defining the:
- Dataset
- Agent Harness
- Verifier
- State
For example, a long-running coding agent may need many tool calls before tests pass; a data analysis agent may need to inspect files, run queries, generate charts, and validate results; a scientific agent may need to search literature, call simulators, and revise hypotheses.
The environment can be simple or complex: a parser plus answer checker for math, unit tests for code generation, or a sandbox with tools, files, turn limits, and task-specific success criteria for long-running agents.
Evals and environments are two sides of the same system. A good eval conveys whether the model succeeded, and a good RL environment turns that signal into training data.
NeMo Gym provides a scalable, reproducible way to build environments that connect agents, models, external systems, tools, and verifiers, with tutorials for single-step, multi-step, stateful, real-world, and LLM-as-judge environments.

Reward and verifier design: Start simple
Reward design is where many RL projects get overcomplicated.
Start with the simplest reward that proves the loop works. For RLVR, this can start with binary: +1 if the output passes the verifier, 0 otherwise
Add intermediate signals only when they measure real progress. For a coding agent, it could be
+0.1 selected the right tool
+0.2 produced valid intermediate artifact
+0.3 passed partial test
+1.0 completed task
-1.0 unsafe action
Too much shaping can teach the model to optimize the checklist instead of the task. Good reward functions have three properties:
- They measure the real task.
- They are hard to game/hack.
- They fail visibly when wrong.
Before training, run your reward function against 50-100 model outputs and inspect the scores manually. If the reward disagrees with your judgment, fix the reward.
Compute: Budget for training and rollouts
RL cost comes from two workloads: rollout and training. Both are affected by batch size, model size and sequence lengths. Rollout cost specifically scales with number of tool calls, conversation turns and environment steps. Inference software such as vLLM improves rollout latency while NeMo Gym improves tool calls orchestration.
Alternately, training cost scales with dataset size and number of policy updates. Training software such as Megatron and NeMo Automodel improve throughput. RL frameworks such as NeMo RL build on top of these inference and training softwares, enabling an efficient loop for optimal model learning.
GPU needs vary by workload. A small adapter-based ~1B-8B experiment can start on a single modern GPU or small multi-GPU node. Larger models, full fine-tuning, long-context tasks, high rollout counts, or multi-step agent environments need multiple GPUs. When compute is limited, reduce model size, max tokens, generations per prompt, and parallel environments first.
For early experiments, start small. Smaller models excel at debugging data, verifiers, environments, and training loops. Complex tasks need a more capable model before the reward curve or held-out evals show meaningful improvement.
A practical first RL training run is small, verifiable and inspectable
Let’s build a workplace assistant-style agent that generates correct JSON tool calls from natural-language requests:
First, pipe-clean the setup with the NeMo RL getting-started example.
Then move to a multi-step example such as the NeMo RL and NeMo Gym Workplace Assistant tutorial, which trains Nemotron Nano 9B v2 with GRPO for tool-calling across project-management workflows. We will start with a simple one-step tool use task which can be extended to multi-step environments too.
Step 1: Pick one behavior
Choose one behavior for automatic evaluation.
Example: Given a natural-language request, produce the correct JSON tool call for an internal CLI or API.
{
"prompt": "Create a calendar event for Alex next Tuesday at 2 PM.",
"expected_tool": "calendar.create_event",
"expected_args": {
"attendee": "Alex",
"day": "Tuesday",
"time": "14:00"
}
}
Step 2: Run a baseline eval and classify failures
Prepare separate training and validation task files before training. Run the baseline model on the validation set and measure valid JSON rate, correct tool or command rate, correct argument rate, execution success rate, and unsafe action rate.
Then inspect outputs and group failures by type: format errors, wrong tool or command, inconsistent success, unsafe actions, or long-horizon failures. Confirm the model has a measurable failure pattern before training.
This tells you which training method to use.
Step 3: Decide whether SFT is needed
If the model rarely follows the expected format or tool family, start with SFT. If it can sometimes succeed but is inconsistent, move to RLVR with GRPO.
A practical path is:
- SFT for format and task understanding
- RLVR with GRPO for reliability improvement
- Held-out evals before deployment
Step 4: Build the verifier or reward function
Once RL is the right next step, turn your eval logic into a reward function. Start simple and deterministic.
def reward(output, expected):
if not is_valid_json(output):
return -1.0
parsed = json.loads(output)
score = 0.0
if parsed["tool"] == expected["expected_tool"]:
score += 0.4
score += 0.4 * argument_match(
parsed["args"],
expected["expected_args"]
)
if executes_safely(parsed):
score += 0.2
return score
Run this verifier against sample outputs before training. If the reward disagrees with what you would consider correct, fix the verifier first.
Step 5: Run a small GRPO job
Start with a small model or adapter-based run. Keep the first run intentionally narrow.
model: nvidia/Nemotron-Nano-9B-v2
algorithm: grpo
adapter: lora
num_generations_per_prompt: 8
reward: tool_call_verifier
eval_interval: 10
held_out_eval: tool_call_eval
Step 6: Track the right metrics
Do not only track training rewards. Track validation reward, success rate, invalid outputs, unsafe actions, latency, and cost. See if validation reward or accuracy improve over the baseline on tasks the model did not train on.
Step 7: Inspect failures and promote carefully
Sample outputs at every checkpoint. Look for reward hacking, formatting regressions, unsafe actions, or cases where reward improves but real quality gets worse. Ship only after the tuned model beats the baseline on held-out evals without regressing on safety, latency, or general capability checks.
Continuous improvement for long-running agents
A long-running agent should improve like a software system. Use RL as a practical loop for continuously improving a production-grade agentic workflow:
- Log real trajectoriesCapture prompts, tool calls, observations, outputs, failures, human interventions, and final outcomes.
- Convert failures into evalsEvery production failure should become a regression test or environment task.
- Bucket failure modesSeparate format errors, wrong tool choice, bad planning, unsafe actions, retrieval failures, hallucinated APIs, and incomplete execution.
- Choose the lightest fixPrompt or tool change first. SFT for repeated format or domain behavior. DPO for preference quality. RLVR/GRPO when you can verify success.
- Train on held-out tasksKeep a fixed eval set that the model never trains on. Add fresh tasks continuously.
- Promote only if behavior improvesCompare baseline vs tuned model on success rate, safety failures, cost, latency, and regression tests.
- Keep tuned models versionedFor agent specialization, version each tuned checkpoint or adapter so you can compare behavior, roll back safely, and avoid overwriting the base model.
The output of this loop is an agent flywheel: production failures become evals, evals become environments, environments generate rewards, rewards improve the model, and the next model is tested before deployment.
Get started with reinforcement learning for LLMs and agents
The shortest path to a useful RL run is a clear task, a trustworthy verifier, a small baseline model, and a held-out eval that tells you whether the model actually got better.
Ready to apply RL to your own models and agents? Accelerate development with NVIDIA NeMo and Nemotron:
- Open models, recipes, and agentic AI examples with Nemotron
- Scalable post-training with NeMo RL
- Verifiable reward environments, rollouts, and evaluation with NeMo Gym
- Synthetic data generation with NeMo Data Designer
- A detailed guide on different techniques for customizing agents
These tools help developers move from task definition and data generation to training, evaluation, and optimization without rebuilding the full RL stack from scratch.
関連記事
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み