StarCoder2 pairs fully auditable code provenance with aggressive data scaling beyond Chinchilla-optimal ratios. Built by the BigCode collaboration atop the Software Heritage (SWH) archive, The Stack v2 expands from 67.5 TB of raw snapshots (10x The Stack v1) into a curated 3 TB, 913.23B-token pretraining corpus spanning 619 programming languages, 4x larger than the original StarCoder dataset.
Training 3B, 7B, and 15B models for 4.49 to 5.31 epochs (3.1T to 4.1T tokens, plus 200B long-context tokens at 16k) makes the smallest and largest variants punch far above their weight: StarCoder2-3B beats StarCoderBase-15B on EvalPlus and DS-1000, while StarCoder2-15B matches or outperforms CodeLlama-34B and beats DeepSeekCoder-33B on math (65.1% vs 58.7% GSM8K PAL) and low-resource languages.
- Full source lineage: every repository snapshot ties to immutable Software Heritage persistent identifiers (
SWHIDs), backed by a70 GBBloom-filter Data Portrait and an Elasticsearch index for membership auditing. - Repository-level context and richer artifacts: replaces random-file packing with full-repository file grouping,
19.54BPull Request tokens,11.06BIssues,32.71Bnotebooks,10.26BLlama-2-70B-filtered StackOverflow Q&A, and6BLLVM IR translation pairs. - Small and large standouts:
StarCoder2-3Bscores27.4%on HumanEval+ and47.4%on MBPP+ (beatingStarCoderBase-15B’s25.6%and43.6%), whileStarCoder2-15Breaches37.8%HumanEval+,53.1%MBPP+, and48.1%CRUXEval-I. - Native Issue prompting: formatting bug-fix prompts like GitHub issues lifts
StarCoder2-15Bon HumanEvalFix from22.0%(Instruct) to38.7%, ahead ofCodeLlama-34B-Instruct(28.4%).
Building The Stack v2 and StarCoder2
Because GitHub repositories change licenses, rename branches, or vanish, BigCode anchored The Stack v2 on Software Heritage’s deduplicated Merkle DAG (2023-09-06 crawl). The Stack v2 retains both permissively licensed and unlicensed code while dropping copyleft and commercial-restricted code; because GHArchive lacked repo-level license metadata for 96.93% of repositories, the team ran ScanCode Toolkit over license files and propagated SPDX IDs down directory trees.
To tailor capacity across model sizes, BigCode did not feed identical data to all three models. StarCoder2-3B trains on 622.09B unique tokens (17 major languages plus documentation, notebooks, PRs, issues, StackOverflow, and LLVM IR), StarCoder2-7B adds OpenWebMath, Wikipedia, and ArXiv (658.58B unique tokens), and StarCoder2-15B unlocks all 619 languages (913.23B unique tokens). All three use RoPE and Grouped Query Attention (2 KV heads on 3B, 4 on 7B and 15B), train past Chinchilla-optimal token counts for roughly 4.5 to 5.3 epochs under data-constrained scaling, and finish with 200B tokens at 16,384 context using FlashAttention-2 (4,096 sliding window).
Key findings
Across repository-level completion (RepoBench v1.1 and CrossCodeEval), all StarCoder2 sizes consistently beat their StarCoderBase counterparts, reflecting both 16k context and grouping files by repository. StarCoder2-15B also excels on reasoning-heavy benchmarks (48.1% CRUXEval-I vs 47.2% for CodeLlama-34B; 43.08% descriptive / 38.45% lazy pass@1 on CanItEdit) and beats DeepSeekCoder-33B on four low-resource MultiPL-E languages (D 23.6%, Julia 33.2%, Lua 43.8%, Perl 37.2%), aided by 4M compiled LLVM IR pairs bridging 11 languages.
Equally important, the paper candidly documents three stumbles. First, a training bug lowered the Fill-in-the-Middle (FIM) rate for most of StarCoder2-15B’s run, leaving its Python FIM exact match (48.4%) well behind StarCoder2-7B (61.1%) and StarCoderBase-15B (62%). Second, a config-parsing bug trained 15B with RoPE theta = 1e4 instead of 1e5 and stopped at 1M iterations (4.1T tokens) rather than 1.1M. Third, StarCoder2-7B lags DeepSeekCoder-6.7B (35.4% vs 47.6% HumanEval), a gap the authors explicitly leave unexplained.
Caveats and builder takeaway
Openness cuts both ways on security and governance. On the Asleep at the Keyboard CWE suite, StarCoder2-7B (39.8%) and 15B (39.2%) emit insecure patterns at higher rates than CodeLlama-13B (30.2%), partly because generating valid, complete code exposes more vulnerability paths; downstream deployments still require static analysis and secret scanning. Traceable SWHIDs solve corpus auditability for compliance teams, though tracing individual snippets back to upstream repos remains non-trivial tooling work.
For teams picking an open code base model, StarCoder2-3B and StarCoder2-15B stand out for local completion, Python/math reasoning, and repository-level tasks (while 7B is a better choice than 15B only if single-line FIM infilling is critical).


