coderofpears commited on
Commit
0ee35dc
·
verified ·
1 Parent(s): f62cb24

Upload prep.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. prep.py +13 -8
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 = 120 + 90 = 210 km"),
196
  ("If I buy 3 items at $4.50 each and a $2 tax, total cost?",
197
- "3*4.50 = 13.50; +2 = 15.50"),
198
  ("A rectangle is 8 by 5. Area and perimeter?",
199
- "area 8*5=40; perimeter 2*(8+5)=26"),
200
  ("Compound 5% on $1000 for 2 years?",
201
- "1000*1.05^2 = 1102.50"),
202
  ("Mix 2L at 10C with 3L at 40C, final temp?",
203
- "(2*10+3*40)/5 = 140/5 = 28C"),
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\">{ans.split('=')[0].strip()}</tool>"
213
- f"<result>{eval(ans.split('=')[0].strip())}</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)