--- dataset_info: - config_name: C features: - name: blob_id dtype: large_string - name: language dtype: large_string - name: repo_name dtype: large_string - name: path dtype: large_string - name: src_encoding dtype: large_string - name: length_bytes dtype: int64 - name: score dtype: float64 - name: int_score dtype: int64 - name: detected_licenses large_list: large_string - name: license_type dtype: large_string splits: - name: train num_bytes: 1100442974 num_examples: 5848375 download_size: 571816053 dataset_size: 1100442974 - config_name: CSharp features: - name: blob_id dtype: large_string - name: language dtype: large_string - name: repo_name dtype: large_string - name: path dtype: large_string - name: src_encoding dtype: large_string - name: length_bytes dtype: int64 - name: score dtype: float64 - name: int_score dtype: int64 - name: detected_licenses large_list: large_string - name: license_type dtype: large_string splits: - name: train num_bytes: 2392066248 num_examples: 11425016 download_size: 1232015539 dataset_size: 2392066248 - config_name: Cpp features: - name: blob_id dtype: large_string - name: language dtype: large_string - name: repo_name dtype: large_string - name: path dtype: large_string - name: src_encoding dtype: large_string - name: length_bytes dtype: int64 - name: score dtype: float64 - name: int_score dtype: int64 - name: detected_licenses large_list: large_string - name: license_type dtype: large_string splits: - name: train num_bytes: 3167426435 num_examples: 16246746 download_size: 1632803797 dataset_size: 3167426435 - config_name: Go features: - name: blob_id dtype: large_string - name: language dtype: large_string - name: repo_name dtype: large_string - name: path dtype: large_string - name: src_encoding dtype: large_string - name: length_bytes dtype: int64 - name: score dtype: float64 - name: int_score dtype: int64 - name: detected_licenses large_list: large_string - name: license_type dtype: large_string - name: detected_licenses_right large_list: large_string - name: license_type_right dtype: large_string splits: - name: train num_bytes: 433053889 num_examples: 1917163 download_size: 179388495 dataset_size: 433053889 - config_name: Java features: - name: blob_id dtype: large_string - name: language dtype: large_string - name: repo_name dtype: large_string - name: path dtype: large_string - name: src_encoding dtype: large_string - name: length_bytes dtype: int64 - name: score dtype: float64 - name: int_score dtype: int64 - name: detected_licenses large_list: large_string - name: license_type dtype: large_string splits: - name: train num_bytes: 10292427437 num_examples: 44990158 download_size: 5291667797 dataset_size: 10292427437 - config_name: JavaScript features: - name: blob_id dtype: large_string - name: language dtype: large_string - name: repo_name dtype: large_string - name: path dtype: large_string - name: src_encoding dtype: large_string - name: length_bytes dtype: int64 - name: score dtype: float64 - name: int_score dtype: int64 - name: detected_licenses large_list: large_string - name: license_type dtype: large_string splits: - name: train num_bytes: 2654326008 num_examples: 13253431 download_size: 1287066511 dataset_size: 2654326008 - config_name: Markdown features: - name: blob_id dtype: large_string - name: language dtype: large_string - name: repo_name dtype: large_string - name: path dtype: large_string - name: src_encoding dtype: large_string - name: length_bytes dtype: int64 - name: score dtype: float64 - name: int_score dtype: int64 - name: detected_licenses large_list: large_string - name: license_type dtype: large_string splits: - name: train num_bytes: 4268378053 num_examples: 20687077 download_size: 2058772192 dataset_size: 4268378053 - config_name: PHP features: - name: blob_id dtype: large_string - name: language dtype: large_string - name: repo_name dtype: large_string - name: path dtype: large_string - name: src_encoding dtype: large_string - name: length_bytes dtype: int64 - name: score dtype: float64 - name: int_score dtype: int64 - name: detected_licenses large_list: large_string - name: license_type dtype: large_string splits: - name: train num_bytes: 1985843762 num_examples: 9914497 download_size: 983498806 dataset_size: 1985843762 - config_name: Python features: - name: blob_id dtype: large_string - name: language dtype: large_string - name: repo_name dtype: large_string - name: path dtype: large_string - name: src_encoding dtype: large_string - name: length_bytes dtype: int64 - name: score dtype: float64 - name: int_score dtype: int64 - name: detected_licenses large_list: large_string - name: license_type dtype: large_string splits: - name: train num_bytes: 4947575770 num_examples: 25286019 download_size: 2500795086 dataset_size: 4947575770 - config_name: Ruby features: - name: blob_id dtype: large_string - name: language dtype: large_string - name: repo_name dtype: large_string - name: path dtype: large_string - name: src_encoding dtype: large_string - name: length_bytes dtype: int64 - name: score dtype: float64 - name: int_score dtype: int64 - name: detected_licenses large_list: large_string - name: license_type dtype: large_string splits: - name: train num_bytes: 592832039 num_examples: 2976874 download_size: 284535771 dataset_size: 592832039 - config_name: Rust features: - name: blob_id dtype: large_string - name: language dtype: large_string - name: repo_name dtype: large_string - name: path dtype: large_string - name: src_encoding dtype: large_string - name: length_bytes dtype: int64 - name: score dtype: float64 - name: int_score dtype: int64 - name: detected_licenses large_list: large_string - name: license_type dtype: large_string splits: - name: train num_bytes: 227434676 num_examples: 1135379 download_size: 103158397 dataset_size: 227434676 - config_name: SQL features: - name: blob_id dtype: large_string - name: language dtype: large_string - name: repo_name dtype: large_string - name: path dtype: large_string - name: src_encoding dtype: large_string - name: length_bytes dtype: int64 - name: score dtype: float64 - name: int_score dtype: int64 - name: detected_licenses large_list: large_string - name: license_type dtype: large_string splits: - name: train num_bytes: 505669712 num_examples: 2504412 download_size: 261176608 dataset_size: 505669712 - config_name: Shell features: - name: blob_id dtype: large_string - name: language dtype: large_string - name: repo_name dtype: large_string - name: path dtype: large_string - name: src_encoding dtype: large_string - name: length_bytes dtype: int64 - name: score dtype: float64 - name: int_score dtype: int64 - name: detected_licenses large_list: large_string - name: license_type dtype: large_string splits: - name: train num_bytes: 811611733 num_examples: 4133547 download_size: 394872047 dataset_size: 811611733 - config_name: Swift features: - name: blob_id dtype: large_string - name: language dtype: large_string - name: repo_name dtype: large_string - name: path dtype: large_string - name: src_encoding dtype: large_string - name: length_bytes dtype: int64 - name: score dtype: float64 - name: int_score dtype: int64 - name: detected_licenses large_list: large_string - name: license_type dtype: large_string splits: - name: train num_bytes: 529873695 num_examples: 2454309 download_size: 257883733 dataset_size: 529873695 - config_name: TypeScript features: - name: blob_id dtype: large_string - name: language dtype: large_string - name: repo_name dtype: large_string - name: path dtype: large_string - name: src_encoding dtype: large_string - name: length_bytes dtype: int64 - name: score dtype: float64 - name: int_score dtype: int64 - name: detected_licenses large_list: large_string - name: license_type dtype: large_string splits: - name: train num_bytes: 904736029 num_examples: 4290356 download_size: 425942502 dataset_size: 904736029 configs: - config_name: C data_files: - split: train path: C/train-* - config_name: CSharp data_files: - split: train path: CSharp/train-* - config_name: Cpp data_files: - split: train path: Cpp/train-* - config_name: Go data_files: - split: train path: Go/train-* - config_name: Java data_files: - split: train path: Java/train-* - config_name: JavaScript data_files: - split: train path: JavaScript/train-* - config_name: Markdown data_files: - split: train path: Markdown/train-* - config_name: PHP data_files: - split: train path: PHP/train-* - config_name: Python data_files: - split: train path: Python/train-* - config_name: Ruby data_files: - split: train path: Ruby/train-* - config_name: Rust data_files: - split: train path: Rust/train-* - config_name: SQL data_files: - split: train path: SQL/train-* - config_name: Shell data_files: - split: train path: Shell/train-* - config_name: Swift data_files: - split: train path: Swift/train-* - config_name: TypeScript data_files: - split: train path: TypeScript/train-* --- # 💻 Stack-Edu ![image/png](https://cdn-uploads.huggingface.co/production/uploads/61c141342aac764ce1654e43/3W_vdVnYBBAifrF5JU5QM.png) Stack-Edu is a 125B token dataset of educational code filtered from [The Stack v2](https://huggingface.co/datasets/bigcode/the-stack-v2), precisely the curated training corpus of [StarCoder2](https://arxiv.org/abs/2402.19173) models denoted StarCoder2Data. It is intended for Language Models training. This dataset was curated using a classifier-based filtering strategy, inspired by [📚 FineWeb-Edu](https://huggingface.co/datasets/HuggingFaceFW/fineweb-edu), to retain only the highest-quality educational programming content. Stack-Edu shows consistent improvement over StarCoder2data on all the programming languages on MultiPL-E benchmark. ## Downloading the data This dataset only contains the SWHIDs to download the code files and not the content of the files itself. The contents can be downloaded from Software Heritage's S3 bucket to ensure data compliance. Please refer to [the-stack-v2](https://huggingface.co/datasets/bigcode/the-stack-v2-train-full-ids) for the data license. When running on a 16-core AWS `us-east-1` instance, this script takes ~6 hours to download the files: ```python import boto3 import gzip from datasets import load_dataset from botocore.exceptions import ClientError num_proc = 16 s3 = boto3.client('s3') bucket_name = "softwareheritage" def download_contents(blob_id): key = f"content/{blob_id}" try: obj = s3.get_object(Bucket=bucket_name, Key=key) with gzip.GzipFile(fileobj=obj['Body']) as fin: content = fin.read().decode("utf-8", errors="ignore") return {"text": content, "download_success": True} except ClientError as e: if e.response['Error']['Code'] == 'NoSuchKey': print(f"File not found: {key}") return {"text": "", "download_success": False} else: raise # For Python ds = load_dataset("HuggingFaceTB/stack-edu", "Python", split="train", num_proc=num_proc) ds = ds.map(download_contents, input_columns="blob_id", num_proc=num_proc) # Filter out failed downloads ds = ds.filter(lambda x: x['download_success']) # Optionally, print the first example to verify the data print(ds[0]) ``` ## Details The table below shows the number of tokens in each programming language using [SmolLM2](https://huggingface.co/HuggingFaceTB/SmolLM2-1.7B-Instruct) tokenizer. | Language | Stack-Edu (B tokens) | |------------|----------------------| | Python | 21.8 | | Cpp | 16.0 | | Markdown | 14.0 | | C | 11.1 | | JavaScript | 11.1 | | Java | 42.1 | | SQL | 9.62 | | PHP | 9.07 | | C-Sharp | 8.87 | | TypeScript | 3.03 | | Shell | 3.13 | | Swift | 1.83 | | Go | 1.80 | | Rust | 1.75 | | Ruby | 1.61 | ## Dataset curation To build Stack-Edu, we: - Selected 15 largest programming languages from StarCoder2Data - Trained 15 language-specific classifiers, using [StarEncoder](https://huggingface.co/bigcode/starencoder) model on synthetic annotations generated by Llama3-70B-Instruct. The classifiers for each language are available in this [collection](https://huggingface.co/collections/HuggingFaceTB/the-ultimate-collection-of-code-classifiers-67b5aa3eb8994a4b71453005). - Applied a filtering threshold of 3 (out of 5) to retain highly educational content, except for Java, which performed best at threshold 2. ## Citation Information ``` @misc{allal2025smollm2smolgoesbig, title={SmolLM2: When Smol Goes Big -- Data-Centric Training of a Small Language Model}, author={Loubna Ben Allal and Anton Lozhkov and Elie Bakouch and Gabriel Martín Blázquez and Guilherme Penedo and Lewis Tunstall and Andrés Marafioti and Hynek Kydlíček and Agustín Piqueres Lajarín and Vaibhav Srivastav and Joshua Lochner and Caleb Fahlgren and Xuan-Son Nguyen and Clémentine Fourrier and Ben Burtenshaw and Hugo Larcher and Haojun Zhao and Cyril Zakka and Mathieu Morlon and Colin Raffel and Leandro von Werra and Thomas Wolf}, year={2025}, eprint={2502.02737}, archivePrefix={arXiv}, primaryClass={cs.CL}, url={https://arxiv.org/abs/2502.02737}, } ```