-
Notifications
You must be signed in to change notification settings - Fork 355
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add optional r1-style thinking reward (#551)
* Add optional r1-style thinking reward * quick change * test * quick change * push latest change * fix * tested it to work * Push changes * push
- Loading branch information
Showing
5 changed files
with
125 additions
and
7 deletions.
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) | ||
|
||
|
||
 |
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 |