srush HF staff commited on
Commit
fcc66cf
1 Parent(s): 01f1f31

Upload with huggingface_hub

Browse files
Files changed (5) hide show
  1. math.log +12 -0
  2. math.pmpt.tpl +48 -0
  3. math.pmpt.tpl~ +26 -0
  4. math_demo.py +38 -0
  5. math_prompts.py +165 -0
math.log ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"action_status": "started", "timestamp": 1678759967.2008536, "task_uuid": "81655907-1b95-4737-a624-b80c13bf67c6", "action_type": "math", "task_level": [1]}
2
+ {"action_status": "succeeded", "timestamp": 1678759967.2009714, "task_uuid": "81655907-1b95-4737-a624-b80c13bf67c6", "action_type": "math", "task_level": [2]}
3
+ {"action_status": "started", "timestamp": 1678759967.2243814, "task_uuid": "f1fd39ca-381d-4b9e-9a0d-5812a8c20c21", "action_type": "bash", "task_level": [1]}
4
+ {"action_status": "succeeded", "timestamp": 1678759967.2245207, "task_uuid": "f1fd39ca-381d-4b9e-9a0d-5812a8c20c21", "action_type": "bash", "task_level": [2]}
5
+ {"action_status": "started", "timestamp": 1678759967.2472994, "task_uuid": "d8d39770-770f-47b8-9220-ad86e3d3caab", "action_type": "pal", "task_level": [1]}
6
+ {"action_status": "succeeded", "timestamp": 1678759967.2474098, "task_uuid": "d8d39770-770f-47b8-9220-ad86e3d3caab", "action_type": "pal", "task_level": [2]}
7
+ {"action_status": "started", "timestamp": 1678759967.4239852, "task_uuid": "20b25aab-148d-4f7e-8d5a-e4f812df7390", "action_type": "gatsby", "task_level": [1]}
8
+ {"action_status": "succeeded", "timestamp": 1678759967.4241192, "task_uuid": "20b25aab-148d-4f7e-8d5a-e4f812df7390", "action_type": "gatsby", "task_level": [2]}
9
+ {"action_status": "started", "timestamp": 1678759967.5648448, "task_uuid": "166d72a3-608f-4a3b-ad1f-53067e284187", "action_type": "qa", "task_level": [1]}
10
+ {"action_status": "succeeded", "timestamp": 1678759967.5656788, "task_uuid": "166d72a3-608f-4a3b-ad1f-53067e284187", "action_type": "qa", "task_level": [2]}
11
+ {"action_status": "started", "timestamp": 1678759967.5982351, "task_uuid": "d9a2055f-ef19-4094-a058-38024869062f", "action_type": "stats", "task_level": [1]}
12
+ {"action_status": "succeeded", "timestamp": 1678759967.598474, "task_uuid": "d9a2055f-ef19-4094-a058-38024869062f", "action_type": "stats", "task_level": [2]}
math.pmpt.tpl ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Question:
2
+
3
+ * What is 37593 * 67?
4
+
5
+ #### Code:
6
+
7
+ ```python
8
+ print(37593 * 67)
9
+ ```
10
+
11
+ #### Question:
12
+
13
+ * Janet's ducks lay 16 eggs per day. She eats three for breakfast every morning and bakes muffins for her friends every day with four. She sells the remainder at the farmers' market daily for $2 per fresh duck egg. How much in dollars does she make every day at the farmers' market?
14
+
15
+ #### Code:
16
+
17
+ ```python
18
+ print((16-3-4)*2)
19
+ ```
20
+
21
+ #### Question:
22
+
23
+ * How many of the integers between 0 and 99 inclusive are divisible by 8?
24
+
25
+ #### Code:
26
+
27
+ ```python
28
+ count = 0
29
+ for i in range(0, 99+1):
30
+ if i % 8 == 0: count += 1
31
+ print(count)
32
+ ```
33
+
34
+ #### Question:
35
+
36
+ * A robe takes 2 bolts of blue fiber and half that much white fiber. How many bolts in total does it take?
37
+
38
+ #### Code:
39
+
40
+ ```python
41
+ print(2 + 2/2)
42
+ ```
43
+
44
+ #### Question:
45
+
46
+ * {{question}}
47
+
48
+ #### Code:
math.pmpt.tpl~ ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ question:
2
+ What is 37593 * 67?
3
+ code:
4
+ 37593 * 67
5
+ 1:
6
+ { question, code }
7
+ question:
8
+ Janet's ducks lay 16 eggs per day. She eats three for breakfast every morning and bakes muffins for her friends every day with four. She sells the remainder at the farmers' market daily for $2 per fresh duck egg. How much in dollars does she make every day at the farmers' market?
9
+ code:
10
+ (16-3-4)*2
11
+ 2:
12
+ { question, code }
13
+ question:
14
+ How many of the integers between 0 and 99 inclusive are divisible by 8?
15
+ code:
16
+ let count = 0;
17
+ for (let i = 0; i <= 99; i++) {
18
+ if (i % 8 === 0) { count+=1 }
19
+ };
20
+ count
21
+ 3:
22
+ { question, code }
23
+ question:
24
+ A robe takes 2 bolts of blue fiber and half that much white fiber. How many bolts in total does it take?
25
+ code:
26
+ 2 + 2/2
math_demo.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Notebook to answer a math problem with code.
2
+ # Adapted from Dust [maths-generate-code](https://dust.tt/spolu/a/d12ac33169)
3
+
4
+ import minichain
5
+
6
+ # Prompt that asks LLM for code from math.
7
+
8
+ class MathPrompt(minichain.TemplatePrompt[str]):
9
+ template_file = "math.pmpt.tpl"
10
+
11
+
12
+ # Ask a question and run it as python code.
13
+
14
+ with minichain.start_chain("math") as backend:
15
+ math_prompt = MathPrompt(backend.OpenAI())
16
+ code_prompt = minichain.SimplePrompt(backend.Python())
17
+ prompt = math_prompt.chain(code_prompt)
18
+ # result = prompt({"question": question})
19
+ # print(result)
20
+
21
+ gradio = prompt.to_gradio(fields =["question"],
22
+ examples=["What is the sum of the powers of 3 (3^i) that are smaller than 100?"],
23
+ out_type="markdown"
24
+
25
+ )
26
+ if __name__ == "__main__":
27
+ gradio.launch()
28
+
29
+
30
+ # View the prompt
31
+
32
+ # + tags=["hide_inp"]
33
+ # MathPrompt().show({"question": "What is 10 + 12?"}, "10 + 12")
34
+ # # -
35
+
36
+ # # View the log
37
+
38
+ # minichain.show_log("math.log")
math_prompts.py ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2022 PAL Authors. All rights reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+
16
+ MATH_PROMPT = '''
17
+ Q: Olivia has $23. She bought five bagels for $3 each. How much money does she have left?
18
+
19
+ # solution in Python:
20
+
21
+
22
+ def solution():
23
+ """Olivia has $23. She bought five bagels for $3 each. How much money does she have left?"""
24
+ money_initial = 23
25
+ bagels = 5
26
+ bagel_cost = 3
27
+ money_spent = bagels * bagel_cost
28
+ money_left = money_initial - money_spent
29
+ result = money_left
30
+ return result
31
+
32
+
33
+
34
+
35
+
36
+ Q: Michael had 58 golf balls. On tuesday, he lost 23 golf balls. On wednesday, he lost 2 more. How many golf balls did he have at the end of wednesday?
37
+
38
+ # solution in Python:
39
+
40
+
41
+ def solution():
42
+ """Michael had 58 golf balls. On tuesday, he lost 23 golf balls. On wednesday, he lost 2 more. How many golf balls did he have at the end of wednesday?"""
43
+ golf_balls_initial = 58
44
+ golf_balls_lost_tuesday = 23
45
+ golf_balls_lost_wednesday = 2
46
+ golf_balls_left = golf_balls_initial - golf_balls_lost_tuesday - golf_balls_lost_wednesday
47
+ result = golf_balls_left
48
+ return result
49
+
50
+
51
+
52
+
53
+
54
+ Q: There were nine computers in the server room. Five more computers were installed each day, from monday to thursday. How many computers are now in the server room?
55
+
56
+ # solution in Python:
57
+
58
+
59
+ def solution():
60
+ """There were nine computers in the server room. Five more computers were installed each day, from monday to thursday. How many computers are now in the server room?"""
61
+ computers_initial = 9
62
+ computers_per_day = 5
63
+ num_days = 4 # 4 days between monday and thursday
64
+ computers_added = computers_per_day * num_days
65
+ computers_total = computers_initial + computers_added
66
+ result = computers_total
67
+ return result
68
+
69
+
70
+
71
+
72
+
73
+ Q: Shawn has five toys. For Christmas, he got two toys each from his mom and dad. How many toys does he have now?
74
+
75
+ # solution in Python:
76
+
77
+
78
+ def solution():
79
+ """Shawn has five toys. For Christmas, he got two toys each from his mom and dad. How many toys does he have now?"""
80
+ toys_initial = 5
81
+ mom_toys = 2
82
+ dad_toys = 2
83
+ total_received = mom_toys + dad_toys
84
+ total_toys = toys_initial + total_received
85
+ result = total_toys
86
+ return result
87
+
88
+
89
+
90
+
91
+
92
+ Q: Jason had 20 lollipops. He gave Denny some lollipops. Now Jason has 12 lollipops. How many lollipops did Jason give to Denny?
93
+
94
+ # solution in Python:
95
+
96
+
97
+ def solution():
98
+ """Jason had 20 lollipops. He gave Denny some lollipops. Now Jason has 12 lollipops. How many lollipops did Jason give to Denny?"""
99
+ jason_lollipops_initial = 20
100
+ jason_lollipops_after = 12
101
+ denny_lollipops = jason_lollipops_initial - jason_lollipops_after
102
+ result = denny_lollipops
103
+ return result
104
+
105
+
106
+
107
+
108
+
109
+ Q: Leah had 32 chocolates and her sister had 42. If they ate 35, how many pieces do they have left in total?
110
+
111
+ # solution in Python:
112
+
113
+
114
+ def solution():
115
+ """Leah had 32 chocolates and her sister had 42. If they ate 35, how many pieces do they have left in total?"""
116
+ leah_chocolates = 32
117
+ sister_chocolates = 42
118
+ total_chocolates = leah_chocolates + sister_chocolates
119
+ chocolates_eaten = 35
120
+ chocolates_left = total_chocolates - chocolates_eaten
121
+ result = chocolates_left
122
+ return result
123
+
124
+
125
+
126
+
127
+
128
+ Q: If there are 3 cars in the parking lot and 2 more cars arrive, how many cars are in the parking lot?
129
+
130
+ # solution in Python:
131
+
132
+
133
+ def solution():
134
+ """If there are 3 cars in the parking lot and 2 more cars arrive, how many cars are in the parking lot?"""
135
+ cars_initial = 3
136
+ cars_arrived = 2
137
+ total_cars = cars_initial + cars_arrived
138
+ result = total_cars
139
+ return result
140
+
141
+
142
+
143
+
144
+
145
+ Q: There are 15 trees in the grove. Grove workers will plant trees in the grove today. After they are done, there will be 21 trees. How many trees did the grove workers plant today?
146
+
147
+ # solution in Python:
148
+
149
+
150
+ def solution():
151
+ """There are 15 trees in the grove. Grove workers will plant trees in the grove today. After they are done, there will be 21 trees. How many trees did the grove workers plant today?"""
152
+ trees_initial = 15
153
+ trees_after = 21
154
+ trees_added = trees_after - trees_initial
155
+ result = trees_added
156
+ return result
157
+
158
+
159
+
160
+
161
+
162
+ Q: {question}
163
+
164
+ # solution in Python:
165
+ '''.strip() + '\n\n\n'