StarCoder

Also known as: BigCode StarCoder

On this page 7

StarCoder is a family of open large language models for source code developed by the BigCode project, a collaboration led by Hugging Face and ServiceNow. In AI for coding, it is known as one of the first openly released code models trained on permissively licensed data with documented provenance, an opt-out process for developers and a responsible-use license. The first StarCoder model appeared in May 2023, and the StarCoder2 generation followed in February 2024.

StarCoder models complete, generate and infill code across dozens of programming languages. They are often called BigCode StarCoder to distinguish them from unrelated products, and they serve both as self-hostable coding assistants and as base models that organizations fine-tune for their own codebases.

How StarCoder is built and trained

StarCoder is a decoder-only transformer trained to predict the next token in source code and related text. The original model has about 15.5 billion parameters, uses multi-query attention to speed up inference, and supports a context window of 8,192 tokens, which was large for an open code model in 2023.

Training data came from The Stack, a dataset of source code collected from public repositories and filtered to permissive licenses such as MIT and Apache 2.0. The team removed near-duplicates, redacted personal information such as email addresses and keys with a dedicated detection model, and honored opt-out requests from repository owners.

Training also used the fill-in-the-middle (FIM) objective. Part of the training documents were rearranged so the model learned to generate a missing middle given the code before and after it, which is exactly what an editor needs for inline completion inside an existing function.

The table summarizes the main technical properties of the first generation.

PropertyValuePractical effect
ParametersAbout 15.5 billionNeeds a data-center GPU or quantization
Context window8,192 tokensSees several files or a long module
Training tokensAbout 1 trillionBroad exposure to many languages
Attention typeMulti-query attentionFaster batched inference
Training objectivesNext-token prediction and FIMSupports both generation and infilling
Key properties of the original StarCoder

StarCoder model generations and variants

The StarCoder name covers several related checkpoints that differ in training data, size and specialization. Choosing the right one depends on hardware and the target language mix.

ModelSizesTraining focusContext
StarCoderBase15.5BMore than 80 programming languages8K tokens
StarCoder15.5BStarCoderBase further trained on Python8K tokens
StarCoder23B, 7B and 15BThe Stack v2 with over 600 languages16K tokens
StarCoder2-Instruct15BInstruction tuning with self-generated data16K tokens
Main StarCoder variants

StarCoder2 was trained on The Stack v2, built with the Software Heritage archive, together with documentation, notebooks and mathematical text. The 15B model saw more than 4 trillion tokens and uses grouped-query attention with sliding-window attention, which improves both quality and memory efficiency. Its smaller 3B and 7B versions make local deployment on a single consumer GPU practical.

How StarCoder compares with other code models

StarCoder stands out among code models mainly for its data transparency and governance, rather than for top benchmark scores. Newer open models have since overtaken it on accuracy, but few match its documentation of training data.

ModelDeveloperDistinguishing trait
StarCoder2BigCodeFully documented training data and opt-out
Code LlamaMetaDerived from a general Llama base model
DeepSeek-CoderDeepSeekStrong benchmarks and repository-level training
Qwen-CoderAlibabaHigh accuracy across many languages
CodestralMistral AIFast FIM completion with a restrictive license
StarCoder and comparable code models

On the HumanEval Python benchmark, the original StarCoder reached roughly one third pass@1, which matched closed models of its time. StarCoder2-15B improved this to the mid-40 percent range. Current leading models score far higher, so StarCoder is now chosen chiefly when license clarity, auditability or fine-tuning freedom outweighs raw accuracy.

Deploying StarCoder in practice

StarCoder is typically deployed as a self-hosted completion backend connected to an editor extension, or as a base model for fine-tuning on private code. Both paths keep source code inside the organization.

SituationRecommended setupReason
Laptop or small GPUStarCoder2-3B, quantizedLow latency for inline completion
Team serverStarCoder2-15B on one large GPUBetter quality for shared use
Private language or frameworkFine-tuned StarCoder2-7BLearns internal conventions
Chat-style requestsStarCoder2-InstructFollows natural-language instructions
Choosing a StarCoder setup

Effective deployments use FIM prompting with the model’s special prefix, suffix and middle tokens, limit completion length to keep latency low, and add retrieval of relevant repository files to the prompt. Fine-tuning with parameter-efficient methods such as LoRA lets a team adapt the model without retraining all its weights.

Licensing, limitations and risks

StarCoder weights are released under the BigCode OpenRAIL-M license, which allows commercial use but forbids listed harmful uses. Teams should read these use restrictions carefully, because the license is not a standard open-source license.

  • Accuracy: generated code can compile and still be wrong, so tests and review remain necessary.
  • Security: the model may reproduce insecure patterns found in public code.
  • Package hallucination: it can suggest imports of libraries that do not exist.
  • Memorization: rare cases of verbatim reproduction occur, so BigCode provided search tools for tracing output to training data.
  • Instruction following: base models complete code rather than answer questions unless an instruct variant is used.

Despite these limits, StarCoder remains a reference point for responsible open code models, and its data practices influenced how later projects document provenance.

Explained without jargon

StarCoder is a computer program that writes code. It learned by reading a huge amount of public code. The creators used only code whose owners allow reuse.

You can run it on your own computer or server. It then suggests the next lines as you type, or fills a gap in the middle of a file. Anyone can download it. That openness is its main strength. Newer tools are often more accurate.

A typical use case

A regional bank wants AI code completion for its 40 developers, but its security policy forbids sending source code to external services. The platform team installs StarCoder2-15B on an internal server with one 80 GB GPU and connects it to the developers’ editors through an open-source extension.

Because much of the bank’s code uses an internal Java framework, the team fine-tunes StarCoder2-7B with LoRA on 2 million lines of approved repositories. Developers then receive fill-in-the-middle suggestions that follow internal naming rules. After three months, the team reports that routine boilerplate such as data-transfer classes and test setups takes noticeably less time, while every suggestion still passes the same code review and automated tests as handwritten code. The bank also documents the OpenRAIL-M license terms in its software inventory.