[Paper] ๐ฆ Code Llama: Open Foundation Models for Code
By Meta AI
[Paper] ๐ฆ Code Llama: Open Foundation Models for Code
By Meta AI
๐ Summary
Code Llama is a family of open-source large language models specialized for code generation, built on top of Llama 2. It comes in three main variants:
- Code Llama โ general-purpose code generation.
- Code Llama โ Python โ Python-focused specialization.
- Code Llama โ Instruct โ instruction-following, safety-tuned models.
Key features:
- Fill-in-the-middle (infilling) capabilities.
- Long context support (up to 100k tokens).
- Instruction fine-tuning for safer, more helpful outputs.State-of-the-art performance among open models on benchmarks like HumanEval, MBPP, and MultiPL-E.
- Released under a permissive license for research and commercial use.
๐ก Intuition
Most general-purpose AI models can write code, but specializing them on large-scale code data โ and adapting them to developer workflows โ dramatically improves performance. By layering code-specific training, long-context adaptation, and instruction fine-tuning on top of a strong foundation model, you get a model that is more capable, multilingual, and safe for real-world programming.
๐ฏ Problem
Many existing open-source code LLMs:
- Are trained from scratch on code alone, losing general language understanding.
- Have short context windows, limiting repository-level reasoning.
- Lack flexible infilling capabilities or safety alignment for interactive coding.
The challenge: Build an open, high-performing, and versatile code model that supports multiple languages, long inputs, safe instruction following, and modern developer use cases.
๐ ๏ธ Solution
Specialization Pipeline:
- Code training โ Start with Llama 2, fine-tune on a 500Bโ1T token code-heavy dataset.
- Python specialization โ Add 100B tokens of Python-heavy data.
- Infilling training โ Use causal masking to enable fill-in-the-middle editing.
- Long context fine-tuning (LCFT) โ Extend maximum sequence length to 100k tokens using modified RoPE embeddings.
- Instruction fine-tuning โ Train with human-curated and self-generated coding tasks for safety and helpfulness.
๐ Diagram from the paper:
๐ง Limitations and Future Opportunities
Limitations:
- Long-context fine-tuning trade-off โ Slight drop in performance on short-context benchmarks.
- Infilling training cost โ Small performance decrease on some metrics.
- Safety limits โ Safety tuning reduces but does not remove dual-use risks in code generation.
Future Opportunities:
- Scale beyond 70B parameters with larger training datasets.
- Improve safety mechanisms for malicious or dual-use code prompts.
- Expand multilingual coverage, including niche programming languages.
- Integrate iterative multi-turn coding capabilities for complex software tasks.
๋ฉํ๋ฐ์ดํฐ
- post_id
- c13fa94a0605
- slug
- paper-code-llama-open-foundation-models-for-code-c13fa94a0605
- url
- https://medium.com/@huguosuo/paper-code-llama-open-foundation-models-for-code-c13fa94a0605
- canonical_url
- https://medium.com/@huguosuo/paper-code-llama-open-foundation-models-for-code-c13fa94a0605
- author_url
- https://medium.com/@huguosuo
- status
- ok
- fetched_at
- 2026-06-24 11:06:28