-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprompt.py
More file actions
92 lines (82 loc) · 3.68 KB
/
Copy pathprompt.py
File metadata and controls
92 lines (82 loc) · 3.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# -*- coding: utf-8 -*-
# Prompt templates for different tasks
class GSM8K_Prompt:
@staticmethod
def get_prompt(question, demonstrations=None):
if demonstrations:
demo_text = "\n\n".join([
f"Q: {demo['question']}\nA: {demo['answer']}"
for demo in demonstrations
])
return f"{demo_text}\n\nQ: {question}\nA: Let's think step by step."
else:
return f"Q: {question}\nA: Let's think step by step."
class AQuA_Prompt:
@staticmethod
def get_prompt(question, options, demonstrations=None):
options_text = "\n".join([f"({chr(65+i)}) {opt}" for i, opt in enumerate(options)])
if demonstrations:
demo_text = "\n\n".join([
f"Q: {demo['question']}\nOptions:\n{demo['options']}\nA: {demo['answer']}"
for demo in demonstrations
])
return f"{demo_text}\n\nQ: {question}\nOptions:\n{options_text}\nA: Let's think step by step."
else:
return f"Q: {question}\nOptions:\n{options_text}\nA: Let's think step by step."
class CSQA_Prompt:
@staticmethod
def get_prompt(question, choices, demonstrations=None):
choices_text = "\n".join([f"({chr(65+i)}) {choice}" for i, choice in enumerate(choices)])
if demonstrations:
demo_text = "\n\n".join([
f"Q: {demo['question']}\nChoices:\n{demo['choices']}\nA: {demo['answer']}"
for demo in demonstrations
])
return f"{demo_text}\n\nQ: {question}\nChoices:\n{choices_text}\nA: Let's think step by step."
else:
return f"Q: {question}\nChoices:\n{choices_text}\nA: Let's think step by step."
class StrategyQA_Prompt:
@staticmethod
def get_prompt(question, demonstrations=None):
if demonstrations:
demo_text = "\n\n".join([
f"Q: {demo['question']}\nA: {demo['answer']}"
for demo in demonstrations
])
return f"{demo_text}\n\nQ: {question}\nA: Let's think step by step."
else:
return f"Q: {question}\nA: Let's think step by step."
# Prompt lists for demonstrations
GSM8K_Prompt_list = [
{
"question": "Natalia sold clips to 48 of her friends in April, and then she sold half as many clips in May. How many clips did Natalia sell altogether in April and May?",
"reasoning": "Natalia sold 48/2 = 24 clips in May. Natalia sold 48+24 = 72 clips altogether in April and May.",
"answer": "72"
},
{
"question": "A robe takes 2 bolts of blue fabric and half that much white fabric. How many bolts of fabric does it take?",
"reasoning": "A robe takes 2 bolts of blue fabric. It takes 2/2 = 1 bolt of white fabric. A robe takes 2+1 = 3 bolts of fabric.",
"answer": "3"
}
]
AQuA_Prompt_list = [
{
"question": "A train 150 m long is running at a speed of 90 km/h. How long will it take to cross a platform 300 m long?",
"reasoning": "Speed = 90 km/h = 90 * 1000/3600 = 25 m/s. Distance = 150 + 300 = 450 m. Time = 450/25 = 18 seconds.",
"answer": "18"
}
]
CSQA_Prompt_list = [
{
"question": "What do people use to absorb extra ink from a fountain pen?",
"reasoning": "People use blotting paper to absorb extra ink from a fountain pen.",
"answer": "blotting paper"
}
]
StrategyQA_Prompt_list = [
{
"question": "Do hamsters provide food for any fish?",
"reasoning": "Hamsters are small rodents that are sometimes kept as pets. Fish are aquatic animals. Hamsters do not provide food for fish in their natural habitat or as pets.",
"answer": "No"
}
]