Skip to content

Commit 55fc9b3

Browse files
authored
[Fix] Fix AlpacaEval output conversion without example file (#2541)
1 parent e67d9ba commit 55fc9b3

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

opencompass/tasks/outer_eval/alpacaeval.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,18 @@ def run(self):
6060
print('length mismatch')
6161
return
6262

63-
with open(
64-
osp.realpath(osp.join(self.dataset_cfg['path'],
65-
'example.json')), 'r') as f:
66-
data_format = json.load(f)
67-
63+
data_format = []
6864
for idx in range(len(preds)):
69-
data_format[idx]['output'] = preds[str(idx)]['prediction']
70-
data_format[idx]['generator'] = self.model_cfg['abbr']
65+
sample = dataset.test[idx]
66+
data = dict(
67+
instruction=sample['question'],
68+
output=preds[str(idx)]['prediction'],
69+
generator=self.model_cfg['abbr'],
70+
datasplit='eval',
71+
)
72+
data['dataset'] = sample.get('capability',
73+
self.dataset_cfg.get('abbr', ''))
74+
data_format.append(data)
7175

7276
print(f'Convert to {alpaca_format_filename}')
7377
with open(alpaca_format_filename, 'w', encoding='utf-8') as f:

0 commit comments

Comments
 (0)