From 2b435e9eca791447803a8caf03abff51d7a5b79b Mon Sep 17 00:00:00 2001 From: Haofei Yu <1125027232@qq.com> Date: Mon, 13 Nov 2023 02:40:07 -0500 Subject: [PATCH] fix and replace scenario and social goal agent name (#104) * support inference on the whole dataset * add initial code for scenario and social goal generation * modify readme * add step1 and step2 but still not correct * add a test * support generating env and match it with existing agents to be a combo * add readme * support gpt-4-turbo change and add db doc and conert to json * fix prompt to generate better scenario based on gpt-4-turbo * complete the overall 4 steps * modify readme * support bert score filtering * change name * delete file * delete jsonl * delete dump.rdb * modify readme * fix data processing agent1 and agent2 name bug * fix data processing agent1 and agent2 name bug --- README.md | 3 +-- data_generate/step4_convert_json_to_gen_input.py | 13 +++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d1baa453..0dae69e2 100644 --- a/README.md +++ b/README.md @@ -7,5 +7,4 @@ We split our overall framework into multiple parts 2. Together AI Finetuning --> Input the train and test data / Output model checkpoint 3. LLM Finetuning --> Input the train and test data / Output model checkpoint 4. LLM Deplyment --> Input LLM Finetuned model checkpoint / Output Deployable OpenAI type API -5. Eval --> Input model checkpoint / Output evaluation scores - +5. Eval --> Input model checkpoint / Output evaluation scores \ No newline at end of file diff --git a/data_generate/step4_convert_json_to_gen_input.py b/data_generate/step4_convert_json_to_gen_input.py index 736ddcb9..e51d69ba 100644 --- a/data_generate/step4_convert_json_to_gen_input.py +++ b/data_generate/step4_convert_json_to_gen_input.py @@ -38,8 +38,11 @@ def get_agent_info(agent1_pk, agent2_pk, env_pk, agent_dict, env_dict): agent1_secret = agent_dict[agent1_pk]['secret'] agent2_secret = agent_dict[agent2_pk]['secret'] - agent1_goal = env_dict[env_pk]['agent_goals'][0].replace('', '') - agent2_goal = env_dict[env_pk]['agent_goals'][1].replace('', '') + agent1_goal = env_dict[env_pk]['agent_goals'][0].replace('', '').replace('', '') + agent2_goal = env_dict[env_pk]['agent_goals'][1].replace('', '').replace('', '') + + agent1_goal = agent1_goal.replace('Agent1', agent1_name).replace('Agent2', agent2_name).replace('agent2', agent2_name).replace('agent1', agent1_name) + agent2_goal = agent2_goal.replace('Agent2', agent2_name).replace('Agent1', agent1_name).replace('agent1', agent1_name).replace('agent2', agent2_name) agent1_info = { 'agent_name': agent1_name, @@ -92,6 +95,10 @@ def fill_template(agent1_info, agent2_info, scenario): "Conversation Starts:\n.\nYou are at Turn #0." ) + scenario = scenario.replace('agent2', agent2_info['agent_name']).replace('agent1', agent1_info['agent_name']) + scenario = scenario.replace('Agent2', agent2_info['agent_name']).replace('Agent1', agent1_info['agent_name']) + + prompt = prompt_template.format( agent1_name=agent1_info['agent_name'], agent1_age=agent1_info['agent_age'], @@ -115,8 +122,6 @@ def fill_template(agent1_info, agent2_info, scenario): return prompt + format_instruction - - with open('redis_json_data.json', 'r') as f: all_json_data = json.load(f)