File size: 9,299 Bytes
6fc619a a5867fc 6fc619a a5867fc fccf48d a5867fc f28490f a5867fc f28490f a5867fc 8f3b64f a5867fc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | ---
license: cc-by-4.0
task_categories:
- text-generation
language:
- en
tags:
- code
- reinforcement-learning
- rlvr
- test-cases
- code-generation
- competitive-programming
size_categories:
- 10K<n<100K
---
<div align="center">
<h2><strong>Robust Code RL via Faulty-Code-Driven Test Case Synthesis and Dense Reward Shaping</strong></h2>
[](https://arxiv.org/abs/2608.24135)
[](https://arxiv.org/abs/2608.24135)
[](https://creativecommons.org/licenses/by/4.0/)
</div>
## Dataset Description
RobustTests is a high-quality test case dataset specifically designed for **reinforcement learning from verifiable rewards (RLVR)** in code generation tasks. It addresses the fundamental limitation of insufficient test coverage that often causes **false positives** and **reward hacking** in RL-based code training.
**Important**: To avoid copyright issues, this dataset only provides the test case collections — it does not include the original problem descriptions. Each problem is identified by its `id` and `source`, which can be used to match with the corresponding problems in [Code-Contests-Plus](https://huggingface.co/datasets/ByteDance-Seed/Code-Contests-Plus) or the original competitive programming platforms.
## Key Features
- **High-Coverage Test Cases**: Each problem is equipped with a rich set of test cases covering various edge cases, boundary conditions, and corner cases, significantly reducing false positives in reward computation.
- **Anti-Reward-Hacking**: By providing thorough test coverage, RobustTests mitigates reward hacking — a common failure mode where models learn to pass a small number of visible test cases without producing genuinely correct solutions.
- **RLVR-Ready**: Designed specifically for reinforcement learning from verifiable rewards, the test cases serve as reliable verification oracles for code generation tasks.
- **Compact Encoding**: Test cases are encoded using a multi-layer compression scheme (Base64 → Zlib → Pickle) to keep storage efficient while preserving all data fidelity.
## Dataset Statistics
| Metric | Value |
|--------|-------|
| Total problems | 11,636 |
| Number of files | 4 (sharded parquet) |
| License | CC-BY-4.0 |
### Source Distribution
| Source | Count | Percentage |
|--------|-------|------------|
| Codeforces | 7,525 | 64.7% |
| AIZU | 2,028 | 17.4% |
| AtCoder | 1,318 | 11.3% |
| CodeChef | 765 | 6.6% |
## Dataset Structure
### Data Fields
| Field | Type | Description |
|-------|------|-------------|
| `source` | `string` | The competitive programming platform the problem originates from (e.g., Codeforces, AIZU, AtCoder, CodeChef) |
| `id` | `string` | Unique identifier for the problem, which can be used to match with the corresponding problem in Code-Contests-Plus |
| `testcase` | `struct` | Test case container with the following sub-fields: |
| `testcase.inputs` | `list<string>` | List of encoded input strings for each test case (Base64 → Zlib → Pickle compressed) |
| `testcase.outputs` | `list<string>` | List of encoded expected output strings for each test case (Base64 → Zlib → Pickle compressed) |
### Data Format
The dataset is stored in Parquet format, sharded across 4 files:
- `part-00000-of-00004.parquet` (2,909 rows)
- `part-00001-of-00004.parquet` (2,909 rows)
- `part-00002-of-00004.parquet` (2,909 rows)
- `part-00003-of-00004.parquet` (2,909 rows)
## How to Use
### Installation
```bash
pip install datasets
```
### Loading the Dataset
```python
from datasets import load_dataset
# Load the complete dataset
dataset = load_dataset("sid6/RobustTests")
# Access a specific problem
problem = dataset['train'][0]
print(f"Source: {problem['source']}")
print(f"ID: {problem['id']}")
print(f"Number of test cases: {len(problem['testcase']['inputs'])}")
```
### Decoding Test Cases
Test cases are stored using a multi-layer compression encoding. Use the following code to decode:
```python
import base64
import zlib
import pickle
def decode_testcase(encoded_testcase):
"""Decode a single encoded test case.
Decoding chain: Base64 → Zlib → Pickle → UTF-8 string
Args:
encoded_testcase: Base64-encoded compressed test case string
Returns:
str: Decoded raw input/output text
"""
# Step 1: Base64 decode - convert the encoded string back to binary data
decoded = base64.b64decode(encoded_testcase)
# Step 2: Zlib decompress - restore the compressed binary data
decompressed = zlib.decompress(decoded)
# Step 3: Pickle deserialize - reconstruct Python object from binary
data = pickle.loads(decompressed)
# Step 4: Decode bytes to UTF-8 string
if isinstance(data, bytes):
data = data.decode('utf-8')
return data
def parse_testcase(testcase):
"""Parse the entire testcase field by decoding all inputs and outputs.
Args:
testcase: A dict with 'inputs' and 'outputs' fields,
where each element is a Base64-encoded compressed string
Returns:
dict: Decoded testcase in the format:
{'inputs': [str, ...], 'outputs': [str, ...]}
"""
return {
'inputs': [decode_testcase(x) for x in testcase['inputs']],
'outputs': [decode_testcase(x) for x in testcase['outputs']]
}
```
### Usage Example
```python
from datasets import load_dataset
dataset = load_dataset("sid6/RobustTests")
problem = dataset['train'][0]
# Decode all test cases
decoded = parse_testcase(problem['testcase'])
# Inspect test cases
for i, (inp, out) in enumerate(zip(decoded['inputs'], decoded['outputs'])):
print(f"--- Test Case {i+1} ---")
print(f"Input:\n{inp}")
print(f"Expected Output:\n{out}")
```
## Evaluation
### Benchmark Results
When used to train **Qwen3-32B** via **GRPO**, replacing the original test cases with RobustTests leads to consistent improvements across benchmarks:
| Benchmark | Metric | CodeContests+ | RobustTests | Gain |
|-----------|--------|---------------|-------------|------|
| LiveCodeBench (2024.08–2025.01) | Score | 65.41 | 68.39 | +2.98 |
| Codeforces | Score | 35.56 | 38.50 | +2.94 |
| Codeforces | Rating | 83.96 | 85.99 | +2.03 |
| Codeforces | Percentile | 91.45 | 94.67 | +3.22 |
### Dense Reward Function
The dataset is designed to work with a stepwise dense reward function:
```python
def compute_reward(pass_count, total_count):
"""
Stepwise dense reward based on pass rate.
Args:
pass_count: Number of test cases passed
total_count: Total number of test cases
Returns:
float: Reward value
"""
if pass_count == total_count:
return 1.1 # All tests passed
elif pass_count == 0:
return -0.1 # All tests failed
else:
return 0.1 * (pass_count / total_count) # Partial credit
```
## Intended Uses
- **RLVR Training**: Serve as high-quality verification oracles for reinforcement learning from verifiable rewards in code generation.
- **Code Generation Evaluation**: Provide comprehensive test cases for evaluating code generation models on competitive programming problems.
- **Anti-Reward-Hacking Research**: Enable research into mitigating reward hacking in RL-based code training.
## Limitations
- The dataset only provides test cases — problem descriptions must be obtained from [Code-Contests-Plus](https://huggingface.co/datasets/ByteDance-Seed/Code-Contests-Plus) or the original platforms.
- The dataset covers competitive programming problems, which may not represent the full diversity of real-world software engineering tasks.
- While test coverage is significantly enhanced compared to the original problems, it may still not be exhaustive for all possible edge cases.
- The test cases are designed for programs that read from stdin and write to stdout, following the competitive programming convention.
## Source Data
The test cases in this dataset are designed for problems from [Code-Contests-Plus](https://huggingface.co/datasets/ByteDance-Seed/Code-Contests-Plus), a dataset published by ByteDance Seed that aggregates competitive programming problems from platforms including Codeforces, AIZU, AtCoder, and CodeChef.
## Citation
If you find RobustTests useful in your research, please cite our paper:
```bibtex
@article{zhang2026robust,
title={Robust Code RL via Faulty-Code-Driven Test Case Synthesis and Dense Reward Shaping},
author={Zhang, Yiwen and Yan, Xiaodong and Huang, Zhenyu and Zhao, Deng and Jiang, Liang and Cui, Qing and Wen, Zujie and Zhang, Zhiqiang and Zhou, Jun},
journal={arXiv preprint arXiv:2608.24135},
year={2026}
}
```
## License
This project is licensed under **CC-BY-4.0**. See the [LICENSE](LICENSE) file for details.
## Acknowledgements
- [Code-Contests-Plus](https://huggingface.co/datasets/ByteDance-Seed/Code-Contests-Plus) — the ByteDance Seed dataset that provides the problems these test cases are designed for.
- The competitive programming platforms (Codeforces, AIZU, AtCoder, CodeChef) that originally host these problems. |