File size: 4,554 Bytes
bcf5b98
231dd9a
 
 
 
 
 
 
 
 
 
 
 
 
bcf5b98
231dd9a
 
 
 
 
 
d6b3793
 
231dd9a
 
 
d6b3793
231dd9a
 
 
 
 
d6b3793
231dd9a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d6b3793
 
231dd9a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d6b3793
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
---
license: other
license_name: source-repo-licenses
license_link: https://huggingface.co/datasets/codeparrot/codeparrot-clean
language:
- code
task_categories:
- text-generation
tags:
- python
- code
- pretraining
size_categories:
- 1M<n<10M
---

# python-clean-codeparrot

A cleaned, deduplicated, Python-only pretraining corpus derived from
[`codeparrot/codeparrot-clean`](https://huggingface.co/datasets/codeparrot/codeparrot-clean),
built as the pretraining data for **PocketCoder**, a 95.87M-parameter decoder-only
code language model. **1,800,000 documents, ~2.96 billion tokens**
(DeepSeek-Coder tokenizer, vocabulary 32,022).

- **Paper:** *PocketCoder: What Distillation, SFT, and DPO Each Buy You at 100M Parameters*
- **Model:** [`Ananda100/PocketCoder`](https://huggingface.co/Ananda100/PocketCoder)
- **SFT dataset:** [`Ananda100/python-sft-dataset`](https://huggingface.co/datasets/Ananda100/python-sft-dataset)
- **Code:** [github.com/AnandaRimal/PocketCoder](https://github.com/AnandaRimal/PocketCoder)

## Cleaning pipeline

Applied on top of `codeparrot-clean` (which is itself deduplicated), streaming
file-by-file, collecting until 1,800,000 cleaned files were kept:

1. **Drop autogenerated/vendored files** — files flagged `autogenerated` by the
   upstream dataset, plus regex matches for SWIG output, protocol-buffer compiler
   output, Cython output, "do not edit"/"this file was generated" markers, and
   similar machine-produced code.
2. **Strip license headers** — leading `#`-comment blocks containing
   copyright/license keywords (up to the first 80 lines).
3. **Strip non-Python metadata blobs** — Ansible-style
   `DOCUMENTATION` / `EXAMPLES` / `RETURN` / `ANSIBLE_METADATA` triple-quoted
   assignments.
4. **Strip boilerplate comment lines**`# Filename:`, `# Author:`,
   `# Created:`, `# Version:`, `# Date:`, `# Maintainer:` lines. Real docstrings
   are left untouched.
5. **Redact email addresses** — all email addresses replaced with `<EMAIL>`
   (PII mitigation).
6. **Length band** — files shorter than 100 characters or longer than 20,000
   characters are dropped whole (never truncated).
7. **Exact deduplication** — SHA-256 hash of the cleaned content; duplicates
   dropped at collection time.

The full cleaning script is released in the PocketCoder GitHub repository.

## Measured corpus statistics

Audited on a 5,000-document streamed sample (audit notebook and the resulting
`corpus_quality_report.json` are released alongside the code):

| Metric | Value |
|---|---|
| Total documents | 1,800,000 |
| Total tokens (DeepSeek-Coder tokenizer) | ~2,955,981,351 |
| Natural-language content (chars) | 16.0% (7.8% comments, 8.2% docstrings) |
| Unique documents (exact hash) | 100.0% |
| Unique documents (near, comments/whitespace stripped) | 99.9% |
| Syntactic validity (`ast.parse`, Python 3) | 85.6%* |
| Docstring coverage (functions) | 26.4% |
| Mean function complexity (control-flow branches +1) | 2.31 |
| Document length median / mean / p95 (chars) | 3,569 / 5,170 / 14,977 |

\*Parse failures under Python 3 predominantly reflect legacy Python 2 syntax
present in the upstream GitHub-derived corpus (e.g. `print` statements), not
corrupted files; documents are dropped whole rather than truncated, so no file
is cut mid-statement.

## Format

One field per example:

```python
{"content": "<cleaned Python source file>"}
```

## Usage

```python
from datasets import load_dataset

ds = load_dataset("Ananda100/python-clean-codeparrot", split="train", streaming=True)
for example in ds:
    print(example["content"][:200])
    break
```

## Intended use & limitations

Built for pretraining small code language models. Natural language appears only
as annotation embedded in code (comments/docstrings), never as standalone
problem-to-solution instruction — models pretrained on this corpus alone will
not follow natural-language instructions without subsequent instruction tuning
(measured in the PocketCoder paper: 0.0% MBPP pass@1 before SFT, 8.6% after).

## Licensing

Derived from `codeparrot/codeparrot-clean`, which aggregates public GitHub
Python files under their original licenses. Use of this derived corpus is
subject to the licenses of the underlying source files; see the upstream
dataset card for details.

## Citation

```bibtex
@misc{rimal2026pocketcoder,
  title  = {PocketCoder: What Distillation, SFT, and DPO Each Buy You at 100M Parameters},
  author = {Rimal, Ananda},
  year   = {2026},
  url    = {https://github.com/AnandaRimal/PocketCoder}
}
```