Skip to content

Add an end-to-end agent training notebook: SFT, GRPO and AsyncGRPO on an OpenEnv game - #8751

Closed
behroozazarkhalili wants to merge 1 commit into
huggingface:mainfrom
behroozazarkhalili:add-grpo-guess-the-number-example
Closed

behroozazarkhalili wants to merge 1 commit into
huggingface:mainfrom
behroozazarkhalili:add-grpo-guess-the-number-example

Conversation

@behroozazarkhalili

@behroozazarkhalili behroozazarkhalili commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

This adds examples/grpo_guess_the_number/grpo_guess_the_number.ipynb and its row in the examples overview.

The notebook trains Qwen3-0.6B with LoRA to play TextArena's GuessTheNumber through a tool, on an OpenEnv server it starts locally. SFT on scripted games comes first, then GRPOTrainer with environment_factory and AsyncGRPOTrainer with a vLLM server, both starting from the SFT model and evaluated on the same 50 held-out games. In the committed run, with 200 steps per stage on a 10 GB slice of an H100, the solve rate goes from 0% to 70% after SFT, then to 94% with GRPO and 100% with AsyncGRPO.

The reward is 1 minus 0.1 per guess after the first for a win, and 0 for a loss. With a 0/1 reward the rollouts of a game soon all score 1 and AsyncGRPO drops those groups.

The AsyncGRPO stage needs a vLLM server and is skipped without one. The outputs come from one end-to-end run; I did not run it on a T4.


Note

Low Risk
Documentation and a self-contained example notebook only; no library or training-core code changes.

Overview
Adds examples/grpo_guess_the_number/grpo_guess_the_number.ipynb, an end-to-end tutorial that trains Qwen3-0.6B with LoRA to play TextArena GuessTheNumber via a locally started OpenEnv server.

The pipeline is three stages, each evaluated on the same 50 held-out games: SFT on mediocre scripted tool-calling traces (so RL still has reward variance), GRPO with environment_factory and in-process generation, then AsyncGRPO from the merged SFT checkpoint with a vLLM server (skipped if vllm is missing). The notebook documents a guess-cost reward (wins penalized per extra guess) so AsyncGRPO does not drop constant-reward groups, and includes smoke-test configuration, committed benchmark outputs, and tree-packing metrics for AsyncGRPO.

docs/source/example_overview.md gains an index row for the new example, noting AsyncGRPO needs vLLM and is not runnable on free Colab.

Reviewed by Cursor Bugbot for commit 1869157. Bugbot is set up for automated code reviews on this repo. Configure here.

@bot-ci-comment

bot-ci-comment Bot commented Dec 2, 2026

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Pages changed in this PR:

@sergiopaniego

Copy link
Copy Markdown
Member

Closing, see #8686 (comment). SFT then GRPO on a TextArena env is covered by grpo_wordle and grpo_sudoku, AsyncGRPO can't run on free Colab, and we're planning an AsyncGRPO + environment_factory example on our side. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants