Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
]
},
"lfm/key-concepts/chat-template",
"lfm/key-concepts/thinking",
"lfm/key-concepts/text-generation-and-prompting",
"lfm/key-concepts/tool-use",
"lfm/key-concepts/vision-capabilities",
Expand Down
17 changes: 14 additions & 3 deletions lfm/key-concepts/chat-template.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
The complete chat template definition can be found in the `chat_template.jinja` file in each model's Hugging Face repository.

<Note>
Using LFM2 or LFM2.5? See [LFM2 and LFM2.5](#lfm2-and-lfm25) for their chat template.
Using LFM2 or LFM2.5? See [LFM2 and LFM2.5](#lfm2-and-lfm2-5) for their chat template.
</Note>

## Text Models
Expand Down Expand Up @@ -74,7 +74,12 @@

### Reasoning

Reasoning is enabled by default, so the template opens every assistant turn with `<think>`. Set `enable_thinking=False` in `apply_chat_template()` for direct answers. Reasoning from turns before the latest user message is removed unless `preserve_thinking=True`.
Thinking models reason before they answer, so the template opens every assistant turn with `<think>`. Two arguments to `apply_chat_template()` control this:

* **`enable_thinking`** (default `True`) — On models that can switch thinking off, `enable_thinking=False` fills in an empty `<think></think>` block instead, so the model starts on the answer straight away. Models that always think don't support `False`.
* **`preserve_thinking`** (default `False`) — The template removes the reasoning from assistant turns before the latest user message. Set `preserve_thinking=True` to keep it in the prompt.

See [Thinking](/lfm/key-concepts/thinking) for how to use thinking, separate the reasoning from the answer, and check which models can switch thinking off.

## Vision Models

Expand Down Expand Up @@ -116,7 +121,7 @@
<think>
```

## Audio and Omni Models

Check warning on line 124 in lfm/key-concepts/chat-template.mdx

View check run for this annotation

Mintlify / Mintlify Validation (liquidai) - vale-spellcheck

lfm/key-concepts/chat-template.mdx#L124

Did you really mean 'Omni'?

LFM3-Omni follows the same chat template. Every input audio clip, image, and video sits inside a `<|vision_start|>` / `<|vision_end|>` span, which `apply_chat_template()` inserts for you. Audio clips render as `<|vision_start|><|audio|><|vision_end|>`.

Expand All @@ -132,7 +137,7 @@

## LFM2 and LFM2.5

LFM2 and LFM2.5 use a ChatML-like chat template without the `<think>` prefill:
LFM2 and LFM2.5 use a ChatML-like chat template. Unlike LFM3, most of their templates don't open the assistant turn with `<think>` (see [LFM2.5 Thinking Models](#lfm2-5-thinking-models)):

<ChatMLExample />

Expand Down Expand Up @@ -173,6 +178,12 @@
<|im_start|>assistant
```

### LFM2.5 Thinking Models

LFM2.5 thinking models always think, and their templates have no `enable_thinking` argument. Depending on the model, the template opens the assistant turn with `<think>` or the model writes it itself. Either way, the reply contains a closing `</think>` before the answer.

For LFM2.5-8B-A1B and LFM2.5-24B-A2B, reasoning before the latest user message is removed by default, while reasoning from later assistant turns stays. LFM2.5-1.2B-Thinking instead retains only the last assistant message's reasoning by default. Set `preserve_thinking=True` to retain reasoning from all assistant messages; LFM2.5-1.2B-Thinking also accepts the older name `keep_past_thinking`. See [Thinking](/lfm/key-concepts/thinking#multi-turn-conversations) for guidance on agent conversations.

### LFM2 Vision Models

LFM2-VL models follow the same chat template with additional support for images. When formatted, images are represented with a sentinel token (`<image>`), which is automatically replaced with image tokens by the processor.
Expand Down
Loading
Loading