diff --git a/src/instructlab/eval/mt_bench_answers.py b/src/instructlab/eval/mt_bench_answers.py index 91333d29..79fc1287 100644 --- a/src/instructlab/eval/mt_bench_answers.py +++ b/src/instructlab/eval/mt_bench_answers.py @@ -119,10 +119,10 @@ def generate_answers( data_base_dir = bench_dir(data_dir, bench_name, branch) output_base_dir = bench_dir(output_dir, bench_name, branch) - question_file = f"{data_base_dir}/question.jsonl" + question_file = os.path.join(data_base_dir, "question.jsonl") questions = load_questions(question_file, question_begin, question_end) - answer_file = f"{output_base_dir}/model_answer/{model_name}.jsonl" + answer_file = os.path.join(output_base_dir, "model_answer", f"{model_name}.jsonl") if os.path.isfile(answer_file): os.remove(answer_file) logger.debug("Removing previous answer file: %s", answer_file) diff --git a/src/instructlab/eval/mt_bench_branch_generator.py b/src/instructlab/eval/mt_bench_branch_generator.py index ed9a4889..76bec8d0 100644 --- a/src/instructlab/eval/mt_bench_branch_generator.py +++ b/src/instructlab/eval/mt_bench_branch_generator.py @@ -112,16 +112,16 @@ def generate(judge_model_name, branch, taxonomy_dir, output_dir): output_base_dir = bench_dir(output_dir, "mt_bench_branch", branch) os.makedirs(output_base_dir, exist_ok=True) - question_fn = "question.jsonl" - question_file = os.path.join(output_base_dir, question_fn) + question_file = os.path.join(output_base_dir, "question.jsonl") logger.debug("Generating question file: %s", question_file) with open(question_file, "w", encoding="utf-8") as outfile: for entry in question_lst: json.dump(entry, outfile) outfile.write("\n") - answer_file_dir = os.path.join(output_base_dir, "reference_answer") - answer_file = os.path.join(answer_file_dir, f"{judge_model_name}.jsonl") + answer_file = os.path.join( + output_base_dir, "reference_answer", f"{judge_model_name}.jsonl" + ) logger.debug("Generating answer file: %s", answer_file) os.makedirs(os.path.dirname(answer_file), exist_ok=True) with open( diff --git a/src/instructlab/eval/mt_bench_common.py b/src/instructlab/eval/mt_bench_common.py index ee23546d..7c13e2c4 100644 --- a/src/instructlab/eval/mt_bench_common.py +++ b/src/instructlab/eval/mt_bench_common.py @@ -71,7 +71,7 @@ class MatchSingle: def bench_dir(output_dir, bench_name, branch) -> str: - b_dir = f"{output_dir}/{bench_name}" + b_dir = os.path.join(output_dir, bench_name) if branch is not None: b_dir = os.path.join(b_dir, branch) return b_dir @@ -283,7 +283,7 @@ def _get_messages( and messages[0]["role"] == "system" and messages[1]["role"] == "user" ): - messages[1]["content"] = messages[0]["content"] + "\n" + messages[1]["content"] + messages[1]["content"] = f"{messages[0]['content']}\n{messages[1]['content']}" return messages[1:] return messages diff --git a/src/instructlab/eval/mt_bench_judgment.py b/src/instructlab/eval/mt_bench_judgment.py index f7b40b89..a4893c34 100644 --- a/src/instructlab/eval/mt_bench_judgment.py +++ b/src/instructlab/eval/mt_bench_judgment.py @@ -169,12 +169,12 @@ def judge_model( data_base_dir = bench_dir(data_dir, bench_name, branch) output_base_dir = bench_dir(output_dir, bench_name, branch) - judge_file = f"{package_data_dir}/{bench_name}/judge_prompts.jsonl" + judge_file = os.path.join(package_data_dir, bench_name, "judge_prompts.jsonl") - question_file = f"{data_base_dir}/question.jsonl" - answer_file = f"{output_base_dir}/model_answer/{model_name}.jsonl" + question_file = os.path.join(data_base_dir, "question.jsonl") + answer_file = os.path.join(output_base_dir, "model_answer", f"{model_name}.jsonl") answer_dir = os.path.dirname(answer_file) - ref_answer_dir = f"{data_base_dir}/reference_answer" + ref_answer_dir = os.path.join(data_base_dir, "reference_answer") # Load questions questions = load_questions(question_file, None, None) @@ -195,7 +195,9 @@ def judge_model( models = model_list judges = make_judge_single(judge_model_name, judge_prompts) - output_file = f"{output_base_dir}/model_judgment/{judge_model_name}_single.jsonl" + output_file = os.path.join( + output_base_dir, "model_judgment", f"{judge_model_name}_single.jsonl" + ) if os.path.isfile(output_file): os.remove(output_file) logger.debug("Removing previous judgment file: %s", output_file)