NOTE: The brackets are artifacts of the WikiHow dataset portion underlying
HellaSwag.
"""
text=re.sub('\[.*?\]','',text)
returntext
defhas_training_docs(self):
defhas_training_docs(self):
returnTrue
returnTrue
...
@@ -30,10 +39,13 @@ class HellaSwag(HFTask):
...
@@ -30,10 +39,13 @@ class HellaSwag(HFTask):
returnself.data["test"]
returnself.data["test"]
deffewshot_description(self):
deffewshot_description(self):
return"Label for the relevant action: Sentences describing the context, with an incomplete sentence trailing\nanswer that plausibly completes the situation."
return"Label for the relevant action: Sentences describing the " \
"context, with an incomplete sentence trailing\nanswer that " \
"plausibly completes the situation."
defdoc_to_text(self,doc):
defdoc_to_text(self,doc):
returndoc['activity_label']+': '+doc['ctx']+'\n'
text=doc['activity_label']+': '+doc['ctx']+'\n'
returnself.remove_brackets(text)
defdoc_to_target(self,doc):
defdoc_to_target(self,doc):
letter_answer=doc['label']
letter_answer=doc['label']
...
@@ -46,50 +58,59 @@ class HellaSwag(HFTask):
...
@@ -46,50 +58,59 @@ class HellaSwag(HFTask):
elifletter_answer=='3':
elifletter_answer=='3':
index=3
index=3
else:
else:
raiseValueError("HellaSwag from HF datasets contained an invalid answer key")
raiseValueError(
returndoc['endings'][index]
"HellaSwag from HF datasets contained an invalid answer key")
target=doc['endings'][index]
returnself.remove_brackets(target)
defconstruct_requests(self,doc,ctx):
defconstruct_requests(self,doc,ctx):
""" Uses RequestFactory to construct Requests and returns an iterable of
""" Uses RequestFactory to construct Requests and returns an iterable of
Requests which will be sent to the LM.
Requests which will be sent to the LM.
:param doc:
:param doc:
The document as returned from training_docs, validation_docs, or test_docs.
The document as returned from training_docs, validation_docs, or test_docs.
:param ctx: str
:param ctx: str
The context string, generated by fewshot_context. This includes the natural
The context string, generated by fewshot_context. This includes the natural
language description, as well as the few shot examples, and the question
language description, as well as the few shot examples, and the question
part of the document for `doc`.
part of the document for `doc`.
"""
"""
# TODO: implement evaluation.
ll_answers=[]
raiseNotImplementedError('Evaluation not implemented')