def compare_answers(model_output: str | None, ground_truth: str):
    """Compare the predicted answer with the ground truth answer"""
    try:
        # parse the final answer from model output
        predicted_answer = parse_final_answer(model_output)
    except Exception as e:
        # Log the exception
        logger.error(f'An error occurred: {e}\n defaulting to random guess ...')
        # choose a random answer if the model output is not in the correct format
        predicted_answer = random.choice(['A', 'B', 'C', 'D'])

    logger.info('#############################################')
    logger.info(f'Predicted answer: {predicted_answer}')
    logger.info(f'Ground truth answer: {ground_truth}')
    logger.info('#############################################')
    return predicted_answer == ground_truth
Compare the predicted answer with the ground truth answer
evaluation/benchmarks/gpqa/run_infer.py