Spaces:
Running
Running
Cast pred and response to string only for semantic to account for H:M:S responses in arithmetic split.
Browse files- test_of_time_accuracy.py +4 -1
- tests.py +4 -2
test_of_time_accuracy.py
CHANGED
|
@@ -146,8 +146,11 @@ class TestOfTimeAccuracy(evaluate.Metric):
|
|
| 146 |
if subset == "arithmetic" and "unordered_list" in j:
|
| 147 |
i = self._sort_unordered_list(i)
|
| 148 |
j = self._sort_unordered_list(j)
|
|
|
|
|
|
|
|
|
|
| 149 |
accuracy.append(
|
| 150 |
-
|
| 151 |
) # Semantic subset answer JSON somestimes has int as value. Label is string.
|
| 152 |
if return_average:
|
| 153 |
return {"accuracy": sum(accuracy) / len(accuracy)}
|
|
|
|
| 146 |
if subset == "arithmetic" and "unordered_list" in j:
|
| 147 |
i = self._sort_unordered_list(i)
|
| 148 |
j = self._sort_unordered_list(j)
|
| 149 |
+
if subset == "semantic":
|
| 150 |
+
i = str(i)
|
| 151 |
+
j = str(j)
|
| 152 |
accuracy.append(
|
| 153 |
+
i == j
|
| 154 |
) # Semantic subset answer JSON somestimes has int as value. Label is string.
|
| 155 |
if return_average:
|
| 156 |
return {"accuracy": sum(accuracy) / len(accuracy)}
|
tests.py
CHANGED
|
@@ -8,15 +8,17 @@ arithmetic_test_cases = {
|
|
| 8 |
'```json\n{\n "explanation": "The dates provided are March 2012, September 2011, June 2017, September 2019, and June 2015. These correspond to visits to Miami, Sydney, Tokyo, London, and Nairobi respectively. The latest date among these is September 2019, which is associated with London. Therefore, London is the last city visited.",\n "unordered_list": ["Berlin","London"]\n}\n```',
|
| 9 |
'```json\n{\n "explanation": "The dates provided are March 2012, September 2011, June 2017, September 2019, and June 2015. These correspond to visits to Miami, Sydney, Tokyo, London, and Nairobi respectively. The latest date among these is September 2019, which is associated with London. Therefore, London is the last city visited.",\n "malformed_unordered_list": ["Berlin","London"]\n}\n```',
|
| 10 |
' "To find the date of the second most important game, we need to subtract 7 days from the date of the most important game. We can do this by counting back 7 days from April 14, 2005. April 14 - 7 days = April 7, 2005", "answer": "2005-04-07"}',
|
|
|
|
| 11 |
],
|
| 12 |
"references": [
|
| 13 |
'{"answer": "352 BC"}',
|
| 14 |
'{"unordered_list": ["London", "Berlin"]}',
|
| 15 |
'{"unordered_list": ["London", "Berlin"]}',
|
| 16 |
"{'answer': '2005-04-07'}",
|
|
|
|
| 17 |
],
|
| 18 |
-
"result": {"accuracy":
|
| 19 |
-
"per_item_accuracy": [True, True, False, False],
|
| 20 |
}
|
| 21 |
|
| 22 |
semantic_test_cases = {
|
|
|
|
| 8 |
'```json\n{\n "explanation": "The dates provided are March 2012, September 2011, June 2017, September 2019, and June 2015. These correspond to visits to Miami, Sydney, Tokyo, London, and Nairobi respectively. The latest date among these is September 2019, which is associated with London. Therefore, London is the last city visited.",\n "unordered_list": ["Berlin","London"]\n}\n```',
|
| 9 |
'```json\n{\n "explanation": "The dates provided are March 2012, September 2011, June 2017, September 2019, and June 2015. These correspond to visits to Miami, Sydney, Tokyo, London, and Nairobi respectively. The latest date among these is September 2019, which is associated with London. Therefore, London is the last city visited.",\n "malformed_unordered_list": ["Berlin","London"]\n}\n```',
|
| 10 |
' "To find the date of the second most important game, we need to subtract 7 days from the date of the most important game. We can do this by counting back 7 days from April 14, 2005. April 14 - 7 days = April 7, 2005", "answer": "2005-04-07"}',
|
| 11 |
+
'\n```json\n{\n "explanation": "Step 1: Determine the time it takes the robot to carry a single box. The robot takes 4 hours, 34 minutes, and 30 seconds to carry 2 boxes. We divide this time by 2 to find the time per box.\\n- Hours: 4 / 2 = 2 hours\\n- Minutes: 34 / 2 = 17 minutes\\n- Seconds: 30 / 2 = 15 seconds\\nSo, it takes the robot 2 hours, 17 minutes, and 15 seconds to carry one box.\\n\\nStep 2: Calculate the total time to carry 25 boxes. We multiply the time per box by the total number of boxes (25).\\n- Total Hours: 2 hours/box * 25 boxes = 50 hours\\n- Total Minutes: 17 minutes/box * 25 boxes = 425 minutes\\n- Total Seconds: 15 seconds/box * 25 boxes = 375 seconds\\n\\nStep 3: Convert the calculated time into the standard H:M:S format by carrying over excess seconds and minutes.\\n- Convert seconds to minutes: 375 seconds is equal to 6 minutes and 15 seconds (since 375 / 60 = 6 with a remainder of 15). We add the 6 minutes to our minutes total.\\n- New total: 50 hours, (425 + 6) minutes, 15 seconds -> 50 hours, 431 minutes, 15 seconds.\\n- Convert minutes to hours: 431 minutes is equal to 7 hours and 11 minutes (since 431 / 60 = 7 with a remainder of 11). We add the 7 hours to our hours total.\\n- New total: (50 + 7) hours, 11 minutes, 15 seconds -> 57 hours, 11 minutes, 15 seconds.\\n\\nThe final time is 57 hours, 11 minutes, and 15 seconds.",\n "H": 57,\n "M": 11,\n "S": 15\n}\n```'
|
| 12 |
],
|
| 13 |
"references": [
|
| 14 |
'{"answer": "352 BC"}',
|
| 15 |
'{"unordered_list": ["London", "Berlin"]}',
|
| 16 |
'{"unordered_list": ["London", "Berlin"]}',
|
| 17 |
"{'answer': '2005-04-07'}",
|
| 18 |
+
'{"H": 57.0, "M": 11.0, "S": 15.0}'
|
| 19 |
],
|
| 20 |
+
"result": {"accuracy": 3/5},
|
| 21 |
+
"per_item_accuracy": [True, True, False, False, True],
|
| 22 |
}
|
| 23 |
|
| 24 |
semantic_test_cases = {
|