diagnosis-advantage-grpo
收藏资源简介:
Diagnosis-Advantage RLVR 数据集是为支持 Diagnosis-Advantage RLVR 配方(一种使用 GRPO 方法)的训练和评估而构建的。其核心任务聚焦于代码优化:给定一个针对竞争性编程问题的、正确但执行速度较慢的 Python 解决方案(种子代码),模型需要生成一个在保持功能正确性的前提下,执行速度更快的优化版本。数据集的一个显著特点是采用配对A/B变体结构:每个编程问题都对应两个不同的提示变体(A和B),它们共享同一个唯一问题标识符 (`uid`)。变体A采用先诊断后优化的范式,要求模型首先生成一个 `<diagnosis>...</diagnosis>` 格式的诊断分析,然后输出优化后的代码。变体B则作为反事实基线,要求模型直接优化,不提供诊断步骤。这种设计便于对比研究诊断环节对优化效果的影响。数据集包含三个标准划分:训练集(15,686行,对应7,843个问题)、验证集(184行,对应92个问题)和测试集(240行,对应120个问题)。每个数据样本包含以下字段:`prompt`(以聊天格式组织的用户提示,内容内嵌了待优化的慢速种子代码)、`data_source`(标识数据源自 codecontests-o)、`reward_model`(描述用于评估的奖励模型类型和预期的真实输出)、`extra_info`(包含问题ID、提示变体类型、时间限制、所有测试用例的输入、原始的慢速种子代码、测试数量等元信息)、`uid`(作为分组键的问题ID)。该数据集派生自 `caijanfeng/CodeContests-O`(提供测试用例)和 `deepmind/code_contests`(提供Python-3的慢速种子解决方案)。原始数据经过预处理:种子代码长度被限制在6000字符以内,单个测试用例的输入/输出大小被限制在128KB以内(以过滤掉极端消耗内存的案例,此操作保留了约88%的原始测试用例)。需要注意的是,数据集中不包含运行时性能指标,模型的正确性和速度评分需在训练或评估时通过外部工具(如 SandboxFusion)在沙箱环境中执行代码并测量CPU时间来完成。
The Diagnosis-Advantage RLVR dataset is constructed to support the training and evaluation of the Diagnosis-Advantage RLVR recipe, which employs the GRPO method. Its core task focuses on code optimization: given a correct but slow Python solution (seed code) for a competitive programming problem, the model needs to generate an optimized version that executes faster while maintaining functional correctness. A notable feature of the dataset is its paired A/B variant structure: each programming problem corresponds to two different prompt variants (A and B), which share a unique problem identifier (`uid`). Variant A adopts a diagnose-then-optimize paradigm, requiring the model to first generate a diagnostic analysis in the format `<diagnosis>...</diagnosis>`, then output the optimized code. Variant B serves as a counterfactual baseline, requiring the model to directly optimize without providing a diagnostic step. This design facilitates comparative studies on the impact of the diagnostic phase on optimization effectiveness. The dataset includes three standard splits: training set (15,686 rows, corresponding to 7,843 problems), validation set (184 rows, corresponding to 92 problems), and test set (240 rows, corresponding to 120 problems). Each data sample contains the following fields: `prompt` (user prompt organized in chat format, embedding the slow seed code to be optimized), `data_source` (identifying the data source as codecontests-o), `reward_model` (describing the type of reward model used for evaluation and the expected true output), `extra_info` (containing metadata such as problem ID, prompt variant type, time limit, all test case inputs, the original slow seed code, number of tests, etc.), `uid` (problem ID used as a grouping key). The dataset is derived from `caijanfeng/CodeContests-O` (providing test cases) and `deepmind/code_contests` (providing Python-3 slow seed solutions). The original data has been preprocessed: the seed code length is limited to 6,000 characters, and the input/output size of a single test case is limited to 128KB (to filter out extreme memory-consuming cases, retaining approximately 88% of the original test cases). It is important to note that the dataset does not include runtime performance metrics; the correctness and speed scores of the model need to be completed during training or evaluation by executing the code in a sandbox environment using external tools (such as SandboxFusion) and measuring CPU time.
数据集概述
名称:Diagnosis-Advantage RLVR (CodeContests-O, route-B paired A/B)
许可证:Apache-2.0
语言:英语
任务类别:文本生成
标签:代码、代码优化、RLVR、GRPO、推理、CodeContests
数据来源:该数据集源自 caijanfeng/CodeContests-O(测试用例)和 deepmind/code_contests(Python-3 种子解决方案,作为慢速初始代码;种子代码长度限制为 6000 字符)。
数据处理说明:
- 单个测试的 stdin/stdout 被限制在 128 KB 以内,以剔除会导致沙箱执行内存爆炸的病态大尺寸用例,约保留 88% 的测试。
- 评分在训练/评估时通过 SandboxFusion 进行(正确性 +
process_time_nsCPU 时间作为加速信号);本数据集仅提供提示和测试数据。
数据集结构
该数据集包含三个分割:train(训练)、validation(验证)和 test(测试),以 Parquet 格式存储。
| 分割 | 行数 | 问题数(×2 变体) |
|---|---|---|
| train | 15,686 | 7,843 |
| validation | 184 | 92 |
| test | 240 | 120 |
核心设计:每个问题包含两个提示变体,共享同一个 uid(即 GRPO 分组键):
- 变体
A— “诊断后优化”:模型需先输出<diagnosis>…</diagnosis>诊断块,再输出优化后的代码。 - 变体
B— “直接优化”:不进行诊断,作为反事实基线。
数据列
prompt— 聊天格式[{role: user, content}],内容中嵌入了慢速的种子解决方案。data_source— 固定值"codecontests-o"。reward_model— 格式为{style: "rule", ground_truth: [每个测试的预期 stdout]}。extra_info— 包含以下信息:problem_id:问题IDvariant:变体标识("A"或"B")time_limit:时间限制test_inputs:每个测试的 stdinslow_code:原始的慢速种子代码n_tests:测试数量
uid— 等于problem_id,由同一个问题的 A/B 两行共享,作为 GRPO 的分组键。
使用提示:要获取诊断 vs. 无诊断的测试分割,可通过筛选 extra_info.variant == "A" 或 "B" 来提取相应数据。
任务描述
给定一个针对竞赛编程问题的正确但运行缓慢的 Python 解决方案,模型必须生成一个更快且仍然正确的优化版本。该数据集专为 Diagnosis-Advantage RLVR 方法(即 verl GRPO)设计,通过成对的变体对比来评估诊断步骤对代码优化效果的影响。




