guanning commited on
Commit
de32d94
·
verified ·
1 Parent(s): 3c7b6f9

AceCode-87K train / held-out 1k test split used for the Qwen3-1.7B-Base code RL runs

Browse files
Files changed (5) hide show
  1. README.md +59 -0
  2. eval.parquet +3 -0
  3. preprocess_acecode_data.py +127 -0
  4. stats.json +35 -0
  5. train.parquet +3 -0
README.md ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ task_categories:
4
+ - text-generation
5
+ tags:
6
+ - code
7
+ - reinforcement-learning
8
+ - rlvr
9
+ configs:
10
+ - config_name: default
11
+ data_files:
12
+ - split: train
13
+ path: train.parquet
14
+ - split: test
15
+ path: eval.parquet
16
+ ---
17
+
18
+ # AceCode-87K train / held-out test split (verl format)
19
+
20
+ The exact train and test data used for the binary-reward code RL runs on Qwen3-1.7B-Base
21
+ (GRPO / MaxRL) in [max-rl](https://huggingface.co/max-rl).
22
+
23
+ Source: [TIGER-Lab/AceCode-87K](https://huggingface.co/datasets/TIGER-Lab/AceCode-87K)
24
+ (AceCoder, arXiv:2502.01718), which ships a single `train` split: function-level Python problems,
25
+ each with GPT-4o-mini-synthesized `assert` test cases.
26
+
27
+ | file | split | rows | `data_source` |
28
+ |---|---|---|---|
29
+ | `train.parquet` | train | 85,847 | `acecode` |
30
+ | `eval.parquet` | test (held-out) | 1,000 | `acecode_eval` |
31
+
32
+ Train and test share no AceCode `id` (overlap 0). Per-split counts are in `stats.json`.
33
+
34
+ ## How the split was made
35
+
36
+ `preprocess_acecode_data.py` (included) on the full 87,149 rows:
37
+
38
+ 1. shuffle with seed 42;
39
+ 2. keep only `assert ...` test strings; drop rows with < 3 tests, empty questions, or a
40
+ duplicate question (302 rows dropped); keep at most 16 tests per prompt;
41
+ 3. drop prompts longer than 3,072 tokens under the Qwen3-1.7B-Base chat template (0 dropped);
42
+ 4. the **last 1,000** surviving rows are the test split, the rest are train.
43
+
44
+ ## Schema (verl RL parquet)
45
+
46
+ - `prompt`: chat messages, one user turn = the AceCode question + the suffix
47
+ `"\nPlease reason step by step, then write a self-contained Python solution. Give your final program in a single ```python code block."`
48
+ - `ability`: `"code"`
49
+ - `reward_model`: `{"style": "rule", "ground_truth": "{\"tests\": [\"assert ...\", ...]}"}`
50
+ - `extra_info`: `split`, `index`, `acecode_id`, `num_tests`
51
+
52
+ ## Reward
53
+
54
+ Strictly binary: take the last ```python block of the response, append all `assert` tests, run
55
+ in a fresh `python -I` subprocess (10 s wall / CPU limit, 4 GiB address space). Score 1.0 iff
56
+ the process exits 0, else 0.0 (no code block → 0.0). Validated 60/60 against AceCode-87K's own
57
+ `pass_rate ∈ {0, 1}` inference labels.
58
+
59
+ Evaluation in the runs: 4 samples per test prompt (T=0.6, top-p 0.95), reporting mean@4 and best@4.
eval.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5fbcfbca1612f99ca6894e43b0767445e6c34acc47042107a66467eb074f5b5f
3
+ size 652037
preprocess_acecode_data.py ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2024 Bytedance Ltd. and/or its affiliates
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ """Preprocess TIGER-Lab/AceCode-87K into verl parquet for the binary code-RL recipe.
15
+
16
+ Writes the same schema as scripts/preprocess_knights_and_knaves_data.py:
17
+ data_source | prompt (chat, single user turn) | ability | reward_model | extra_info
18
+
19
+ * data_source : "acecode" for train, "acecode_eval" for the held-out split
20
+ (both route to verl/utils/reward_score/acecode.py, binary all-tests-pass)
21
+ * prompt : the AceCode question + a fixed suffix asking for ONE ```python block
22
+ * ground_truth: JSON {"tests": [...]} straight from the dataset's test list
23
+ * split : the LAST --eval-size rows of a seeded shuffle are eval, the rest train
24
+
25
+ Rows are dropped when the question or the tests are unusable (empty / non-assert / too
26
+ few tests) or when the prompt would exceed --max-prompt-tokens under the model's chat
27
+ template (data.filter_overlong_prompts would drop them at train time anyway; doing it
28
+ here keeps the parquet row count honest).
29
+
30
+ Usage (login node has internet; needs the `maxrl` conda env):
31
+ python scripts/preprocess_acecode_data.py \
32
+ --out-dir /n/netscratch/qianqian_lab/Lab/gzeng/RL-ASSETS/acecode_data/acecode87k \
33
+ --model-path $HOME/.cache/maxrl/models/Qwen3-1.7B-Base
34
+ """
35
+
36
+ from __future__ import annotations
37
+
38
+ import argparse
39
+ import json
40
+ import os
41
+
42
+ PROMPT_SUFFIX = (
43
+ "\nPlease reason step by step, then write a self-contained Python solution. "
44
+ "Give your final program in a single ```python code block."
45
+ )
46
+
47
+ MIN_TESTS = 3 # AceCoder filtering keeps prompts with enough signal for binary reward
48
+
49
+
50
+ def build_row(question: str, tests: list[str], data_source: str, split: str, index: int, src_id) -> dict:
51
+ return {
52
+ "data_source": data_source,
53
+ "prompt": [{"role": "user", "content": question + PROMPT_SUFFIX}],
54
+ "ability": "code",
55
+ "reward_model": {"style": "rule", "ground_truth": json.dumps({"tests": tests})},
56
+ "extra_info": {"split": split, "index": index, "acecode_id": str(src_id), "num_tests": len(tests)},
57
+ }
58
+
59
+
60
+ def main() -> None:
61
+ ap = argparse.ArgumentParser()
62
+ ap.add_argument("--dataset", default="TIGER-Lab/AceCode-87K")
63
+ ap.add_argument("--out-dir", required=True)
64
+ ap.add_argument("--eval-size", type=int, default=1000)
65
+ ap.add_argument("--seed", type=int, default=42)
66
+ ap.add_argument("--model-path", required=True, help="tokenizer for the prompt-length filter")
67
+ ap.add_argument("--max-prompt-tokens", type=int, default=3072)
68
+ ap.add_argument("--max-tests", type=int, default=16, help="cap tests per prompt (reward caps at 32)")
69
+ args = ap.parse_args()
70
+
71
+ import pandas as pd
72
+ from datasets import load_dataset
73
+ from transformers import AutoTokenizer
74
+
75
+ tokenizer = AutoTokenizer.from_pretrained(args.model_path)
76
+ ds = load_dataset(args.dataset, split="train")
77
+ ds = ds.shuffle(seed=args.seed)
78
+
79
+ kept, dropped_tests, dropped_long = [], 0, 0
80
+ seen_questions: set[int] = set()
81
+ for row in ds:
82
+ question = (row.get("question") or "").strip()
83
+ tests = [t.strip() for t in (row.get("test_cases") or []) if isinstance(t, str) and t.strip()]
84
+ tests = [t for t in tests if t.startswith("assert")]
85
+ if not question or len(tests) < MIN_TESTS:
86
+ dropped_tests += 1
87
+ continue
88
+ qh = hash(question)
89
+ if qh in seen_questions:
90
+ dropped_tests += 1
91
+ continue
92
+ seen_questions.add(qh)
93
+
94
+ n_tokens = len(
95
+ tokenizer.apply_chat_template(
96
+ [{"role": "user", "content": question + PROMPT_SUFFIX}],
97
+ add_generation_prompt=True,
98
+ tokenize=True,
99
+ )
100
+ )
101
+ if n_tokens > args.max_prompt_tokens:
102
+ dropped_long += 1
103
+ continue
104
+ kept.append((question, tests[: args.max_tests], row.get("id")))
105
+
106
+ assert len(kept) > args.eval_size, f"only {len(kept)} usable rows"
107
+ eval_rows = kept[-args.eval_size :]
108
+ train_rows = kept[: -args.eval_size]
109
+
110
+ os.makedirs(args.out_dir, exist_ok=True)
111
+ train_df = pd.DataFrame(
112
+ [build_row(q, t, "acecode", "train", i, sid) for i, (q, t, sid) in enumerate(train_rows)]
113
+ )
114
+ eval_df = pd.DataFrame(
115
+ [build_row(q, t, "acecode_eval", "eval", i, sid) for i, (q, t, sid) in enumerate(eval_rows)]
116
+ )
117
+ train_df.to_parquet(os.path.join(args.out_dir, "train.parquet"))
118
+ eval_df.to_parquet(os.path.join(args.out_dir, "eval.parquet"))
119
+
120
+ print(
121
+ f"wrote {len(train_df)} train / {len(eval_df)} eval to {args.out_dir} "
122
+ f"(dropped: {dropped_tests} bad-tests/dup, {dropped_long} overlong)"
123
+ )
124
+
125
+
126
+ if __name__ == "__main__":
127
+ main()
stats.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "train": {
3
+ "rows": 85847,
4
+ "data_source": [
5
+ "acecode"
6
+ ],
7
+ "num_tests": {
8
+ "mean": 14.05,
9
+ "min": 3,
10
+ "max": 16
11
+ },
12
+ "acecode_source": {
13
+ "bigcode_python_fns": 33910,
14
+ "evol": 26505,
15
+ "oss": 25432
16
+ }
17
+ },
18
+ "eval": {
19
+ "rows": 1000,
20
+ "data_source": [
21
+ "acecode_eval"
22
+ ],
23
+ "num_tests": {
24
+ "mean": 14.08,
25
+ "min": 5,
26
+ "max": 16
27
+ },
28
+ "acecode_source": {
29
+ "bigcode_python_fns": 400,
30
+ "evol": 324,
31
+ "oss": 276
32
+ }
33
+ },
34
+ "train_eval_id_overlap": 0
35
+ }
train.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:08663a09682c52d57a98c4d2aaa30868da78223dc104e1276f7de271a983f0e6
3
+ size 55665848