← Open Source
hkust-nlp

CodeIO

[ICML 2025 Oral] CodeI/O: Condensing Reasoning Patterns via Code Input-Output Prediction.

Model DevelopmentArchitecturePython
Open on GitHub
Momentum
+0stars in 24 hours0.0%
572
Stars
35
Forks
+0
This week
1
Contributors
Created 2025-02-08 · Updated 2026-10-05 · #16790 today
Top developers

hkust-nlp/CodeIO is ranked 16,790 with 572 stars.

Same-category comparison

hkust-nlp/CodeIO is ranked 16,790 among these 8 peers; leftthomas/SimCLR is ranked 16,791.

Same-category comparison
NameRankMetrics
Sergio0694/NeuralNetwork.NET16,777
Language:
C#
Stars:
572
Forks:
90
Description:
A TensorFlow-inspired neural network library built from scratch in C# 7.3 for . NET Standard 2.0, with GPU support through cuDNN.
XingangPan/GAN2Shape16,778
Language:
Python
Stars:
572
Forks:
98
Description:
Code for GAN2Shape (ICLR2021 oral).
aqibsaeed/Multilabel-timeseries-classification-with-LSTM16,781
Language:
Jupyter Notebook
Stars:
572
Forks:
183
Description:
Tensorflow implementation of paper: Learning to Diagnose with LSTM Recurrent Neural Networks.
google-research-datasets/paws16,788
Language:
Python
Stars:
572
Forks:
54
Description:
This dataset contains 108,463 human-labeled and 656k noisily labeled pairs that feature the importance of modeling structure, context, and word order information for the problem of paraphrase identification.
leftthomas/SimCLR16,791
Language:
Python
Stars:
572
Forks:
114
Description:
A PyTorch implementation of SimCLR based on ICML 2020 paper "A Simple Framework for Contrastive Learning of Visual Representations".
luca-medeiros/lightning-sam16,794
Language:
Python
Stars:
572
Forks:
53
Description:
Fine-tune Segment-Anything Model with Lightning Fabric.
open-nudge/torchlayers16,795
Language:
Python
Stars:
572
Forks:
45
Description:
Shape and dimension inference (Keras-like) for PyTorch layers and neural networks.
salesforce/PyRCA16,797
Language:
Python
Stars:
572
Forks:
70
Description:
PyRCA: A Python Machine Learning Library for Root Cause Analysis.
Key parameters and specifications
Key parameters and specifications
ParameterValue
LanguagePython
CategoryModel Development
SubcategoryArchitecture
KeywordsCoding, Reasoning
Stars572
Forks35
Contributors1
Created date2025-02-08
Updated date2026-10-05
Stars in 1 day0
Stars in 7 days0
Rank16,790
Previous rank16,584
Rank change-206
7-day stars rank15,726
Previous 7-day stars rank15,739
7-day stars rank change13
Total stars rank17,434
Previous total stars rank17,406
Total stars rank change-28
CountryHong Kong
README summary

CodeI/O: Condensing Reasoning Patterns via Code Input-Output Prediction Table of contents Introduction Released Resources Dataset Models Get Started Setup Data Processing Training Citation Acknowledgement Introduction CodeI/O is a novel approach that transforms code-based reasoning patterns into natural language formats to enhance Large Language Models' reasoning capabilities. Unlike traditional methods focusing on specific skills, our approach systematically extracts universal reasoning primitives while maintaining procedural rigor, enabling better performance across various reasoning tasks. **Key Features & Contributions** 🔄 Universal Transformation

: Converts diverse code patterns into natural language Chain-of-Thought rationales 🧠 Syntax-Decoupled: Decouples reasoning from code syntax while preserving logical structure 📊 Multi-Task Enhancement: Improves performance across symbolic, scientific, logic, mathematical, commonsense and code reasoning ✨ Fully-Verifiable: Supports precise prediction verification through cached ground-truth matching or code re-execution 🚀 Advanced Iteration: Enhanced version (CodeI/O++) with multi-turn revision for better accuracy Released Resources Dataset |Dataset|Link| |-|-| |CodeI/O-PythonEdu-Reasoning|🤗| |CodeI/O-PythonEdu-Raw|🤗| |LeetCode-O Benchmark

|🤗| Due to our collaborators' compliance requirements, we only release the PythonEdu-Reasoning subset of the CodeI/O(++) dataset. Models Get Started Setup We provide both the and . You can choose either way to setup the environment. or Please note that our setup does not guarantee the execution of all types of Python code; you may need to update the environment to meet your personal requirements when processing different code files. Data Processing We provide a complete guide for you to

build data for CodeI/O on a toy dataset. After all these steps you can get a dataset with the same format as in our huggingface dataset. All intermediate results will be stored under , but we have also provided a set of pre-processed files under . Step 1: Convert raw code files into the unified format. 2: Inference You can also use GPT series models to do this transformation step, since recently the DeepSeek API is under heavy pressure. For

example, set as and change accordingly. You may find some the requests failed, it's OK and we just skip them. *Note that we only provide the code to inference with OpenAI-style APIs. However, it is also 100\% feasible to deploy other open-source models and inference locally via frameworks like vllm or sglang. Please refer to their official websites for more details. Step 2: Parse & Generate I/O Pairs The is the python path you will use to run

the I/O pair generation code, which can be different from what you use in the main workflow, e. , installed with some specific packages. The is the path where the I/O pair generation code will be executed, since sometimes it will store some temp files in the file systems, so we explicitly assign a place for it to save them. Step 3: Build Input-Output Prediction Instances We only pick 3 input prediction and 3 output prediction instances for

each sample. Step 4: Inference on CodeI/O data Step 5: Verification In the bash script we run the verification

Frequently asked questions

How many stars and forks are recorded?

hkust-nlp/CodeIO has 572 stars and 35 forks.

What is the repository rank?

hkust-nlp/CodeIO is ranked 16,790.

What language and category are recorded?

hkust-nlp/CodeIO has 572 stars, uses Python and belongs to Model Development.

Which repository is closest in rank?

hkust-nlp/CodeIO is compared with leftthomas/SimCLR, ranked 16,791 with 572 stars.

README

CodeI/O: Condensing Reasoning Patterns via Code Input-Output Prediction

📑 [Paper](https://huggingface.co/papers/2502.07316) &nbsp&nbsp | &nbsp&nbsp 🌐 [Project Page](https://codei-o.github.io/) &nbsp&nbsp | &nbsp&nbsp 🤗 [Released Resources](https://huggingface.co/collections/hkust-nlp/codei-o-67a978e28fd926b56a4f55a2) &nbsp&nbsp | &nbsp&nbsp 💾 [Dataset](https://huggingface.co/datasets/hkust-nlp/CodeIO-PyEdu-Reasoning) &nbsp&nbsp | &nbsp&nbsp 📦 [Repo](https://github.com/hkust-nlp/CodeIO)  





 ![](figures/overview.png) 

Table of contents

Introduction

CodeI/O is a novel approach that transforms code-based reasoning patterns into natural language formats to enhance Large Language Models' reasoning capabilities. Unlike traditional methods focusing on specific skills, our approach systematically extracts universal reasoning primitives while maintaining procedural rigor, enabling better performance across various reasoning tasks.

Key Features & Contributions

  • 🔄 Universal Transformation: Converts diverse code patterns into natural language Chain-of-Thought rationales
  • 🧠 Syntax-Decoupled: Decouples reasoning from code syntax while preserving logical structure
  • 📊 Multi-Task Enhancement: Improves performance across symbolic, scientific, logic, mathematical, commonsense and code reasoning
  • ✨ Fully-Verifiable: Supports precise prediction verification through cached ground-truth matching or code re-execution
  • 🚀 Advanced Iteration: Enhanced version (CodeI/O++) with multi-turn revision for better accuracy

Released Resources

Dataset

Dataset Link
CodeI/O-PythonEdu-Reasoning 🤗
CodeI/O-PythonEdu-Raw 🤗
LeetCode-O Benchmark 🤗

Due to our collaborators' compliance requirements, we only release the PythonEdu-Reasoning subset of the CodeI/O(++) dataset.

Models

Base Model / Training

CodeI/O

CodeI/O++

Stage 1

Stage 2

Stage 1

Stage 2

Qwen 2.5 7B Coder

🤗

🤗

🤗

🤗

LLaMA 3.1 8B

🤗

🤗

🤗

🤗

DeepSeek v2 Lite Coder

🤗

🤗

🤗

🤗

Get Started

Setup

We provide both the requirements.txt and environment.yaml. You can choose either way to setup the environment.

conda create -n codeio_exec python 3.11
conda activate codeio_exec
pip install -r requirements.txt

or

conda env create -f environment.yaml --name codeio_exec
conda activate codeio_exec

Please note that our setup does not guarantee the execution of all types of Python code; you may need to update the environment to meet your personal requirements when processing different code files.

Data Processing

We provide a complete guide for you to build data for CodeI/O on a toy dataset. After all these steps you can get a dataset with the same format as in our huggingface dataset.

All intermediate results will be stored under ./data, but we have also provided a set of pre-processed files under ./processed_data.

Step 1: Convert raw code files into the unified format.

Step 1.1: Build Messages
python ./src/build_transform_msg.py \
--raw_code_file data/rawcode_1k.jsonl \
--raw_code_msg_file data/rawcode_1k_msg.jsonl
Step 1.2: Inference
python ./src/batched_api_inference.py \
--input data/rawcode_1k_msg.jsonl \
--output data/rawcode_1k_unified.jsonl \
--model deepseek-chat \
--num_process 10 \
--num_thread 10 \
--key  \
--temperature 0.7 \
--max_tokens 4096

You can also use GPT series models to do this transformation step, since recently the DeepSeek API is under heavy pressure. For example, set --model as gpt-4o-mini-2024-07-18​ and change --key accordingly. You may find some the requests failed, it's OK and we just skip them.

*Note that we only provide the code to inference with OpenAI-style APIs. However, it is also 100% feasible to deploy other open-source models and inference locally via frameworks like vllm or sglang. Please refer to their official websites for more details.

Step 2: Parse & Generate I/O Pairs

python ./src/parse_gen_ios.py \
--input_file data/rawcode_1k_unified.jsonl \
--output_file data/rawcode_1k_parsed.jsonl \
--python_path "python" \
--run_path "./temp/temp/temp"

The --python_path is the python path you will use to run the I/O pair generation code, which can be different from what you use in the main workflow, e.g., installed with some specific packages. The --run_path is the path where the I/O pair generation code will be executed, since sometimes it will store some temp files in the file systems, so we explicitly assign a place for it to save them.

Step 3: Build Input-Output Prediction Instances

We only pick 3 input prediction and 3 output prediction instances for each sample.

python ./src/build_codeio_msg.py \
--input_file data/rawcode_1k_parsed.jsonl \
--output_file data/codeio_1k_msg.jsonl

Step 4: Inference on CodeI/O data

python ./src/batched_api_inference.py \
--input data/codeio_1k_msg.jsonl \
--output data/codeio_1k_gens.jsonl \
--model deepseek-chat \
--num_process 10 \
--num_thread 10 \
--key  \
--temperature 0.7 \
--max_tokens 4096

Step 5: Verification

bash ./scripts/pipeline_check.sh \
data/rawcode_1k_parsed.jsonl \
data/codeio_1k_gens.jsonl \
data/codeio_1k_gens_verified.jsonl \
python \
./temp/temp/temp

In the bash script we run the verification for several times to try our best avoid the runtime effect brought by multi-processing execution (e.g. timeout). This is helpful for large scale verification. You can change the number of process to match your machine (e.g. more if you have a large number of CPUs and a large memory).

Step 6: Second Turn - Revision and Re-verification

Step 6.1: Build Multi-turn Messages
python ./src/build_codeio_rev_msg.py \
--input_file data/codeio_1k_gens_verified.jsonl \
--output_file data/codeio_1k_msg_rev.jsonl
Step 6.2: Re-generate
python ./src/batched_api_inference.py \
--input data/codeio_1k_msg_rev.jsonl \
--output data/codeio_1k_gens_rev.jsonl \
--model deepseek-chat \
--num_process 10 \
--num_thread 10 \
--key  \
--temperature 0.7 \
--max_tokens 4096
Step 6.3: Re-verification
bash ./scripts/pipeline_check.sh \
data/rawcode_1k_parsed.jsonl \
data/codeio_1k_gens_rev.jsonl \
data/codeio_1k_gens_rev_verified.jsonl \
python \
./temp/temp/temp
Step 6.4: Final Data
python ./src/assemble_codeio_demo.py \
--result_file_turn1 data/codeio_1k_gens_verified.jsonl \
--result_file_turn2 data/codeio_1k_gens_rev_verified.jsonl \
--output_file codeio_demo_final.jsonl

By doing so, you can get data data/codeio_demo_final.jsonl with the same format as in our huggingface dataset.

Training

You can use any popular training framework to train your model like llama-factory.

Citation

If you find this work helpful, please kindly cite as:

@article{li2025codeio,
  title={CodeI/O: Condensing Reasoning Patterns via Code Input-Output Prediction},
  author={Li, Junlong and Guo, Daya and Yang, Dejian and Xu, Runxin and Wu, Yu and He, Junxian},
  journal={arXiv preprint arXiv:2502.07316},
  year={2025}
}

Acknowledgement

We thank Fan Zhou, Wei Liu and Yiheng Xu for their valuable feedback and suggestions! 🤗🤗🤗

Nearby in the ranking
Similar items