The Stack v2 is a large open dataset of source code built by the BigCode Project, an open scientific collaboration led by Hugging Face and ServiceNow that develops large language models for code. It was released in February 2024 alongside the StarCoder2 models and described in the paper StarCoder 2 and The Stack v2: The Next Generation (arXiv 2402.19173). Unlike its predecessor, which was crawled from GitHub directly, version 2 is derived from the Software Heritage archive, the non-profit initiative launched by Inria in partnership with UNESCO to collect and preserve publicly available source code.

What it contains

According to the official dataset card, the collection process traversed the Software Heritage graph dataset of September 6, 2023 and found 3.28 billion unique files belonging to 104.2 million GitHub repositories, with a total uncompressed size of 67.53 TB. Repository metadata such as stars, forks and creation dates comes from GitHub Archive data up to September 14, 2023. The card lists 658 languages, covering programming and markup languages.

Each record holds metadata rather than the code itself: the Software Heritage ID of the file, the repository name, path, branch, commit, detected licences, language, flags for vendored or generated files and the file size. The file contents are stored in a Software Heritage bucket on Amazon S3 and must be downloaded separately using those IDs.

Versions and subsets

BigCode publishes several variants on Hugging Face:

  • the-stack-v2: the full dataset.
  • the-stack-v2-dedup: near-deduplicated on top of exact deduplication.
  • the-stack-v2-train-full-ids: further filtered with quality heuristics across 600+ languages and grouped by repository, for pretraining with whole-repository context.
  • the-stack-v2-train-smol-ids: the same approach restricted to 17 languages.

The dataset is updated to honour removal requests. StarCoder2 was trained on version 2.0.1; later versions removed repositories that opted out before April 9, 2024 (v2.1.0) and before July 29, 2026 (v2.2.0).

Licence and access

The repository on Hugging Face is public but gated: users must accept conditions before accessing it. Bulk downloads require an agreement with Software Heritage and Inria, and anyone training models on it must follow Software Heritage’s principles for language-model training. Every file remains under its original licence, including attribution clauses. For 96.93% of repositories no repository-level licence was available, so BigCode used the ScanCode Toolkit to detect licences from files such as LICENSE and README, and labels each file as permissive or no-licence.

Who uses it

The Stack v2 is the pretraining corpus for the StarCoder2 family and a common reference for research on code models, because the data, its provenance and its filtering are documented in the open. Developers can check whether their code is included with the “Am I In The Stack?” tool and request removal through the instructions on GitHub. For how corpora like this feed a model, see our glossary entries on pretraining and training data.

Limits

  • The card warns that the data may contain sensitive information such as emails, IP addresses and API or SSH keys previously published in public repositories; deduplication reduces but does not remove it.
  • There are no official train and test splits, and the many near-duplicates can leak into any custom test split.
  • Automatic licence detection can be wrong, so users remain responsible for complying with each file’s licence.
  • The snapshot ends in September 2023, so newer libraries and language versions are missing.

Facts are taken from the official Hugging Face dataset card and the StarCoder2 paper, checked on December 1, 2026.