tianyi-in-the-bush's picture
Dataset card: test-case wrapper rule, new columns, version notes
3169e60 verified
|
Raw History Blame Contribute Delete
10.2 kB
---
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},
}
```