Unverified Commit ac47d481 authored by Leo Gao's avatar Leo Gao Committed by GitHub
Browse files

Merge branch 'master' into translation

parents 404530d0 0601c909
...@@ -24,7 +24,8 @@ from . import sciq ...@@ -24,7 +24,8 @@ from . import sciq
from . import webqs from . import webqs
from . import qa4mre from . import qa4mre
from . import translation from . import translation
from . import headqa
from . import mathqa
TASK_REGISTRY = { TASK_REGISTRY = {
# GLUE # GLUE
...@@ -70,6 +71,8 @@ TASK_REGISTRY = { ...@@ -70,6 +71,8 @@ TASK_REGISTRY = {
# "squad": squad.SQuAD, # not implemented yet # "squad": squad.SQuAD, # not implemented yet
"race": race.RACE, "race": race.RACE,
# "naturalqs": naturalqs.NaturalQs, # not implemented yet # "naturalqs": naturalqs.NaturalQs, # not implemented yet
"headqa": headqa.HeadQA,
"mathqa": mathqa.MathQA,
"webqs": webqs.WebQs, "webqs": webqs.WebQs,
"wsc273": wsc273.WinogradSchemaChallenge273, "wsc273": wsc273.WinogradSchemaChallenge273,
"winogrande": winogrande.Winogrande, "winogrande": winogrande.Winogrande,
......
from . common import HFTask
from lm_eval.base import MultipleChoiceTask
class HeadQA(HFTask, MultipleChoiceTask):
DATASET_PATH = "head_qa"
DATASET_NAME = None
def has_training_docs(self):
return True
def has_validation_docs(self):
return True
def has_test_docs(self):
return True
def _convert_standard(self, doc):
out_doc = {
"id": doc["qid"],
"query": "Question: " + doc["qtext"] + "\nAnswer:",
"choices": [answer["atext"] for answer in doc["answers"]],
"gold": int(doc["ra"]) - 1,
}
return out_doc
def _load_docs(self, docs):
for doc in docs:
yield self._convert_standard(doc)
def training_docs(self):
docs = super().training_docs()
return self._load_docs(docs)
def validation_docs(self):
docs = super().validation_docs()
return self._load_docs(docs)
def test_docs(self):
docs = super().test_docs()
return self._load_docs(docs)
def fewshot_description(self):
# TODO: figure out description
return ""
def doc_to_text(self, doc):
return doc["query"]
from . common import HFTask
from lm_eval.base import mean, rf, MultipleChoiceTask
import re
class MathQA(HFTask, MultipleChoiceTask):
DATASET_PATH = "math_qa"
DATASET_NAME = None
def has_training_docs(self):
return True
def has_validation_docs(self):
return True
def has_test_docs(self):
return True
def _convert_standard(self, doc):
answer_idx = ['a', 'b', 'c', 'd', 'e'].index(doc['correct'])
choices = [c[4:].rstrip(" ,") for c in re.findall(r"[abcd] \) .*?, |e \) .*?$", doc['options'])]
out_doc = {
"query": "Question: " + doc['Problem'] +"\nAnswer:",
"choices": choices,
"gold": answer_idx,
}
return out_doc
def _load_docs(self, docs):
for record in docs:
yield self._convert_standard(record)
def training_docs(self):
docs = super().training_docs()
return self._load_docs(docs)
def validation_docs(self):
docs = super().validation_docs()
return self._load_docs(docs)
def test_docs(self):
docs = super().test_docs()
return self._load_docs(docs)
def fewshot_description(self):
# TODO: figure out description
return ""
def doc_to_text(self, doc):
return doc["query"]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment