NOTE: The brackets are artifacts of the WikiHow dataset portion underlying
HellaSwag.
"""
text=re.sub('\[.*?\]','',text)
returntext
defhas_training_docs(self):
returnTrue
...
...
@@ -30,10 +39,13 @@ class HellaSwag(HFTask):
returnself.data["test"]
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):
returndoc['activity_label']+': '+doc['ctx']+'\n'
text=doc['activity_label']+': '+doc['ctx']+'\n'
returnself.remove_brackets(text)
defdoc_to_target(self,doc):
letter_answer=doc['label']
...
...
@@ -46,50 +58,59 @@ class HellaSwag(HFTask):
elifletter_answer=='3':
index=3
else:
raiseValueError("HellaSwag from HF datasets contained an invalid answer key")
returndoc['endings'][index]
raiseValueError(
"HellaSwag from HF datasets contained an invalid answer key")
target=doc['endings'][index]
returnself.remove_brackets(target)
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.
:param doc:
The document as returned from training_docs, validation_docs, or test_docs.
: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
part of the document for `doc`.
part of the document for `doc`.
"""
# TODO: implement evaluation.
raiseNotImplementedError('Evaluation not implemented')