task_categories:text-generation size_categories:10K<n<100K language:en license:cc-by-sa-3.0 region:us
---
configs:
- config_name: default
  data_files:
  - split: train
    path: data/train-*
  - split: test
    path: data/test-*
dataset_info:
  features:
  - name: text
    dtype: string
  splits:
  - name: train
    num_bytes: 34661192.7
    num_examples: 19000
  - name: test
    num_bytes: 1824273.3
    num_examples: 1000
  download_size: 19060329
  dataset_size: 36485466
license: cc-by-sa-3.0
task_categories:
- text-generation
language:
- en
pretty_name: Instruct Python 500k
size_categories:
- 10K<n<100K
---


# Fine-tuning Instruct Llama2 Stack Overflow Python Q&A


## Transformed Dataset

### Objective

The transformed dataset is designed for fine-tuning LLMs to improve Python coding assistance by focusing on high-quality content from Stack Overflow. It has around 20k instructions.

### Structure

- **Question-Answer Pairing**: Questions and answers are paired using the `ParentId` linkage.
- **Quality Focus**: Only top-rated answers for each question are retained.
- **HTML Tag Removal**: All HTML tags in the content are removed.
- **Combined Question Field**: Each question's title and body are merged.
- **Filtering**: Entries with negative scores or those not containing Python code structures are excluded.

Final columns:
- `score_question`
- `score_answer`
- `question`
- `answer`

### Llama2 Transformation

The dataset has been transformed to match the Llama2 prompt structure, which is relevant for the model's fine-tuning. The format is the following:

`<s>[INST] <<SYS>> {{ system_prompt }} <</SYS>> {{ user_message }} [/INST]`

Where:
- `system_prompt` gives context or instructions to the model.
- `user_message` is the user's query following the system prompt, expecting a particular response from the model.

This structure ensures the training aligns with Llama2's expectations, optimizing the fine-tuning quality.


## Original Dataset

The dataset contains questions and answers from Stack Overflow with the `python` tag, covering the period from August 2, 2008, to October 19, 2016.



## License

All contributions are under the [CC-BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/). Attribution is required. The original dataset was posted [here](https://www.kaggle.com/datasets/stackoverflow/pythonquestions).

Keep in touch: [LinkedIn](https://www.linkedin.com/in/luisbrasroque/)