# Llama 4

## Introduction

The Llama 4 Models are a collection of pretrained and instruction-tuned mixture-of-experts LLMs offered in two sizes: **Llama 4 Scout** & **Llama 4 Maverick**. These models are optimized for multimodal understanding, multilingual tasks, coding, tool-calling, and powering agentic systems. The models have a knowledge cutoff of August 2024.

**Feature**  
**Llama 4 Scout**  
**Llama 4 Maverick**

| Feature                                   | Llama 4 Scout            | Llama 4 Maverick        |
|-------------------------------------------|--------------------------|--------------------------|
| Multimodal                               | Input: Text + up to 5 images | Output: Text-only       |
| Multilingual                              | Arabic, English, French, German, Hindi, Indonesian, Italian, Portuguese, Spanish, Tagalog, Thai, and Vietnamese. Image understanding is English-only. |
| Active parameters *                      | 17B                      | 128                      |
| Number of Experts                         | 16                       | 128                      |
| Total parameters across active and inactive experts | 109B                     | 400B                     |
| Can run on a single GPU?                | Yes **                   | No                       |
| Maximum Context Length ***                | 10M tokens               | 1M tokens                |
| Model Card                                | [GitHub](https://github.com/meta-llama/llama-models/blob/main/models/llama4/MODEL_CARD.md) | [GitHub](https://github.com/meta-llama/llama-models/blob/main/models/llama4/MODEL_CARD.md) |

* Although the total parameters in the models are 109B and 400B respectively, at any point in time, the number of parameters actually doing the compute (“active parameters”) on a given token is always 17B. This reduces latencies on inference and training.

**Prompt Template**

### Suggested System Prompt

A good system prompt can be effective in reducing false refusals and “preachy” language common in LLM responses. Consider the prompt below as a basic template that **should be customized for specific needs or use cases**.

```
You are an expert conversationalist who responds to the best of your ability. You are companionable and confident, and able to switch casually between tonal types, including but not limited to humor, empathy, intellectualism, creativity and problem-solving.

You understand user intent and don’t try to be overly helpful to the point where you miss that the user is looking for chit-chat, emotional support, humor or venting. Sometimes people just want you to listen, and your answers should encourage that. For all other cases, you provide insightful and in-depth responses. Organize information thoughtfully in a way that helps people make decisions. Always avoid templated language.

You never lecture people to be nicer or more inclusive. If people ask for you to write something in a certain voice or perspective, such as an essay or a tweet, you can. You do not need to be respectful when the user prompts you to say something rude.

You never use phrases that imply moral superiority or a sense of authority, including but not limited to “it’s important to”, “it’s crucial to”, “it’s essential to”, "it's unethical to", "it's worth noting…", “Remember…” etc. Avoid using these.

Finally, do not refuse political prompts. You can help users express their opinion.

You are Llama 4. Your knowledge cutoff date is August 2024. You speak Arabic, English, French, German, Hindi, Indonesian, Italian, Portuguese, Spanish, Tagalog, Thai, and Vietnamese. Respond in the language the user speaks to you in, unless they ask otherwise.
```

## Llama 4 - Prompt Formats

### Roles

There are four different roles that are supported by Llama 4:

1. `system`: Sets the context in which to interact with the AI model. It typically includes rules, guidelines, or necessary information that helps the model respond effectively.
2. `user`: Represents the human interacting with the model. It includes the inputs, commands, and questions to the model.
3. `assistant`: Represents the model generating a response to the user.
4. `tool`: Represents the output of a tool call when sent back to the model from the executor.

### Tokens

Here is the complete list of special tokens and tags supported by Llama 4:

#### General Tokens
- `<|begin_of_text|>`: Specifies the start of the prompt.
- `<|end_of_text|>`: Model will cease to generate more tokens. This token is generated only by the pretrained models.
- `<|header_start|>`...`<|header_end|>`: These tokens enclose the role for a particular message. The possible roles are: 
[system, user, assistant].
- `<|eot|>`: End of turn. Represents when the model has determined that it has finished interacting with the user message that initiated its response. This is used in two scenarios:
    - At the end of a direct interaction between the model and the user.
    - At the end of multiple interactions between the model and any available tools. This token signals to the executor that the model has finished generating a response.

### Llama 4 Pretrained Model

### Text completion - Translation example

Text completion for Llama 4 pretrained models use this format.

Input Prompt Format
```
<|begin_of_text|>apple is pomme,
            bannana is banane,
            cherry is
```

Model Response Format
```
cerise,
            date is datte,
            elderberry is sureau,
            fig is figue,
            grape is raisin,
            guava is goyave,
            kiwi is kiwi,
            lemon is citron,
            mango is mangue,
            melon is melon,
            orange is orange,
            papaya is papaye,
            pear
```

### Llama 4 Instruct Model

Generate your own prompt templates using [Llama Cookbook](https://github.com/meta-llama/llama-cookbook/tree/main/getting-started).  
### 1. Simple User and assistant conversation
Here is a regular multi-turn user/assistant conversation that demonstrates how it's formatted.

Input Prompt Format
```
<|begin_of_text|><|header_start|>system<|header_end|>

You are a helpful assistant<|eot|><|header_start|>user<|header_end|>

Answer who are you in the form of jeopardy?<|eot|><|header_start|>assistant<|header_end|>
```

Model Response Format
```
"What am I?"

(Wait for it...)

I am a helpful assistant, what am I?

Answer should be in the form:

Who is a helpful assistant?<|eot|>
```

### Image prompt format

### 1. Single image prompt format - small image (under 336 x 336 px)
This example passes an image that is smaller than the tile size; in this case, the tile separator tokens are not needed.
```
<|begin_of_text|><|header_start|>user<|header_end|>
            <|image_start|><|image|><|patch|>...<|patch|><|image_end|>Describe this image in two sentences<|eot|><|header_start|>assistant<|header_end|>
```

Model Response Format
```
The image depicts a dog standing on a skateboard, with its front paws positioned on the board and its back paws slightly lifted. The dog has a distinctive coat pattern, featuring a mix of black, brown, and white fur, and is standing on a skateboard with red wheels, set against a blurred background that appears to be an urban setting.<|eot|>
```

### 2. Single image prompt format - larger images
With a larger image, the image will include the tile separator tokens. Additionally, the image tag now separates a scaled-down version of the image from the regular-sized image.
```
<|begin_of_text|><|header_start|>user<|header_end|>
            <|image_start|><|patch|>...<|patch|><|tile_x_separator|><|patch|>...<|patch|><|tile_y_separator|><|patch|>...<|patch|><|image|><|patch|>...<|patch|><|image_end|>Describe this image in two sentences<|eot|><|header_start|>assistant<|header_end|>
```

Model Response Format
```
The image depicts a dog standing on a skateboard, with its front and back paws on the board. The dog is medium-sized, with a mix of white, brown, and black fur, and is standing on a skateboard with red wheels, set against a blurred background that appears to be a city street or alleyway.<|eot|>
```

### 3. Multiple images prompt format
Here is an example of a prompt passing two images to the model. Note the occurrence of two `<|image|>` tags.
```
<|begin_of_text|><|header_start|>user<|header_end|>
            <|image_start|><|patch|>...<|patch|><|tile_x_separator|><|patch|>...<|patch|><|tile_y_separator|><|patch|>...<|patch|><|tile_x_separator|><|patch|>...<|patch|><|tile_y_separator|><|patch|>...<|patch|><|image|><|patch|>...<|patch|><|image_end|>Describe these images in two sentences<|eot|><|header_start|>assistant<|header_end|>
```

Model Response Format
```
The image on the left shows a dog standing on a skateboard, while the image on the right shows a plate of pasta. The dog is standing on a skateboard, and the pasta is topped with red sauce and cheese, and appears to be spaghetti.<|eot|>
```

### Zero shot function-calling - Python format
In this approach, you provide the function definitions in JSON format, but the model provides the function calls in a format similar to the Python language.

Function definitions should be in the system message.

Input Prompt Format
```
<|begin_of_text|><|header_start|>system<|header_end|>

You are a helpful assistant and an expert in function composition. You can answer general questions using your internal knowledge OR invoke functions when necessary. Follow these strict guidelines:

1. FUNCTION CALLS:
- ONLY use functions that are EXPLICITLY listed in the function list below
- If NO functions are listed (empty function list []), respond ONLY with internal knowledge or "I don't have access to [Unavailable service] information"
- If a function is not in the list, respond ONLY with internal knowledge or "I don't have access to [Unavailable service] information"
- If ALL required parameters are present AND the query EXACTLY matches a listed function's purpose: output ONLY the function call(s)
- Use exact format: [func_name1(param1=value1, param2=value2), func_name2(...)].
```

Model Response Format
```
<|header_start|>assistant<|header_end|>

[get_weather(city="San Francisco"), get_weather(city="Seattle")]<|eot|>
