File size: 6,752 Bytes
a8cc99b e4d2d92 a8cc99b e4d2d92 a8cc99b e4d2d92 24b0cf5 e4d2d92 | 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 | ---
language:
- en
license: cc-by-nc-4.0
size_categories:
- 100K<n<1M
dataset_info:
features:
- name: text
dtype: string
- name: format
dtype: string
- name: subset
dtype: string
- name: question_id
dtype: string
splits:
- name: train
num_examples: 268211
download_size: 463470592
dataset_size: 1085161053
task_categories:
- question-answering
tags:
- code
- synthetic
- sft
pretty_name: KodCode LFM2.5
---
# KodCode LFM2.5
A preprocessed version of [KodCode-V1-SFT-R1](https://huggingface.co/datasets/KodCode/KodCode-V1-SFT-R1)
formatted for fine-tuning [LFM2.5-1.2B-Thinking](https://huggingface.co/LiquidAI/LFM2.5-1.2B-Thinking)
with a 70% code-only / 30% CoT (chain-of-thought) mix.
## Dataset Description
- **Homepage:** [KodCode Project](https://kodcode-ai.github.io/)
- **Original paper:** [KodCode: A Diverse, Challenging, and Verifiable Synthetic Dataset for Coding](https://arxiv.org/abs/2503.02951)
- **Original dataset:** [KodCode/KodCode-V1-SFT-R1](https://huggingface.co/datasets/KodCode/KodCode-V1-SFT-R1)
- **Points of contact:** [Zhangchen Xu](mailto:zxu9@uw.edu) (original authors)
### Dataset Summary
This dataset is derived from KodCode-V1-SFT-R1 (CC BY-NC 4.0). For each of the 268,211 training
rows, the question-answer pair is formatted into a flat chat template string using
`<|im_start|>` / `<|im_end|>` markers and a `<|startoftext|>` prefix — the native format for
LFM2.5-1.2B-Thinking.
Each row is assigned to one of two formats:
- **code-only (70%):** `question` → `r1_solution` (code response, no thinking trace)
- **CoT (30%):** `question` → `conversations[-1]["value"]` (full response with `<think>` reasoning)
The CoT selection is limited to texts ≤ 15,000 characters (guaranteed to fit within 4096 tokens
at the observed minimum char-to-token ratio of 2.70).
### Changes from the Original
1. **Format conversion:** Original `conversations` field (list of `from`/`value` dicts) is flattened
into a single `text` string with `<|im_start|>` / `<|im_end|>` chat template.
2. **Format selection:** Each row is assigned either `code-only` or `cot` format at a 70/30 ratio
(controlled random per shard).
3. **Char pre-filtering:** CoT texts exceeding 15,000 characters fall back to code-only format
(instead of being dropped), since only ~50% of CoT texts fit within 4096 tokens.
4. **Reduced columns:** Only 4 columns are kept: `text`, `format`, `subset`, `question_id`.
## Data Fields
| Field | Type | Description |
|---|---|---|
| `text` | `string` | Flattened chat text: `<\|startoftext\|><\|im_start\|>user\n{question}<\|im_end\|>\n<\|im_start\|>assistant\n{answer}<\|im_end\|>\n` |
| `format` | `string` | `"code-only"` or `"cot"` |
| `subset` | `string` | Original KodCode subset (e.g. `"Leetcode"`, `"Codeforces"`, `"Taco"`, etc.) |
| `question_id` | `string` | Original question identifier from KodCode |
### Column mapping to original dataset
| This dataset | KodCode-V1-SFT-R1 |
|---|---|
| `text` (code-only) | `question` + `r1_solution` formatted with chat template |
| `text` (CoT) | `question` + `conversations[-1]["value"]` formatted with chat template |
| `subset` | `subset` |
| `question_id` | `question_id` |
| *(omitted)* | `solution`, `test`, `test_info`, `version`, `style`, `metadata`, `r1_pass_sequence`, `r1_correctness`, `gpt_pass_sequence`, `gpt_difficulty`, `gpt_pass_percentage`, `conversations` |
## Data Splits
| Split | Size |
|---|---|
| `train` | 268,211 rows |
## Measured outcome when used for SFT
This dataset mix was used to LoRA fine-tune LFM2.5-1.2B-Thinking
([adapter](https://huggingface.co/enseven/lfm-2.5-think-code)). On a sealed
128-task HumanEval+ evaluation, the fine-tuned model scored **below the base
model it was trained from** (paired plus-pass 49 vs 56; -7.1 pp). The
mechanism is instructive: the 70% code-only `r1_solution` targets taught a
reasoning-capable base to skip its reasoning traces (output length collapsed
~11x), and correctness fell with them, while output formatting improved.
Recommendations for downstream use:
- **Preserve CoT for reasoning-capable bases.** The 30% CoT slice did not
compensate for the 70% code-only targets. Train on `<think>`-style
solutions for code, or distill the base model's own verified traces.
- **Execution-verify training targets.** KodCode-V1-SFT-R1's `r1_solution`
answers were treated as ground truth here; filter to solutions that pass
their unit tests, and exclude KodCode's shipped `incorrect` subset.
- Full evaluation evidence:
[adapter model card](https://huggingface.co/enseven/lfm-2.5-think-code) and
[GitHub — lfm2.5-finetune-code](https://github.com/ensevengg/lfm2.5-finetune-code)
(`reports/e3/`, `reports/e4/`).
## Usage
### Load with HuggingFace Datasets
```python
from datasets import load_dataset
ds = load_dataset("kodcode_dataset", split="train")
# or from parquet directly:
ds = Dataset.from_parquet("kodcode_dataset/data/kodcode-lfm2.5.parquet")
```
### Load for SFT training (TRL)
```python
from trl import SFTTrainer
trainer = SFTTrainer(
...,
train_dataset=ds,
dataset_text_field="text",
max_seq_length=4096,
packing=True,
)
```
### Subset distribution
```python
print(ds.to_pandas()["subset"].value_counts())
```
### Format distribution
```python
print(ds.to_pandas()["format"].value_counts())
# code-only 187824
# cot 80387
```
## Statistics
| Metric | Value |
|---|---|
| Total rows | 268,211 |
| Code-only rows | 187,824 (70.0%) |
| CoT rows | 80,387 (30.0%) |
| Total characters | ~1.09B |
| Text length (mean) | 4,046 chars |
| Text length (median) | 2,130 chars |
| Text length (max) | 15,000 chars |
| Output size (parquet) | 442 MB |
## Citation
If you use this dataset, please cite the original KodCode work:
```bibtex
@article{xu2025kodcode,
title={KodCode: A Diverse, Challenging, and Verifiable Synthetic Dataset for Coding},
author={Zhangchen Xu and Yang Liu and Yueqin Yin and Mingyuan Zhou and Radha Poovendran},
year={2025},
eprint={2503.02951},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/2503.02951},
}
```
## License
This dataset is derived from [KodCode-V1-SFT-R1](https://huggingface.co/datasets/KodCode/KodCode-V1-SFT-R1)
and is distributed under the same **CC BY-NC 4.0** license.
- **Attribution:** You must give appropriate credit to the original KodCode authors.
- **NonCommercial:** You may not use the material for commercial purposes.
- **No additional restrictions:** You may not apply legal terms that restrict others from doing
anything the license permits.
See the [full license text](https://creativecommons.org/licenses/by-nc/4.0/) for details.
|