kreatix-code-debug / README.md
misukisu's picture
kreatix-code-debug v0.1.0: verified Python data, card, generator
1c01ed6 verified
|
Raw History Blame Contribute Delete
5.67 kB
---
license: apache-2.0
language:
- en
- fi
pretty_name: Kreatix Code Debug
size_categories:
- 1K<n<10K
task_categories:
- text-generation
tags:
- code
- python
- debugging
- bug-fixing
- reasoning
- finnish
- synthetic
- procedurally-generated
- verified
configs:
- config_name: default
data_files:
- split: train
path: data/train.jsonl
- split: test
path: data/test.jsonl
---
# Kreatix Code Debug
**1,364 debugging conversations in English and Finnish. Each one shows a Python solution with one real bug. The
reply finds the line, explains the cause, fixes it, and shows the input that failed. Every bug was checked: the
buggy code really fails, and the fix restores a solution verified against an independent brute-force solver.**
The user asks in one of three ways:
| Mode | The user gives | The reply starts from |
|---|---|---|
| failing call | a call that returns the wrong value | the expected and actual values |
| traceback | the real traceback from running the buggy file | the line that raised the error |
| no hint | only the code and the task | finding a failing input first, then the bug |
Bugs are the kind people actually make: a flipped comparison (`<` vs `<=`), `+` and `-` swapped, `and` and `or`
swapped, `min` and `max` swapped, `bisect_left` and `bisect_right` swapped, an off-by-one in `range()`, index `0`
and `-1` swapped, a wrong starting value, a dropped minus sign, or a statement missing from a loop.
Made by [KreatixLabs](https://huggingface.co/KreatixLabs). Every row is built by a program: no language model wrote
any text or code in this dataset.
![Injected bug types in the train split](assets/code-debug-bugs.png)
## What it looks like
**User**
````text
I get an exception for `rooms_needed([[0, 1]])`:
```
Traceback (most recent call last):
File "solution.py", line 14, in <module>
rooms_needed([[0, 1]])
~~~~~~~~~~~~^^^^^^^^^^
File "solution.py", line 7, in rooms_needed
if ends or ends[0] <= start:
~~~~^^^
IndexError: list index out of range
```
```python
import heapq
def rooms_needed(meetings: list[list[int]]) -> int:
ends = []
for start, end in sorted(meetings):
if ends or ends[0] <= start:
heapq.heapreplace(ends, end)
else:
heapq.heappush(ends, end)
return len(ends)
```
````
**Assistant**
````text
The crash comes from line 7: on this input the bug drives the code into an invalid operation (`IndexError`).
**Bug:** line 7
```python
if ends or ends[0] <= start:
```
The two conditions are joined with `or`, but the logic needs `and` (both conditions must hold).
**Fix:**
```python
if ends and ends[0] <= start:
```
**Corrected code:**
```python
import heapq
def rooms_needed(meetings: list[list[int]]) -> int:
ends = []
for start, end in sorted(meetings):
if ends and ends[0] <= start:
heapq.heapreplace(ends, end)
else:
heapq.heappush(ends, end)
return len(ends)
```
With the fix, `rooms_needed([[0, 1]])` returns `1` instead of raising an error, and the code gives the expected result on all 18 test inputs, including the edge cases.
````
`meta`: `{"kind": "code.debug.bool_flip.meeting_rooms", "lang": "en", "generator": "kreatix-code-debug", "version": "0.1.0", "mode": "traceback", "bug_line": 7, "entry": "rooms_needed", "checked_by": "buggy code fails on [[[0, 1]]]...; fix == verified reference (oracle-checked on 18 inputs)", "problem_id": "a177e8982e5d", "program_id": "0788d5ac5157"}`
## How it was checked
1. The starting solution comes from [Kreatix Code Hard](https://huggingface.co/datasets/KreatixLabs/kreatix-code-hard):
it agrees with an independent brute-force solver on every test input and passes a large-input time limit.
2. One bug is injected by editing an exact span of the source found through Python's AST, so comments and layout
are untouched and the diff is a single line.
3. The buggy program is run on all of the problem's inputs. It is kept only if it compiles and fails at least one
of them; the smallest failing input is the one shown.
4. Tracebacks are real output from running the buggy file (file name shown as `solution.py`).
5. The fix shown restores the verified solution exactly, so "with the fix, all N test inputs pass" is true.
`meta.bug_line` is the line of the bug in the code the user shows.
## Size and repetition
| Split | Rows | en | fi | Distinct buggy programs |
|---|---|---|---|---|
| train | 1,196 | 809 | 387 | 642 |
| test | 168 | 116 | 52 | 84 |
About 0.8M tokens in total.
Each buggy program appears at most twice (with different request styles or failing inputs), and each problem family
at most 80 times. `meta.program_id` identifies the buggy program and `meta.problem_id` the solution it came from.
**Test split:** bugs in five families that never appear in train (two-colouring, decode ways, next greater element,
trapped water / container, running median), so the test measures debugging code the model has not seen.
`stats.json` has the counts per bug type and problem family; `samples.md` shows examples in full.
## Limitations
- **One bug per program.** Real code often has several interacting bugs; this dataset teaches the core loop:
reproduce, localise, explain, fix, re-check.
- **Explanations** come from a template per bug type, filled with the actual line, values and error.
- **Python only.** The Finnish text is awaiting review by native speakers.
## License
Apache-2.0.