Skip to content
Open
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 task_eval/claude_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,15 @@ def get_claude_answers(in_data, out_data, prediction_key, args):
out_data['qa'][idx][prediction_key] = str(answers[str(k)]).replace('(a)', '').replace('(b)', '').strip()
except:
out_data['qa'][idx][prediction_key] = ', '.join([str(n) for n in list(answers[str(k)].values())])
except:
except json.decoder.JSONDecodeError:
try:
answers = json.loads(answer.strip())
if k in cat_5_idxs:
predicted_answer = get_cat_5_answer(answers[k], cat_5_answers[cat_5_idxs.index(k)])
out_data['qa'][idx][prediction_key] = predicted_answer
else:
out_data['qa'][idx][prediction_key] = answers[k].replace('(a)', '').replace('(b)', '').strip()
except:
except json.decoder.JSONDecodeError:
if k in cat_5_idxs:
predicted_answer = get_cat_5_answer(answer.strip(), cat_5_answers[cat_5_idxs.index(k)])
out_data['qa'][idx][prediction_key] = predicted_answer
Expand Down
4 changes: 2 additions & 2 deletions task_eval/gemini_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,15 @@ def get_gemini_answers(model, in_data, out_data, prediction_key, args):
out_data['qa'][idx][prediction_key] = str(answers[str(k)]).replace('(a)', '').replace('(b)', '').strip()
except:
out_data['qa'][idx][prediction_key] = ', '.join([str(n) for n in list(answers[str(k)].values())])
except:
except json.decoder.JSONDecodeError:
try:
answers = json.loads(answer.strip())
if k in cat_5_idxs:
predicted_answer = get_cat_5_answer(answers[k], cat_5_answers[cat_5_idxs.index(k)])
out_data['qa'][idx][prediction_key] = predicted_answer
else:
out_data['qa'][idx][prediction_key] = answers[k].replace('(a)', '').replace('(b)', '').strip()
except:
except json.decoder.JSONDecodeError:
if k in cat_5_idxs:
predicted_answer = get_cat_5_answer(answer.strip(), cat_5_answers[cat_5_idxs.index(k)])
out_data['qa'][idx][prediction_key] = predicted_answer
Expand Down
4 changes: 2 additions & 2 deletions task_eval/gpt_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,15 +331,15 @@ def get_gpt_answers(in_data, out_data, prediction_key, args):
out_data['qa'][idx][prediction_key] = str(answers[str(k)]).replace('(a)', '').replace('(b)', '').strip()
except:
out_data['qa'][idx][prediction_key] = ', '.join([str(n) for n in list(answers[str(k)].values())])
except:
except json.decoder.JSONDecodeError:
try:
answers = json.loads(answer.strip())
if k in cat_5_idxs:
predicted_answer = get_cat_5_answer(answers[k], cat_5_answers[cat_5_idxs.index(k)])
out_data['qa'][idx][prediction_key] = predicted_answer
else:
out_data['qa'][idx][prediction_key] = answers[k].replace('(a)', '').replace('(b)', '').strip()
except:
except json.decoder.JSONDecodeError:
if k in cat_5_idxs:
predicted_answer = get_cat_5_answer(answer.strip(), cat_5_answers[cat_5_idxs.index(k)])
out_data['qa'][idx][prediction_key] = predicted_answer
Expand Down