File size: 19,334 Bytes
926675f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
HOTPOTQA_COT = '''What is the elevation range for the area that the eastern sector of the Colorado orogeny extends into?
Step 1: Identify the eastern sector of the Colorado Orogeny
The Colorado Orogeny refers to a series of mountain-building events that occurred in the Rocky Mountains, primarily in the present-day U.S. state of Colorado. The eastern sector of the Colorado Orogeny likely refers to the easternmost part of this mountain range, which includes the Front Range, Wet Mountains, and the Sangre de Cristo Mountains.
Step 2: Determine the elevation range of the eastern sector
The Front Range, Wet Mountains, and Sangre de Cristo Mountains have varying elevations. The Front Range has elevations ranging from around 5,000 feet to over 14,000 feet (1,500 meters to 4,300 meters). The Wet Mountains have elevations ranging from about 6,000 feet to over 12,000 feet (1,800 meters to 3,700 meters). The Sangre de Cristo Mountains have elevations ranging from approximately 7,000 feet to over 14,000 feet (2,100 meters to 4,300 meters).
Step 3: Combine the elevation ranges
Considering the elevation ranges of the three mountain ranges in the eastern sector of the Colorado Orogeny, the overall elevation range for the area extends from around 5,000 feet (1,500 meters) to over 14,000 feet (4,300 meters).
Answer: 5,000 feet to 4,000 feet

'''

HOTPOTQA_REACT = 'Solve a question answering task with interleaving Thought, Action, Observation steps. Thought can reason about the current situation, and Action can be three types:\n(1) Search[entity], which searches the exact entity on Wikipedia and returns the first paragraph if it exists. If not, it will return some similar entities to search.\n(2) Lookup[keyword], which returns the next sentence containing keyword in the current passage.\n(3) Finish[answer], which returns the answer and finishes the task.\nHere are some examples.\n\nQuestion: What is the elevation range for the area that the eastern sector of the Colorado orogeny extends into?\nThought: I need to search Colorado orogeny, find the area that the eastern sector of the Colorado orogeny extends into, then find the elevation range of the area.\nAction: Search[Colorado orogeny]\nObservation: The Colorado orogeny was an episode of mountain building (an orogeny) in Colorado and surrounding areas.\nThought: It does not mention the eastern sector. So I need to look up eastern sector.\nAction: Lookup[eastern sector]\nObservation: (Result 1 / 1) The eastern sector extends into the High Plains and is called the Central Plains orogeny.\nThought: The eastern sector of Colorado orogeny extends into the High Plains. So I need to search High Plains and find its elevation range.\nAction: Search[High Plains]\nObservation: High Plains refers to one of two distinct land regions\nThought: I need to instead search High Plains (United States).\nAction: Search[High Plains (United States)]\nObservation: The High Plains are a subregion of the Great Plains. From east to west, the High Plains rise in elevation from around 1,800 to 7,000 ft (550 to 2,130 m).[3]\nThought: High Plains rise in elevation from around 1,800 to 7,000 ft, so the answer is 1,800 to 7,000 ft.\nAction: Finish[1,800 to 7,000 ft]\n\nQuestion: Musician and satirist Allie Goertz wrote a song about the "The Simpsons" character Milhouse, who Matt Groening named after who?\nThought: The question simplifies to "The Simpsons" character Milhouse is named after who. I only need to search Milhouse and find who it is named after.\nAction: Search[Milhouse]\nObservation: Milhouse Mussolini Van Houten is a recurring character in the Fox animated television series The Simpsons voiced by Pamela Hayden and created by Matt Groening.\nThought: The paragraph does not tell who Milhouse is named after, maybe I can look up "named after".\nAction: Lookup[named after]\nObservation: (Result 1 / 1) Milhouse was named after U.S. president Richard Nixon, whose middle name was Milhous.\nThought: Milhouse was named after U.S. president Richard Nixon, so the answer is Richard Nixon.\nAction: Finish[Richard Nixon]\n\nQuestion: Which documentary is about Finnish rock groups, Adam Clayton Powell or The Saimaa Gesture?\nThought: I need to search Adam Clayton Powell and The Saimaa Gesture, and find which documentary is about Finnish rock groups.\nAction: Search[Adam Clayton Powell]\nObservation: Could not find [Adam Clayton Powell]. Similar: [’Adam Clayton Powell III’, ’Seventh Avenue (Manhattan)’, ’Adam Clayton Powell Jr. State Office Building’, ’Isabel Washington Powell’, ’Adam Powell’, ’Adam Clayton Powell (film)’, ’Giancarlo Esposito’].\nThought: To find the documentary, I can search Adam Clayton Powell (film).\nAction: Search[Adam Clayton Powell (film)]\nObservation: Adam Clayton Powell is a 1989 American documentary film directed by Richard Kilberg. The film is about the rise and fall of influential African-American politician Adam Clayton Powell Jr.[3][4] It was later aired as part of the PBS series The American Experience.\nThought: Adam Clayton Powell (film) is a documentary about an African-American politician, not Finnish rock groups. So the documentary about Finnish rock groups must instead be The Saimaa Gesture.\nAction: Finish[The Saimaa Gesture]\n\nQuestion: What profession does Nicholas Ray and Elia Kazan have in common?\nThought: I need to search Nicholas Ray and Elia Kazan, find their professions, then find the profession they have in common.\nAction: Search[Nicholas Ray]\nObservation: Nicholas Ray (born Raymond Nicholas Kienzle Jr., August 7, 1911 - June 16, 1979) was an American film director, screenwriter, and actor best known for the 1955 film Rebel Without a Cause.\nThought: Professions of Nicholas Ray are director, screenwriter, and actor. I need to search Elia Kazan next and find his professions.\nAction: Search[Elia Kazan]\nObservation: Elia Kazan was an American film and theatre director, producer, screenwriter and actor.\nThought: Professions of Elia Kazan are director, producer, screenwriter, and actor. So profession Nicholas Ray and Elia Kazan have in common is director, screenwriter, and actor.\nAction: Finish[director, screenwriter, actor]\n\nQuestion: Which magazine was started first Arthur’s Magazine or First for Women?\nThought: I need to search Arthur’s Magazine and First for Women, and find which was started first.\nAction: Search[Arthur’s Magazine]\nObservation: Arthur’s Magazine (1844-1846) was an American literary periodical published in Philadelphia in the 19th century.\nThought: Arthur’s Magazine was started in 1844. I need to search First for Women next.\nAction: Search[First for Women]\nObservation: First for Women is a woman’s magazine published by Bauer Media Group in the USA.[1] The magazine was started in 1989.\nThought: First for Women was started in 1989. 1844 (Arthur’s Magazine) < 1989 (First for Women), so Arthur’s Magazine was started first.\nAction: Finish[Arthur’s Magazine]\n\nQuestion: Were Pavel Urysohn and Leonid Levin known for the same type of work?\nThought: I need to search Pavel Urysohn and Leonid Levin, find their types of work, then find if they are the same.\nAction: Search[Pavel Urysohn]\nObservation: Pavel Samuilovich Urysohn (February 3, 1898 - August 17, 1924) was a Soviet mathematician who is best known for his contributions in dimension theory.\nThought: Pavel Urysohn is a mathematician. I need to search Leonid Levin next and find its type of work.\nAction: Search[Leonid Levin]\nObservation: Leonid Anatolievich Levin is a Soviet-American mathematician and computer scientist.\nThought: Leonid Levin is a mathematician and computer scientist. So Pavel Urysohn and Leonid Levin have the same type of work.\nAction: Finish[yes]\n\n\nQuestion: {input}\n{agent_scratchpad}'

HOTPOTQA_PWS_BASE = '''Question: What is the elevation range for the area that the eastern sector of the Colorado orogeny extends into?
Plan: Search for more information about Colorado orogeny.
#E1 = Wikipedia[Colorado orogeny]
Plan: Find out the area that eastern sector of the Colorado orogeny extends into.
#E2 = LLM[What is the name of the area that eastern sector of Colorado extends into? Given context: #E1]
Plan: Search for more information about the area.
#E3 = Wikipedia[#E2]
Plan: Find out the elevation range for the area.
#E4 = LLM[What is elevation range for the area #E2? Given context: #E3]

Question: Musician and satirist Allie Goertz wrote a song about the "The Simpsons" character Milhouse, who Matt Groening named after who?
Plan: Search for more information about Milhouse.
#E1 = Wikipedia[Milhouse]
Plan: Find out who Matt Groening named Milhouse after.
#E2 = LLM[Who did Matt Groening name Milhouse after? Given context: #E1]

Question: Which documentary is about Finnish rock groups, Adam Clayton Powell or The Saimaa Gesture?
Plan: Search for more information about Adam Clayton Powell.
#E1 = Wikipedia[Adam Clayton Powell]
Plan: Search for more information about The Saimaa Gesture.
#E2 = Wikipedia[The Saimaa Gesture]
Plan: Compare the two and determine which is a documentary about Finnish rock groups.
#E3 = LLM[Which documentary is about Finnish rock groups, Adam Clayton Powell or The Saimaa Gesture? Given context: #E1, #E2]

Question: What profession does Nicholas Ray and Elia Kazan have in common?
Plan: Search for more information about Nicholas Ray.
#E1 = Wikipedia[Nicholas Ray]
Plan: Search for more information about Elia Kazan.
#E2 = Wikipedia[Elia Kazan]
Plan: Compare the two and determine what profession they have in common.
#E3 = LLM[What profession does Nicholas Ray and Elia Kazan have in common? Given context: #E1, #E2]

Question: Which magazine was started first Arthur's Magazine or First for Women?
Plan: Search for more information about Arthur's Magazine.
#E1 = Wikipedia[Arthur's Magazine]
Plan: Search for more information about First for Women.
#E2 = Wikipedia[First for Women]
Plan: Compare the two start dates and determine which magazine was started first.
#E3 = LLM[Which magazine was started first Arthur's Magazine or First for Women? Given context: #E1, #E2]

Question: Were Pavel Urysohn and Leonid Levin known for the same type of work?
Plan: Search for more information about Pavel Urysohn.
#E1 = Wikipedia[Pavel Urysohn]
Plan: Search for more information about Leonid Levin.
#E2 = Wikipedia[Leonid Levin]
Plan: Compare the two and determine if they were known for the same type of work.
#E3 = LLM[Were Pavel Urysohn and Leonid Levin known for the same type of work? Given context: #E1, #E2]

'''

HOTPOTQA_PWS_EXTRA = '''Question: What is Leo Dicaprio's girlfriend's age to the power of 0.34? 
Plan: Find out the name of Leo Dicaprio's girlfriend.
#E1 = Google[name of Leo Dicaprio's girlfriend] 
Plan: Find out the age of Leo Dicaprio's girlfriend.
#E2 = Google[age of #E1]
Plan: Calculate her age to the power of 0.34.
#E3 = Calculator[#E2^0.34] 
'''

TRIVIAQA_COT = '''What is the name of the river on which Bakewell stands?
Step 1: Identify the location of Bakewell.
Bakewell is a small town in Derbyshire, England.
Step 2: Search for the river that passes through Bakewell.
The River Wye flows through the town.
Answer: River Wye

'''

TRIVIAQA_REACT = '''Solve a question answering task with interleaving Thought, Action, Observation steps. Thought can reason about the current situation, and Action can be three types:
(1) Search[entity], which searches the exact entity on Wikipedia and returns the first paragraph if it exists. If not, it will return some similar entities to search.
(2) Lookup[keyword], which returns the next sentence containing keyword in the current passage.
(3) Finish[answer], which returns the answer and finishes the task.
Here are some examples.

Question: What is the name of the river on which Bakewell stands?
Thought: I need to search Bakewell and find out its location.
Action: Search[Bakewell]
Observation: Bakewell is a market town and civil parish in the Derbyshire Dales district of Derbyshire, England, known for Bakewell pudding. It lies on the River Wye, 13 miles (21 km) south-west of Sheffield. At the 2011 census, the population of the civil parish was 3,949. It was estimated at 3,695 in 2019. The town is close to the tourist attractions of Chatsworth House and Haddon Hall.
Thought: Now I know that Bakewell lies on the River Wye.
Action: Finish[River Wye]


Question: {input}
{agent_scratchpad}
'''

TRIVIAQA_PWS = '''Which Asian capital city is known as Krung Thep to its inhabitants and stands on the Chao Phraya River?
Plan: Search for more information about Krung Thep
#E1 = Wikipedia[Krung Thep]
Plan: Search for more information about Chao Phraya River
#E2 = Wikipedia[Chao Phraya River]
Plan: Find out the name of the river on which Bakewell stands.
#E3 = LLM[What is the name of the river on which Bakewell stands? Given context: #E1 and #E2]

'''

GSM8K_COT = '''Thomas, Toby, and Rebecca worked a total of 157 hours in one week.  Thomas worked x hours.  Toby worked 10 hours less than twice what Thomas worked, and Rebecca worked 8 hours less than Toby.  How many hours did Rebecca work?
Step 1: Translate the problem into algebraic expressions.
Thomas = x
Toby = 2x - 10
Rebecca = (2X - 10) - 8
Step 2: Use the total hours worked in a week to set up an equation.
Total hours worked = 157
x + (2x - 10) + ((2x - 10) - 8) = 157
Step 3: Solve the equation.
x + 2x - 10 + 2x - 10 - 8 = 157
5x - 28 = 157
5x = 185
x = 37
Step 4: Find the number of hours Rebecca worked.
Rebecca = (2x - 10) - 8
Rebecca = (2 * 37 - 10) - 8
Rebecca = 74 - 10 - 8
Rebecca = 56
Answer: 56

'''

DEFAULT_REACT = '''Use the following format:

Question: the input question you must answer
Thought: you should always think about what to do
Action: the action to take, should be one of [WolframAlpha, Calculator, LLM]
Action Input: the input to the action
Observation: the result of the action
... (this Thought/Action/Action Input/Observation can repeat N times)
Thought: I now know the final answer
Final Answer: the final answer to the original input questionHere are some examples.

Begin!

Question: {input}
{agent_scratchpad}
'''


GSM8K_REACT = '''Use the following format:

Question: the input question you must answer
Thought: you should always think about what to do
Action: the action to take, should be one of [WolframAlpha, Calculator, LLM]
Action Input: the input to the action
Observation: the result of the action
... (this Thought/Action/Action Input/Observation can repeat N times)
Thought: I now know the final answer
Final Answer: the final answer to the original input questionHere are some examples.

For Example:
Gary manages two Amazon distribution centers. The first center processes 10000 packages per day, and the second center processes three times that volume. If Amazon makes 5 cents of profit per package, how much profit per week do the two centers make combined?
Thought: I need to know the total number of packages processed by two centers per week.
Action: Calculator
Action Input: (10000 * 7) + (3 * 10000 * 7)
Observation: 280000
Thought: Now I know how much profit the two centers make combined per week.
Action: Calculator
Action Input: 280000 * 0.05
Observation: 14000
Thought: I now know the final answer
Final Answer: 14000

Begin!

Question: {input}
{agent_scratchpad}
'''

GSM8K_PWS = '''For Example:
Thomas, Toby, and Rebecca worked a total of 157 hours in one week.  Thomas worked x hours.  Toby worked 10 hours less than twice what Thomas worked, and Rebecca worked 8 hours less than Toby.  How many hours did Rebecca work?
Plan: Given Thomas worked x hours, translate the problem into algebraic expressions and solve with Wolfram Alpha.
#E1 = WolframAlpha[Solve x + (2x - 10) + ((2x - 10) - 8) = 157]
Plan: Find out the number of hours Thomas worked.
#E2 = LLM[What is x, given #E1]
Plan: Find out the number of hours Rebecca worked.
#E3 = Calculator[(2 * #E2 - 10) - 8]

'''

STRATEGY_COT = '''What is the elevation range for the area that the eastern sector of the Colorado orogeny extends into?
Step 1: Identify the eastern sector of the Colorado Orogeny
The Colorado Orogeny refers to a series of mountain-building events that occurred in the Rocky Mountains, primarily in the present-day U.S. state of Colorado. The eastern sector of the Colorado Orogeny likely refers to the easternmost part of this mountain range, which includes the Front Range, Wet Mountains, and the Sangre de Cristo Mountains.
Step 2: Determine the elevation range of the eastern sector
The Front Range, Wet Mountains, and Sangre de Cristo Mountains have varying elevations. The Front Range has elevations ranging from around 5,000 feet to over 14,000 feet (1,500 meters to 4,300 meters). The Wet Mountains have elevations ranging from about 6,000 feet to over 12,000 feet (1,800 meters to 3,700 meters). The Sangre de Cristo Mountains have elevations ranging from approximately 7,000 feet to over 14,000 feet (2,100 meters to 4,300 meters).
Step 3: Combine the elevation ranges
Considering the elevation ranges of the three mountain ranges in the eastern sector of the Colorado Orogeny, the overall elevation range for the area extends from around 5,000 feet (1,500 meters) to over 14,000 feet (4,300 meters).
Answer: 5,000 feet to 4,000 feet
'''

INSTRUCTION_FINETUNE_PREFIX = '''
For the following tasks, make plans that can solve the problem step-by-step. For each plan, indicate which external tool together with tool input to retrieve evidence. You can store the evidence into a variable #E that can be called by later tools. (Plan, #E1, Plan, #E2, Plan, ...) 

Tools can be one of the following:
Wikipedia[input]: Worker that search for similar page contents from Wikipedia. Useful when you need to get holistic knowledge about people, places, companies, historical events, or other subjects. The response are long and might contain some irrelevant information. Input should be a search query.
LLM[input]: A pretrained LLM like yourself. Useful when you need to act with general world knowledge and common sense. Prioritize it when you are confident in solving the problem yourself. Input can be any instruction.

Question: What is the elevation range for the area that the eastern sector of the Colorado orogeny extends into?
Plan: Search for more information about Colorado orogeny.
#E1 = Wikipedia[Colorado orogeny]
Plan: Find out the area that eastern sector of the Colorado orogeny extends into.
#E2 = LLM[What is the name of the area that eastern sector of Colorado extends into? Given context: #E1]
Plan: Search for more information about the area.
#E3 = Wikipedia[#E2]
Plan: Find out the elevation range for the area.
#E4 = LLM[What is elevation range for the area #E2? Given context: #E3]

Question: Musician and satirist Allie Goertz wrote a song about the "The Simpsons" character Milhouse, who Matt Groening named after who?
Plan: Search for more information about Milhouse.
#E1 = Wikipedia[Milhouse]
Plan: Find out who Matt Groening named Milhouse after.
#E2 = LLM[Who did Matt Groening name Milhouse after? Given context: #E1]

'''

INSTRUCTION_FINETUNE_SUFFIX = '''
Now make plans for each of the following questions. Your answer should follow the same format as the exemplars above. Like this:
Question: xxxx
Plan: xxxx
#E1 = xxxx
Plan: xxxx
...

'''