Datasets:
updates check answer logic
Browse files95 unmodified lines9697989910010110210310410510610710810911011111211311495 unmodified lines```pythonimport redef check_answer(generation: str,ground_truth: List[str]):preds = generation.split("\n")[-1]preds = re.sub("Answer:", "", preds)preds = preds.split(",")preds = [p.strip() for p in preds]preds = sorted(preds, key=lambda x: x[0])ground_truth = sorted(ground_truth)return preds == ground_truth```95 unmodified lines9697989910010110210310410510610710810911011111211311411511611711811995 unmodified lines```pythonimport redef check_answer(generation: str, ground_truth: str) -> bool:"""Args:generation: model response, expected to contain "Answer: ..."ground_truth: comma-separated string of correct answersReturns: bool, whether the prediction matches the ground truth"""preds = generation.split("\n")[-1]preds = re.sub("Answer:", "", preds)preds = preds.split(",")preds = [p.strip() for p in preds]preds = sorted(preds, key=lambda x: x[0])# split into a listground_truth_list = [a.strip() for a in ground_truth.split(",")]ground_truth_list = sorted(ground_truth_list)return preds == ground_truth_list```
README.md+13-8