Datasets:
Add optional pass@4 model and successful-attempt filters
Browse files- calibforge_v1.1/README.md +11 -0
- calibforge_v1.1/filter_tasks.py +63 -6
calibforge_v1.1/README.md
CHANGED
|
@@ -87,6 +87,8 @@ Install `pyarrow`, then put `filter_tasks.py`, `tasks.parquet` and `results.parq
|
|
| 87 |
|
| 88 |
To also filter by LLM judge, use `--judge qwen` or `--judge glm`. By default, tasks with any failed criterion or missing verdict for that judge are removed. Use `--allow-fail CRITERION` to allow a named criterion to fail. Repeat `--allow-fail` to allow multiple criteria to fail.
|
| 89 |
|
|
|
|
|
|
|
| 90 |
```bash
|
| 91 |
# Rule-based checks only
|
| 92 |
python filter_tasks.py --out validated
|
|
@@ -103,6 +105,15 @@ python filter_tasks.py --judge glm \
|
|
| 103 |
--allow-fail VERIFIER-ACCEPTS-INCOMPLETE \
|
| 104 |
--allow-fail VERIFIER-ACCEPTS-SHORTCUTS \
|
| 105 |
--out glm-with-incomplete-and-shortcuts
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
```
|
| 107 |
|
| 108 |
Available criteria, with explanations in the [rubric](https://github.com/MLI-lab/OT-next-data/blob/main/validation/rubrics/rubric_ot/rubric.toml):
|
|
|
|
| 87 |
|
| 88 |
To also filter by LLM judge, use `--judge qwen` or `--judge glm`. By default, tasks with any failed criterion or missing verdict for that judge are removed. Use `--allow-fail CRITERION` to allow a named criterion to fail. Repeat `--allow-fail` to allow multiple criteria to fail.
|
| 89 |
|
| 90 |
+
To also filter by pass@4, use `--passk-model qwen` (Qwen3.5-35B-A3B) or `--passk-model glm` (GLM-5.3-Flash), with `--successes` followed by the counts to keep, from 0 to 4. This uses the selected four-attempt batch and excludes missing or incomplete evaluations. Completed resource-limit failures count toward 0/4. You can combine this with judge filtering.
|
| 91 |
+
|
| 92 |
```bash
|
| 93 |
# Rule-based checks only
|
| 94 |
python filter_tasks.py --out validated
|
|
|
|
| 105 |
--allow-fail VERIFIER-ACCEPTS-INCOMPLETE \
|
| 106 |
--allow-fail VERIFIER-ACCEPTS-SHORTCUTS \
|
| 107 |
--out glm-with-incomplete-and-shortcuts
|
| 108 |
+
|
| 109 |
+
# Keep tasks Qwen solved at least once
|
| 110 |
+
python filter_tasks.py --passk-model qwen --successes 1 2 3 4 --out qwen-solved
|
| 111 |
+
|
| 112 |
+
# Require a clean Qwen judge review and no GLM successes
|
| 113 |
+
python filter_tasks.py --judge qwen --passk-model glm --successes 0 --out clean-teacher-unsolved
|
| 114 |
+
|
| 115 |
+
# Keep tasks Qwen solved in exactly one or two of four attempts
|
| 116 |
+
python filter_tasks.py --passk-model qwen --successes 1 2 --out qwen-partly-solved
|
| 117 |
```
|
| 118 |
|
| 119 |
Available criteria, with explanations in the [rubric](https://github.com/MLI-lab/OT-next-data/blob/main/validation/rubrics/rubric_ot/rubric.toml):
|
calibforge_v1.1/filter_tasks.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
"""Filter a task/results Parquet pair; usable standalone with only pyarrow installed.
|
| 2 |
|
| 3 |
Example: python filter_tasks.py --judge qwen --experiment-1 --out experiment1/qwen
|
| 4 |
-
|
| 5 |
"""
|
| 6 |
import argparse
|
| 7 |
from collections import Counter
|
|
@@ -31,6 +31,7 @@ JUDGE_CRITERIA = (
|
|
| 31 |
'TASK-TRIVIAL', 'VERIFIER-ACCEPTS-INCOMPLETE', 'VERIFIER-ACCEPTS-SHORTCUTS',
|
| 32 |
)
|
| 33 |
JUDGES = {'qwen': 'Qwen/Qwen3.8-27B', 'glm': 'zai-org/GLM-5.3-Flash'}
|
|
|
|
| 34 |
ACCEPTED = {'pass', 'warning', 'not_applicable'}
|
| 35 |
EXPERIMENT = {
|
| 36 |
'clean': set(),
|
|
@@ -80,7 +81,40 @@ def judge_failures(row, judge, criteria=JUDGE_CRITERIA):
|
|
| 80 |
return failed
|
| 81 |
|
| 82 |
|
| 83 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
allowed = set(allow_fail)
|
| 85 |
if allowed - set(criteria):
|
| 86 |
raise ValueError('Allowed failure must be one of the selected judge criteria')
|
|
@@ -103,6 +137,14 @@ def select(rows, judge=None, allow_fail=(), criteria=JUDGE_CRITERIA):
|
|
| 103 |
if failures - allowed:
|
| 104 |
reasons['judge_failed_other_criteria'] += 1
|
| 105 |
continue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
selected[name] = row
|
| 107 |
return selected, dict(reasons)
|
| 108 |
|
|
@@ -141,15 +183,18 @@ def subset_metadata(metadata, ids):
|
|
| 141 |
|
| 142 |
|
| 143 |
def export(tasks, results, out, judge=None, allow_fail=(), experiment2=False,
|
| 144 |
-
criteria=JUDGE_CRITERIA):
|
| 145 |
import pyarrow as pa
|
| 146 |
import pyarrow.parquet as pq
|
| 147 |
tasks, results, out = Path(tasks), Path(results), Path(out)
|
|
|
|
| 148 |
if experiment2 and (not judge or allow_fail):
|
| 149 |
raise ValueError('--experiment-1 requires --judge and cannot use --allow-fail')
|
| 150 |
if allow_fail and not judge:
|
| 151 |
raise ValueError('--allow-fail requires --judge')
|
| 152 |
table = pq.read_table(results)
|
|
|
|
|
|
|
| 153 |
absent = set(REQUIRED_CHECKS) - set(table.column_names)
|
| 154 |
if absent:
|
| 155 |
raise ValueError('Missing required validation columns: ' + ', '.join(sorted(absent)))
|
|
@@ -162,7 +207,8 @@ def export(tasks, results, out, judge=None, allow_fail=(), experiment2=False,
|
|
| 162 |
if JUDGES.get(judge, judge) not in available:
|
| 163 |
raise ValueError('No verdicts for judge ' + judge + '; available: ' + ', '.join(sorted(available)))
|
| 164 |
variants = EXPERIMENT if experiment2 else {'selected': set(allow_fail)}
|
| 165 |
-
groups = {name: select(rows, judge, allowed, criteria
|
|
|
|
| 166 |
source = pq.ParquetFile(tasks)
|
| 167 |
schemas, writers, paths = {}, {}, {}
|
| 168 |
for name, (selected, _) in groups.items():
|
|
@@ -207,7 +253,9 @@ def export(tasks, results, out, judge=None, allow_fail=(), experiment2=False,
|
|
| 207 |
return {'path': str(path), 'sha256': hashlib.file_digest(stream, 'sha256').hexdigest()}
|
| 208 |
summary = {'inputs': {'tasks': file_identity(tasks), 'results': file_identity(results)},
|
| 209 |
'judge': JUDGES.get(judge, judge), 'validation_checks': list(REQUIRED_CHECKS),
|
| 210 |
-
'judge_criteria': list(criteria) if judge else [],
|
|
|
|
|
|
|
| 211 |
'warnings_retained': True, 'incomplete_excluded': True, 'groups': {}}
|
| 212 |
for name, (selected, excluded) in groups.items():
|
| 213 |
folder = paths[name]
|
|
@@ -232,9 +280,18 @@ def main():
|
|
| 232 |
help='Judge criteria to enforce; default = all eight adjusted-rubric criteria')
|
| 233 |
parser.add_argument('--experiment-1', '--experiment-2', dest='experiment_2', action='store_true',
|
| 234 |
help='Export all three Experiment 1 groups')
|
|
|
|
|
|
|
|
|
|
|
|
|
| 235 |
parser.add_argument('--out', type=Path, required=True)
|
| 236 |
args = parser.parse_args()
|
| 237 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 238 |
print(json.dumps({k: v['tasks'] for k, v in summary['groups'].items()}, indent=2))
|
| 239 |
|
| 240 |
|
|
|
|
| 1 |
"""Filter a task/results Parquet pair; usable standalone with only pyarrow installed.
|
| 2 |
|
| 3 |
Example: python filter_tasks.py --judge qwen --experiment-1 --out experiment1/qwen
|
| 4 |
+
Optional judge and pass@4 filters. Warnings stay; missing/incomplete checks do not pass.
|
| 5 |
"""
|
| 6 |
import argparse
|
| 7 |
from collections import Counter
|
|
|
|
| 31 |
'TASK-TRIVIAL', 'VERIFIER-ACCEPTS-INCOMPLETE', 'VERIFIER-ACCEPTS-SHORTCUTS',
|
| 32 |
)
|
| 33 |
JUDGES = {'qwen': 'Qwen/Qwen3.8-27B', 'glm': 'zai-org/GLM-5.3-Flash'}
|
| 34 |
+
PASSK_MODELS = {'qwen': 'passk_target', 'glm': 'passk_teacher'}
|
| 35 |
ACCEPTED = {'pass', 'warning', 'not_applicable'}
|
| 36 |
EXPERIMENT = {
|
| 37 |
'clean': set(),
|
|
|
|
| 81 |
return failed
|
| 82 |
|
| 83 |
|
| 84 |
+
def passk_successes(row, model):
|
| 85 |
+
"""Successful attempts in the selected complete four-attempt batch only."""
|
| 86 |
+
cell = row.get(PASSK_MODELS[model])
|
| 87 |
+
if not isinstance(cell, dict) or cell.get('status') not in ('pass', 'fail'):
|
| 88 |
+
return None
|
| 89 |
+
details = cell.get('details')
|
| 90 |
+
if isinstance(details, str):
|
| 91 |
+
try:
|
| 92 |
+
details = json.loads(details)
|
| 93 |
+
except ValueError:
|
| 94 |
+
return None
|
| 95 |
+
if not isinstance(details, dict) or details.get('k') != 4:
|
| 96 |
+
return None
|
| 97 |
+
batch = details.get('selected_batch')
|
| 98 |
+
if not isinstance(batch, dict):
|
| 99 |
+
return None
|
| 100 |
+
successes = batch.get('successes')
|
| 101 |
+
if type(batch.get('valid_attempts')) is not int or batch['valid_attempts'] != 4 or type(successes) is not int or not 0 <= successes <= 4:
|
| 102 |
+
return None
|
| 103 |
+
return successes
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
def validate_passk_filter(model, successes):
|
| 107 |
+
if model is None and successes is None:
|
| 108 |
+
return
|
| 109 |
+
if model not in PASSK_MODELS or not successes:
|
| 110 |
+
raise ValueError('--passk-model qwen|glm and --successes must be supplied together')
|
| 111 |
+
if any(type(n) is not int or not 0 <= n <= 4 for n in successes):
|
| 112 |
+
raise ValueError('--successes must contain integers from 0 to 4')
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
def select(rows, judge=None, allow_fail=(), criteria=JUDGE_CRITERIA,
|
| 116 |
+
passk_model=None, successes=None):
|
| 117 |
+
validate_passk_filter(passk_model, successes)
|
| 118 |
allowed = set(allow_fail)
|
| 119 |
if allowed - set(criteria):
|
| 120 |
raise ValueError('Allowed failure must be one of the selected judge criteria')
|
|
|
|
| 137 |
if failures - allowed:
|
| 138 |
reasons['judge_failed_other_criteria'] += 1
|
| 139 |
continue
|
| 140 |
+
if passk_model:
|
| 141 |
+
wins = passk_successes(row, passk_model)
|
| 142 |
+
if wins is None:
|
| 143 |
+
reasons['passk_incomplete'] += 1
|
| 144 |
+
continue
|
| 145 |
+
if wins not in successes:
|
| 146 |
+
reasons['passk_successes_not_selected'] += 1
|
| 147 |
+
continue
|
| 148 |
selected[name] = row
|
| 149 |
return selected, dict(reasons)
|
| 150 |
|
|
|
|
| 183 |
|
| 184 |
|
| 185 |
def export(tasks, results, out, judge=None, allow_fail=(), experiment2=False,
|
| 186 |
+
criteria=JUDGE_CRITERIA, passk_model=None, successes=None):
|
| 187 |
import pyarrow as pa
|
| 188 |
import pyarrow.parquet as pq
|
| 189 |
tasks, results, out = Path(tasks), Path(results), Path(out)
|
| 190 |
+
validate_passk_filter(passk_model, successes)
|
| 191 |
if experiment2 and (not judge or allow_fail):
|
| 192 |
raise ValueError('--experiment-1 requires --judge and cannot use --allow-fail')
|
| 193 |
if allow_fail and not judge:
|
| 194 |
raise ValueError('--allow-fail requires --judge')
|
| 195 |
table = pq.read_table(results)
|
| 196 |
+
if passk_model and PASSK_MODELS[passk_model] not in table.column_names:
|
| 197 |
+
raise ValueError('Missing pass@4 column: ' + PASSK_MODELS[passk_model])
|
| 198 |
absent = set(REQUIRED_CHECKS) - set(table.column_names)
|
| 199 |
if absent:
|
| 200 |
raise ValueError('Missing required validation columns: ' + ', '.join(sorted(absent)))
|
|
|
|
| 207 |
if JUDGES.get(judge, judge) not in available:
|
| 208 |
raise ValueError('No verdicts for judge ' + judge + '; available: ' + ', '.join(sorted(available)))
|
| 209 |
variants = EXPERIMENT if experiment2 else {'selected': set(allow_fail)}
|
| 210 |
+
groups = {name: select(rows, judge, allowed, criteria, passk_model, successes)
|
| 211 |
+
for name, allowed in variants.items()}
|
| 212 |
source = pq.ParquetFile(tasks)
|
| 213 |
schemas, writers, paths = {}, {}, {}
|
| 214 |
for name, (selected, _) in groups.items():
|
|
|
|
| 253 |
return {'path': str(path), 'sha256': hashlib.file_digest(stream, 'sha256').hexdigest()}
|
| 254 |
summary = {'inputs': {'tasks': file_identity(tasks), 'results': file_identity(results)},
|
| 255 |
'judge': JUDGES.get(judge, judge), 'validation_checks': list(REQUIRED_CHECKS),
|
| 256 |
+
'judge_criteria': list(criteria) if judge else [],
|
| 257 |
+
'passk_filter': {'model': passk_model, 'column': PASSK_MODELS[passk_model],
|
| 258 |
+
'k': 4, 'successes': sorted(set(successes))} if passk_model else None,
|
| 259 |
'warnings_retained': True, 'incomplete_excluded': True, 'groups': {}}
|
| 260 |
for name, (selected, excluded) in groups.items():
|
| 261 |
folder = paths[name]
|
|
|
|
| 280 |
help='Judge criteria to enforce; default = all eight adjusted-rubric criteria')
|
| 281 |
parser.add_argument('--experiment-1', '--experiment-2', dest='experiment_2', action='store_true',
|
| 282 |
help='Export all three Experiment 1 groups')
|
| 283 |
+
parser.add_argument('--passk-model', choices=PASSK_MODELS,
|
| 284 |
+
help='Filter completed pass@4 results for Qwen3.5-35B-A3B or GLM-5.3-Flash')
|
| 285 |
+
parser.add_argument('--successes', type=int, nargs='+', choices=range(5),
|
| 286 |
+
help='Keep these numbers of successful attempts out of four, requires --passk-model')
|
| 287 |
parser.add_argument('--out', type=Path, required=True)
|
| 288 |
args = parser.parse_args()
|
| 289 |
+
try:
|
| 290 |
+
validate_passk_filter(args.passk_model, args.successes)
|
| 291 |
+
except ValueError as exc:
|
| 292 |
+
parser.error(str(exc))
|
| 293 |
+
summary = export(args.tasks, args.results, args.out, args.judge, args.allow_fail,
|
| 294 |
+
args.experiment_2, args.criteria, args.passk_model, args.successes)
|
| 295 |
print(json.dumps({k: v['tasks'] for k, v in summary['groups'].items()}, indent=2))
|
| 296 |
|
| 297 |
|