task_categories:text-generation language:en license:apache-2.0 size_categories:10K<n<100K format:json modality:text library:datasets library:pandas library:mlcroissant library:polars arxiv:2007.14390 region:us code
---
task_categories:
- text-generation
language:
- en
tags:
- code
pretty_name: CodeAlpaca 20K
size_categories:
- 10K<n<100K
license: apache-2.0
---
# Dataset Card for Dataset Name

This dataset originates from the [Code Alpaca repository](https://github.com/sahil280114/codealpaca).
The CodeAlpaca 20K dataset is specifically used for training code generation models.

## Dataset Details

### Dataset Description

Each sample is comprised of three columns: instruction, input and output. 

- **Language(s):** English
- **License:** Apache-2.0 License

### Dataset Sources

The code from the original repository was adopted to post it here. 

- **Repository:** https://github.com/sahil280114/codealpaca

## Uses

This dataset is primarily used for training code generation models. It can also be utilized in Federated Learning settings by partitioning the data into multiple shards (e.g. [FlowerTune LLM Leaderboard](https://flower.ai/benchmarks/llm-leaderboard/)).


### Direct Use in FL
This dataset can be used in FL settings. We recommend using [Flower Datasets](https://flower.ai/docs/datasets/) (flwr-datasets) and [Flower](https://flower.ai/docs/framework/) (flwr).

To partition the dataset, do the following. 
1. Install the package.
```bash
pip install flwr-datasets
```
2. Use the HF Dataset under the hood in Flower Datasets.
```python
from flwr_datasets import FederatedDataset
from flwr_datasets.partitioner import IidPartitioner

fds = FederatedDataset(
    dataset="flwrlabs/code-alpaca-20k",
    partitioners={"train": IidPartitioner(num_partitions=10)}
)
partition = fds.load_partition(partition_id=0)
```

## Dataset Structure

The dataset contains only train split. Each sample is comprised of columns:
* `instruction`: str - description of the coding task the model should perform. Each of the 20K instructions is unique.
* `input`: str - optional context or input for the coding task.
* `output`: str - the answer to the instruction as generated by `text-davinci-003`.

## Dataset Creation

### Curation Rationale

This dataset was created as a part of the [Code Alpaca repository](https://github.com/sahil280114/codealpaca).

#### Data Collection and Processing

For the preprocessing details, please refer to the source code.

## Citation

When working on the this dataset, please cite the original GitHub repository. If you're using this dataset with Flower Datasets, you can cite Flower.

**BibTeX:**
```
@misc{codealpaca,
  author = {Sahil Chaudhary},
  title = {Code Alpaca: An Instruction-following LLaMA model for code generation},
  year = {2023},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/sahil280114/codealpaca}},
}
```
```
@article{DBLP:journals/corr/abs-2007-14390,
  author       = {Daniel J. Beutel and
                  Taner Topal and
                  Akhil Mathur and
                  Xinchi Qiu and
                  Titouan Parcollet and
                  Nicholas D. Lane},
  title        = {Flower: {A} Friendly Federated Learning Research Framework},
  journal      = {CoRR},
  volume       = {abs/2007.14390},
  year         = {2020},
  url          = {https://arxiv.org/abs/2007.14390},
  eprinttype    = {arXiv},
  eprint       = {2007.14390},
  timestamp    = {Mon, 03 Aug 2020 14:32:13 +0200},
  biburl       = {https://dblp.org/rec/journals/corr/abs-2007-14390.bib},
  bibsource    = {dblp computer science bibliography, https://dblp.org}
}
```

## Dataset Card Contact

In case of any doubts, please contact [Flower Labs](https://flower.ai/).