task_categories:text-generation task_categories:question-answering size_categories:10K<n<100K language:en license:apache-2.0 code region:us
---
license: apache-2.0
task_categories:
- text-generation
- question-answering
language:
- en
tags:
- code
size_categories:
- 10K<n<100K
---


# Dataset Description
edit: fixed some bugs with datasets not handling all pyarrow types.

## Dataset Summary

This dataset consists of Python coding problems from LeetCode, which have been bugged using the [OpenBugger](https://github.com/furlat/OpenBugger) package. This dataset provides a unique opportunity to study the debugging process in a controlled and replicable environment.

For each correct code snippet, 15 bugged versions were attempted. For each succesfully bugged version, a corresponding question mimicking a beginner coder's perspective was generated, creating a Q/A pair. In addition to the code and question, each data entry contains the task description, the bug's location, and debugging instructions.
Finally the code snippets are wrapped in python markdown headers and the conversation is structured using the [ChatML](https://github.com/openai/openai-python/blob/main/chatml.md) format.

Highest quality data for training LLM are found in https://huggingface.co/datasets/NeuroDragon/BuggedPythonLeetCode/blob/main/train/bugged_leetcode_no_replaced.parquet

## Supported Tasks

This dataset supports a variety of tasks:
- Code Debugging: Predict the correct code snippet given the bugged code and the question.
- Question Answering: Given the task description and bugged code, generate the question.
- Code Generation: Given the task description, question, and debugging instructions, generate the correct code.
- CST Generation: Given the code, generate the concrete syntax tree.

## Languages

The text in the dataset is in English, and the code is in Python.

# Dataset Structure

## Data Instances

The core of the dataset is constructed around the following concepts, refer to the dataframes columns headers for the specific names:
- correct_code: The original, correct Python code snippet.
- task_description: A brief description of the coding task.
- bugged_code: The bugged version of the correct code.
- bugs_location: The location(s) of the bug(s) in the code.
- debugging_instructions: Instructions to help debug the code.
- question: A question related to the bugged code, mimicking a beginner's query.
- answer: The answer to the question, which alawys contain the original correct code or a chunk of GPT-generated code that matches the original up to linting and comments.

## Data Splits

The dataset is split into five files:
- bugged_leetcode_all_conversations_with_embeddings.parquet
- bugged_leetcode_all_conversations.parquet
- bugged_leetcode_no_replaced_with_embeddings.parquet
- bugged_leetcode_no_replaced.parquet
- bugged_leetcode_all_steps.parquet

## Data Generation Process

The data was generated using a combination of LeetCode problem data, the OpenBugger package, and the GPT 3.5 model. The original code was bugged using OpenBugger, and then the GPT model was used to generate a question and answer based on the bugged code and task description in order to limit GPT contribution to the natural language and not the coding aspect of the dataset. Additional processing ensured that the final answer was a compilable Python code and that corresponded to the original leetcode solution.

# Dataset Creation

## Curation Rationale

This dataset was curated to provide a large-scale, diverse set of Python programming problems and their bugged versions, which could be used for developing and evaluating models for debugging, code generation, and question answering.

## Dataset Source

The original coding problems were sourced from [leetcode-solutions-python](https://huggingface.co/datasets/mhhmm/leetcode-solutions-python
).

## Licensing Information

Please refer to the licensing information of the original dataset.

# Dataset Usage

## Usage Caveats

Users should be aware that the questions in this dataset contain some stereotypical phrases, and may benefit from checking for n-gram distributions and filtering the spikes. Multiple post-processing steps have already been applied, but better safe than sorry.

# Dataset Maintenance

## Contact Information

Please contact the [original author](https://github.com/furlat) for any questions or concerns related to this dataset.

## Dataset Updates

This is a static dataset that does not receive updates.