Unverified Commit 2bde99e4 authored by tawsif's avatar tawsif Committed by GitHub
Browse files

Update utils.py (#2870)

parent 86a3b270
from functools import partial
choices = [
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
"J",
"K",
"L",
"M",
"N",
"O",
"P",
]
choices = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J"]
def format_cot_example(example, including_answer=True):
prompt = "Question:\n"
......@@ -27,8 +8,12 @@ def format_cot_example(example, including_answer=True):
options = example["options"]
prompt += question + "\n"
prompt += "Options:\n"
for i, opt in enumerate(options):
if i >= len(choices):
break
prompt += "{}. {}\n".format(choices[i], opt)
if including_answer:
cot_content = example["cot_content"].replace(
"A: Let's think step by step.", "Answer: Let's think step by step."
......@@ -36,17 +21,15 @@ def format_cot_example(example, including_answer=True):
prompt += cot_content + "\n\n"
else:
prompt += "Answer: Let's think step by step."
return prompt
doc_to_text = partial(format_cot_example, including_answer=False)
fewshot_to_text = partial(format_cot_example, including_answer=True)
def process_docs(dataset, subject):
return dataset.filter(lambda x: x["category"] == subject)
process_biology = partial(process_docs, subject="biology")
process_business = partial(process_docs, subject="business")
process_chemistry = partial(process_docs, subject="chemistry")
......
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