What Is StarCoder2?
StarCoder2 is the second generation of the BigCode project's open coding models, released in February 2024. The project is a collaboration between Hugging Face, ServiceNow, and the broader open-source research community. The flagship 15B model is trained on The Stack v2 — a cleaned and deduplicated dataset of source code across 619 programming languages.
Model Variants
BigCode released three sizes:
- StarCoder2-3B — fits on a single consumer GPU (12GB VRAM), good for autocomplete
- StarCoder2-7B — balanced size for most IDE integration use cases
- StarCoder2-15B — best quality, recommended for generation tasks
All three are released under the BigCode Open RAIL-M license, which allows commercial use with attribution.
HumanEval and Benchmark Comparisons
| Model | HumanEval pass@1 | Parameters | |---|---|---| | StarCoder2-15B | 46.3% (base), ~72% instruct | 15B | | CodeLlama 34B | 53.7% | 34B | | StarCoder (v1) 15B | 33.6% | 15B | | Qwen2.5-Coder 7B | 88.4% | 7B |
The instruct-tuned version (StarCoder2-15B-Instruct-v0.1) reaches competitive scores on instruction following, though newer models like Qwen2.5-Coder have surpassed it on raw HumanEval. StarCoder2 remains relevant for its breadth of language coverage and fill-in-the-middle support.
Fill-in-the-Middle Training
StarCoder2 is trained with the FIM (fill-in-the-middle) objective, using a special set of tokens that makes code completion feel natural:
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
tokenizer = AutoTokenizer.from_pretrained("bigcode/starcoder2-15b")
model = AutoModelForCausalLM.from_pretrained(
"bigcode/starcoder2-15b",
torch_dtype=torch.bfloat16,
device_map="auto"
)
prefix = "def is_palindrome(s: str) -> bool:\n "
suffix = "\n\nassert is_palindrome('racecar') == True"
fim_prompt = f"<fim_prefix>{prefix}<fim_suffix>{suffix}<fim_middle>"
inputs = tokenizer(fim_prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=64, temperature=0.2)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
VS Code Integration via Continue
The easiest way to use StarCoder2-15B for day-to-day coding is through the Continue extension:
- Install Continue from the VS Code marketplace
- In
~/.continue/config.json, add:
{
"tabAutocompleteModel": {
"title": "StarCoder2",
"provider": "ollama",
"model": "starcoder2:15b"
}
}
- Run
ollama pull starcoder2:15b
You now have local, private tab completion that never sends your code to a third-party server.
Hugging Face Code Leaderboard
The Big Code Models Leaderboard tracks models on HumanEval, MBPP, MultiPL-E, and DS-1000. As of early 2025, StarCoder2-15B sits in the top 10 for models under 20B parameters, though the Qwen2.5-Coder family has moved above it in absolute scores.
When to Choose StarCoder2
- You need maximum language breadth (619 languages vs ~100 for most models)
- You want IDE tab completion with FIM and full local privacy
- You need a model in the 7–15B range that balances quality and hardware requirements
- You want to build on top of a permissively licensed, academically documented model