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_training_docs(self):
defhas_training_docs(self):
returnFalse
returnFalse
defhas_validation_docs(self):
defhas_validation_docs(self):
returnFalse
returnFalse
defhas_test_docs(self):
defhas_test_docs(self):
returnTrue
returnTrue
deftraining_docs(self):
deftraining_docs(self):
return[]
return[]
defvalidation_docs(self):
defvalidation_docs(self):
return[]
return[]
deftest_docs(self):
deftest_docs(self):
data=[]
data=[]
withopen("data/sat/SAT-package-V3.txt","r")asf:
withopen("data/sat/SAT-package-V3.txt","r")asf:
lines=f.read().splitlines()
lines=f.read().splitlines()
record=[]
record=[]
forlineinlines:
forlineinlines:
iflen(line)==0andrecord:
iflen(line)==0andrecord:
data.append(record)
data.append(record)
record=[]
record=[]
eliflen(line)>0andline[0]=='#':
eliflen(line)>0andline[0]=='#':
continue
continue
else:
else:
record.append(line)
record.append(line)
data.append(record)
data.append(record)
docs=[]
docs=[]
forrecordindata:
forrecordindata:
source=record[-8]
source=record[-8]
query=record[-7]
query=record[-7]
choices=record[-6:-1]
choices=record[-6:-1]
answer_key=record[-1]
answer_key=record[-1]
doc={
doc={
'source':source,
'source':source,
'query':query,
'query':query,
'choices':choices,
'choices':choices,
'answer_key':answer_key,
'answer_key':answer_key,
}
}
docs.append(doc)
docs.append(doc)
returndocs
returndocs
deffewshot_description(self):
deffewshot_description(self):
# This format is ONLY for the purposes of deduplication. For the task evaluation, we'll need to find a new strategy,
# 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.
# 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"
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"
defdoc_to_text(self,doc,include_target=True):
defdoc_to_text(self,doc,include_target=True):
# SAT Analogies is currently only writing out full examples. Partial evaluation needs implementing.
# SAT Analogies is currently only writing out full examples. Partial evaluation needs implementing.
format_qn=lambdax:x[0]+' is to '+x[1]
format_qn=lambdax:x[0]+' is to '+x[1]
query=doc['query']
query=doc['query']
choices=doc['choices']
choices=doc['choices']
answer=doc['answer_key']
answer=doc['answer_key']
query_words=query.split(' ')[:2]
query_words=query.split(' ')[:2]
text=format_qn(query_words)+' as'+'\n'
text=format_qn(query_words)+' as'+'\n'
forchoiceinchoices:
forchoiceinchoices:
choice_words=choice.split(' ')[:2]
choice_words=choice.split(' ')[:2]
text+=format_qn(choice_words)+'\n'
text+=format_qn(choice_words)+'\n'
ifinclude_target:
ifinclude_target:
text+=answer
text+=answer
returntext
returntext
defdoc_to_target(self,doc):
# assumes answer_key is the true-answer's letter
defdoc_to_target(self,doc):
returndoc['answer_key']
# 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
defconstruct_requests(self,ctx):
ll_a=rf.loglikelihood(ctx,' a')
# assumes the output is the predicted-answer's letter