Sasha Rush
commited on
Commit
•
01f1f31
1
Parent(s):
abc9939
- math.ipynb +0 -302
- math.log +0 -12
- math.pmpt.tpl +0 -48
- math.pmpt.tpl~ +0 -26
- math.py +0 -38
- math.py~ +0 -14
- math_demo.py +0 -38
- math_prompts.py +0 -165
math.ipynb
DELETED
@@ -1,302 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"cells": [
|
3 |
-
{
|
4 |
-
"cell_type": "markdown",
|
5 |
-
"id": "c0381b39",
|
6 |
-
"metadata": {},
|
7 |
-
"source": [
|
8 |
-
"Notebook to answer a math problem with code.\n",
|
9 |
-
"Adapted from Dust [maths-generate-code](https://dust.tt/spolu/a/d12ac33169)"
|
10 |
-
]
|
11 |
-
},
|
12 |
-
{
|
13 |
-
"cell_type": "code",
|
14 |
-
"execution_count": 1,
|
15 |
-
"id": "d709d448",
|
16 |
-
"metadata": {
|
17 |
-
"execution": {
|
18 |
-
"iopub.execute_input": "2023-02-27T14:14:11.694164Z",
|
19 |
-
"iopub.status.busy": "2023-02-27T14:14:11.693422Z",
|
20 |
-
"iopub.status.idle": "2023-02-27T14:14:11.909671Z",
|
21 |
-
"shell.execute_reply": "2023-02-27T14:14:11.908948Z"
|
22 |
-
},
|
23 |
-
"lines_to_next_cell": 1
|
24 |
-
},
|
25 |
-
"outputs": [],
|
26 |
-
"source": [
|
27 |
-
"import minichain"
|
28 |
-
]
|
29 |
-
},
|
30 |
-
{
|
31 |
-
"cell_type": "markdown",
|
32 |
-
"id": "8ae06a28",
|
33 |
-
"metadata": {},
|
34 |
-
"source": [
|
35 |
-
"Prompt that asks LLM for code from math."
|
36 |
-
]
|
37 |
-
},
|
38 |
-
{
|
39 |
-
"cell_type": "code",
|
40 |
-
"execution_count": 2,
|
41 |
-
"id": "89496133",
|
42 |
-
"metadata": {
|
43 |
-
"execution": {
|
44 |
-
"iopub.execute_input": "2023-02-27T14:14:11.914563Z",
|
45 |
-
"iopub.status.busy": "2023-02-27T14:14:11.913355Z",
|
46 |
-
"iopub.status.idle": "2023-02-27T14:14:11.918659Z",
|
47 |
-
"shell.execute_reply": "2023-02-27T14:14:11.918034Z"
|
48 |
-
},
|
49 |
-
"lines_to_next_cell": 1
|
50 |
-
},
|
51 |
-
"outputs": [],
|
52 |
-
"source": [
|
53 |
-
"class MathPrompt(minichain.TemplatePrompt[str]):\n",
|
54 |
-
" template_file = \"math.pmpt.tpl\""
|
55 |
-
]
|
56 |
-
},
|
57 |
-
{
|
58 |
-
"cell_type": "markdown",
|
59 |
-
"id": "22169567",
|
60 |
-
"metadata": {},
|
61 |
-
"source": [
|
62 |
-
"Ask a question and run it as python code."
|
63 |
-
]
|
64 |
-
},
|
65 |
-
{
|
66 |
-
"cell_type": "code",
|
67 |
-
"execution_count": 3,
|
68 |
-
"id": "6e122554",
|
69 |
-
"metadata": {
|
70 |
-
"execution": {
|
71 |
-
"iopub.execute_input": "2023-02-27T14:14:11.923599Z",
|
72 |
-
"iopub.status.busy": "2023-02-27T14:14:11.922332Z",
|
73 |
-
"iopub.status.idle": "2023-02-27T14:14:14.957037Z",
|
74 |
-
"shell.execute_reply": "2023-02-27T14:14:14.956368Z"
|
75 |
-
}
|
76 |
-
},
|
77 |
-
"outputs": [
|
78 |
-
{
|
79 |
-
"name": "stdout",
|
80 |
-
"output_type": "stream",
|
81 |
-
"text": [
|
82 |
-
"121\n",
|
83 |
-
"\n"
|
84 |
-
]
|
85 |
-
}
|
86 |
-
],
|
87 |
-
"source": [
|
88 |
-
"with minichain.start_chain(\"math\") as backend:\n",
|
89 |
-
" question = \"What is the sum of the powers of 3 (3^i) that are smaller than 100?\"\n",
|
90 |
-
" prompt = MathPrompt(backend.OpenAI()).chain(minichain.SimplePrompt(backend.Python()))\n",
|
91 |
-
" result = prompt({\"question\": question})\n",
|
92 |
-
" print(result)"
|
93 |
-
]
|
94 |
-
},
|
95 |
-
{
|
96 |
-
"cell_type": "markdown",
|
97 |
-
"id": "c41d0936",
|
98 |
-
"metadata": {},
|
99 |
-
"source": [
|
100 |
-
"View the prompt"
|
101 |
-
]
|
102 |
-
},
|
103 |
-
{
|
104 |
-
"cell_type": "code",
|
105 |
-
"execution_count": 4,
|
106 |
-
"id": "df25f904",
|
107 |
-
"metadata": {
|
108 |
-
"execution": {
|
109 |
-
"iopub.execute_input": "2023-02-27T14:14:14.960159Z",
|
110 |
-
"iopub.status.busy": "2023-02-27T14:14:14.959694Z",
|
111 |
-
"iopub.status.idle": "2023-02-27T14:14:15.006679Z",
|
112 |
-
"shell.execute_reply": "2023-02-27T14:14:15.006127Z"
|
113 |
-
},
|
114 |
-
"tags": [
|
115 |
-
"hide_inp"
|
116 |
-
]
|
117 |
-
},
|
118 |
-
"outputs": [
|
119 |
-
{
|
120 |
-
"data": {
|
121 |
-
"text/html": [
|
122 |
-
"\n",
|
123 |
-
"<!-- <link rel=\"stylesheet\" href=\"https://cdn.rawgit.com/Chalarangelo/mini.css/v3.0.1/dist/mini-default.min.css\"> -->\n",
|
124 |
-
" <main class=\"container\">\n",
|
125 |
-
"\n",
|
126 |
-
"<h3>MathPrompt</h3>\n",
|
127 |
-
"\n",
|
128 |
-
"<dl>\n",
|
129 |
-
" <dt>Input:</dt>\n",
|
130 |
-
" <dd>\n",
|
131 |
-
"<div class=\"highlight\"><pre><span></span><span class=\"p\">{</span><span class=\"s1\">'question'</span><span class=\"p\">:</span> <span class=\"s1\">'What is 10 + 12?'</span><span class=\"p\">}</span>\n",
|
132 |
-
"</pre></div>\n",
|
133 |
-
"\n",
|
134 |
-
"\n",
|
135 |
-
" </dd>\n",
|
136 |
-
"\n",
|
137 |
-
" <dt> Full Prompt: </dt>\n",
|
138 |
-
" <dd>\n",
|
139 |
-
" <details>\n",
|
140 |
-
" <summary>Prompt</summary>\n",
|
141 |
-
" <p>Question:<br>What is 37593 * 67?<br>Code:<br>37593 * 67<br><br>Question:<br>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?<br>Code:<br>(16-3-4)*2<br><br>Question:<br>How many of the integers between 0 and 99 inclusive are divisible by 8?<br>Code:<br>count = 0<br>for i in range(0, 99+1):<br> if i % 8 == 0: count += 1<br><br>Question:<br>A robe takes 2 bolts of blue fiber and half that much white fiber. How many bolts in total does it take?<br>Code:<br>2 + 2/2<br><br>Question:<br><div style='color:red'>What is 10 + 12?</div><br>Code:</p>\n",
|
142 |
-
" </details>\n",
|
143 |
-
" </dd>\n",
|
144 |
-
"\n",
|
145 |
-
" <dt> Response: </dt>\n",
|
146 |
-
" <dd>\n",
|
147 |
-
" 10 + 12\n",
|
148 |
-
" </dd>\n",
|
149 |
-
"\n",
|
150 |
-
" <dt>Value:</dt>\n",
|
151 |
-
" <dd>\n",
|
152 |
-
"<div class=\"highlight\"><pre><span></span><span class=\"mi\">10</span> <span class=\"o\">+</span> <span class=\"mi\">12</span>\n",
|
153 |
-
"</pre></div>\n",
|
154 |
-
"\n",
|
155 |
-
" </dd>\n",
|
156 |
-
"</main>\n"
|
157 |
-
],
|
158 |
-
"text/plain": [
|
159 |
-
"HTML(html='\\n<!-- <link rel=\"stylesheet\" href=\"https://cdn.rawgit.com/Chalarangelo/mini.css/v3.0.1/dist/mini-default.min.css\"> -->\\n <main class=\"container\">\\n\\n<h3>MathPrompt</h3>\\n\\n<dl>\\n <dt>Input:</dt>\\n <dd>\\n<div class=\"highlight\"><pre><span></span><span class=\"p\">{</span><span class=\"s1\">'question'</span><span class=\"p\">:</span> <span class=\"s1\">'What is 10 + 12?'</span><span class=\"p\">}</span>\\n</pre></div>\\n\\n\\n </dd>\\n\\n <dt> Full Prompt: </dt>\\n <dd>\\n <details>\\n <summary>Prompt</summary>\\n <p>Question:<br>What is 37593 * 67?<br>Code:<br>37593 * 67<br><br>Question:<br>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?<br>Code:<br>(16-3-4)*2<br><br>Question:<br>How many of the integers between 0 and 99 inclusive are divisible by 8?<br>Code:<br>count = 0<br>for i in range(0, 99+1):<br> if i % 8 == 0: count += 1<br><br>Question:<br>A robe takes 2 bolts of blue fiber and half that much white fiber. How many bolts in total does it take?<br>Code:<br>2 + 2/2<br><br>Question:<br><div style=\\'color:red\\'>What is 10 + 12?</div><br>Code:</p>\\n </details>\\n </dd>\\n\\n <dt> Response: </dt>\\n <dd>\\n 10 + 12\\n </dd>\\n\\n <dt>Value:</dt>\\n <dd>\\n<div class=\"highlight\"><pre><span></span><span class=\"mi\">10</span> <span class=\"o\">+</span> <span class=\"mi\">12</span>\\n</pre></div>\\n\\n </dd>\\n</main>\\n')"
|
160 |
-
]
|
161 |
-
},
|
162 |
-
"execution_count": 4,
|
163 |
-
"metadata": {},
|
164 |
-
"output_type": "execute_result"
|
165 |
-
}
|
166 |
-
],
|
167 |
-
"source": [
|
168 |
-
"MathPrompt().show({\"question\": \"What is 10 + 12?\"}, \"10 + 12\")"
|
169 |
-
]
|
170 |
-
},
|
171 |
-
{
|
172 |
-
"cell_type": "markdown",
|
173 |
-
"id": "5f726907",
|
174 |
-
"metadata": {},
|
175 |
-
"source": [
|
176 |
-
"View the log"
|
177 |
-
]
|
178 |
-
},
|
179 |
-
{
|
180 |
-
"cell_type": "code",
|
181 |
-
"execution_count": 5,
|
182 |
-
"id": "0aa84914",
|
183 |
-
"metadata": {
|
184 |
-
"execution": {
|
185 |
-
"iopub.execute_input": "2023-02-27T14:14:15.009395Z",
|
186 |
-
"iopub.status.busy": "2023-02-27T14:14:15.008955Z",
|
187 |
-
"iopub.status.idle": "2023-02-27T14:14:15.032165Z",
|
188 |
-
"shell.execute_reply": "2023-02-27T14:14:15.031585Z"
|
189 |
-
}
|
190 |
-
},
|
191 |
-
"outputs": [
|
192 |
-
{
|
193 |
-
"name": "stderr",
|
194 |
-
"output_type": "stream",
|
195 |
-
"text": [
|
196 |
-
"\u001b[38;5;15md962c2e7-4475-4094-bd1d-24f450acac26\u001b[1m\u001b[0m\n",
|
197 |
-
"└── \u001b[38;5;5m<class '__main__.MathPrompt'>\u001b[0m/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 14:14:12Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m2.713s\u001b[2m\u001b[0m\n",
|
198 |
-
" ├── \u001b[38;5;5mInput Function\u001b[0m/2/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 14:14:12Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m0.002s\u001b[2m\u001b[0m\n",
|
199 |
-
" │ ├── \u001b[38;5;4minput\u001b[0m: \u001b[0m\n",
|
200 |
-
" │ │ └── \u001b[38;5;4mquestion\u001b[0m: What is the sum of the powers of 3 (3^i) that are smaller than 100?\u001b[0m\n",
|
201 |
-
" │ └── \u001b[38;5;5mInput Function\u001b[0m/2/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 14:14:12Z\u001b[2m\u001b[0m\n",
|
202 |
-
" ├── \u001b[38;5;5mPrompted\u001b[0m/3/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 14:14:12Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m2.711s\u001b[2m\u001b[0m\n",
|
203 |
-
" │ ├── \u001b[38;5;4mprompt\u001b[0m: Question:⏎\n",
|
204 |
-
" │ │ What is 37593 * 67?⏎\n",
|
205 |
-
" │ │ Code:⏎\n",
|
206 |
-
" │ │ 37593 * 67⏎\n",
|
207 |
-
" │ │ ⏎\n",
|
208 |
-
" │ │ Question:⏎\n",
|
209 |
-
" │ │ 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?⏎\n",
|
210 |
-
" │ │ Code:⏎\n",
|
211 |
-
" │ │ (16-3-4)*2⏎\n",
|
212 |
-
" │ │ ⏎\n",
|
213 |
-
" │ │ Question:⏎\n",
|
214 |
-
" │ │ How many of the integers between 0 and 99 inclusive are divisible by 8?⏎\n",
|
215 |
-
" │ │ Code:⏎\n",
|
216 |
-
" │ │ count = 0⏎\n",
|
217 |
-
" │ │ for i in range(0, 99+1):⏎\n",
|
218 |
-
" │ │ if i % 8 == 0: count += 1⏎\n",
|
219 |
-
" │ │ ⏎\n",
|
220 |
-
" │ │ Question:⏎\n",
|
221 |
-
" │ │ A robe takes 2 bolts of blue fiber and half that much white fiber. How many bolts in total does it take?⏎\n",
|
222 |
-
" │ │ Code:⏎\n",
|
223 |
-
" │ │ 2 + 2/2⏎\n",
|
224 |
-
" │ │ ⏎\n",
|
225 |
-
" │ │ Question:⏎\n",
|
226 |
-
" │ │ What is the sum of the powers of 3 (3^i) that are smaller than 100?⏎\n",
|
227 |
-
" │ │ Code:\u001b[0m\n",
|
228 |
-
" │ └── \u001b[38;5;5mPrompted\u001b[0m/3/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 14:14:14Z\u001b[2m\u001b[0m\n",
|
229 |
-
" ├── \u001b[38;5;5mResult\u001b[0m/4/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 14:14:14Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m0.000s\u001b[2m\u001b[0m\n",
|
230 |
-
" │ ├── \u001b[38;5;4mresult\u001b[0m: ⏎\n",
|
231 |
-
" │ │ sum = 0⏎\n",
|
232 |
-
" │ │ for i in range(0, 100):⏎\n",
|
233 |
-
" │ │ if 3**i < 100:⏎\n",
|
234 |
-
" │ │ sum += 3**i⏎\n",
|
235 |
-
" │ │ ⏎\n",
|
236 |
-
" │ │ print(sum)\u001b[0m\n",
|
237 |
-
" │ └── \u001b[38;5;5mResult\u001b[0m/4/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 14:14:14Z\u001b[2m\u001b[0m\n",
|
238 |
-
" └── \u001b[38;5;5m<class '__main__.MathPrompt'>\u001b[0m/5\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 14:14:14Z\u001b[2m\u001b[0m\n",
|
239 |
-
"\n",
|
240 |
-
"\u001b[38;5;15m3ce24477-fa41-4ca1-b11e-f7d253a7c511\u001b[1m\u001b[0m\n",
|
241 |
-
"└── \u001b[38;5;5m<class 'minichain.prompts.SimplePrompt'>\u001b[0m/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 14:14:14Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m0.000s\u001b[2m\u001b[0m\n",
|
242 |
-
" ├── \u001b[38;5;5mInput Function\u001b[0m/2/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 14:14:14Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m0.000s\u001b[2m\u001b[0m\n",
|
243 |
-
" │ ├── \u001b[38;5;4minput\u001b[0m: ⏎\n",
|
244 |
-
" │ │ sum = 0⏎\n",
|
245 |
-
" │ │ for i in range(0, 100):⏎\n",
|
246 |
-
" │ │ if 3**i < 100:⏎\n",
|
247 |
-
" │ │ sum += 3**i⏎\n",
|
248 |
-
" │ │ ⏎\n",
|
249 |
-
" │ │ print(sum)\u001b[0m\n",
|
250 |
-
" │ └── \u001b[38;5;5mInput Function\u001b[0m/2/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 14:14:14Z\u001b[2m\u001b[0m\n",
|
251 |
-
" ├── \u001b[38;5;5mPrompted\u001b[0m/3/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 14:14:14Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m0.000s\u001b[2m\u001b[0m\n",
|
252 |
-
" │ ├── \u001b[38;5;4mprompt\u001b[0m: ⏎\n",
|
253 |
-
" │ │ sum = 0⏎\n",
|
254 |
-
" │ │ for i in range(0, 100):⏎\n",
|
255 |
-
" │ │ if 3**i < 100:⏎\n",
|
256 |
-
" │ │ sum += 3**i⏎\n",
|
257 |
-
" │ │ ⏎\n",
|
258 |
-
" │ │ print(sum)\u001b[0m\n",
|
259 |
-
" │ └── \u001b[38;5;5mPrompted\u001b[0m/3/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 14:14:14Z\u001b[2m\u001b[0m\n",
|
260 |
-
" ├── \u001b[38;5;5mResult\u001b[0m/4/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 14:14:14Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m0.000s\u001b[2m\u001b[0m\n",
|
261 |
-
" │ ├── \u001b[38;5;4mresult\u001b[0m: 121⏎\n",
|
262 |
-
" │ │ \u001b[0m\n",
|
263 |
-
" │ └── \u001b[38;5;5mResult\u001b[0m/4/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 14:14:14Z\u001b[2m\u001b[0m\n",
|
264 |
-
" └── \u001b[38;5;5m<class 'minichain.prompts.SimplePrompt'>\u001b[0m/5\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 14:14:14Z\u001b[2m\u001b[0m\n",
|
265 |
-
"\n",
|
266 |
-
"\u001b[38;5;15m4d75cc49-ca9f-4512-8ca0-9393732c7d14\u001b[1m\u001b[0m\n",
|
267 |
-
"└── \u001b[38;5;5mmath\u001b[0m/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 14:14:11Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m3.028s\u001b[2m\u001b[0m\n",
|
268 |
-
" └── \u001b[38;5;5mmath\u001b[0m/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 14:14:14Z\u001b[2m\u001b[0m\n",
|
269 |
-
"\n"
|
270 |
-
]
|
271 |
-
}
|
272 |
-
],
|
273 |
-
"source": [
|
274 |
-
"minichain.show_log(\"math.log\")"
|
275 |
-
]
|
276 |
-
}
|
277 |
-
],
|
278 |
-
"metadata": {
|
279 |
-
"jupytext": {
|
280 |
-
"cell_metadata_filter": "tags,-all"
|
281 |
-
},
|
282 |
-
"kernelspec": {
|
283 |
-
"display_name": "minichain",
|
284 |
-
"language": "python",
|
285 |
-
"name": "minichain"
|
286 |
-
},
|
287 |
-
"language_info": {
|
288 |
-
"codemirror_mode": {
|
289 |
-
"name": "ipython",
|
290 |
-
"version": 3
|
291 |
-
},
|
292 |
-
"file_extension": ".py",
|
293 |
-
"mimetype": "text/x-python",
|
294 |
-
"name": "python",
|
295 |
-
"nbconvert_exporter": "python",
|
296 |
-
"pygments_lexer": "ipython3",
|
297 |
-
"version": "3.10.6"
|
298 |
-
}
|
299 |
-
},
|
300 |
-
"nbformat": 4,
|
301 |
-
"nbformat_minor": 5
|
302 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
math.log
DELETED
@@ -1,12 +0,0 @@
|
|
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
DELETED
@@ -1,48 +0,0 @@
|
|
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~
DELETED
@@ -1,26 +0,0 @@
|
|
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.py
DELETED
@@ -1,38 +0,0 @@
|
|
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.py~
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
from typing import List
|
2 |
-
from minichain import Backend, JinjaPrompt, Prompt, start_chain
|
3 |
-
|
4 |
-
|
5 |
-
# Prompt that asks LLM to produce a bash command.
|
6 |
-
|
7 |
-
class CLIPrompt(JinjaPrompt[List[str]]):
|
8 |
-
template_file = "bash.pmpt.tpl"
|
9 |
-
def parse(self, result: str) -> str:
|
10 |
-
return result
|
11 |
-
|
12 |
-
CLIPrompt().show(
|
13 |
-
{"question": "list the files in the directory"},
|
14 |
-
"""```bash\nls\n```""")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
math_demo.py
DELETED
@@ -1,38 +0,0 @@
|
|
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
DELETED
@@ -1,165 +0,0 @@
|
|
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'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|