ImageNet classification with deep convolutional neural networks
Alex Krizhevsky, Ilya Sutskever et al.
3.4k
Citations
386
Influential Citations
arXiv.org
Venue
2023
Year
We release Code Llama, a family of large language models for code based on Llama 2 providing state-of-the-art performance among open models, infilling capabilities, support for large input contexts, and zero-shot instruction following ability for programming tasks. We provide multiple flavors to cover a wide range of applications: foundation models (Code Llama), Python specializations (Code Llama - Python), and instruction-following models (Code Llama - Instruct) with 7B, 13B, 34B and 70B parameters each. All models are trained on sequences of 16k tokens and show improvements on inputs with up to 100k tokens. 7B, 13B and 70B Code Llama and Code Llama - Instruct variants support infilling based on surrounding content. Code Llama reaches state-of-the-art performance among open models on several code benchmarks, with scores of up to 67% and 65% on HumanEval and MBPP, respectively. Notably, Code Llama - Python 7B outperforms Llama 2 70B on HumanEval and MBPP, and all our models outperform every other publicly available model on MultiPL-E. We release Code Llama under a permissive license that allows for both research and commercial use.
The release of Code Llama marks a significant milestone in open-source code generation. Built upon Meta's Llama 2, this family of models delivers state-of-the-art performance among publicly available models, closing the gap with proprietary systems like GPT-4 and Codex. By offering specialized variants for general code, Python, and instruction following, Code Llama addresses a wide range of practical needs—from autocomplete in IDEs to complex code synthesis from natural language descriptions. Its permissive license further accelerates adoption in both research and industry, making high-quality code AI accessible to a broader audience.
Code Llama starts from Llama 2 and undergoes a multi-stage specialization pipeline. First, the foundation model (Code Llama) is fine-tuned on 500 billion tokens of nearly deduplicated public code, with 8% of data coming from natural language discussions about code to preserve language understanding. The Python variant (Code Llama - Python) receives an additional 100 billion tokens of Python-heavy data. The instruction-following models (Code Llama - Instruct) are further fine-tuned on a mix of self-instruct and human-curated data.

A key technical innovation is the infilling capability, trained using causal masking with reordered sequences. The model learns to predict missing code spans given surrounding context, which is crucial for real-time code completion. For long-context handling, the authors introduce Long Context Fine-Tuning (LCFT). They modify the rotary position embeddings by extending the base period from 10,000 to 1,000,000, allowing the model to handle sequences up to 100,000 tokens without a sharp perplexity increase. This is achieved by fine-tuning on sequences of 16,384 tokens, which is computationally efficient yet enables extrapolation to much longer inputs.

Code Llama achieves impressive results across multiple benchmarks. On HumanEval, Code Llama 34B scores 67% pass@1, and on MBPP it reaches 65%. Notably, Code Llama - Python 7B outperforms Llama 2 70B on both benchmarks, demonstrating the power of domain-specific fine-tuning. In multilingual evaluations using MultiPL-E, Code Llama 7B surpasses Llama 2 70B, and all Code Llama models outperform other open models like CodeGen-Multi and StarCoder.

Infilling evaluations show state-of-the-art performance on random span infilling across multiple languages, though the SPM format lags behind PSM due to token healing issues. Long-context tests reveal that Code Llama maintains decreasing perplexity up to 100k tokens, and LCFT significantly improves code completion accuracy on long sequences, albeit with a slight trade-off on short-sequence benchmarks.

Code Llama sets a new standard for open-source code LLMs, offering competitive performance with proprietary models while being freely available for research and commercial use. Its ability to handle long contexts and perform infilling makes it particularly suitable for real-world coding assistants. The trade-off between long-context performance and short-sequence accuracy highlights an area for future improvement, but the overall impact is substantial: Code Llama democratizes access to state-of-the-art code generation, enabling developers worldwide to leverage AI for programming tasks. The permissive license and multiple model sizes ensure that even resource-constrained teams can benefit from this technology.
Alex Krizhevsky, Ilya Sutskever et al.
Ashish Vaswani, Noam Shazeer et al.
Douglas M. Bates, Martin Mächler et al.
Diederik P. Kingma, Jimmy Ba