Datasets:
Upload folder using huggingface_hub
Browse files- README.md +34 -0
- problems.py +146 -0
- tasks.jsonl +8 -0
README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
task_categories:
|
| 4 |
+
- text-generation
|
| 5 |
+
pretty_name: Reason Bench
|
| 6 |
+
---
|
| 7 |
+
|
| 8 |
+
# Reason Bench
|
| 9 |
+
|
| 10 |
+
An OpenEnv environment of one-step, programmatically verified problems, one task per OpenEnv Arena domain.
|
| 11 |
+
Image: `ghcr.io/minimaddy/reason-bench:v1`. `problems.py` holds the generators and grader.
|
| 12 |
+
|
| 13 |
+
Each `reset(task_id=...)` generates a fresh randomized problem from a seeded generator. The model replies with one JSON action `{"answer": "..."}`; the episode ends after that step.
|
| 14 |
+
|
| 15 |
+
## Tasks
|
| 16 |
+
|
| 17 |
+
| task_id | What it asks |
|
| 18 |
+
|---|---|
|
| 19 |
+
| software-engineering | Output of a short generated Python program |
|
| 20 |
+
| industrial-systems | Tank fill time with inflow and drain rates |
|
| 21 |
+
| natural-science | Molar mass of a generated formula |
|
| 22 |
+
| office-work | Conditional sum over spreadsheet-style rows |
|
| 23 |
+
| finance-economics | Compound-interest balance |
|
| 24 |
+
| math-formal | Modular exponentiation, gcd, or divisor counts |
|
| 25 |
+
| cybersecurity | Usable hosts in a CIDR block, or Caesar decryption |
|
| 26 |
+
| media-production | Video file size from bitrate, or frame counts after trimming |
|
| 27 |
+
|
| 28 |
+
## Reward
|
| 29 |
+
|
| 30 |
+
- `1.0`: exact match (numeric answers within 0.005)
|
| 31 |
+
- `0.2`: numeric answer within 5% of the truth
|
| 32 |
+
- `0.0`: anything else
|
| 33 |
+
|
| 34 |
+
All rewards are in [0, 1]. Answers are compared case-insensitively after trimming.
|
problems.py
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
+
|
| 3 |
+
"""Procedural problem generators. Each returns (prompt, answer) from a seeded RNG."""
|
| 4 |
+
|
| 5 |
+
import math
|
| 6 |
+
import random
|
| 7 |
+
from typing import Callable, Dict, Tuple
|
| 8 |
+
|
| 9 |
+
Problem = Tuple[str, str]
|
| 10 |
+
|
| 11 |
+
ATOMS = {"H": 1.008, "C": 12.011, "N": 14.007, "O": 15.999, "Na": 22.990, "S": 32.06, "Cl": 35.45, "K": 39.098}
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def software(rng: random.Random) -> Problem:
|
| 15 |
+
n = rng.randint(5, 9)
|
| 16 |
+
xs = [rng.randint(1, 20) for _ in range(n)]
|
| 17 |
+
m = rng.randint(2, 4)
|
| 18 |
+
t = rng.randint(3, 12)
|
| 19 |
+
kind = rng.choice(["sum", "count", "max"])
|
| 20 |
+
if kind == "sum":
|
| 21 |
+
code = f"xs = {xs}\nprint(sum(x * {m} for x in xs if x % 2 == 1 and x > {t}))"
|
| 22 |
+
ans = sum(x * m for x in xs if x % 2 == 1 and x > t)
|
| 23 |
+
elif kind == "count":
|
| 24 |
+
code = f"xs = {xs}\nprint(len([x for x in xs if x % {m} == 0 or x > {t + 8}]))"
|
| 25 |
+
ans = len([x for x in xs if x % m == 0 or x > t + 8])
|
| 26 |
+
else:
|
| 27 |
+
code = f"xs = {xs}\nprint(max(x % {m + 5} for x in xs[::2]) + len(xs))"
|
| 28 |
+
ans = max(x % (m + 5) for x in xs[::2]) + len(xs)
|
| 29 |
+
return f"What exact integer does this Python program print?\n{code}", str(ans)
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def industrial(rng: random.Random) -> Problem:
|
| 33 |
+
vol = rng.randint(2, 9) * 1000
|
| 34 |
+
inflow = rng.randint(20, 60)
|
| 35 |
+
outflow = rng.randint(5, inflow - 10)
|
| 36 |
+
start = rng.randint(0, vol // 4)
|
| 37 |
+
minutes = math.ceil((vol - start) / (inflow - outflow))
|
| 38 |
+
return (
|
| 39 |
+
f"A tank holds {vol} L and currently has {start} L. A pump adds {inflow} L/min while a drain removes "
|
| 40 |
+
f"{outflow} L/min. After how many whole minutes is the tank first full or overfull?",
|
| 41 |
+
str(minutes),
|
| 42 |
+
)
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def science(rng: random.Random) -> Problem:
|
| 46 |
+
c = rng.randint(1, 6)
|
| 47 |
+
h = rng.randint(2, 14)
|
| 48 |
+
o = rng.randint(1, 4)
|
| 49 |
+
n = rng.randint(0, 2)
|
| 50 |
+
formula = f"C{c}H{h}" + (f"N{n}" if n else "") + f"O{o}"
|
| 51 |
+
mass = c * ATOMS["C"] + h * ATOMS["H"] + n * ATOMS["N"] + o * ATOMS["O"]
|
| 52 |
+
return (
|
| 53 |
+
f"Molar mass of {formula} in g/mol using C=12.011, H=1.008, N=14.007, O=15.999? Round to 2 decimals.",
|
| 54 |
+
f"{mass:.2f}",
|
| 55 |
+
)
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def office(rng: random.Random) -> Problem:
|
| 59 |
+
regions = ["North", "South", "East", "West"]
|
| 60 |
+
rows = [(rng.choice(regions), rng.randint(10, 99) * 10) for _ in range(rng.randint(6, 9))]
|
| 61 |
+
region = rng.choice(regions)
|
| 62 |
+
floor = rng.randint(2, 6) * 100
|
| 63 |
+
table = "\n".join(f"{r},{v}" for r, v in rows)
|
| 64 |
+
ans = sum(v for r, v in rows if r == region and v >= floor)
|
| 65 |
+
return (
|
| 66 |
+
f"Sales rows (region,amount):\n{table}\nWhat is the sum of amounts where region is {region} and amount >= {floor}?",
|
| 67 |
+
str(ans),
|
| 68 |
+
)
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
def finance(rng: random.Random) -> Problem:
|
| 72 |
+
p = rng.randint(10, 90) * 100
|
| 73 |
+
r = rng.randint(2, 11)
|
| 74 |
+
years = rng.randint(2, 6)
|
| 75 |
+
bal = p * (1 + r / 100) ** years
|
| 76 |
+
return (
|
| 77 |
+
f"Deposit {p} at {r}% annual interest compounded yearly for {years} years. "
|
| 78 |
+
f"What is the final balance, rounded to 2 decimals?",
|
| 79 |
+
f"{bal:.2f}",
|
| 80 |
+
)
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
def math_formal(rng: random.Random) -> Problem:
|
| 84 |
+
kind = rng.choice(["modpow", "gcd", "divisors"])
|
| 85 |
+
if kind == "modpow":
|
| 86 |
+
a, e, m = rng.randint(2, 30), rng.randint(10, 60), rng.randint(7, 97)
|
| 87 |
+
return f"Compute {a}^{e} mod {m}.", str(pow(a, e, m))
|
| 88 |
+
if kind == "gcd":
|
| 89 |
+
g = rng.randint(2, 15)
|
| 90 |
+
a, b = g * rng.randint(3, 40), g * rng.randint(3, 40)
|
| 91 |
+
return f"What is gcd({a}, {b})?", str(math.gcd(a, b))
|
| 92 |
+
n = rng.randint(30, 400)
|
| 93 |
+
return f"How many positive divisors does {n} have?", str(sum(1 for d in range(1, n + 1) if n % d == 0))
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
def cybersecurity(rng: random.Random) -> Problem:
|
| 97 |
+
kind = rng.choice(["cidr", "caesar"])
|
| 98 |
+
if kind == "cidr":
|
| 99 |
+
prefix = rng.randint(16, 29)
|
| 100 |
+
a, b = rng.randint(1, 223), rng.randint(0, 255)
|
| 101 |
+
return f"How many usable host addresses are in the IPv4 network {a}.{b}.0.0/{prefix}?", str(2 ** (32 - prefix) - 2)
|
| 102 |
+
words = ["admin", "firewall", "payload", "exploit", "token", "session", "backdoor", "malware", "phishing"]
|
| 103 |
+
plain = rng.choice(words)
|
| 104 |
+
k = rng.randint(1, 25)
|
| 105 |
+
cipher = "".join(chr((ord(ch) - 97 + k) % 26 + 97) for ch in plain)
|
| 106 |
+
return f"The lowercase word '{cipher}' was Caesar-shifted forward by {k}. What is the plaintext?", plain
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
def media(rng: random.Random) -> Problem:
|
| 110 |
+
kind = rng.choice(["size", "frames"])
|
| 111 |
+
if kind == "size":
|
| 112 |
+
kbps = rng.choice([800, 1500, 2500, 4000, 6000])
|
| 113 |
+
sec = rng.randint(30, 600)
|
| 114 |
+
mb = kbps * sec / 8 / 1000
|
| 115 |
+
return f"A video is encoded at {kbps} kbps for {sec} seconds. File size in MB (1 MB = 1000 kB, 1 byte = 8 bits), rounded to 2 decimals?", f"{mb:.2f}"
|
| 116 |
+
fps = rng.choice([24, 25, 30, 60])
|
| 117 |
+
sec = rng.randint(5, 120)
|
| 118 |
+
cut = rng.randint(1, sec // 2)
|
| 119 |
+
return f"A {sec}-second clip at {fps} fps has its last {cut} seconds trimmed. How many frames remain?", str(fps * (sec - cut))
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
GENERATORS: Dict[str, Callable[[random.Random], Problem]] = {
|
| 123 |
+
"software-engineering": software,
|
| 124 |
+
"industrial-systems": industrial,
|
| 125 |
+
"natural-science": science,
|
| 126 |
+
"office-work": office,
|
| 127 |
+
"finance-economics": finance,
|
| 128 |
+
"math-formal": math_formal,
|
| 129 |
+
"cybersecurity": cybersecurity,
|
| 130 |
+
"media-production": media,
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
def grade(answer: str, expected: str) -> Tuple[float, str]:
|
| 135 |
+
got = answer.strip().strip(".").lower()
|
| 136 |
+
if got == expected.lower():
|
| 137 |
+
return 1.0, "correct"
|
| 138 |
+
try:
|
| 139 |
+
g, e = float(got.replace(",", "")), float(expected)
|
| 140 |
+
except ValueError:
|
| 141 |
+
return 0.0, "wrong"
|
| 142 |
+
if abs(g - e) <= 0.005:
|
| 143 |
+
return 1.0, "correct"
|
| 144 |
+
if e != 0 and abs(g - e) / abs(e) <= 0.05:
|
| 145 |
+
return 0.2, "close"
|
| 146 |
+
return 0.0, "wrong"
|
tasks.jsonl
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"task_id":"software-engineering","reset_kwargs":{"task_id":"software-engineering"},"split":"train"}
|
| 2 |
+
{"task_id":"industrial-systems","reset_kwargs":{"task_id":"industrial-systems"},"split":"train"}
|
| 3 |
+
{"task_id":"natural-science","reset_kwargs":{"task_id":"natural-science"},"split":"train"}
|
| 4 |
+
{"task_id":"office-work","reset_kwargs":{"task_id":"office-work"},"split":"train"}
|
| 5 |
+
{"task_id":"finance-economics","reset_kwargs":{"task_id":"finance-economics"},"split":"train"}
|
| 6 |
+
{"task_id":"math-formal","reset_kwargs":{"task_id":"math-formal"},"split":"train"}
|
| 7 |
+
{"task_id":"cybersecurity","reset_kwargs":{"task_id":"cybersecurity"},"split":"train"}
|
| 8 |
+
{"task_id":"media-production","reset_kwargs":{"task_id":"media-production"},"split":"train"}
|