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
18 changes: 16 additions & 2 deletions prepare/cards/mmmu.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from unitxt.blocks import LoadHF, TaskCard
from unitxt.catalog import add_to_catalog
from unitxt.collections_operators import Filter
from unitxt.operators import ListFieldValues, MapValues
from unitxt.operators import (
ExecuteExpression,
ListFieldValues,
MapValues,
)
from unitxt.processors import LiteralEval, Lower
from unitxt.splitters import RenameSplits
from unitxt.string_operators import MapReplace
Expand Down Expand Up @@ -40,6 +44,8 @@
"Sociology",
]

mapping = {"A": 0, "B": 1, "C": 2, "D": 3, "E": 4, "F": 5, "G": 6, "H": 7, "I": 8}

for name in config_names:
card = TaskCard(
loader=LoadHF(
Expand All @@ -51,6 +57,14 @@
fields=[f"image_{i}" for i in range(1, 8)], to_field="media/images"
),
Filter(field="media/images", values=[None]),
ExecuteExpression(
expression="options if options != '[]' else '[\"'+answer+'\"]'",
to_field="options",
),
ExecuteExpression(
expression="'A' if options == '[\"'+answer+'\"]' else answer",
to_field="answer",
),
MapReplace(
field_to_field={"question": "question", "options": "choices"},
mapping={
Expand All @@ -62,7 +76,7 @@
Lower(field="subfield", to_field="topic"),
MapValues(
field="answer",
mapping={"A": 0, "B": 1, "C": 2, "D": 3, "E": 4, "?": None},
mapping=mapping,
),
],
task="tasks.qa.multiple_choice.with_topic",
Expand Down
15 changes: 14 additions & 1 deletion src/unitxt/catalog/cards/mmmu/accounting.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@
null
]
},
{
"__type__": "execute_expression",
"expression": "options if options != '[]' else '[\"'+answer+'\"]'",
"to_field": "options"
},
{
"__type__": "execute_expression",
"expression": "'A' if options == '[\"'+answer+'\"]' else answer",
"to_field": "answer"
},
{
"__type__": "map_replace",
"field_to_field": {
Expand Down Expand Up @@ -70,7 +80,10 @@
"C": 2,
"D": 3,
"E": 4,
"?": null
"F": 5,
"G": 6,
"H": 7,
"I": 8
}
}
],
Expand Down
15 changes: 14 additions & 1 deletion src/unitxt/catalog/cards/mmmu/agriculture.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@
null
]
},
{
"__type__": "execute_expression",
"expression": "options if options != '[]' else '[\"'+answer+'\"]'",
"to_field": "options"
},
{
"__type__": "execute_expression",
"expression": "'A' if options == '[\"'+answer+'\"]' else answer",
"to_field": "answer"
},
{
"__type__": "map_replace",
"field_to_field": {
Expand Down Expand Up @@ -70,7 +80,10 @@
"C": 2,
"D": 3,
"E": 4,
"?": null
"F": 5,
"G": 6,
"H": 7,
"I": 8
}
}
],
Expand Down
15 changes: 14 additions & 1 deletion src/unitxt/catalog/cards/mmmu/architecture_and_engineering.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@
null
]
},
{
"__type__": "execute_expression",
"expression": "options if options != '[]' else '[\"'+answer+'\"]'",
"to_field": "options"
},
{
"__type__": "execute_expression",
"expression": "'A' if options == '[\"'+answer+'\"]' else answer",
"to_field": "answer"
},
{
"__type__": "map_replace",
"field_to_field": {
Expand Down Expand Up @@ -70,7 +80,10 @@
"C": 2,
"D": 3,
"E": 4,
"?": null
"F": 5,
"G": 6,
"H": 7,
"I": 8
}
}
],
Expand Down
15 changes: 14 additions & 1 deletion src/unitxt/catalog/cards/mmmu/art.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@
null
]
},
{
"__type__": "execute_expression",
"expression": "options if options != '[]' else '[\"'+answer+'\"]'",
"to_field": "options"
},
{
"__type__": "execute_expression",
"expression": "'A' if options == '[\"'+answer+'\"]' else answer",
"to_field": "answer"
},
{
"__type__": "map_replace",
"field_to_field": {
Expand Down Expand Up @@ -70,7 +80,10 @@
"C": 2,
"D": 3,
"E": 4,
"?": null
"F": 5,
"G": 6,
"H": 7,
"I": 8
}
}
],
Expand Down
15 changes: 14 additions & 1 deletion src/unitxt/catalog/cards/mmmu/art_theory.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@
null
]
},
{
"__type__": "execute_expression",
"expression": "options if options != '[]' else '[\"'+answer+'\"]'",
"to_field": "options"
},
{
"__type__": "execute_expression",
"expression": "'A' if options == '[\"'+answer+'\"]' else answer",
"to_field": "answer"
},
{
"__type__": "map_replace",
"field_to_field": {
Expand Down Expand Up @@ -70,7 +80,10 @@
"C": 2,
"D": 3,
"E": 4,
"?": null
"F": 5,
"G": 6,
"H": 7,
"I": 8
}
}
],
Expand Down
15 changes: 14 additions & 1 deletion src/unitxt/catalog/cards/mmmu/basic_medical_science.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@
null
]
},
{
"__type__": "execute_expression",
"expression": "options if options != '[]' else '[\"'+answer+'\"]'",
"to_field": "options"
},
{
"__type__": "execute_expression",
"expression": "'A' if options == '[\"'+answer+'\"]' else answer",
"to_field": "answer"
},
{
"__type__": "map_replace",
"field_to_field": {
Expand Down Expand Up @@ -70,7 +80,10 @@
"C": 2,
"D": 3,
"E": 4,
"?": null
"F": 5,
"G": 6,
"H": 7,
"I": 8
}
}
],
Expand Down
15 changes: 14 additions & 1 deletion src/unitxt/catalog/cards/mmmu/biology.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@
null
]
},
{
"__type__": "execute_expression",
"expression": "options if options != '[]' else '[\"'+answer+'\"]'",
"to_field": "options"
},
{
"__type__": "execute_expression",
"expression": "'A' if options == '[\"'+answer+'\"]' else answer",
"to_field": "answer"
},
{
"__type__": "map_replace",
"field_to_field": {
Expand Down Expand Up @@ -70,7 +80,10 @@
"C": 2,
"D": 3,
"E": 4,
"?": null
"F": 5,
"G": 6,
"H": 7,
"I": 8
}
}
],
Expand Down
15 changes: 14 additions & 1 deletion src/unitxt/catalog/cards/mmmu/chemistry.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@
null
]
},
{
"__type__": "execute_expression",
"expression": "options if options != '[]' else '[\"'+answer+'\"]'",
"to_field": "options"
},
{
"__type__": "execute_expression",
"expression": "'A' if options == '[\"'+answer+'\"]' else answer",
"to_field": "answer"
},
{
"__type__": "map_replace",
"field_to_field": {
Expand Down Expand Up @@ -70,7 +80,10 @@
"C": 2,
"D": 3,
"E": 4,
"?": null
"F": 5,
"G": 6,
"H": 7,
"I": 8
}
}
],
Expand Down
15 changes: 14 additions & 1 deletion src/unitxt/catalog/cards/mmmu/clinical_medicine.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@
null
]
},
{
"__type__": "execute_expression",
"expression": "options if options != '[]' else '[\"'+answer+'\"]'",
"to_field": "options"
},
{
"__type__": "execute_expression",
"expression": "'A' if options == '[\"'+answer+'\"]' else answer",
"to_field": "answer"
},
{
"__type__": "map_replace",
"field_to_field": {
Expand Down Expand Up @@ -70,7 +80,10 @@
"C": 2,
"D": 3,
"E": 4,
"?": null
"F": 5,
"G": 6,
"H": 7,
"I": 8
}
}
],
Expand Down
15 changes: 14 additions & 1 deletion src/unitxt/catalog/cards/mmmu/computer_science.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@
null
]
},
{
"__type__": "execute_expression",
"expression": "options if options != '[]' else '[\"'+answer+'\"]'",
"to_field": "options"
},
{
"__type__": "execute_expression",
"expression": "'A' if options == '[\"'+answer+'\"]' else answer",
"to_field": "answer"
},
{
"__type__": "map_replace",
"field_to_field": {
Expand Down Expand Up @@ -70,7 +80,10 @@
"C": 2,
"D": 3,
"E": 4,
"?": null
"F": 5,
"G": 6,
"H": 7,
"I": 8
}
}
],
Expand Down
15 changes: 14 additions & 1 deletion src/unitxt/catalog/cards/mmmu/design.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@
null
]
},
{
"__type__": "execute_expression",
"expression": "options if options != '[]' else '[\"'+answer+'\"]'",
"to_field": "options"
},
{
"__type__": "execute_expression",
"expression": "'A' if options == '[\"'+answer+'\"]' else answer",
"to_field": "answer"
},
{
"__type__": "map_replace",
"field_to_field": {
Expand Down Expand Up @@ -70,7 +80,10 @@
"C": 2,
"D": 3,
"E": 4,
"?": null
"F": 5,
"G": 6,
"H": 7,
"I": 8
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@
null
]
},
{
"__type__": "execute_expression",
"expression": "options if options != '[]' else '[\"'+answer+'\"]'",
"to_field": "options"
},
{
"__type__": "execute_expression",
"expression": "'A' if options == '[\"'+answer+'\"]' else answer",
"to_field": "answer"
},
{
"__type__": "map_replace",
"field_to_field": {
Expand Down Expand Up @@ -70,7 +80,10 @@
"C": 2,
"D": 3,
"E": 4,
"?": null
"F": 5,
"G": 6,
"H": 7,
"I": 8
}
}
],
Expand Down
Loading