codeforces-cots
收藏魔搭社区2026-04-28 更新2025-03-15 收录
下载链接:
https://modelscope.cn/datasets/open-r1/codeforces-cots
下载链接
链接失效反馈官方服务:
资源简介:
# Dataset Card for CodeForces-CoTs
## Dataset description
CodeForces-CoTs is a large-scale dataset for training reasoning models on competitive programming tasks. It consists of 10k CodeForces problems with up to five reasoning traces generated by [DeepSeek R1](https://huggingface.co/deepseek-ai/DeepSeek-R1). We did not filter the traces for correctness, but found that around 84% of the Python ones pass the public tests.
The dataset consists of several subsets:
- `solutions`: we prompt R1 to solve the problem and produce code.
- `solutions_w_editorials`: we prompt R1 to solve the problem/produce code, but also provide it with a human-written solution.
- `solutions_short_and_long`: a subset of `solutions` where we take the shortest and longest solution from R1.
- `test_input_generator`: we prompt R1 to come up with tricky edge test cases and create a test code generator in Python.
- `checker_interactor`: we prompt R1 to classify problems based on how we should verify the output (some problems are interactive, some allow multiple correct outputs, etc)
Each subset contains a `messages` column, so can be used directly for SFT. We've found that the `solutions` and `solutions_w_editorials` subsets provide best performance, with `solutions` obtaining better performance on LiveCodeBench. Training on `solutions_short_and_long` also results in comparable performance as the full `solutions` subset, but is significantly more data efficient.
By default, all subsets contains C++ generated solutions, except those with a `_py` suffix, which denote Python solutions with just one completion per problem. We also provide decontaminated subsets (indicated with a `_decontaminated` suffix), which have been decontaminated using 8-gram overlap against the AIME24, AIME25, GPQA Diamond, MATH-500, and LiveCodeBench benchmarks. Check out [this script](https://github.com/huggingface/open-r1/blob/main/scripts/decontaminate.py) for the underlying logic.
You can load the dataset as follows:
```python
from datasets import load_dataset
ds = load_dataset("open-r1/codeforces-cots", "solutions")
```
## Dataset curation
[CodeForces](https://codeforces.com/) is one of the most popular websites among competitive programmers, hosting regular contests where participants must solve challenging algorithmic optimization problems. The challenging nature of these problems makes them an interesting dataset to improve and test models’ code reasoning capabilities.
While previous efforts such as [DeepMind’s CodeContests dataset](https://huggingface.co/datasets/deepmind/code_contests) have compiled a large amount of CodeForces problems, today we are releasing our own `open-r1/codeforces` dataset, with more than **10k problems** covering the very first contests all the way to 2025, **~3k** of which were not included in DeepMind’s dataset. Additionally, for around 60% of problems, we have **included the *editorial*,** which is an explanation, written by the contest organizers, explaining the correct solution. You will also find 3 correct solutions per problem extracted from the official website.
Furthermore, we are releasing `open-r1/codeforces-cots`, which contains chain of thought generations produced by DeepSeek-R1 on these problems, where we asked the model to produce solutions in C++ (the main language used in competitive programming) and Python, totaling close to **100k** samples.
## License
The dataset is licensed under the Open Data Commons Attribution License (ODC-By) 4.0 license.
## Citation
If you find CodeForces-CoTs useful in your work, please consider citing it as:
```
@misc{penedo2025codeforces,
title={CodeForces CoTs},
author={Guilherme Penedo and Anton Lozhkov and Hynek Kydlíček and Loubna Ben Allal and Edward Beeching and Agustín Piqueres Lajarín and Quentin Gallouédec and Nathan Habib and Lewis Tunstall and Leandro von Werra},
year={2025},
publisher = {Hugging Face},
journal = {Hugging Face repository},
howpublished = {\url{https://huggingface.co/datasets/open-r1/codeforces-cots}}
}
```
# CodeForces-CoTs 数据集卡片
## 数据集描述
CodeForces-CoTs 是一款用于在竞赛编程任务上训练推理模型的大规模数据集。它包含10000道CodeForces题目,以及由[DeepSeek R1](https://huggingface.co/deepseek-ai/DeepSeek-R1)生成的最多5条推理轨迹。我们未对轨迹的正确性进行过滤,但发现其中约84%的Python版本轨迹可通过公开测试用例。
该数据集包含以下多个子集:
- `solutions`:我们提示R1解决问题并生成代码。
- `solutions_w_editorials`:我们提示R1解决问题/生成代码,同时为其提供人工撰写的题解。
- `solutions_short_and_long`:`solutions`的子集,我们从中选取R1生成的最短与最长代码解。
- `test_input_generator`:我们提示R1生成具有挑战性的边界测试用例,并编写Python测试代码生成器。
- `checker_interactor`:我们提示R1对题目进行分类,以确定验证输出的方式(部分题目为交互型,部分允许多种正确输出等)。
每个子集均包含`messages`列,可直接用于监督微调(Supervised Fine-Tuning,简称SFT)。我们发现`solutions`与`solutions_w_editorials`子集可实现最优性能,其中`solutions`在LiveCodeBench上的表现更佳。在`solutions_short_and_long`子集上训练,亦可取得与完整`solutions`子集相当的性能,但数据效率显著更高。
默认情况下,所有子集均包含C++代码解,后缀为`_py`的子集除外——此类子集仅包含每道题目的单条Python代码解。我们还提供了去污染子集(后缀为`_decontaminated`),该类子集通过与AIME24、AIME25、GPQA Diamond、MATH-500及LiveCodeBench基准集进行8元组重叠比对完成去污染。相关底层逻辑可参阅[此脚本](https://github.com/huggingface/open-r1/blob/main/scripts/decontaminate.py)。
你可以通过如下方式加载该数据集:
python
from datasets import load_dataset
ds = load_dataset("open-r1/codeforces-cots", "solutions")
## 数据集构建说明
[CodeForces](https://codeforces.com/) 是竞赛编程爱好者中最热门的平台之一,定期举办竞赛,要求参赛者解决具有挑战性的算法优化类问题。此类问题的挑战性使其成为提升与测试模型代码推理能力的优质数据集。
此前已有如[DeepMind的CodeContests数据集](https://huggingface.co/datasets/deepmind/code_contests)等工作收录了大量CodeForces题目,而我们此次发布的`open-r1/codeforces`数据集则收录了超过**10000道题目**,覆盖从首届竞赛至2025年的所有赛事,其中约**3000道题目未被DeepMind的数据集收录**。此外,针对约60%的题目,我们还**收录了由竞赛主办方撰写的官方题解**,同时还可从官方网站获取每道题目的3份正确代码解。
进一步地,我们还发布了`open-r1/codeforces-cots`数据集,其中包含DeepSeek-R1在上述题目上生成的思维链(Chain of Thought,CoT)结果,我们要求模型以竞赛编程的主流语言C++与Python生成代码解,总样本量接近**100000**。
## 授权协议
本数据集采用开放数据 Commons 署名许可(Open Data Commons Attribution License,ODC-By)4.0协议进行授权。
## 引用
若你在工作中使用了CodeForces-CoTs数据集,请引用如下文献:
@misc{penedo2025codeforces,
title={CodeForces CoTs},
author={Guilherme Penedo and Anton Lozhkov and Hynek Kydlíček and Loubna Ben Allal and Edward Beeching and Agustín Piqueres Lajarín and Quentin Gallouédec and Nathan Habib and Lewis Tunstall and Leandro von Werra},
year={2025},
publisher = {Hugging Face},
journal = {Hugging Face repository},
howpublished = {url{https://huggingface.co/datasets/open-r1/codeforces-cots}}
}
提供机构:
maas
创建时间:
2025-03-12



