Skip to content

Commit 7edf3d8

Browse files
committed
llm as a judge running now
1 parent 57c0517 commit 7edf3d8

2 files changed

Lines changed: 15 additions & 15 deletions

File tree

end-to-end-use-cases/coding/text2sql/fine-tuning/grpo/grpo-llama323b-text2sql.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ torch_dtype: bfloat16
55
attn_implementation: flash_attention_2
66
bf16: true
77
tf32: true
8-
output_dir: runs/llama-3.2-3b-grpo-text2sql-3rewards-6gpu
8+
output_dir: runs/llama-3.2-3b-grpo-text2sql-4rewards-6gpu
99

1010
# Lora Arguments
1111
# No LoRA is used here
@@ -29,7 +29,7 @@ use_vllm: true
2929

3030
# Reward function weights
3131
# Order: [format_reward_func, execution_reward_func, ensemble_n_gram_reward_func]
32-
reward_weights: [1.0, 3.0, 1.0]
32+
reward_weights: [1.0, 3.0, 1.0, 1.0]
3333
# **Recommended Weight Strategy**
3434
# Current Setting: `[1.0, 3.0, 1.0]`**
3535
# * **Format reward (1.0)**: Standard weight since format correctness is binary but essential

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,6 @@ def ensemble_n_gram_reward_func(completions, answer, **kwargs):
274274
for completion, gt, question, evidence in zip(
275275
completions, answer, questions, evidences
276276
):
277-
# print(f">>>>>ensemble_n_gram_reward_func: {gt=}")
278-
# print(f">>>>>ensemble_n_gram_reward_func: {completion=}")
279-
# print(f">>>>>ensemble_n_gram_reward_func: {question=}")
280-
# print(f">>>>>ensemble_n_gram_reward_func: {evidence=}")
281277
try:
282278
match = re.search(r"<answer>(.*?)<\/answer>", completion)
283279
if match is None:
@@ -407,7 +403,9 @@ def llm_as_a_judge_reward_func(completions, answer, **kwargs):
407403
messages=[{"role": "user", "content": prompt}],
408404
temperature=0,
409405
)
410-
rewards.append(float(response.choices[0].message.content))
406+
reward = float(response.choices[0].message.content)
407+
print(f"llm_as_a_judge_reward_func>>> {reward=}")
408+
rewards.append(reward)
411409
except Exception as e:
412410
rewards.append(0.0)
413411
log_reward(f"llm_as_a_judge_reward_func 0 - exception {e=}", completion, gt)
@@ -593,6 +591,7 @@ def generate_r1_prompt(
593591
format_reward_func,
594592
execution_reward_func,
595593
ensemble_n_gram_reward_func,
594+
llm_as_a_judge_reward_func,
596595
],
597596
args=training_args,
598597
train_dataset=train_dataset,
@@ -607,7 +606,7 @@ def generate_r1_prompt(
607606
###############
608607
# Check for last checkpoint
609608
last_checkpoint = get_checkpoint(training_args)
610-
# JT: by default training_args.resume_from_checkpoint is None
609+
# by default training_args.resume_from_checkpoint is None
611610
if last_checkpoint is not None and training_args.resume_from_checkpoint is None:
612611
logger.info(f"Checkpoint detected, resuming training at {last_checkpoint}.")
613612

@@ -652,10 +651,6 @@ def generate_r1_prompt(
652651
def main():
653652
parser = TrlParser((ModelConfig, ScriptArguments, GRPOConfig))
654653
model_args, script_args, training_args = parser.parse_args_and_config()
655-
# print("model_args", model_args)
656-
# print("script_args", script_args)
657-
# print("training_args", training_args)
658-
# exit()
659654

660655
# Run the main training loop
661656
grpo_function(model_args, script_args, training_args)
@@ -664,7 +659,12 @@ def main():
664659
if __name__ == "__main__":
665660
main()
666661

667-
# two ways to run this script:
668-
# with-proxy accelerate launch --num_processes 8 --config_file deepspeed_zero3.yaml grpo_text2sql.py --config grpo-llama323b-text2sql.yaml
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>
669665

670-
# with-proxy nohup accelerate launch --num_processes 4 --config_file deepspeed_zero3.yaml grpo_text2sql.py --config grpo-llama323b-text2sql.yaml &
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)