def make_problems(n, seed=0):
rng = random.Random(seed)
out = []
for _ in vary(n):
t = rng.alternative(["discount", "travel", "wallet", "chain"])
if t == "low cost":
unit = rng.alternative([40, 60, 80, 120])
qty = rng.alternative([5, 6, 8, 10])
disc = rng.alternative([10, 20, 25, 50])
whole = unit * qty
gold = whole - whole * disc // 100
q = (f"A store sells notebooks at {unit} rupees every. You purchase {qty} "
f"notebooks and get a {disc}% low cost on the overall invoice. "
f"What number of rupees do you pay in whole?")
elif t == "journey":
s1, h1 = rng.alternative([40, 50, 60]), rng.alternative([2, 3])
s2, h2 = rng.alternative([30, 45, 70]), rng.alternative([1, 2, 3])
gold = s1 * h1 + s2 * h2
q = (f"A automobile drives at {s1} km/h for {h1} hours, then at {s2} km/h "
f"for {h2} hours. What's the whole distance travelled, in km?")
elif t == "pockets":
tens = rng.alternative([3, 5, 7, 9])
fifties= rng.alternative([2, 4, 6])
spent = rng.alternative([50, 80, 110, 150])
gold = tens * 10 + fifties * 50 - spent
q = (f"You've {tens} ten-rupee notes and {fifties} fifty-rupee "
f"notes. You spend {spent} rupees. What number of rupees are left?")
else:
x = rng.alternative([6, 9, 12, 15]); y = rng.alternative([4, 7, 10]); z = rng.alternative([3, 8, 11])
gold = x * 2 - y + z
q = (f"Begin with the quantity {x}. Double it, then subtract {y}, "
f"then add {z}. What quantity do you finish with?")
out.append({"query": q, "reply": gold})
return out
all_problems = make_problems(18, seed=42)
random.Random(1).shuffle(all_problems)
trainset = all_problems[:12]
valset = all_problems[12:]
print(f"Dataset: {len(trainset)} practice / {len(valset)} val problemsn")
Home Artificial Intelligence Constructing Reflective Immediate Optimization with GEPA: Multi-component Prompts, Structured Suggestions, and Steady Validation
Constructing Reflective Immediate Optimization with GEPA: Multi-component Prompts, Structured Suggestions, and Steady Validation
by root

