# LlamaFactory Prompt Templates: Complete Guide to 80+ Built-In Chat Formats

> Explore LlamaFactory prompt templates and discover 80+ built-in chat formats like Alpaca LLaMA-2 LLaMA-3 ChatML Qwen and Gemma. Easily use them via CLI Web UI or Python API.

- Repository: [Yaowei Zheng/LlamaFactory](https://github.com/hiyouga/LlamaFactory)
- Tags: tutorial
- Published: 2026-03-04

---

**LlamaFactory supports over 80 built-in prompt templates including Alpaca, LLaMA-2, LLaMA-3, ChatML, Qwen, and Gemma, all registered in [`src/llamafactory/data/template.py`](https://github.com/hiyouga/LlamaFactory/blob/main/src/llamafactory/data/template.py) and selectable via CLI, YAML, Web UI, or Python API.**

LlamaFactory is a unified open-source framework for fine-tuning large language models. Understanding the **prompt templates supported by LlamaFactory** is essential because these templates define how multi-turn conversations are serialized into the token sequences that models actually process during training and inference.

## What Are LlamaFactory Prompt Templates?

A **prompt template** in LlamaFactory is a Python class that encodes conversation history—system messages, user turns, and assistant responses—into a formatted string compatible with a specific model family.

In [`src/llamafactory/data/template.py`](https://github.com/hiyouga/LlamaFactory/blob/main/src/llamafactory/data/template.py), each template is registered via the `register_template` function, which stores template objects in the global dictionary `TEMPLATES`. The string name passed to `register_template` becomes the **template identifier** used throughout the framework.

```python

# From src/llamafactory/data/template.py

@register_template(name="llama3")
def get_llama3_template() -> Template:
    return Template(
        format_user=StringFormatter(slots=["<|start_header_id|>user<|end_header_id|>\n\n{{content}}<|eot_id|>"]),
        format_assistant=StringFormatter(slots=["<|start_header_id|>assistant<|end_header_id|>\n\n{{content}}<|eot_id|>"]),
        format_system=StringFormatter(slots=["<|start_header_id|>system<|end_header_id|>\n\n{{content}}<|eot_id|>"]),
        stop_words=["<|eot_id|>"],
    )

```

## Complete List of Supported Prompt Templates

LlamaFactory organizes its 80+ templates by model family and use case. Below are the most commonly used identifiers, with the full registry available in [`src/llamafactory/data/template.py`](https://github.com/hiyouga/LlamaFactory/blob/main/src/llamafactory/data/template.py).

### Classic Instruction Formats

These templates follow the original "Instruction / Response" paradigm popularized by early fine-tuning datasets.

- **`alpaca`** – The classic Alpaca format with `### Instruction:` and `### Response:` blocks (line 653 in [`template.py`](https://github.com/hiyouga/LlamaFactory/blob/main/template.py))

- **`vicuna`** – Vicuna-style `USER:` and `ASSISTANT:` turns with optional system messages (line 1523)
- **`default`** – Minimal fallback format using `Human:` and `Assistant:` prefixes (line 834)

### Modern Chat Formats

These templates implement the specific token conventions required by contemporary foundation models.

- **`llama2`** – Meta LLaMA-2 format with `[INST]` and `[/INST]` tokens, including system message injection via `<<SYS>>` (line 1313)
- **`llama3`** – LLaMA-3 format with `<|start_header_id|>` and `<|eot_id|>` tokens, supporting reasoning tags (line 1331)
- **`mistral_small`** – Mistral Small format using `[INST] … [/INST]` with efficient EOS handling (line 1702)
- **`gemma`** – Google Gemma format with `<start_of_turn>` and `<end_of_turn>` tags (line 937)

### Multilingual and Specialized Templates

Templates optimized for specific languages or model families with unique tokenization requirements.

- **`chatml`** – HuggingFace ChatML format using `<|im_start|>user` and `<|im_end|>` tokens