Skip to content

Commit 06fa64f

Browse files
committed
fix: KeyError in run_comparison when using processed data
1 parent b7fa14c commit 06fa64f

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

src/evaluation/evaluator.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,19 @@ def run_comparison(self, raw_data_path: str, num_samples: int = 20):
7171
results = []
7272

7373
for sample in tqdm(samples):
74-
instr = sample['instruction']
75-
ref = sample['response']
74+
# handle both raw and processed formats
75+
if 'instruction' in sample:
76+
instr = sample['instruction']
77+
ref = sample['response']
78+
elif 'text' in sample:
79+
# hacky regex to pull out the prompt parts
80+
import re
81+
instr_match = re.search(r'<instruction> (.*?) </instruction>', sample['text'])
82+
ref_match = re.search(r'<response> (.*?) </response>', sample['text'])
83+
instr = instr_match.group(1) if instr_match else ""
84+
ref = ref_match.group(1) if ref_match else ""
85+
else:
86+
continue
7687

7788
pred_data = self.engine.generate(instr)
7889
pred = pred_data['response']

0 commit comments

Comments
 (0)