CoolFace
Datasetpublic

cublya/OpenCodeReasoning-2

OpenCodeReasoning-2: A Large-scale Dataset for Reasoning in Code Generation and Critique Dataset Description OpenCodeReasoning-2 is the largest reasoning-based synthetic dataset to date for coding, comprising 1.4M samples in Python and 1.1M samples in C++ across 34,799 unique competitive programming questions. OpenCodeReasoning-2 is designed for supervised fine-tuning (SFT) tasks of code completion and code critique. Github Repo - Access the complete pipeline… See the full description on the dataset page: https://huggingface.co/datasets/cublya/OpenCodeReasoning-2.

sourceHugging Facecc-by-4.0updated 8mo agoView on Hugging Face
0likes558downloads
Dataset Card

OpenCodeReasoning-2: A Large-scale Dataset for Reasoning in Code Generation and Critique

Dataset Description

OpenCodeReasoning-2 is the largest reasoning-based synthetic dataset to date for coding, comprising 1.4M samples in Python and 1.1M samples in C++ across 34,799 unique competitive programming questions. OpenCodeReasoning-2 is designed for supervised fine-tuning (SFT) tasks of code completion and code critique.

  • Github Repo - Access the complete pipeline used to perform SFT.

This dataset is ready for commercial/non-commercial use.

Data distribution

  • The CodeForces problems are sourced from http://codeforces.com.
  • The question collections are gathered from TACO (https://huggingface.co/datasets/BAAI/TACO), APPS (https://huggingface.co/datasets/codeparrot/apps), CodeContests (https://huggingface.co/datasets/deepmind/code_contests), and open-r1/codeforces (https://huggingface.co/datasets/open-r1/codeforces).
  • We do not include the test split of CodeContests and open-r1/codeforces.
  • The solution responses are generated by R1 and critique responses are generated by QwQ.

Python

Source# Question#Sample
AIZU215071,681
AtCoder208064,468
CodeChef3869120,040
CodeForces15641834,523
Codewars250679,771
GeeksForGeeks267058,154
HackerEarth228573,559
HackerRank91226,106
Kattis123539,938
LeetCode77729,926
Total34,1251,398,166

C++

Source# Question#Sample
AIZU206735,471
AtCoder198862,493
CodeChef3830171,882
CodeForces11887355,180
Codewars2492155,162
GeeksForGeeks2668167,610
HackerEarth227382,765
HackerRank90343,867
Kattis120949,699
LeetCode77550,346
Total30,0921,174,475

Data Fields

FieldTypeDescription
idstringA unique id for each data instance
question_idstringA unique id for each question
questionstringThe input competitive programming question. We leave it blank. Check the how-to-use-it section to get them.
r1_generationstringR1's response.
qwq_critiquestringQwQ's response.
solutionstringOnly the code portion of R1's response.
judgementstringOnly the judgement (right/wrong) from QwQ's response.
pass_ratefloatValue in range [0, 1] or -1 (not enough unit tests or execution system couldn't validate).
datasetstringThe name of the dataset from which this question is collected from (e.g., "apps", "taco", "code_contests")
licensestringThe license associated with the dataset (e.g., "mit", "apache-2.0", "cc-by-4.0")
splitstringThe name of the split of the dataset from which this question is collected from (e.g., "train", "valid", "test")
sourcestringThe name of the competitive programming platform (e.g., CodeForces, CodeChef)
difficultystringA difficulty label for the input question.
indexstringAn index to retrieve the input question from APPS/TACO dataset (only available for train-extra split).

How to use it

from tqdm import tqdm
from datasets import load_dataset

hf_datasets = {
    "taco": load_dataset("BAAI/TACO", trust_remote_code=True),
    "apps": load_dataset("codeparrot/apps", trust_remote_code=True),
    "code_contests": load_dataset("deepmind/code_contests"),
    "open-r1/codeforces": load_dataset("open-r1/codeforces")
}


def get_question(ds_name, split, index):
    benchmark = hf_datasets[ds_name][split][int(index)]
    if ds_name == "code_contests":
        if not benchmark["description"]:
            return None
        return benchmark["description"]
    elif ds_name in ["taco", "apps"]:
        return benchmark["question"]
    elif ds_name == "open-r1/codeforces":
        if not benchmark["description"]:
            return None
        question = benchmark["description"]
        if benchmark["input_format"]:
            question += "\n\nInput\n\n" + benchmark["input_format"]
        if benchmark["output_format"]:
            question += "\n\nOutput\n\n" + benchmark["output_format"]
        if benchmark["examples"]:
            question += "\n\nExamples"
            for example in benchmark["examples"]:
                if "input" in example:
                    question += "\n\nInput\n\n" + example["input"]
                if "output" in example:
                    question += "\n\nOutput\n\n" + example["output"]
        if benchmark["note"]:
            question += "\n\nNote\n\n" + benchmark["note"]
        return question

    return None


ocr2_dataset = load_dataset("nvidia/OpenCodeReasoning-2")
for ocr2_ds in [ocr2_dataset["python"], ocr2_dataset["cpp"]]:
    for ocr2_ds_item in tqdm(ocr2_ds):
        assert ocr2_ds_item["dataset"] in ["taco", "apps", "code_contests", "open-r1/codeforces"]
        ds_name, ds_split, ds_index = ocr2_ds_item["dataset"], ocr2_ds_item["split"], int(ocr2_ds_item["index"])
        question = get_question(ds_name, ds_split, ds_index)
        assert question is not None
        assert ocr2_ds_item["question"] == "-"
        ocr2_ds_item["question"] = question

Dataset Owner(s)

NVIDIA Corporation

Dataset Creation Date

March 2025 - May 2025

License/Terms of Use

GOVERNING TERMS: GOVERNING TERMS: This dataset is licensed under the Creative Commons Attribution 4.0 International License (CC BY 4.0) available at https://creativecommons.org/licenses/by/4.0/legalcode.

NOTICE FOR SCRIPTS: You may run the scripts below to pull datasets from their original source. The underlying datasets are available from the original sources subject to their own license terms.

Data Developer: NVIDIA

Use Case: <br>

Developers training Large Language Models (LLMs) to specialize LLMs in code generation and code critique. <br>

Release Date: <br>

05/15/2025 <br>

Data Version

1.0 (05/15/2025)

Dataset Characterization

** Data Collection Method<br>

  • [Hybrid: Automated, Synthetic] <br>

** Labeling Method<be>

  • [Hybrid: Automated, Synthetic] <br>

Intended Usage

The OpenCodeReasoning-2 Dataset is intended to be used by the community to continue to improve open models. The data may be freely used to train models. However, for each dataset a user elects to use, the user is responsible for checking if the dataset license is fit for the intended purpose.

Ethical Considerations:

NVIDIA believes Trustworthy AI is a shared responsibility and we have established policies and practices to enable development for a wide array of AI applications. When downloaded or used in accordance with our terms of service, developers should work with their internal model team to ensure this model meets requirements for the relevant industry and use case and addresses unforeseen product misuse.

Please report security vulnerabilities or NVIDIA AI Concerns here.