KMnO4-zx/agentic-rl-lab

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

333

stars

70

commits

Python

primary language

Sep 10, 2026

updated

agent-rl
alfworld
dapo
gspo
harness-rl
opd
opsd
pytrio
retool
search-r1

README

Agentic-RL Lab

中文 | English

复现和拆解前沿 LLM 强化学习算法,用更简单的代码和更低的 GPU 门槛,把 GRPO、OPD、OPSD、GSPO、DAPO、Search-R1、ReTool、ALFWorld、Vision GRPO、TEMPO、AgentOPSD、Slime 等方法跑起来,方便复现。

PyTRIO SwanLab SwanLab Experiments Zhihu Rednote visitors Python

💬 微信交流群: 点击查看群二维码

项目介绍

  这是一个偏实验记录和教程的仓库。我会用 PyTRIO 复现一组和 LLM / Agent RL 相关的强化学习算法,主要做三件事:

  1. 先把算法讲明白:它从哪篇论文来,解决什么问题,核心变量是什么。
  2. 再用可运行代码复现:数据、reward、loss、训练循环、SwanLab 记录都放在仓库里。
  3. 可能未来会做一个更友好和轻量的 Agent RL 训练框架~
  4. 第十篇,我会做 Harness-RL 的复现和拆解。

  选择 PyTRIO 的原因很简单,我曾很想要深度研究一下 Agentic-RL 算法,但一直受一些阻力困扰。比如:没卡、训推一体的代码复杂度、Verl 的高耦合工程代码等等。让我一直迟迟没有动手研究。PyTRIO 的出现,让我可以用更简单的代码和更低的门槛来研究 Agentic-RL 算法。仓库的全部内容我仅仅花了不到一个月时间就全部学习和复现完了。

  我认为 PyTrio 或 Tinker 这类产品是面向未来的大模型后训练基础设施,早一点接触对算法工程师或是 Researcher 而言都是很有价值的。

文章目录

篇章主题内容
第 0 篇Loss Function用直觉解释 importance_samplingppocispo 分别在优化什么
第 1 篇GRPO复现 GSM8K 上的 GRPO,并比较 importance_sampling / ppo / cispo 三个 loss
第 2 篇General OPD用 DeepMath-103K 跑通 Student 采样、Teacher 打分与 reverse KL 的最小闭环
第 2 篇Medical OPD从 Medical SFT 出发,用 SAR-OPD 和 IDT-OPD 增强医疗能力,同时保持通用能力
第 3 篇Search-R1用 Qwen3.5-4B、PyTRIO 和可切换的在线搜索后端复现多轮搜索 RL
第 4 篇OPSD用固定的 step-0 Teacher 蒸馏 Student 自采样轨迹
第 5 篇ReTool用 Qwen3.5-4B、PyTRIO 和本地代码沙箱复现代码交织的 Agentic RL
第 6 篇DAPO拆解四项核心改进,并记录 Dynamic Sampling 在真实训练中的时间成本
第 7 篇GSPO将重要性比率与裁剪从 token 级提升到 sequence 级
第 8 篇ALFWorld用 12K 长轨迹、真实 TextWorld 环境和 group-relative advantage 训练家务 Agent
第 9 篇Vision GRPO在 GeoQA 上接入图片输入,解决几何数学题
第 9 篇TEMPO算法级复现 macro-step 优化与生成式 critic
第 9 篇AgentOPSD用带 Skill 的 Self-Teacher 分配 turn-level credit

快速启动

  如果是直接 clone 这个仓库:

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

  运行 ALFWorld、TEMPO 或 AgentOPSD 章节时,需要额外安装 TextWorld 环境依赖:

uv sync --extra alfworld

  如果只想把某个 demo 脚本拎到自己的项目里跑,当前基础依赖为:

uv add \
  "datasets>=5.0.0" \
  "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.8" \
  "swanlab==0.9.2" \
  "torch>=2.9.1" \
  "torchvision>=0.27.1" \
  "tqdm>=4.68.3"

  Search-R1 的 DeepSeek Search 后端使用固定源码版本:

uv add "deepseek-search @ git+https://github.com/KMnO4-zx/deepseek-search.git@6215c8dbb7347f94e9dcea6e741df5918449d6c4"

  ALFWorld 的 optional extra 对应:

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

Star History

GitHub Star History

Contributor

License

See LICENSE.

Contributors

KMnO4-zx

64 commits

Zeyi-Lin

2 commits

KiritoHugh

1 commits

kites262

1 commits

KMnO4-zx/agentic-rl-lab

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

333

stars

70

commits

Python

primary language

Sep 10, 2026

updated

agent-rl
alfworld
dapo
gspo
harness-rl
opd
opsd
pytrio
retool
search-r1

README

Agentic-RL Lab

中文 | English

复现和拆解前沿 LLM 强化学习算法,用更简单的代码和更低的 GPU 门槛,把 GRPO、OPD、OPSD、GSPO、DAPO、Search-R1、ReTool、ALFWorld、Vision GRPO、TEMPO、AgentOPSD、Slime 等方法跑起来,方便复现。

PyTRIO SwanLab SwanLab Experiments Zhihu Rednote visitors Python

💬 微信交流群: 点击查看群二维码

项目介绍

  这是一个偏实验记录和教程的仓库。我会用 PyTRIO 复现一组和 LLM / Agent RL 相关的强化学习算法,主要做三件事:

  1. 先把算法讲明白:它从哪篇论文来,解决什么问题,核心变量是什么。
  2. 再用可运行代码复现:数据、reward、loss、训练循环、SwanLab 记录都放在仓库里。
  3. 可能未来会做一个更友好和轻量的 Agent RL 训练框架~
  4. 第十篇,我会做 Harness-RL 的复现和拆解。

  选择 PyTRIO 的原因很简单,我曾很想要深度研究一下 Agentic-RL 算法,但一直受一些阻力困扰。比如:没卡、训推一体的代码复杂度、Verl 的高耦合工程代码等等。让我一直迟迟没有动手研究。PyTRIO 的出现,让我可以用更简单的代码和更低的门槛来研究 Agentic-RL 算法。仓库的全部内容我仅仅花了不到一个月时间就全部学习和复现完了。

  我认为 PyTrio 或 Tinker 这类产品是面向未来的大模型后训练基础设施,早一点接触对算法工程师或是 Researcher 而言都是很有价值的。

文章目录

篇章主题内容
第 0 篇Loss Function用直觉解释 importance_samplingppocispo 分别在优化什么
第 1 篇GRPO复现 GSM8K 上的 GRPO,并比较 importance_sampling / ppo / cispo 三个 loss
第 2 篇General OPD用 DeepMath-103K 跑通 Student 采样、Teacher 打分与 reverse KL 的最小闭环
第 2 篇Medical OPD从 Medical SFT 出发,用 SAR-OPD 和 IDT-OPD 增强医疗能力,同时保持通用能力
第 3 篇Search-R1用 Qwen3.5-4B、PyTRIO 和可切换的在线搜索后端复现多轮搜索 RL
第 4 篇OPSD用固定的 step-0 Teacher 蒸馏 Student 自采样轨迹
第 5 篇ReTool用 Qwen3.5-4B、PyTRIO 和本地代码沙箱复现代码交织的 Agentic RL
第 6 篇DAPO拆解四项核心改进,并记录 Dynamic Sampling 在真实训练中的时间成本
第 7 篇GSPO将重要性比率与裁剪从 token 级提升到 sequence 级
第 8 篇ALFWorld用 12K 长轨迹、真实 TextWorld 环境和 group-relative advantage 训练家务 Agent
第 9 篇Vision GRPO在 GeoQA 上接入图片输入,解决几何数学题
第 9 篇TEMPO算法级复现 macro-step 优化与生成式 critic
第 9 篇AgentOPSD用带 Skill 的 Self-Teacher 分配 turn-level credit

快速启动

  如果是直接 clone 这个仓库:

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

  运行 ALFWorld、TEMPO 或 AgentOPSD 章节时,需要额外安装 TextWorld 环境依赖:

uv sync --extra alfworld

  如果只想把某个 demo 脚本拎到自己的项目里跑,当前基础依赖为:

uv add \
  "datasets>=5.0.0" \
  "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.8" \
  "swanlab==0.9.2" \
  "torch>=2.9.1" \
  "torchvision>=0.27.1" \
  "tqdm>=4.68.3"

  Search-R1 的 DeepSeek Search 后端使用固定源码版本:

uv add "deepseek-search @ git+https://github.com/KMnO4-zx/deepseek-search.git@6215c8dbb7347f94e9dcea6e741df5918449d6c4"

  ALFWorld 的 optional extra 对应:

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

Star History

GitHub Star History

Contributor

License

See LICENSE.

Contributors

KMnO4-zx

64 commits

Zeyi-Lin

2 commits

KiritoHugh

1 commits

kites262

1 commits

Languages

Python

100.0%