Datasets:
Update README.md
Browse files32 unmodified lines3334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323432 unmodified lines- text-generation---# GitHub-Python — Licensed & Elaborated VariantsThis repository ships **two complementary Python-code corpora** extracted frompublic GitHub:- **Licensed Subset** – strictly _permissive-licensed_ files suitable forcommercial redistribution / model training (main corpus used in ourexperiments).- **Elaborated Collection** – a broader crawl that additionally contains filesunder _copyleft_ or unclear licenses (GPL/AGPL/LGPL, etc.). Useful foranalysis or pre-training where license mixing is acceptable.Both variants target **code-completion / generation** research.## Dataset at a glance| | **Licensed Subset** | **Elaborated Collection** || ------------------- | ------------------- | ------------------------- || Files (.py) | 53,017 | 186,066 || Unique repositories | 16,447 | 59,852 || Repository owners | 12,515 | 43,517 || Compressed size | 732 MB | 2.4 GB \* || Vocabulary (tokens) | 443,431 | 443,431 † || License coverage | Permissive only | Mixed (perm. + copyleft) || Secrets redacted | ✅ | ⚠️ not guaranteed || Time window | ≥ 2015-01-01 | ≥ 2015-01-01 |\* estimated – elaborated corpus is distributed as raw file list, not a singletext file.† same tokenizer file is shared by both variants.Numbers were obtained from the final redacted corpus and companion metadata.---## Dataset structure```huggingface_dataset/├─ mega_licensed_corpus_redacted.txt # Licensed Subset – concatenated code├─ python_files.txt # Licensed Subset – raw file URLs├─ python_files_elaborated.txt # Elaborated Collection – raw file URLs├─ python_files_elaborated_metadata.csv # Elaborated Collection metadata└─ custom_tokens_vocab.txt # `<token>\t<id>` vocabulary file```### File separatorIndividual files are concatenated with the sentinel line:```# <FILESEP>```Anything following the sentinel until the next sentinel (or EOF) is the sourcecode of one file.---## Dataset variants### 1. Licensed Subset (`mega_licensed_corpus_redacted.txt`)• 53 K permissively-licensed files (MIT/BSD/Apache/ISC/Unlicense).• All API keys & credentials removed.• Ready for redistribution & commercial use (respect upstream NOTICE files).### 2. Elaborated Collection (`python_files_elaborated.txt`)• 186 K files from a much larger crawl.• Contains **GPL / LGPL / AGPL and other copyleft** licenses.• Shipped _as URL list_ + metadata CSV; you must download the files yourself(`datasets.load_dataset` streaming, `wget`, etc.).• **No license filtering or secret-redaction performed** – use with caution.When first loading the dataset, decide which variant aligns with your use case(e.g. proprietary model training → Licensed Subset only).---## Collection methodology1. **Repository discovery**- Queried GitHub REST API for projects with **≥ 10 stars**(earlier iterations used 100+, later expanded for coverage).- Only repositories with primary language _Python_ and last commit ≥ 2015.2. **File filtering**- Retain files whose **size ∈ [1 KB, 100 KB]**.- Exclude common build/packaging scripts (`setup.py`, `__init__.py`, etc.).3. **License compliance**- Allowed: MIT, Apache-2.0, BSD-2/3-Clause, ISC, Unlicense.- GPL, LGPL, AGPL and proprietary licenses were **excluded**.4. **Deduplication**- Unique file SHA hashes; duplicates skipped.5. **Formatting & cleaning**- Formatted with _autopep8_ to normalise whitespace.- Custom script removed trailing whitespace & normalised newlines.6. **Secret redaction**- `truffleHog` + custom regex pass removed >150 active credentials.- Redacted corpus stored as `mega_licensed_corpus_redacted.txt`.---## Custom tokenisationThe accompanying `custom_tokens_vocab.txt` implements a **Python-awaresub-token scheme**:1. Strip doc-strings & comments.2. Split on:- Camel-Case boundaries (`Camel` → `Camel`, `Case`)- Underscores, spaces- Indentation & newlines (preserved as `<newline>` token)3. Rare tokens (frequency < 10) were dropped → 443 k vocabulary.Example:```pythondef helloWorld(value):return value + 1```tokenises to:```def hello world ( value ) <newline> return value + 1 <newline>```---## Usage```pythonfrom datasets import load_datasetds = load_dataset("jblitzar/github-python", split="train")print(ds[0]["code"][:300]) # raw source code```If you prefer token level examples (small reasons: memory), map the tokenizer:```pythonfrom tokenizers import Tokenizertok = Tokenizer.from_file("custom_tokens_vocab.txt")def encode(ex):ex["input_ids"] = tok.encode(ex["code"]).idsreturn exds = ds.map(encode, remove_columns=["code"])```---## Ethical considerations & limitations- **Licenses respected** – only permissive licenses included; retain NOTICEfiles when redistributing derivative works.- **Secrets removed** – automated & manual audits performed, yet users **mustnot assume zero secrets**; re-audit before public deployments.- **Code quality** – projects vary in style & correctness. Generated modelsmay replicate bugs or vulnerable patterns.---## CitationIf you use this dataset, please cite:```@misc{github-python-2024,author = {JBlitzar},title = {GitHub-Python: A Permissively Licensed Corpus of Python Code},year = {2024},howpublished = {\url{https://huggingface.co/datasets/jblitzar/github-python}},note = {Version 1.0}}```---## LicenseDataset card and aggregation scripts: **GPLv3**.Each code snippet remains under its **original repository license** (MIT,Apache-2.0, BSD, ISC, etc.). Users must comply with upstream notices whenredistributing code or derivatives.32 unmodified lines3334353632 unmodified lines- text-generation---https://huggingface.co/datasets/jblitzar/github-python/blob/main/README.md
README.md+1-199