Ananda100's picture
Update README.md
d6b3793 verified
|
Raw
History Blame Contribute Delete
4.55 kB
metadata
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, 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).

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:

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

Usage

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

@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}
}