@@ -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(
652651def 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():
664659if __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