Datasets:

Modalities:
Image
Text
Formats:
parquet
Languages:
English
ArXiv:
License:
marksibrahim commited on
Commit
39b57ba
·
verified ·
1 Parent(s): 998dc60

updates check answer logic

Browse files
Files changed (1) hide show
  1. README.md +13 -8
README.md CHANGED
@@ -96,19 +96,24 @@ To check the answer, we use an exact match criteria:
96
  ```python
97
  import re
98
 
99
-
100
- def check_answer(
101
- generation: str,
102
- ground_truth: List[str]
103
- ):
 
 
 
104
  preds = generation.split("\n")[-1]
105
  preds = re.sub("Answer:", "", preds)
106
  preds = preds.split(",")
107
  preds = [p.strip() for p in preds]
108
  preds = sorted(preds, key=lambda x: x[0])
109
-
110
- ground_truth = sorted(ground_truth)
111
- return preds == ground_truth
 
 
112
  ```
113
 
114
 
 
96
  ```python
97
  import re
98
 
99
+ def check_answer(generation: str, ground_truth: str) -> bool:
100
+ """
101
+ Args:
102
+ generation: model response, expected to contain "Answer: ..."
103
+ ground_truth: comma-separated string of correct answers
104
+
105
+ Returns: bool, whether the prediction matches the ground truth
106
+ """
107
  preds = generation.split("\n")[-1]
108
  preds = re.sub("Answer:", "", preds)
109
  preds = preds.split(",")
110
  preds = [p.strip() for p in preds]
111
  preds = sorted(preds, key=lambda x: x[0])
112
+
113
+ # split into a list
114
+ ground_truth_list = [a.strip() for a in ground_truth.split(",")]
115
+ ground_truth_list = sorted(ground_truth_list)
116
+ return preds == ground_truth_list
117
  ```
118
 
119