Commit 6cc21f4b authored by Leo Gao's avatar Leo Gao
Browse files

Fix include_target

parent 12852d5c
...@@ -18,9 +18,8 @@ class ARCEasy(HFNLPTask): ...@@ -18,9 +18,8 @@ class ARCEasy(HFNLPTask):
return "" return ""
def doc_to_text(self, doc, include_target=True): def doc_to_text(self, doc, include_target=True):
print(doc)
q = "Question: " + doc['question'] + '\n' q = "Question: " + doc['question'] + '\n'
a = "Answer:" + (" " + doc['choices']['text'][doc['choices']['label'].index(doc['answerKey'])]) if include_target else "" a = "Answer:" + ((" " + doc['choices']['text'][doc['choices']['label'].index(doc['answerKey'])]) if include_target else "")
return q + a return q + a
def evaluate(self, docs, lm, provide_description, num_fewshot): def evaluate(self, docs, lm, provide_description, num_fewshot):
......
...@@ -55,12 +55,13 @@ class RACE(HFNLPTask): ...@@ -55,12 +55,13 @@ class RACE(HFNLPTask):
return "" return ""
def doc_to_text(self, doc, include_target=True): def doc_to_text(self, doc, include_target=True):
print(doc)
r = "Article:\n" + doc['article'] + '\n\n' r = "Article:\n" + doc['article'] + '\n\n'
r += doc['problems'] >> each( r += doc['problems'] >> apply(enumerate) >> each(
lambda x: 'Q: ' + x['question'] + '\n\nA: ' + x['options'][['A', 'B', 'C', 'D'].index(x['answer'])]) \ lambda x: 'Q: ' + x[1]['question'] + '\n\nA:'
>> join('\n\n') + ((' ' + x[1]['options'][['A', 'B', 'C', 'D'].index(x[1]['answer'])]) \
if x[0] != len(doc['problems']) - 1 or include_target else '')) \
>> join('\n\n')
return r return r
......
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