Upload prep.py with huggingface_hub
Browse files
prep.py
CHANGED
|
@@ -190,27 +190,32 @@ def gen_memory(n=30000):
|
|
| 190 |
|
| 191 |
|
| 192 |
# Multi-step reasoning with INTERLEAVED think/act/think/answer.
|
|
|
|
| 193 |
REASON_QA = [
|
| 194 |
("A train travels 60 km/h for 2 hours, then 90 km/h for 1 hour. Total distance?",
|
| 195 |
-
"60*2 + 90*1
|
| 196 |
("If I buy 3 items at $4.50 each and a $2 tax, total cost?",
|
| 197 |
-
"3*4.50
|
| 198 |
("A rectangle is 8 by 5. Area and perimeter?",
|
| 199 |
-
"
|
| 200 |
("Compound 5% on $1000 for 2 years?",
|
| 201 |
-
"1000*1.05
|
| 202 |
("Mix 2L at 10C with 3L at 40C, final temp?",
|
| 203 |
-
"(2*10+3*40)/5
|
| 204 |
]
|
| 205 |
def gen_interleaved(n=30000):
|
| 206 |
out = []
|
| 207 |
for _ in range(n):
|
| 208 |
-
q, ans = random.choice(REASON_QA)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 209 |
conv = (f"<bos><system>{SYSTEM}</system>"
|
| 210 |
f"<user>{q}</user>"
|
| 211 |
f"<assistant><think>Break it into parts.</think>"
|
| 212 |
-
f"<tool name=\"calc\">{
|
| 213 |
-
f"<result>{
|
| 214 |
f"<think>That gives the first part; combine with the rest.</think> "
|
| 215 |
f"The answer is {ans}.</assistant><eos>")
|
| 216 |
out.append(conv)
|
|
|
|
| 190 |
|
| 191 |
|
| 192 |
# Multi-step reasoning with INTERLEAVED think/act/think/answer.
|
| 193 |
+
# Each entry: (question, calc_expr, final_answer)
|
| 194 |
REASON_QA = [
|
| 195 |
("A train travels 60 km/h for 2 hours, then 90 km/h for 1 hour. Total distance?",
|
| 196 |
+
"60*2 + 90*1", "210 km"),
|
| 197 |
("If I buy 3 items at $4.50 each and a $2 tax, total cost?",
|
| 198 |
+
"3*4.50 + 2", "$15.50"),
|
| 199 |
("A rectangle is 8 by 5. Area and perimeter?",
|
| 200 |
+
"8*5", "area 40, perimeter 26"),
|
| 201 |
("Compound 5% on $1000 for 2 years?",
|
| 202 |
+
"1000*1.05**2", "$1102.50"),
|
| 203 |
("Mix 2L at 10C with 3L at 40C, final temp?",
|
| 204 |
+
"(2*10+3*40)/5", "28C"),
|
| 205 |
]
|
| 206 |
def gen_interleaved(n=30000):
|
| 207 |
out = []
|
| 208 |
for _ in range(n):
|
| 209 |
+
q, expr, ans = random.choice(REASON_QA)
|
| 210 |
+
try:
|
| 211 |
+
res = str(eval(expr))
|
| 212 |
+
except Exception:
|
| 213 |
+
res = "?"
|
| 214 |
conv = (f"<bos><system>{SYSTEM}</system>"
|
| 215 |
f"<user>{q}</user>"
|
| 216 |
f"<assistant><think>Break it into parts.</think>"
|
| 217 |
+
f"<tool name=\"calc\">{expr}</tool>"
|
| 218 |
+
f"<result>{res}</result>"
|
| 219 |
f"<think>That gives the first part; combine with the rest.</think> "
|
| 220 |
f"The answer is {ans}.</assistant><eos>")
|
| 221 |
out.append(conv)
|