The Stack v2
Supersedes The Stack v1 / v2.
The Stack v2 is BigCode's large-scale source code corpus, released in February 2024 as the pretraining set behind the StarCoder2 models. It was built with Software Heritage, a long-term public archive of code, and its full version spans roughly 67.5TB across more than 600 programming languages, drawn from around 3.28 billion unique files and 104 million repositories. A deduplicated version reduces this to about 32.1TB, and the filtered training splits total in the region of 900 billion tokens, making it several times larger than the original Stack.
Access works differently to most datasets on HuggingFace. The published Parquet tables do not contain the code itself: each record holds a Software Heritage identifier (SWHID) plus metadata such as the file path, detected licence, and repository information. You fetch the actual file contents from Software Heritage's S3 bucket, and bulk downloading requires a prior agreement with Software Heritage and INRIA. HuggingFace access is gated behind an agreement in which you accept that any use of the code must follow the terms of the original licences.
For RAG and AI work, this is a strong retrieval and pretraining corpus for code assistants, letting you index real implementations across a very broad language range while keeping each file tied back to its repository licence. Plan for the extra pipeline step of resolving SWHIDs to blobs, which is the price of the wider coverage.
On licensing, the collection keeps only permissively licensed code, so commercial use is permitted in principle, but the terms travel with each file: many permissive licences still require you to preserve attribution notices in redistributed code. BigCode also honours an opt-out through the Am I in The Stack tool, so a snapshot is not a complete mirror of public code. Compared with our the-stack entry, which covers both versions at a glance, this is the dedicated, much larger v2 profile for teams committing to the Software Heritage workflow.
Related sources
DevDocs
An open-source aggregator that pulls API documentation for major programming languages, frameworks, and tools into one searchable place. A tidy RAG source when you want up-to-date developer reference material without scraping dozens of separate documentation sites yourself.
GitHub Public Repositories (GH Archive / GHTorrent)
Two projects that capture public GitHub activity for analysis. GH Archive records the public GitHub event timeline as downloadable hourly archives, and GHTorrent offers a queryable mirror of GitHub metadata. Together they help you mine code, issues, pull requests, and documentation at scale.
RefineCode (OpenCoder)
A reproducible code pretraining corpus of roughly 960 billion tokens spanning about 607 programming languages, built with a published cleaning pipeline. It is the pretraining data behind the OpenCoder code models.
Software Heritage
A non-profit universal archive built specifically for software source code, preserving not just files but their full development history. Over 27 billion unique source files collected from public repositories, each identified by a cryptographic hash. The upstream source for The Stack v2.