โ† Back to list

[Paper] ๐Ÿฆ™ Code Llama: Open Foundation Models for Code

By Meta AI

Dixon ยท 2025-08-09 15:36 ยท 0 claps ยท 1.5 min read
#code-llama #codellms #meta-llm #foundation-models #coding
Open on Medium โ†—
Wiki topics: LLM ยท Large Language Models ๐Ÿ’ป ยท Programming

[Paper] ๐Ÿฆ™ Code Llama: Open Foundation Models for Code

By Meta AI

Paper link

๐Ÿ“ 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:

  1. Code training โ€” Start with Llama 2, fine-tune on a 500Bโ€“1T token code-heavy dataset.
  2. Python specialization โ€” Add 100B tokens of Python-heavy data.
  3. Infilling training โ€” Use causal masking to enable fill-in-the-middle editing.
  4. Long context fine-tuning (LCFT) โ€” Extend maximum sequence length to 100k tokens using modified RoPE embeddings.
  5. 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