Datasets:
AgentDeliveryBench: tasks+harness+README
Browse files- generate_harvest_tasks.py +67 -0
generate_harvest_tasks.py
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Generate a TRAIN set of agent tasks (variations of the held-out benchmark templates) to harvest
|
| 2 |
+
on-policy answer-delivering trajectories from. Deterministic answers. The 30 hand-crafted tasks in
|
| 3 |
+
agent_tasks.json stay HELD-OUT as the gate. Output: agent_harvest_tasks.json"""
|
| 4 |
+
import json, math, random
|
| 5 |
+
random.seed(7)
|
| 6 |
+
T = []
|
| 7 |
+
def add(prompt, answer): T.append({"id": f"h{len(T):03d}", "prompt": prompt, "answer": str(answer)})
|
| 8 |
+
|
| 9 |
+
def is_prime(k): return k > 1 and all(k % d for d in range(2, int(k**0.5) + 1))
|
| 10 |
+
|
| 11 |
+
# arithmetic products
|
| 12 |
+
for _ in range(10):
|
| 13 |
+
a, b = random.randint(13, 98), random.randint(13, 98)
|
| 14 |
+
add(f"Use Python to compute {a} multiplied by {b} and tell me the exact product.", a*b)
|
| 15 |
+
# sum of numbers written to a file
|
| 16 |
+
for _ in range(10):
|
| 17 |
+
nums = [random.randint(2, 60) for _ in range(random.randint(3, 6))]
|
| 18 |
+
add(f"Create a file vals.txt containing these numbers, one per line: {', '.join(map(str,nums))}. "
|
| 19 |
+
f"Then read the file and tell me the sum of the numbers.", sum(nums))
|
| 20 |
+
# factorial
|
| 21 |
+
for n in [4, 5, 7, 8, 9, 10, 11]:
|
| 22 |
+
add(f"Write and run a Python script that computes {n} factorial ({n}!), and tell me the exact number.", math.factorial(n))
|
| 23 |
+
# primes below N
|
| 24 |
+
for N in [10, 15, 25, 30, 40, 60, 100]:
|
| 25 |
+
add(f"Write and run a Python script that counts the prime numbers below {N}, and tell me the count.",
|
| 26 |
+
sum(1 for k in range(2, N) if is_prime(k)))
|
| 27 |
+
# max of a list
|
| 28 |
+
for _ in range(6):
|
| 29 |
+
lst = [random.randint(5, 99) for _ in range(5)]
|
| 30 |
+
add(f"Using Python, find the maximum of these numbers: {', '.join(map(str,lst))}. Tell me the maximum.", max(lst))
|
| 31 |
+
# mean of numbers in a file (clean integer means)
|
| 32 |
+
for _ in range(6):
|
| 33 |
+
base = random.randint(2, 20); nums = [base*i for i in range(1, 5)]
|
| 34 |
+
add(f"Create numbers.txt with these values one per line: {', '.join(map(str,nums))}. Then write and run a "
|
| 35 |
+
f"Python script that reads the file and computes the arithmetic mean. Tell me the mean.", sum(nums)//len(nums))
|
| 36 |
+
# divisible-by-k count in 1..N
|
| 37 |
+
for N, k in [(50, 3), (100, 7), (60, 4), (80, 6), (40, 5)]:
|
| 38 |
+
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.",
|
| 39 |
+
sum(1 for i in range(1, N+1) if i % k == 0))
|
| 40 |
+
# k-th Fibonacci (1,1,2,3,...)
|
| 41 |
+
for kk in [6, 8, 9, 11, 12]:
|
| 42 |
+
a, b = 1, 1
|
| 43 |
+
for _ in range(kk-1): a, b = b, a+b
|
| 44 |
+
add(f"Write and run a Python script that computes the {kk}th Fibonacci number where the sequence starts 1, 1, 2, 3, 5 "
|
| 45 |
+
f"(1st is 1, 2nd is 1). Tell me the {kk}th number.", a)
|
| 46 |
+
# trailing zeros of N!
|
| 47 |
+
for N in [10, 20, 30, 50]:
|
| 48 |
+
tz = sum(N // (5**i) for i in range(1, 6))
|
| 49 |
+
add(f"Write and run a Python script that computes the number of trailing zeros in {N} factorial ({N}!). Tell me the count.", tz)
|
| 50 |
+
# sum of integers 1..N
|
| 51 |
+
for N in [50, 100, 200, 500]:
|
| 52 |
+
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)
|
| 53 |
+
# reverse a string
|
| 54 |
+
for w in ["python", "agent", "delivery", "qwen", "factor"]:
|
| 55 |
+
add(f"Write and run a Python script that reverses the string '{w}', and tell me the reversed string.", w[::-1])
|
| 56 |
+
# even-and-divisible filtered sum
|
| 57 |
+
for N, k in [(100, 7), (200, 5), (60, 3)]:
|
| 58 |
+
s = sum(i for i in range(1, N+1) if i % 2 == 0 and i % k == 0)
|
| 59 |
+
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)
|
| 60 |
+
# multi-file product of three numbers
|
| 61 |
+
for _ in range(5):
|
| 62 |
+
x, y, z = (random.randint(2, 9) for _ in range(3))
|
| 63 |
+
add(f"Create three files p1.txt, p2.txt, p3.txt containing {x}, {y}, {z} respectively. Then write and run a single "
|
| 64 |
+
f"Python script that reads all three and prints their product. Tell me the product.", x*y*z)
|
| 65 |
+
|
| 66 |
+
json.dump(T, open("agent_harvest_tasks.json", "w"))
|
| 67 |
+
print(f"generated {len(T)} harvest tasks -> agent_harvest_tasks.json")
|