NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Stable Code Technical Report

Nikhil Pinnaparaju, Reshinth Adithyan, Duy Phung, Jonathan Tow, James Baicoianu, Ashish Datta, Maksym Zhuravinskyi, Dakota Mahan, Marco Bellagente, Carlos Riquelme, Nathan CooperarXiv 2024

Abstract

We introduce Stable Code, the first in our new-generation of code language models series, which serves as a general-purpose base code language model targeting code completion, reasoning, math, and other software engineering-based tasks. Additionally, we introduce an instruction variant named Stable Code Instruct that allows conversing with the model in a natural chat interface for performing question-answering and instruction-based tasks. In this technical report, we detail the data and training procedure leading to both models. Their weights are available via Hugging Face for anyone to download and use. This report contains thorough evaluations of the models, including multilingual programming benchmarks, and the MT benchmark focusing on multi-turn dialogues. At the time of its release, Stable Code is the state-of-the-art open model under 3B parameters and even performs comparably to larger models of sizes 7 billion and 15 billion parameters on the popular Multi-PL benchmark. Stable Code Instruct also exhibits state-of-the-art performance on the MT-Bench coding tasks and on Multi-PL completion compared to other instruction tuned models. Given its appealing small size, we also provide throughput measurements on a number of edge devices. In addition, we open source several quantized checkpoints and provide their performance metrics compared to the original model.

Introduction: Bringing State-of-the-Art Coding to the Edge

While Large Language Models (LLMs) like GPT-4 or StarCoder 15B are incredibly capable at generating code, they suffer from two major drawbacks in a developer's daily workflow: latency and privacy. Running a 15B+ parameter model requires massive GPU clusters, forcing developers to rely on cloud-based APIs. This introduces network lag—frustrating for real-time code completion—and raises security concerns regarding proprietary codebases. Previous "small" models often lacked the reasoning capabilities or the context window to be truly useful. Stable Code 3B aims to fill this gap by delivering "big model" performance in a 3-billion parameter package that fits on a standard laptop.

Methods and Architecture

The authors built Stable Code 3B on top of the Stable LM 3B natural language model. The architecture is a causal decoder-only transformer with several specific optimizations, including Rotary Position Embeddings (RoPE) applied to 25% of the head embedding dimensions and LayerNorm with learned biases.

The model was developed through a rigorous multi-stage training process designed to transition a general language model into a specialized coding assistant.

Stable Code Multi-Stage Training Pipeline

The training pipeline consisted of:

  1. Pre-training: Initialized from a natural language model, then trained on 1.3 trillion tokens of code and math.
  2. Long Context Continued Training: The model was further trained on a 16,384-token context window to handle large repositories.
  3. Fill-in-the-Middle (FIM): A training objective where the model learns to predict missing code given both the prefix and the suffix, which is essential for IDE "ghost text" completions.
  4. Instruction Tuning: The "Instruct" variant underwent Supervised Fine-Tuning (SFT) and Direct Preference Optimization (DPO) to handle conversational queries.

Key Insights: The "Naturalness" Transfer

One of the most important findings is that initializing from a natural language model (Stable LM 3B) significantly outperforms training a code model from scratch. The "reasoning" backbone developed during natural language (NL) pre-training transfers effectively to the logical structures of programming.

Python Performance Comparison: Scratch vs NL Base Model Initialization

As shown in the performance comparison, models initialized from an NL base consistently achieve higher Pass@1 scores across varying amounts of code tokens seen compared to those initialized from scratch. This suggests that the linguistic and logical patterns learned from human language provide a superior foundation for understanding code syntax and semantics.

Furthermore, by extending the context window to 16k tokens, the model can account for dependencies across multiple files in a software project. The report also emphasizes that 3B parameters is a "sweet spot." It is large enough to be smart but small enough that 4-bit or 6-bit quantization allows it to run at 50+ tokens per second on consumer hardware like the Apple M2 chip.

Key Results

  • Multi-PL Benchmark: Stable Code 3B achieved a 29.1% average score across languages, matching Code Llama 7B and StarCoder 15B, despite being significantly smaller.
  • MT-Bench (Coding): The Instruct version scored 5.8, notably outperforming CodeLlama 7B (3.6) and DeepSeek Coder 1.3B (4.6).
  • SQL Performance: On SQL-Eval, Stable Code Instruct (47.2%) outperformed DeepSeek-Coder Instruct 1.3B (34.2%).
  • Edge Performance: On an M2 Pro Max, the model reached throughputs of 52-54 tokens/sec using INT4 and Q6_K quantization, making it feel instantaneous for human users.

Conclusion

Stable Code 3B demonstrates that compact models can achieve state-of-the-art performance by leveraging high-quality pre-trained natural language foundations and specialized multi-stage training. While it still trails behind massive models in complex architectural reasoning, it provides a high-performance, low-latency solution for local development. Future work will focus on further expanding the context window and refining synthetic data generation to close the gap with 30B+ parameter models.

Summary updated

BibTeX
@misc{pinnaparaju2024stable,
  author = {Nikhil Pinnaparaju and Reshinth Adithyan and Duy Phung and Jonathan Tow and James Baicoianu and Ashish Datta and Maksym Zhuravinskyi and Dakota Mahan and Marco Bellagente and Carlos Riquelme and Nathan Cooper},
  title = {{Stable Code Technical Report}},
  year = {2024},
  eprint = {2404.01226},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2404.01226},
}
Figure