Skip to content

Commit a0c2bc8

Browse files
committed
fix: catch KeyError in mt_bench_branch
If the keys for the questions and answers don't exist, the file should be ignored. Instead, it would currently crash with a stack trace. This will keep that from happening. Signed-off-by: Brad P. Crochet <brad@redhat.com>
1 parent 6914d27 commit a0c2bc8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/instructlab/eval/mt_bench_branch_generator.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ def generate(judge_model_name, branch, taxonomy_dir, output_dir):
5656
print(f"failed to load {qna_file}. skipping...")
5757
continue
5858
for ex in examples:
59-
q, a = ex["question"], ex["answer"]
59+
q, a = ex.get("question"), ex.get("answer")
6060
if q is None or a is None:
61+
logger.warning("Skipping malformed file %s", qna_file)
6162
continue
6263

6364
c = ex["question"] if "context" in ex else None

0 commit comments

Comments
 (0)