Skip to content

Commit

Permalink
Merge pull request #7 from EvolvingLMMs-Lab/pufanyi/mmbench
Browse files Browse the repository at this point in the history
Fix mmbench dataset submission format
  • Loading branch information
Luodian authored Mar 12, 2024
2 parents cbb3874 + d18f114 commit ea6788b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
4 changes: 1 addition & 3 deletions lmms_eval/api/samplers.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ def get_context(self, doc, num_fewshot):
+ (
str(self.doc_to_target(doc)[0])
if type(self.doc_to_target(doc)) is list
else self.doc_to_target(doc)
if (self.config.doc_to_choice is None or type(self.doc_to_target(doc)) is str)
else str(self.doc_to_choice(doc)[self.doc_to_target(doc)])
else self.doc_to_target(doc) if (self.config.doc_to_choice is None or type(self.doc_to_target(doc)) is str) else str(self.doc_to_choice(doc)[self.doc_to_target(doc)])
)
for doc in selected_docs
]
Expand Down
6 changes: 5 additions & 1 deletion lmms_eval/tasks/mmbench/cc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def mmbench_cn_cc_doc_to_text(doc, model_specific_prompt_kwargs=None):

def mmbench_cn_cc_process_results(doc, results):
model_response = results[0].strip()
return {
data = {
"submission": {
"index": doc["index"],
"question": doc["question"],
Expand All @@ -60,6 +60,10 @@ def mmbench_cn_cc_process_results(doc, results):
"category": doc["category"],
}
}
option_candidate = ["A", "B", "C", "D", "E"]
for c in option_candidate:
data["submission"][c] = doc.get(c, "nan")
return data


def mmbench_cn_cc_aggregate_results(results):
Expand Down
6 changes: 5 additions & 1 deletion lmms_eval/tasks/mmbench/cn_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def mmbench_doc_to_text(doc, model_specific_prompt_kwargs=None):

def mmbench_process_results(doc, results):
model_response = results[0].strip()
return {
data = {
"submission": {
"index": doc["index"],
"question": doc["question"],
Expand All @@ -67,6 +67,10 @@ def mmbench_process_results(doc, results):
"L2-category": doc["L2-category"],
}
}
option_candidate = ["A", "B", "C", "D", "E"]
for c in option_candidate:
data["submission"][c] = doc.get(c, "nan")
return data


def mmbench_aggregate_dev_results(results, args):
Expand Down
6 changes: 5 additions & 1 deletion lmms_eval/tasks/mmbench/en_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def mmbench_doc_to_text(doc, model_specific_prompt_kwargs=None):

def mmbench_process_results(doc, results):
model_response = results[0].strip()
return {
data = {
"submission": {
"index": doc["index"],
"question": doc["question"],
Expand All @@ -67,6 +67,10 @@ def mmbench_process_results(doc, results):
"L2-category": doc["l2-category"],
}
}
option_candidate = ["A", "B", "C", "D", "E"]
for c in option_candidate:
data["submission"][c] = doc.get(c, "nan")
return data


def mmbench_aggregate_dev_results(results, args):
Expand Down

0 comments on commit ea6788b

Please sign in to comment.