-
Notifications
You must be signed in to change notification settings - Fork 316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add optional r1-style thinking reward #551
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
16da676
Add optional r1-style thinking reward
vwxyzjn ee26489
quick change
vwxyzjn 818ed86
test
vwxyzjn 8e1e1d9
Merge branch 'main' into add-optional-format-reward
vwxyzjn 90355d1
quick change
vwxyzjn 4be929e
push latest change
vwxyzjn 79192aa
fix
vwxyzjn f45c51d
tested it to work
vwxyzjn f828fca
Push changes
vwxyzjn b02dcb2
push
vwxyzjn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Grouped Relative Policy Optimization (GRPO) | ||
|
||
GRPO is an online RL method used in [DeepSeek R1 paper](https://arxiv.org/abs/2501.12948) and its first appearance is in [DeepSeekMath](https://arxiv.org/abs/2402.03300) | ||
|
||
`open_instruct/grpo_vllm_thread_ray_gtrl.py` contains an implementation of GRPO. | ||
|
||
|
||
## Get started | ||
|
||
|
||
Here is a command to run GRPO on the Llama3.1-8b on [ai2-adapt-dev/rlvr_gsm8k_zs](https://huggingface.co/datasets/ai2-adapt-dev/rlvr_gsm8k_zs), which is simply a zero-shot version of the RLVR GSM8K dataset. | ||
|
||
|
||
```bash | ||
bash scripts/train/rlvr/grpo_llama3.1-8b.sh | ||
``` | ||
|
||
The results look quite reasonable: with format score, score all going up, KL not exploding, and sequence length seems stable (at least at first) | ||
|
||
|
||
![alt text](grpo_8b.png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
python open_instruct/grpo_vllm_thread_ray_gtrl.py \ | ||
--exp_name $exp_name \ | ||
--output_dir /weka/oe-adapt-default/costah/models/$exp_name \ | ||
--dataset_mixer_list ai2-adapt-dev/rlvr_gsm8k_zs 1.0 \ | ||
--dataset_mixer_list_splits train \ | ||
--dataset_mixer_eval_list ai2-adapt-dev/rlvr_gsm8k_zs 1.0 \ | ||
--dataset_mixer_eval_list_splits train \ | ||
--max_token_length 2048 \ | ||
--max_prompt_token_length 2048 \ | ||
--response_length 2048 \ | ||
--number_samples_per_prompt 4 \ | ||
--model_name_or_path meta-llama/Llama-3.1-8B \ | ||
--stop_strings '"</answer>"' \ | ||
--add_r1_style_format_reward \ | ||
--non_stop_penalty False \ | ||
--stop_token eos \ | ||
--penalty_reward_value 0.0 \ | ||
--temperature 0.7 \ | ||
--ground_truths_key ground_truth \ | ||
--chat_template_name r1_simple_chat_postpend_think \ | ||
--sft_messages_key messages \ | ||
--learning_rate 3e-7 \ | ||
--total_episodes 1000000 \ | ||
--deepspeed_stage 3 \ | ||
--per_device_train_batch_size 1 \ | ||
--local_rollout_forward_batch_size 1 \ | ||
--local_mini_batch_size 16 \ | ||
--local_rollout_batch_size 16 \ | ||
--num_epochs 1 \ | ||
--actor_num_gpus_per_node 6 \ | ||
--vllm_tensor_parallel_size 2 \ | ||
--beta 0.01 \ | ||
--apply_verifiable_reward true \ | ||
--seed 3 \ | ||
--num_evals 100 \ | ||
--save_freq 100 \ | ||
--reward_model_multiplier 0.0 \ | ||
--no_try_launch_beaker_eval_jobs \ | ||
--gradient_checkpointing \ | ||
--with_tracking |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vwxyzjn lets add this to the tests check we have?
Also, let's make the scale of the reward set by a hyperparam / config? Could get tricky reward shaping issues.