Skip to main content
Browse Models

codellama

CodeLlama 7B

Released

2023-08-24

Family

Llama 2

Type

Fine-Tuned Model

Downloads

External Download

You are about to open a link to an external source. Verify the URL before continuing.

Download

4-bit GGUF (Q4_K_M)

GGUF · codellama-7b.Q4_K_M.gguf

5-bit GGUF (Q5_K_M)

GGUF · codellama-7b.Q5_K_M.gguf

6-bit GGUF (Q6_K)

GGUF · codellama-7b.Q6_K.gguf

8-bit GGUF (Q8_0)

GGUF · codellama-7b.Q8_0.gguf

Ollama Model (q4_K_M)

Ollama

Model Report

Overview

Code Llama 7B is an open-access large language model designed by Meta for code synthesis, understanding, and related programming tasks. As a member of the broader Code Llama suite, it specializes in generating, completing, and analyzing code across a range of programming languages. Developed, trained, and released by Meta between January and July 2023, Code Llama 7B leverages advancements in transformer architectures to address the challenges of code completion, debugging, and comprehension within both research and industry settings.

Explaining code using Code Llama 7B

Figure 1. Code Llama 7B provides a natural language explanation of a Python function when prompted, illustrating its code understanding capabilities.

Model Capabilities and Architecture

Code Llama 7B is constructed upon the Llama 2 architecture, re-trained and fine-tuned on code-centric data to enhance its performance in programming environments. The model employs a transformer-based, auto-regressive design which is adept at generating sequences of tokens, effectively enabling tasks such as code autocompletion, fill-in-the-middle infilling, and code summarization. Its architecture allows for stable generations with extended context windows, supporting up to 100,000 tokens, thanks to training on sequences of 16,000 tokens. This capacity makes it capable of reasoning over and generating large codebases, which is particularly valuable in professional software engineering and debugging scenarios.

Among its notable features is the fill-in-the-middle (FIM) capability, which allows the model to insert code within existing files rather than only producing code snippets sequentially. The model comes in several specialized variants, including a Python-focused edition and an Instruct variant fine-tuned for instruction-following scenarios, helping to provide guided, safe, and task-oriented outputs. Multilingual code support covers languages such as Python, C++, Java, PHP, TypeScript (JavaScript), C#, and Bash, catering to a broad spectrum of software development contexts. Further, the model’s large context window aids in handling longer code generation and complex debugging tasks by incorporating more substantial pieces of existing code as input.

Code Llama 7B debugging a Python snippet

Figure 2. A demonstration of Code Llama 7B automatically identifying, correcting, and explaining a bug in a Python code snippet. Prompt: '# Fix the bug in the code above and explain the fix.'

Training Data and Methodology

The development of Code Llama 7B involved extensive re-training of Llama 2 weights using a curated corpus of source code and code-related texts. The dataset encompassed approximately 500 billion tokens, drawn from diverse sources to ensure coverage across many programming languages and paradigms. The specialized Python variant received further fine-tuning on a dedicated subset comprising 100 billion tokens exclusively of Python code. Meta utilized its Research Super Cluster for large-scale training.

Instruction tuning for the Instruct version entailed feeding the model natural language prompts alongside expected outputs, promoting adherence to user instructions and safety protocols. This targeted training approach enhances the model’s ability to generate precise and safe responses to user requests, making it well-suited for deployment in code assistance tools and educational resources.

Summarizing code using Code Llama 7B

Figure 3. Code Llama 7B generates a concise summary of a given Python code segment in response to the prompt: '# Summarize this code.'

Benchmark Performance

Code Llama 7B and its family variants have been rigorously evaluated against industry-standard benchmarks including HumanEval, Mostly Basic Python Programming (MBPP), and MultiPL-E. Results indicate that Code Llama 7B exhibits strong performance relative to other public large language models and earlier iterations, particularly in code generation, completion, and comprehension tasks. The Python-specialized model has demonstrated higher accuracy on Python-centric benchmarks, in some cases surpassing larger general-purpose models in execution correctness.

Benchmark comparison table for Code Llama 7B and other models

Figure 4. Quantitative comparison of Code Llama variants—including 7B—against other large language models on code-generation benchmarks such as HumanEval and MBPP. Higher values indicate greater accuracy.

According to the official research publication, Code Llama models consistently outperform comparable open-access code models and predecessor architectures, particularly for real-time completion scenarios requiring lower latency.

Applications and Use Cases

The model is designed to facilitate a wide range of code-related tasks. In practice, developers employ Code Llama 7B for code autocompletion, bug detection and correction, code summarization, and the automated generation of explanatory documentation. The instruction-tuned variant is suitable for contexts where guided interaction and safety are priorities, such as educational environments or as part of interactive code assistant systems. The Python-specialized model is optimized for workflows concentrated in Python, delivering improved results on Python generation and comprehension tasks.

Code Llama 7B's multilingual support and large context window enable its use across diverse programming projects, from lightweight real-time completion in integrated development environments (IDEs) to deeper analysis and refactoring of substantial codebases. Ongoing testing and research focus on extending the model’s language and task coverage while maintaining safety and reliability.

Model Limitations, License, and Sustainability

Despite the model’s advanced capabilities, several important limitations have been identified. Outputs may occasionally be inaccurate, unexpected, or fail to generalize outside the conditions of training data, particularly with inputs in languages other than English or in highly specialized programming contexts. The model is not recommended for general-purpose natural language processing tasks, as it is optimized for code-oriented interactions. Developers are encouraged to perform context-specific safety evaluations prior to deployment.

Early red teaming assessments indicate that Code Llama 7B generates safer code than prior general language models, but comprehensive risk assessment remains necessary for production scenarios.

Code Llama 7B is released under the Meta Community License, permitting both research and commercial usage within the terms established by Meta. Users must adhere to Meta’s acceptable use policy.

In terms of sustainability, training all Code Llama models—across nine configurations—required 400,000 GPU hours, primarily on A100-80GB hardware. This process generated estimated emissions of 65.3 tCO2eq, which were fully offset in alignment with Meta’s sustainability program.

Helpful Links

About Llama 2: The Llama 2 family, developed by Meta, comprises large language models ranging from 7 billion to 70 billion parameters, trained on 40% more data than their predecessors and featuring a doubled context length of 4,096 tokens.

More in the Llama 2 Family

Meta /

Llama 2 7B

7 billion parameter version of the 2nd iteration in Meta's Llama series of open source models.
lmsys /

Vicuna 7B

Llama 7B fine-tuned on 125k GPT-4 conversations, with strong performance in chatbot and instruction following use-cases.
PygmalionAI /

Pygmalion 2 7B

Llama 7B fine-tuned for conversation, roleplaying, and storywriting.
openchat /

OpenChat 3.5 7B

Llama 2 7B fine-tuned using the C-RLFT strategy, with performance surpassing GPT 3.5 on some benchmarks.
Xwin-LM /

Xwin LM 7B

Llama 2 7B fine-tune using numerous emerging techniques including SFT, RM, and RLHF, achieving top results on AlpacaEval.
Meta /

Llama 2 13B

13 billion parameter version of the 2nd iteration in Meta's Llama series of open source models.
Meta /

CodeLlama 13B

Fine-tuned version of Llama 13b, with training data optimized for code generation and completion tasks.
NousResearch /

Nous Hermes 13b

Llama 13b fine-tuned on over 300k curated GPT-4 outputs, known long high-quality outputs.
lmsys /

Vicuna 13B

Llama 13B fine-tuned on 125k GPT-4 conversations, with strong performance in chatbot and instruction following use-cases.
Gryphe /

MythoMax L2

An improved variant of MythoMix (MythoLogic-L2 and Huginn merge) using an experimental tensor-type merge technique. Originally a merge of multiple popular Llama 2 fine-tunes, including Hermes, Chronos, and Airoboros. Very popular for rich descriptions, storywriting, and roleplay.
WizardLM /

WizardLM 13B

Llama 2 13B model fine-tuned to follow complex instructions using the WizardLM training methodology.
PygmalionAI /

Pygmalion 2 13B

Llama 13B fine-tuned for conversation, roleplaying, and storywriting.
PygmalionAI /

Mythalion 13B

Merge of two popular fine-tunes: Pygmalion and Mythomax L2, resulting in a model that is good at roleplaying and instruction-following.
Xwin-LM /

Xwin LM 13B

Llama 2 13B fine-tune using numerous emerging techniques including SFT, RM, and RLHF, achieving top results on AlpacaEval.
Meta /

CodeLlama 34B

Fine-tuned version of unreleased Llama 2 34b, with training data optimized for code generation and completion tasks.
Meta /

Llama 2 70B

70 billion parameter version of the 2nd iteration in Meta's Llama series of open source models.
Meta /

CodeLlama 70B

Fine-tuned version of Llama 70b, with training data optimized for code generation and completion tasks.
Xwin-LM /

Xwin 70B

Llama 2 70B fine-tune using numerous emerging techniques including SFT, RM, and RLHF, achieving top results on AlpacaEval.
WizardLM /

WizardLM 70B

Llama 2 70B model fine-tuned to follow complex instructions using the WizardLM training methodology.
NousResearch /

Nous Hermes Llama 2 70B

Llama 2 70B fine-tuned on over 300k curated GPT-4 outputs.