Skip to content
Projects

About

Reproducing and studying RL algorithms for LLM agents, including GRPO, GSPO, DAPO, OPD, Search-R1, ReTool, ALFWorld and beyond.

AI & Machine Learning

How these counts are measured

Measured star growth

in 24h
+16
in 7 days
+67
in 15 days
+147
in 1 month
Collecting history

Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.

README_EN.md

Original
Agentic-RL Lab

中文 | English

Reproduce and dissect frontier LLM reinforcement learning algorithms — GRPO, OPD, OPSD, GSPO, DAPO, Search-R1, ReTool, ToolRL, ALFWorld, Vision GRPO, TEMPO, AgentOPSD, Spec-o3, PyTrio-Jev, Harness RL and more — with simpler code and lower barriers to accessing compute.

PyTRIO SwanLab Zhihu Rednote Python

💬 WeChat Group: Click to view the group QR code

📖 Read online: English handbook · 简体中文

Introduction

This is a lab notebook and tutorial-style repository. I use PyTRIO to reproduce a set of reinforcement learning algorithms related to LLM / Agent RL, with three goals in mind:

  1. Explain each algorithm clearly first: which paper it comes from, what problem it solves, and what its core variables are.
  2. Then reproduce it with runnable code: data, reward, loss, training loop, and SwanLab tracking are all in this repo.
  3. I built Rondo-RL, a lightweight harness RL framework that uses PyTRIO. For the SWE-Gym experiment, I plugged Qwen3.5-4B into Codex and trained it to fix bugs reported in GitHub issues.

I had long wanted to dig deep into Agentic RL, but the training setups I saw at the time routinely called for four or eight GPUs. The complexity of combining training and inference, along with the tightly coupled code in existing frameworks such as verl, Slime, and Areal, kept me from getting started. After discovering Tinker and PyTRIO, I became increasingly convinced that Train APIs are infrastructure for the future of large language models. They gave me a way to reproduce, understand, and run these Agentic RL algorithms with an exceptionally low barrier to entry. I reproduced the algorithms from these 14 Agentic RL papers in less than two months. Now, when I read a paper, its essence comes down to just a few lines of equations. That is the real appeal of Train APIs: stripping away all the noise and distractions so researchers and learners can focus on the core algorithms.

So I wondered: could more people like me get started sooner? Explain the algorithms clearly, simplify the code, and lower the cost of getting started with experiments, so anyone who wants to learn can try them hands-on. I believe the opportunity to study and research frontier technology should not depend on which school you attend, which company you work for, or how many GPUs you have. What we can do may be small, but there is still no systematic collection of Agentic RL learning materials. Only Datawhale can do it!

I want the sky to be within everyone's reach. Agentic RL belongs to everyone who wants to learn about it and research it!

Table of Contents

Topic Content Read online
Environment Setup and Core Concepts From scratch: install dependencies, register PyTRIO and SwanLab, and run your first training Read
Loss Function An intuitive explanation of what importance_sampling, ppo, and cispo are each optimizing Read
GRPO Reproduce GRPO on GSM8K and compare the importance_sampling / ppo / cispo losses Read
Vision GRPO Add image inputs on GeoQA and train Qwen3.5-4B to solve geometry multiple-choice questions with rule-based rewards Read
PyTrio-Jev For the price of a McDonald's breakfast, anyone can train their own Jev decision model Read
General OPD A minimal closed loop on DeepMath-103K: Student sampling, Teacher scoring, and reverse KL Read
Medical OPD Starting from Medical SFT, boost medical capability with SAR-OPD and IDT-OPD while preserving general ability Read
DAPO Dissect the four core improvements and measure the real time cost of Dynamic Sampling in training Read
GSPO Lift the importance ratio and clipping from the token level to the sequence level Read
OPSD Distill the Student's self-sampled trajectories with a fixed step-0 Teacher Read
AgentOPSD Use a skill-guided Self-Teacher for turn-level credit assignment Read
Search-R1 Reproduce multi-turn search RL with Qwen3.5-4B, PyTRIO, and switchable online search backends Read
ReTool Reproduce code-interleaved Agentic RL with Qwen3.5-4B, PyTRIO, and a local code sandbox Read
ToolRL Reproduce ToolRL with Qwen3.5-4B and PyTRIO, training single-step tool calls with a format reward and fine-grained correctness rewards Read
ALFWorld Train a household agent with 12K-token long trajectories, a real TextWorld environment, and group-relative advantage Read
TEMPO Algorithm-level reproduction of macro-step optimization with a generative critic Read
Spec-o3 Find stars with reinforcement learning: use SFT + GRPO to interleave spectral inspection, reasoning, and tool use Read
Tournament-GRPO Compare research reports for the same query in knockout tournaments and use wins as GRPO rewards Read
SWE-Gym Train Qwen3.5-4B in Codex with Rondo-RL for 60 GRPO steps, using patch test results as the reward for fixing bugs Read

Suggested Learning Path

If you are new to LLM reinforcement learning, follow Environment Setup and Core Concepts → Loss Function → GRPO: set up the environment, understand the losses, then run your first training on GSM8K. Once GRPO is running, pick a track by interest: to keep digging into policy updates, read DAPO and GSPO; to learn distillation, read General OPD → Medical OPD → OPSD in order; for multi-turn tool-use Agentic RL, go Search-R1 → ReTool → ALFWorld. Vision GRPO, Spec-o3, TEMPO, AgentOPSD, and Tournament-GRPO all build on the earlier chapters, so save them for last; PyTrio-Jev is a standalone chapter that does not depend on any other.

If you already know PPO / GRPO, you can skip the main text of the Loss Function and GRPO chapters: follow the environment setup chapter to configure PyTRIO and SwanLab and run your first training (it is the GRPO demo), then start directly from DAPO, General OPD, or Search-R1 — choose Search-R1 if you want to do Agentic RL.

Quick Start

If this is your first time with the project, start with Environment Setup and Core Concepts: register your accounts, log in, and run your first training step by step — no GPU is needed at any point.

If you want to clone this repository directly:

git clone https://github.com/datawhalechina/agentic-rl-lab.git
cd agentic-rl-lab
uv sync

For Spec-o3 data preparation, SFT, GRPO, evaluation, and plotting commands, see the Spec-o3 Quick Start.

New Spec-o3 RL epoch 3 results on the same 256 development examples: Qwen3.5-4B answers 175 correctly (68.36%), and Qwen3.5-9B answers 191 correctly (74.61%), with Macro F1 scores of 70.93% / 75.94%, respectively. See the Spec-o3 article for the full comparison and evaluation settings.

To run the ALFWorld, TEMPO, or AgentOPSD chapters, you also need the TextWorld environment dependencies:

uv sync --extra alfworld

If you only want to pull a single demo script into your own project, the current base dependencies are:

uv add \
  "datasets>=5.0.0" \
  "httpx>=0.28.1" \
  "math-verify>=0.9.0" \
  "matplotlib>=3.11.0" \
  "modelscope>=1.38.1" \
  "numpy>=2.5.1" \
  "openai>=2.44.0" \
  "python-dotenv>=1.2.2" \
  "pytrio==0.2.11" \
  "swanlab==0.10.4" \
  "torch>=2.9.1" \
  "torchvision>=0.27.1" \
  "tqdm>=4.68.3"

Search-R1 calls the official DeepSeek Search API through httpx. See the quickstart for API key setup.

The ALFWorld optional extra corresponds to:

uv add --optional alfworld "alfworld==0.4.2" "spacy==3.8.13"

User Stories

A few days ago, I shared a MemTensor paper on Xiaohongshu. A reader commented that they'd joined the company, and AgentOPSD from this repo was the project on their interview résumé! After we connected, we discovered that Siyu from Datawhale, who had patiently helped them get started, is also a good friend of mine. Haha, small world! Looks like learning Agentic RL really can help you land a job 🤔. There really isn't a better Agentic RL tutorial out there right now. Only Datawhale can do it!

A quick shout-out to their open-source native-memory model, MemT-1.0: download it and give it a try!

🙏 Acknowledgments

Core Contributors

Content Contributors

Want to contribute to this repo? Welcome! Please read the Contributing Guide first: open an Issue proposal before starting a new algorithm chapter; fixes and docs improvements can go straight to a PR.

Special Thanks

Star History

GitHub Star History

License

See LICENSE.

Explore related projects

Loading…