Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/instructlab/eval/mt_bench_answers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions src/instructlab/eval/mt_bench_branch_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions src/instructlab/eval/mt_bench_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
12 changes: 7 additions & 5 deletions src/instructlab/eval/mt_bench_judgment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down