| """Generate a TRAIN set of agent tasks (variations of the held-out benchmark templates) to harvest |
| on-policy answer-delivering trajectories from. Deterministic answers. The 30 hand-crafted tasks in |
| agent_tasks.json stay HELD-OUT as the gate. Output: agent_harvest_tasks.json""" |
| import json, math, random |
| random.seed(7) |
| T = [] |
| def add(prompt, answer): T.append({"id": f"h{len(T):03d}", "prompt": prompt, "answer": str(answer)}) |
|
|
| def is_prime(k): return k > 1 and all(k % d for d in range(2, int(k**0.5) + 1)) |
|
|
| |
| for _ in range(10): |
| a, b = random.randint(13, 98), random.randint(13, 98) |
| add(f"Use Python to compute {a} multiplied by {b} and tell me the exact product.", a*b) |
| |
| for _ in range(10): |
| nums = [random.randint(2, 60) for _ in range(random.randint(3, 6))] |
| add(f"Create a file vals.txt containing these numbers, one per line: {', '.join(map(str,nums))}. " |
| f"Then read the file and tell me the sum of the numbers.", sum(nums)) |
| |
| for n in [4, 5, 7, 8, 9, 10, 11]: |
| add(f"Write and run a Python script that computes {n} factorial ({n}!), and tell me the exact number.", math.factorial(n)) |
| |
| for N in [10, 15, 25, 30, 40, 60, 100]: |
| add(f"Write and run a Python script that counts the prime numbers below {N}, and tell me the count.", |
| sum(1 for k in range(2, N) if is_prime(k))) |
| |
| for _ in range(6): |
| lst = [random.randint(5, 99) for _ in range(5)] |
| add(f"Using Python, find the maximum of these numbers: {', '.join(map(str,lst))}. Tell me the maximum.", max(lst)) |
| |
| for _ in range(6): |
| base = random.randint(2, 20); nums = [base*i for i in range(1, 5)] |
| add(f"Create numbers.txt with these values one per line: {', '.join(map(str,nums))}. Then write and run a " |
| f"Python script that reads the file and computes the arithmetic mean. Tell me the mean.", sum(nums)//len(nums)) |
| |
| for N, k in [(50, 3), (100, 7), (60, 4), (80, 6), (40, 5)]: |
| add(f"Write and run a Python script that counts how many integers from 1 to {N} inclusive are divisible by {k}. Tell me the count.", |
| sum(1 for i in range(1, N+1) if i % k == 0)) |
| |
| for kk in [6, 8, 9, 11, 12]: |
| a, b = 1, 1 |
| for _ in range(kk-1): a, b = b, a+b |
| add(f"Write and run a Python script that computes the {kk}th Fibonacci number where the sequence starts 1, 1, 2, 3, 5 " |
| f"(1st is 1, 2nd is 1). Tell me the {kk}th number.", a) |
| |
| for N in [10, 20, 30, 50]: |
| tz = sum(N // (5**i) for i in range(1, 6)) |
| add(f"Write and run a Python script that computes the number of trailing zeros in {N} factorial ({N}!). Tell me the count.", tz) |
| |
| for N in [50, 100, 200, 500]: |
| add(f"Use Python to compute the sum of all integers from 1 to {N} inclusive, and tell me the total.", N*(N+1)//2) |
| |
| for w in ["python", "agent", "delivery", "qwen", "factor"]: |
| add(f"Write and run a Python script that reverses the string '{w}', and tell me the reversed string.", w[::-1]) |
| |
| for N, k in [(100, 7), (200, 5), (60, 3)]: |
| s = sum(i for i in range(1, N+1) if i % 2 == 0 and i % k == 0) |
| add(f"Write and run a Python script that sums all integers from 1 to {N} inclusive that are BOTH even AND divisible by {k}. Tell me the sum.", s) |
| |
| for _ in range(5): |
| x, y, z = (random.randint(2, 9) for _ in range(3)) |
| add(f"Create three files p1.txt, p2.txt, p3.txt containing {x}, {y}, {z} respectively. Then write and run a single " |
| f"Python script that reads all three and prints their product. Tell me the product.", x*y*z) |
|
|
| json.dump(T, open("agent_harvest_tasks.json", "w")) |
| print(f"generated {len(T)} harvest tasks -> agent_harvest_tasks.json") |
|
|