File size: 10,193 Bytes
c93f1c0
37827e6
5570738
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d62b9c0
 
 
 
5570738
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d62b9c0
 
 
 
5570738
 
 
 
 
37827e6
 
 
 
 
 
 
 
 
 
 
 
 
 
c93f1c0
37827e6
 
 
 
 
 
0f8fe08
 
 
 
 
 
37827e6
 
3169e60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37827e6
 
 
 
 
 
 
 
 
0f8fe08
37827e6
 
3169e60
 
37827e6
0f8fe08
37827e6
 
 
 
 
 
 
3169e60
37827e6
3169e60
37827e6
3169e60
37827e6
3169e60
0f8fe08
 
 
 
3169e60
 
37827e6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
---
license: cc-by-nc-4.0
dataset_info:
  features:
  - name: version
    dtype: string
  - name: style
    dtype: string
  - name: subset
    dtype: string
  - name: question_id
    dtype: string
  - name: question
    dtype: string
  - name: solution
    dtype: string
  - name: test
    dtype: string
  - name: test_info
    list:
    - name: docstring
      dtype: string
    - name: function_declaration
      dtype: string
    - name: function_name
      dtype: string
    - name: parameter_list
      dtype: string
  - name: gpt_pass_sequence
    list: int64
  - name: gpt_pass_trial_num
    dtype: int64
  - name: gpt_difficulty
    dtype: string
  - name: gpt_pass_percentage
    dtype: float64
  - name: trials
    struct:
    - name: trial_gpt4o_0
      struct:
      - name: file_source
        dtype: string
      - name: solution_code
        dtype: string
      - name: test_code
        dtype: string
      - name: test_coverage
        dtype: float64
      - name: test_result
        dtype: string
    - name: trial_gpt4o_1
      struct:
      - name: file_source
        dtype: string
      - name: solution_code
        dtype: string
      - name: test_code
        dtype: string
      - name: test_coverage
        dtype: float64
      - name: test_result
        dtype: string
    - name: trial_gpt4o_2
      struct:
      - name: file_source
        dtype: string
      - name: solution_code
        dtype: string
      - name: test_code
        dtype: string
      - name: test_coverage
        dtype: float64
      - name: test_result
        dtype: string
    - name: trial_gpt4o_3
      struct:
      - name: file_source
        dtype: string
      - name: solution_code
        dtype: string
      - name: test_code
        dtype: string
      - name: test_coverage
        dtype: float64
      - name: test_result
        dtype: string
    - name: trial_gpt4o_4
      struct:
      - name: file_source
        dtype: string
      - name: solution_code
        dtype: string
      - name: test_code
        dtype: string
      - name: test_coverage
        dtype: float64
      - name: test_result
        dtype: string
    - name: trial_gpt4o_5
      struct:
      - name: file_source
        dtype: string
      - name: solution_code
        dtype: string
      - name: test_code
        dtype: string
      - name: test_coverage
        dtype: float64
      - name: test_result
        dtype: string
    - name: trial_gpt4o_6
      struct:
      - name: file_source
        dtype: string
      - name: solution_code
        dtype: string
      - name: test_code
        dtype: string
      - name: test_coverage
        dtype: float64
      - name: test_result
        dtype: string
    - name: trial_gpt4o_7
      struct:
      - name: file_source
        dtype: string
      - name: solution_code
        dtype: string
      - name: test_code
        dtype: string
      - name: test_coverage
        dtype: float64
      - name: test_result
        dtype: string
    - name: trial_gpt4o_8
      struct:
      - name: file_source
        dtype: string
      - name: solution_code
        dtype: string
      - name: test_code
        dtype: string
      - name: test_coverage
        dtype: float64
      - name: test_result
        dtype: string
    - name: trial_gpt4o_9
      struct:
      - name: file_source
        dtype: string
      - name: solution_code
        dtype: string
      - name: test_code
        dtype: string
      - name: test_coverage
        dtype: float64
      - name: test_result
        dtype: string
  - name: chosen_trial
    dtype: string
  - name: metadata
    struct:
    - name: original_instruction
      dtype: string
    - name: prompt_id
      dtype: string
    - name: row_id
      dtype: int64
    - name: seed_ids
      dtype: string
  - name: benchmark_similarity
    dtype: float64
  - name: benchmark_instruction
    dtype: string
  - name: benchmark_task_id
    dtype: string
  - name: filter_reason
    dtype: string
  - name: base_id
    dtype: string
  - name: variant
    dtype: string
  - name: top_function_names
    list: string
  - name: n_top_functions
    dtype: int64
  - name: helper_call_edges
    list:
      list: string
  - name: n_helper_call_edges
    dtype: int64
  - name: harness_functions
    list: string
  - name: structural_wrapper
    dtype: bool
  - name: class_names
    list: string
  - name: has_class
    dtype: bool
  - name: test_kind
    dtype: string
  - name: test_has_solution_import
    dtype: bool
  - name: third_party_imports
    list: string
  - name: stdlib_only
    dtype: bool
  - name: question_norm_sha1
    dtype: string
  - name: solution_ast_sha1
    dtype: string
  splits:
  - name: train
    num_bytes: 517275943
    num_examples: 28914
  download_size: 451901715
  dataset_size: 517275943
configs:
- config_name: default
  data_files:
  - split: train
    path: data/train-*
language:
- en
size_categories:
- 10K<n<100K
tags:
- code
- python
- synthetic
- unit-tests
source_datasets:
- KodCode/KodCode-V1
task_categories:
- text-generation
pretty_name: Multi-function KodCode
---

# Multi-function KodCode

A subset of the `train` split of [KodCode/KodCode-V1](https://huggingface.co/datasets/KodCode/KodCode-V1)
(revision `97d81f0695ddd7c5c02bfe16436db9a17a4a21e5`) containing only rows whose gold `solution` uses a helper
function: it defines at least two top-level functions and at least one of them
calls another. A call is a direct call or the function's name passed as a
positional argument (a callback such as `cmp_to_key(compare)`). Self-recursion,
calls made by a function named `main`, and names shadowed by a parameter or
local variable of the caller (e.g. `def is_subsequence(sub, main): ... len(main)`)
do not count. Rows whose solution is a single function, or only a class, are
removed, and so are the online-judge (`_OJ`, stdin/stdout) rows. The
`use_with_caution` split is not included.

**Test-case wrappers are removed too.** Many competitive-programming rows are
one real function plus a wrapper that loops over test cases, parses input or
formats output (`process_test_cases`, `process_input`, `solve(test_cases)`,
...). A row is dropped when (a) every helper call is made by a function with
an unambiguous harness name and one other function remains, or (b) the
question mentions multiple test cases / queries, a single function makes every
helper call, one other function remains, and that caller only delegates
(calls it inside a loop over test cases, converts the result to YES/NO, or
parses an input argument first). Rule (b) is a heuristic: in a random sample
of 100 rows it removed, 93 were plain wrappers, 4 were borderline and 3 had
real logic in the caller. A wrapper that orchestrates two or more real
functions is kept.

- Rows: **28,914** (18,722 distinct base questions)
- Rows with pytest tests, standard-library imports only, and no top-level class: 24,502 (15,667 base questions)

No original field is modified. All original columns are kept, and the flag
columns below are added.

## Added columns

| Column | Meaning |
|---|---|
| `base_id` | `question_id` without its style suffix. The `_I` (instruct) and `_C` (complete) rows of one base question share the **same gold solution**; split by `base_id` to avoid leakage. |
| `variant` | `I` or `C` |
| `top_function_names`, `n_top_functions` | Top-level functions of the gold solution |
| `helper_call_edges`, `n_helper_call_edges` | `[caller, callee]` calls between top-level functions (no self-calls, no calls made by `main`) |
| `harness_functions` | Top-level functions with a test-case / input / output harness name (kept rows have them only when they orchestrate two or more real functions) |
| `structural_wrapper` | Rule (b) above; always `false` in this version |
| `class_names`, `has_class` | Top-level classes of the gold solution (methods are not counted as functions) |
| `test_kind` | Always `pytest` in this version (online-judge rows were removed) |
| `test_has_solution_import` | Whether the test imports from `solution` itself |
| `third_party_imports`, `stdlib_only` | Non-standard-library modules imported by the solution or the test |
| `question_norm_sha1` | SHA-1 of the whitespace/case-normalized question |
| `solution_ast_sha1` | SHA-1 of the solution's AST dump |

## Counts

By subset: Filter 6,503, Taco 5,538, Data_Structure 3,122, Docs 2,956, Code_Contests 2,832, Codeforces 2,231, Algorithm 1,796, Prefill 1,112, Apps 939, Evol 889, Leetcode 740, Package 256

By variant: I 18,635, C 10,279

Top-level functions per solution (6 = six or more): 2: 15,893, 3: 7,746, 4: 3,292, 5: 1,155, 6: 828

Rows with a top-level class: 2,055; rows needing third-party packages: 2,589.

## Versions

- Revision `37827e6a` (2026-09-29): 43,605 rows. It counted a name shadowed by a parameter or local variable as a call, which let 74 single-function rows in, and it kept 2 online-judge rows.
- Revision `0f8fe081` (2026-09-30): those 74 rows and the online-judge rows removed; 43,530 rows.
- This version (2026-10-08): test-case wrappers removed (14,616 rows); 28,914 rows. New columns `harness_functions` and `structural_wrapper` (always false in kept rows).

## Running the tests

KodCode's own pipeline writes the solution to `solution.py`, prepends
`from solution import *` to the test code, saves it as `test_solution.py`,
and runs pytest with a 30-second timeout. About 12% of the tests call the
solution's functions without importing them, so the prepended import is
required.

## License and attribution

Derived from KodCode-V1, which is released under
[CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/). This subset
keeps that license (non-commercial use only). Changes: row filtering as
described above, and the added columns. Please cite the original work:

```
@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},
}
```