StarCoder: may the source be with you!

Raymond Li, Loubna Ben Allal, Yangtian Zi, Niklas Muennighoff, Denis Kocetkov, Chenghao Mou, Marc Marone, Christopher Akiki, Jia Li, Jenny Chim, Qian Liu, Evgenii Zheltonozhskii, Terry Yue Zhuo, Thomas Wang, Olivier Dehaene, Mishig Davaadorj, Joel Lamy-Poirier, João Monteiro, Oleh Shliazhko, Nicolas Gontier, Nicholas Meade, Armel Zebaze, Ming-Ho Yee, Logesh Kumar Umapathi, Jian Zhu, Benjamin Lipkin, Muhtasham Oblokulov, Zhiruo Wang, Rudra Murthy V, Jason T. Stillerman, Siva Sankalp Patel, Dmitry Abulkhanov, Marco Zocca, Manan Dey, Zhihan Zhang, Nour Fahmy, Urvashi Bhattacharyya, Wenhao Yu, Swayam Singh, Sasha Luccioni, Paulo Villegas, Maxim Kunakov, Fedor Zhdanov, Manuel Romero, Tony Lee, Nadav Timor, Jennifer Ding, Claire Schlesinger, Hailey Schoelkopf, Jan Ebert, Tri Dao, Mayank Mishra, Alex Gu, Jennifer Robinson, Carolyn Jane Anderson, Brendan Dolan-Gavitt, Danish Contractor, Siva Reddy, Daniel Fried, Dzmitry Bahdanau, Yacine Jernite, Carlos Muñoz Ferrandis, Sean Hughes, Thomas Wolf, Arjun Guha, Leandro von Werra, Harm de Vries

Abstract

StarCoder is a state-of-the-art, 15.5B parameter open-access Large Language Model (LLM) for code. Developed by the BigCode community, it was trained on over 1 trillion tokens across 80+ programming languages. StarCoder matches or exceeds the performance of proprietary models like OpenAI’s code-cushman-001 while introducing robust features for responsible AI, including PII redaction, code attribution tools, and an innovative opt-out mechanism for developers.

Introduction

While Large Language Models (LLMs) have revolutionized software development through tools like GitHub Copilot, the most capable models have historically been proprietary "black boxes." This lack of transparency hinders research into training data, development processes, and ethical governance. Furthermore, many open models suffer from limited context windows and slow inference speeds. To address these challenges, the BigCode community (led by Hugging Face and ServiceNow) developed StarCoder—a high-performance, transparent, and ethically-governed alternative designed to empower the research community.

Architectural Innovations

StarCoder is built on a decoder-only Transformer architecture, incorporating several key technical advancements that differentiate it from standard models:

  • Multi-Query Attention (MQA): By sharing key and value tensors across all attention heads, MQA significantly reduces the memory footprint during inference. This enables much faster, large-batch processing compared to standard multi-head attention.
  • 8K Context Window: Most previous code models were limited to 2,048 tokens. StarCoder quadruples this to 8,192 tokens, allowing the model to "read" and maintain coherence across much larger source files and entire repositories.
  • Fill-in-the-Middle (FIM): The model is trained to predict missing code based on both the prefix and the suffix. This capability makes it significantly more effective at "infilling" code within existing functions.
  • StarEncoder: To address privacy concerns, the team developed a specialized BERT-like model to detect and redact Personally Identifiable Information (PII), such as names and IP addresses, from the training data.

Dataset Composition

The model's foundation is The Stack (v1.2), a massive 6.4 TB collection of permissively licensed GitHub repositories. After rigorous deduplication and quality filtering, the final training set comprised 1 trillion tokens covering 86 programming languages, GitHub issues, and Git commits.

Detailed breakdown of dataset composition by language (O-Z) and non-code sources, including final totals.

A notable component of the dataset is the inclusion of Jupyter notebooks, which provide a rich source of both code and natural language explanation. The distribution of languages within these notebooks is highly skewed toward Python, reflecting its dominance in the data science ecosystem.

Breakdown of programming languages found within the notebook portion of the dataset.

The base model, StarCoderBase, was further fine-tuned on an additional 35 billion Python tokens to create the specialized StarCoder model. Interestingly, this Python-specific fine-tuning did not degrade performance in other languages; rather, it appeared to reinforce general programming reasoning across the model's entire polyglot repertoire.

Performance and Results

StarCoder demonstrates that open-access models can compete with industry leaders:

  • HumanEval Benchmark: StarCoder achieved a 33.6% pass@1 score, matching OpenAI’s code-cushman-001 and outperforming other open models like CodeGen and CodeGeeX.
  • Data Science Mastery: On the DS-1000 benchmark, the model significantly outperformed predecessors across specialized libraries such as Pandas, PyTorch, and SciPy.
  • Multilingual Prowess: Evaluation via MultiPL-E showed StarCoder outperforming code-cushman-001 in several languages, including C++, Java, and PHP.
  • Inference Efficiency: Thanks to MQA, StarCoder serves requests significantly faster than similarly sized models using standard attention mechanisms, making it more viable for real-world deployment.

Ethical Governance and Limitations

The BigCode project emphasizes responsible AI through several pioneering mechanisms. A governance tool allows developers to check if their code is in the dataset and request removal, a major step forward in ethical dataset management. Additionally, the model is released under the OpenRAIL-M license, which includes specific use restrictions to mitigate the generation of harmful or malicious code.

However, limitations remain. Despite advanced filtering, residual PII may persist in the model. The natural language components (comments, issues) are predominantly English-centric, and the legal landscape regarding AI-generated derivatives of open-source code continues to evolve. Future work will focus on increasing natural language diversity and further refining attribution and safety tools.

Summary updated

BibTeX
@article{li2023starcoder,
  author = {Raymond Li and Loubna Ben Allal and Yangtian Zi and Niklas Muennighoff and Denis Kocetkov and Chenghao Mou and Marc Marone and Christopher Akiki and Jia Li and Jenny Chim and Qian Liu and Evgenii Zheltonozhskii and Terry Yue Zhuo and Thomas Wang and Olivier Dehaene and Mishig Davaadorj and Joel Lamy-Poirier and João Monteiro and Oleh Shliazhko and Nicolas Gontier and Nicholas Meade and Armel Zebaze and Ming-Ho Yee and Logesh Kumar Umapathi and Jian Zhu and Benjamin Lipkin and Muhtasham Oblokulov and Zhiruo Wang and Rudra Murthy V and Jason T. Stillerman and Siva Sankalp Patel and Dmitry Abulkhanov and Marco Zocca and Manan Dey and Zhihan Zhang and Nour Fahmy and Urvashi Bhattacharyya and Wenhao Yu and Swayam Singh and Sasha Luccioni and Paulo Villegas and Maxim Kunakov and Fedor Zhdanov and Manuel Romero and Tony Lee and Nadav Timor and Jennifer Ding and Claire Schlesinger and Hailey Schoelkopf and Jan Ebert and Tri Dao and Mayank Mishra and Alex Gu and Jennifer Robinson and Carolyn Jane Anderson and Brendan Dolan-Gavitt and Danish Contractor and Siva Reddy and Daniel Fried and Dzmitry Bahdanau and Yacine Jernite and Carlos Muñoz Ferrandis and Sean Hughes and Thomas Wolf and Arjun Guha and Leandro von Werra and Harm de Vries},
  title = {{StarCoder: may the source be with you!}},
  journal = {Trans. Mach. Learn. Res.},
  year = {2023},
}
Figure