raiseNotImplementedError('SAT Analogies dataset is not provided. Follow instructions on https://aclweb.org/aclwiki/SAT_Analogy_Questions_(State_of_the_art) to locate.')
raiseNotImplementedError('SAT Analogies dataset is not provided. Follow instructions on https://aclweb.org/aclwiki/SAT_Analogy_Questions_(State_of_the_art) to locate.')
defhas_validation_docs(self):
defhas_training_docs(self):
returnFalse
returnFalse
defhas_test_docs(self):
defhas_validation_docs(self):
returnTrue
returnFalse
deftraining_docs(self):
defhas_test_docs(self):
return[]
returnTrue
defvalidation_docs(self):
deftraining_docs(self):
return[]
return[]
deftest_docs(self):
defvalidation_docs(self):
data=[]
return[]
withopen("data/sat/SAT-package-V3.txt","r")asf:
deftest_docs(self):
lines=f.read().splitlines()
data=[]
record=[]
forlineinlines:
withopen("data/sat/SAT-package-V3.txt","r")asf:
iflen(line)==0andrecord:
lines=f.read().splitlines()
data.append(record)
record=[]
record=[]
forlineinlines:
eliflen(line)>0andline[0]=='#':
iflen(line)==0andrecord:
continue
data.append(record)
else:
record=[]
record.append(line)
eliflen(line)>0andline[0]=='#':
data.append(record)
continue
else:
docs=[]
record.append(line)
data.append(record)
forrecordindata:
source=record[-8]
docs=[]
query=record[-7]
choices=record[-6:-1]
forrecordindata:
answer_key=record[-1]
source=record[-8]
query=record[-7]
doc={
choices=record[-6:-1]
'source':source,
answer_key=record[-1]
'query':query,
'choices':choices,
doc={
'answer_key':answer_key,
'source':source,
}
'query':query,
docs.append(doc)
'choices':choices,
'answer_key':answer_key,
returndocs
}
docs.append(doc)
deffewshot_description(self):
returndocs
# This format is ONLY for the purposes of deduplication. For the task evaluation, we'll need to find a new strategy,
# to meet the needs of this particular task.
return"first thing is to second thing as\nthird thing is to fourth thing\nfifth thing is to sixth thing\nseventh thing is to eighth thing\nninth thing is to tenth thing\neleventh thing is to twelfth thing\nanswer which is either a b c d or e"
deffewshot_description(self):
# This format is ONLY for the purposes of deduplication. For the task evaluation, we'll need to find a new strategy,
defdoc_to_text(self,doc,include_target=True):
# to meet the needs of this particular task.
# SAT Analogies is currently only writing out full examples. Partial evaluation needs implementing.
return"first thing is to second thing as\nthird thing is to fourth thing\nfifth thing is to sixth thing\nseventh thing is to eighth thing\nninth thing is to tenth thing\neleventh thing is to twelfth thing\nanswer which is either a b c d or e"
format_qn=lambdax:x[0]+' is to '+x[1]
defdoc_to_text(self,doc,include_target=True):
query=doc['query']
# SAT Analogies is currently only writing out full examples. Partial evaluation needs implementing.
choices=doc['choices']
format_qn=lambdax:x[0]+' is to '+x[1]
answer=doc['answer_key']
query=doc['query']
query_words=query.split(' ')[:2]
choices=doc['choices']
text=format_qn(query_words)+' as'+'\n'
answer=doc['answer_key']
forchoiceinchoices:
query_words=query.split(' ')[:2]
choice_words=choice.split(' ')[:2]
text=format_qn(query_words)+' as'+'\n'
text+=format_qn(choice_words)+'\n'
forchoiceinchoices:
ifinclude_target:
choice_words=choice.split(' ')[:2]
text+=answer
text+=format_qn(choice_words)+'\n'
returntext
ifinclude_target:
text+=answer
# TODO: Implement evaluation code
returntext
# ***IMPORTANT***: this evaluation function needs to be written for the new framework.
# For more info, check out the interface in base.py and the example BoolQ implementation in superglue.py.
# Remove this comment when the evaluation code is implemented.
defdoc_to_target(self,doc):
\ No newline at end of file
# assumes answer_key is the true-answer's letter
returndoc['answer_key']
defconstruct_requests(self,ctx):
# assumes the output is the predicted-answer's letter