Skip to content

Commit 8989e69

Browse files
committed
README for grpo
1 parent 7edf3d8 commit 8989e69

2 files changed

Lines changed: 41 additions & 10 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# GRPO Fine-tuning for Text2SQL
2+
3+
This folder contains scripts to reinforcemen fine-tuning Llama models for the Text2SQL task using GRPO.
4+
5+
## Quick start
6+
7+
1. Download the BIRD train and dev datasets, if you haven't already:
8+
9+
```
10+
git clone https://github.com/meta-llama/llama-cookbook
11+
git checkout text2sql
12+
cd llama-cookbook/end-to-end-use-cases/coding/text2sql/data
13+
sh download_dev_unzip.sh
14+
sh download_train_unzip.sh
15+
```
16+
17+
2. (Optional) Set the following environment variable, so the reward of using LLM as a judge (via Llama 3.3 70b hosted on Together.ai) can be calculated:
18+
19+
```
20+
pip install together
21+
export TOGETHER_API_KEY=<your together.ai api key>
22+
```
23+
24+
If you don't want to use the using LLM as a judge reward, you can comment out this [line](https://github.com/meta-llama/llama-cookbook/blob/text2sql/end-to-end-use-cases/coding/text2sql/fine-tuning/grpo/grpo_text2sql.py#L594) when calling GRPOTrainer and change the reward weights [here](https://github.com/meta-llama/llama-cookbook/blob/text2sql/end-to-end-use-cases/coding/text2sql/fine-tuning/grpo/grpo-llama323b-text2sql.yaml#L32) to [1.0, 3.0, 1.0]
25+
26+
3. Install the required libraries in a conda or virtual environment:
27+
28+
```
29+
cd ../fine-tuning/grpo
30+
pip install -r requirements.txt
31+
```
32+
33+
4. Run the training script, assuming you have 6 GPUs to use for the training (if not, modify the `--num_processes` and `--gpu_ids`):
34+
35+
```
36+
accelerate launch --num_processes 6 --gpu_ids 2,3,4,5,6,7 --config_file deepspeed_zero3.yaml grpo_text2sql.py --config grpo-llama323b-text2sql.yaml
37+
```
38+
39+
You can modify the grpo-llama323b-text2sql.yaml file and tune `num_generations`, `learning_rate`, `reward_weights` and other parameters.
40+
41+
5. To evaluate a saved checkpoint, follow the steps [here](https://github.com/meta-llama/llama-cookbook/tree/text2sql/end-to-end-use-cases/coding/text2sql/eval#evaluation-with-llama-models-on-hugging-face-or-fine-tuned).

end-to-end-use-cases/coding/text2sql/fine-tuning/grpo/grpo_text2sql.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -658,13 +658,3 @@ def main():
658658

659659
if __name__ == "__main__":
660660
main()
661-
662-
# before running this script, make sure you set the following environment variable
663-
# so the reward of using LLM as a judge can be calculated:
664-
# export TOGETHER_API_KEY=<your together.ai api key>
665-
666-
# two ways to run this script, assuming you have 6 GPUs to use for the training
667-
668-
# with-proxy accelerate launch --num_processes 6 --gpu_ids 2,3,4,5,6,7 --config_file deepspeed_zero3.yaml grpo_text2sql.py --config grpo-llama323b-text2sql.yaml
669-
670-
# with-proxy nohup accelerate launch --num_processes 6 --gpu_ids 2,3,4,5,6,7 --config_file deepspeed_zero3.yaml grpo_text2sql.py --config grpo-llama323b-text2sql.yaml &

0 commit comments

Comments
 (0)