Datasets:
File size: 7,095 Bytes
6a483b5 b5b6800 6a483b5 b5b6800 6a483b5 b5b6800 6a483b5 b5b6800 6a483b5 b5b6800 6a483b5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | ---
license: cc-by-nc-4.0
language:
- en
task_categories:
- text-generation
tags:
- code
- non-commercial
- sft
- chatml
pretty_name: CodeAlpaca OpenAI Native
size_categories:
- 10K<n<100K
configs:
- config_name: default
data_files:
- split: train
path: data/train.parquet
- split: test
path: data/test.parquet
---
# CodeAlpaca OpenAI Native
This is a deterministic, lossless-formatting derivative of
[`sahil2801/CodeAlpaca-20k`](https://huggingface.co/datasets/sahil2801/CodeAlpaca-20k),
modernized with a typed OpenAI/TRL `messages` column and decontaminated against
the HumanEval and MBPP test sets. The original Alpaca columns remain available
for backward compatibility.
## Intended use
```python
from datasets import load_dataset
from trl import SFTTrainer
dataset = load_dataset("Archangel-system/codealpaca-openai-native")
trainer = SFTTrainer(model="your-model", train_dataset=dataset["train"])
```
No row-level JSON parsing or prompt concatenation is required. Choose a model
whose tokenizer has an appropriate chat template.
## Schema and conversion rule
Each row has:
- `messages`: a typed list of two records, strictly `user` then `assistant`;
- `instruction`, `input`, and `output`: the unchanged source strings.
The user message equals `instruction` when `input.strip()` is empty. Otherwise
it equals `instruction + "\n\n" + input` (exactly two newline characters).
The assistant message equals `output`. No answer was rewritten or generated.
## Source audit
The build downloaded the source's Hub auto-converted Parquet shard directly.
| Measurement | Count |
|---|---:|
| Source rows | 20022 |
| Non-empty `input` rows | 10258 |
| Empty `output` rows | 6 |
| Exact duplicate instruction rows | 0 |
| Aggressively normalized duplicate instruction rows | 0 |
| Exact `output == instruction` rows | 0 |
| Normalized `output == instruction` rows | 0 |
## Decontamination
Two criteria are applied to CodeAlpaca `instruction` strings against benchmark
**test** prompts. The benchmark sets are never modified.
1. Exact normalized equality: `re.sub(r"[^a-z0-9]+", "", s.lower())`.
2. Shared 13-gram after lowercasing and tokenizing with `[a-z0-9]+`.
| Benchmark | Test items | Exact-normalized source rows | 13-gram source rows |
|---|---:|---:|---:|
| HumanEval | 164 | 0 | 0 |
| MBPP (`full`, `test`, field `text`) | 500 | 1 | 2 |
Any source row matching either criterion was removed before splitting. Complete
row-to-benchmark evidence is in `rejections.jsonl`. A row touching multiple
items or criteria is rejected once but retains every hit in that log.
## Filtering, deduplication, and split
| Stage / reason | Rows removed |
|---|---:|
| Empty output | 6 |
| Benchmark contamination (union) | 2 |
| Duplicate normalized `(instruction, input)` | 0 |
| Train/test signature purge from train | 0 |
| **Total removed** | **8** |
| **Rejection rate** | **0.0400%** |
Rows are deduplicated on the tuple `(normalize_text(instruction),
normalize_text(input))`, where `normalize_text` is the same exact-normalization
function used by verification. The first source occurrence is retained.
The remaining rows are shuffled with Python's `random.Random(42)`. The test
size is `min(1000, round(0.05 * n))`; test receives the first shuffled indices.
Any normalized pair crossing train/test would be purged from **train**, never
test. The measured post-build intersection is 0.
| Split | Rows |
|---|---:|
| train | 19014 |
| test | 1000 |
| total | 20014 |
## Lengths and diversity
Lengths below are lexical token counts using `[a-z0-9]+`.
| Field | Min | Median | Mean | P95 | Max |
|---|---:|---:|---:|---:|---:|
| User message | 4 | 16.0 | 17.5716 | 31.0 | 110 |
| Assistant message | 0 | 20.0 | 28.4568 | 82.0 | 633 |
The final dataset contains 20014
exactly unique instructions and 20014
unique aggressively normalized `(instruction, input)` pairs. It preserves
10252 rows with non-empty inputs.
No semantic-quality filter, language classifier, code execution, or model-based
judgment was applied; this release intentionally does not rewrite source data.
## Reproducibility and files
- Seed: `42`.
- Build script: `build.py`.
- Independent Hub verification script: `verify.py`.
- Machine-readable measurements: `stats.json`.
- Rejection evidence: `rejections.jsonl`.
- Validation report: `validation_report.json`.
- Source revision: `sahil2801/CodeAlpaca-20k@152bb5e9a29651266b018106053980070a0521a1`.
- HumanEval revision: `openai/openai_humaneval@7dce6050a7d6d172f3cc5c32aa97f52fa1a2e544`.
- MBPP revision: `google-research-datasets/mbpp@4bb6404fdc6cacfda99d4ac4205087b89d32030c`.
| File | SHA-256 |
|---|---|
| Source Parquet as downloaded | `5a2fa0c510d42843292c583f357086abb59f95796e0f55727b97e449aa93bed9` |
| `data/train.parquet` | `c00b9902c25983f60ebadb0a08905f42d44c5954ca0c8d5b4e0044e527adac5e` |
| `data/test.parquet` | `1200ef59fdc5854a2c571857c3695488754a783b6e17d778e392f05f60455864` |
| `rejections.jsonl` | `bf88205147fb3074152c43849408aa9476f44441d8f91b99d213980b7d0c3ac7` |
Run `python build.py` to rebuild locally or `python build.py --publish` to rebuild
and upload. Publication reads `HF_TOKEN` from the environment or from the
profile `.env`; the token is never written to an artifact.
## License and attribution
**This dataset is CC BY-NC 4.0 — non-commercial use only.**
The upstream repository [`sahil280114/codealpaca`](https://github.com/sahil280114/codealpaca)
ships **two separate licence files**, and they do not say the same thing:
| File | Covers | Licence |
|---|---|---|
| `LICENSE` | the training/generation **code** | Apache-2.0 |
| `DATA_LICENSE` | `data/code_alpaca_20k.json`, i.e. **the data used here** | **CC BY-NC 4.0** |
The Hugging Face mirror [`sahil2801/CodeAlpaca-20k`](https://huggingface.co/datasets/sahil2801/CodeAlpaca-20k)
is tagged `cc-by-4.0`, which **drops the NonCommercial clause** present in the upstream
`DATA_LICENSE`. We verified both files directly rather than trusting the mirror's tag, and
this derivative follows the stricter upstream data licence: **CC BY-NC 4.0**.
Practical consequence: you may use, modify and redistribute this dataset **for
non-commercial purposes with attribution**. Training a model on it for a commercial
product is **not** covered. If you need a commercially usable code-instruction set,
this is not the right dataset.
Attribution:
- Data: Sahil Chaudhary, *Code Alpaca*, `sahil280114/codealpaca`, `DATA_LICENSE` (CC BY-NC 4.0).
- Outputs were generated with OpenAI `text-davinci-003`; OpenAI's terms of use apply to
the generated content independently of this licence.
## Limitations
The original outputs were generated with `text-davinci-003`; this release does
not independently validate their correctness, security, language, or
executability. Decontamination is limited to exact normalized equality and
lexical 13-gram overlap against the pinned HumanEval and MBPP test prompts; it
does not prove absence of semantic paraphrases. The test split measures this
source distribution and is not a replacement for external code benchmarks.
|