> For the complete documentation index, see [llms.txt](https://unsloth.ai/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://unsloth.ai/docs/de/modelle/tutorials/lfm2.5.md).

# Liquid LFM2.5: So ausführen & feinabstimmen

Liquid AI veröffentlicht LFM2.5, einschließlich ihres [Anweisungs-](#run-lfm2.5-1.2b-instruct) und [Vision-](#liquid-lfm2.5-1.2b-vl-guide) Modells. LFM2.5-1.2B-Instruct ist ein hybrides Reasoning-Modell mit 1,17 Milliarden Parametern, trainiert auf **28T Tokens** und RL und liefert best-in-class Leistung im 1B-Maßstab für Instruktionsbefolgung, Tool-Nutzung und agentische Aufgaben. Siehe [Hugging Face Jobs](/docs/de/grundlagen/inference-and-deployment/deploying-llms-with-hugging-face-jobs.md) zur Verwendung von Codex zum Trainieren von LFM!

LFM2.5 läuft mit weniger als **1 GB RAM** und erreicht **239 Tok/s** Dekodierung auf AMD-CPU. Sie können es auch [**feinabstimmen** lokal ausführen](#fine-tuning-lfm2.5-with-unsloth) mit Unsloth.

<a href="/pages/0ba99f57da4d961b4b6ac0ebc82f8fc360f57cc1#run-lfm2.5-1.2b-instruct" class="button primary">Text LFM2.5-Instruct</a><a href="/pages/0ba99f57da4d961b4b6ac0ebc82f8fc360f57cc1#liquid-lfm2.5-1.2b-vl-guide" class="button primary">Vision LFM2.5-VL</a>

| Dynamische GGUFs                                                                      | 16-Bit Instruct                                                             |
| ------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- |
| [LFM2.5-1.2B-Instruct-GGUF](https://huggingface.co/unsloth/LFM2.5-1.2B-Instruct-GGUF) | [LFM2.5-1.2B-Instruct](https://huggingface.co/unsloth/LFM2.5-1.2B-Instruct) |

**Modellspezifikationen:**

* **Parameter**: 1,17B
* **Architektur**: 16 Schichten (10 doppelt gegatete LIV-Faltungsblöcke + 6 GQA-Blöcke)
* **Trainingsbudget**: 28T Tokens
* **Kontextlänge**: 32.768 Tokens
* **Vokabulargröße**: 65,536
* **Sprachen**: Englisch, Arabisch, Chinesisch, Französisch, Deutsch, Japanisch, Koreanisch, Spanisch

### ⚙️ Nutzungsanleitung

Liquid AI empfiehlt für die Inferenz diese Einstellungen:

* `temperature = 0.1`
* `top_k = 50`
* `top_p = 0.1`
* `repetition_penalty = 1.05`
* Maximale Kontextlänge: `32,768`

#### Chat-Template-Format

LFM2.5 verwendet ein ChatML-ähnliches Format:

```python
tokenizer.apply_chat_template([
    {"role": "system", "content": "Du bist ein hilfreicher Assistent, trainiert von Liquid AI."},
    {"role": "user", "content": "Was ist C. elegans?"},
], add_generation_prompt=True, tokenize=False)
```

**LFM2.5-Chat-Template:**

```
<|startoftext|><|im_start|>system
Du bist ein hilfreicher Assistent, trainiert von Liquid AI.<|im_end|>
<|im_start|>user
Was ist C. elegans?<|im_end|>
<|im_start|>assistant
```

#### Tool-Nutzung

LFM2.5 unterstützt Funktionsaufrufe mit speziellen Tokens `<|tool_call_start|>` und `<|tool_call_end|>`. Stellen Sie die Tools als JSON-Objekt im System-Prompt bereit:

```
<|startoftext|><|im_start|>system
Liste der Tools: [{"name": "get_weather", "description": "Liefert das aktuelle Wetter", "parameters": {"type": "object", "properties": {"city": {"type": "string"}}}}]<|im_end|>
<|im_start|>user
Wie ist das Wetter in Paris?<|im_end|>
<|im_start|>assistant
<|tool_call_start|>[get_weather(city="Paris")]<|tool_call_end|>
```

### 🖥️ LFM2.5-1.2B-Instruct ausführen

#### 📖 llama.cpp-Tutorial (GGUF)

**1. llama.cpp bauen**

Hole dir die neueste `llama.cpp` von [GitHub](https://github.com/ggml-org/llama.cpp). Ändern `-DGGML_CUDA=ON` zu `-DGGML_CUDA=OFF` wenn Sie keine GPU haben. **Für Apple Mac / Metal-Geräte**, setze `-DGGML_CUDA=OFF` und fahre dann wie gewohnt fort - Metal-Unterstützung ist standardmäßig aktiviert.

```bash
apt-get update
apt-get install pciutils build-essential cmake curl libcurl4-openssl-dev -y
git clone https://github.com/ggml-org/llama.cpp
cmake llama.cpp -B llama.cpp/build \
    -DBUILD_SHARED_LIBS=OFF -DGGML_CUDA=ON -DLLAMA_CURL=ON
cmake --build llama.cpp/build --config Release -j --clean-first --target llama-cli llama-server
cp llama.cpp/build/bin/llama-* llama.cpp
```

**2. Direkt von Hugging Face ausführen**

```bash
./llama.cpp/llama-cli \
    -hf LiquidAI/LFM2.5-1.2B-Instruct-GGUF:Q4_K_M \\
    --jinja --ctx-size 32768 \\
    --temp 0.1 --top-k 50 --top-p 0.1 --repeat-penalty 1.05
```

**3. Oder laden Sie das Modell zuerst herunter**

```python
import os
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
from huggingface_hub import snapshot_download
snapshot_download(
    repo_id="LiquidAI/LFM2.5-1.2B-Instruct-GGUF",
    local_dir="LiquidAI/LFM2.5-1.2B-Instruct-GGUF",
    allow_patterns=["*Q4_K_M*"],
)
```

**4. Im Konversationsmodus ausführen**

```bash
./llama.cpp/llama-cli \
    --model LiquidAI/LFM2.5-1.2B-Instruct-GGUF/LFM2.5-1.2B-Instruct-Q4_K_M.gguf \\
    --ctx-size 32768 \\
    --n-gpu-layers 99 \
    --seed 3407 \
    --prio 2 \
    --temp 0.1 \\
    --top-k 50 \\
    --top-p 0.1 \\
    --repeat-penalty 1.05 \\
    --jinja
```

### 🦥 LFM2.5 mit Unsloth feinabstimmen

Unsloth unterstützt das Feinabstimmen von LFM2.5-Modellen. Das 1.2B-Modell passt problemlos auf eine kostenlose Colab-T4-GPU. Das Training ist 2x schneller bei 50 % weniger VRAM.

**Kostenloses Colab-Notebook:**

* [LFM2.5-1.2B-Instruct SFT LoRA-Notebook](https://colab.research.google.com/drive/1vGRg4ksRj__6OLvXkHhvji_Pamv801Ss?usp=sharing)
* [LFM2.5-1.2B-Instruct GRPO LoRA-Notebook](https://colab.research.google.com/drive/1mIikXFaGvcW4vXOZXLbVTxfBRw_XsXa5?usp=sharing)
* [LFM2.5-1.2B-Base Fortgesetztes Vortraining (Textvervollständigung) Notebook](https://colab.research.google.com/drive/10fm7eNMezs-DSn36mF7vAsNYlOsx9YZO?usp=sharing)
* [LFM2.5-1.2B-Base Fortgesetztes Vortraining (Übersetzung) Notebook](https://colab.research.google.com/drive/1gaP8yTle2_v35Um8Gpu9239fqbU7UgY8?usp=sharing)

LFM2.5 wird für agentische Aufgaben, Datenextraktion, RAG und Tool-Nutzung empfohlen. Es wird nicht für wissensintensive Aufgaben oder Programmierung empfohlen.

#### Unsloth-Konfiguration für LFM2.5

```python
from unsloth import FastLanguageModel
import torch

model, tokenizer = FastLanguageModel.from_pretrained(
    model_name="LiquidAI/LFM2.5-1.2B-Instruct",
    max_seq_length=4096,
    load_in_4bit=False,
)

model = FastLanguageModel.get_peft_model(
    model,
    r=16,
    target_modules = ["q_proj", "k_proj", "v_proj", "out_proj", "in_proj",
                      "w1", "w2", "w3"],
    lora_alpha=16,
    lora_dropout=0,
    bias="none",
    use_gradient_checkpointing="unsloth",
    random_state=3407,
)
```

#### Trainings-Setup

```python
from trl import SFTTrainer
from transformers import TrainingArguments
from unsloth import is_bfloat16_supported

trainer = SFTTrainer(
    model=model,
    tokenizer=tokenizer,
    train_dataset=dataset,
    dataset_text_field="text",
    max_seq_length=4096,
    dataset_num_proc=2,
    packing=False,
    args=TrainingArguments(
        per_device_train_batch_size=2,
        gradient_accumulation_steps=4,
        warmup_steps=5,
        max_steps=60,
        learning_rate=2e-4,
        fp16=not is_bfloat16_supported(),
        bf16=is_bfloat16_supported(),
        logging_steps=1,
        optim="adamw_8bit",
        weight_decay=0.01,
        lr_scheduler_type="linear",
        seed=3407,
        output_dir="outputs",
    ),
)

trainer.train()
```

#### Speichern und Exportieren

```python
# LoRA-Adapter speichern
model.save_pretrained("lfm25_lora")
tokenizer.save_pretrained("lfm25_lora")

# Zusammenführen und als 16-Bit speichern
model.save_pretrained_merged("lfm25_merged", tokenizer, save_method="merged_16bit")

# In GGUF exportieren
model.save_pretrained_gguf("lfm25_gguf", tokenizer, quantization_method="q4_k_m")
```

### 🎉 llama-server Bereitstellung & Deployment

Um LFM2.5 produktiv mit einer OpenAI-kompatiblen API bereitzustellen:

```bash
./llama.cpp/llama-server \
    --model LiquidAI/LFM2.5-1.2B-Instruct-GGUF/LFM2.5-1.2B-Instruct-Q4_K_M.gguf \\
    --alias "LiquidAI/LFM2.5-1.2B-Instruct" \\
    --threads -1 \\
    --n-gpu-layers 99 \
    --ctx-size 32768 \\
    --port 8001 \
    --temp 0.1 \\
    --top-k 50 \\
    --top-p 0.1 \\
    --repeat-penalty 1.05 \\
    --jinja
```

**Mit OpenAI-Client testen:**

```python
from openai import OpenAI

client = OpenAI(
    base_url="http://127.0.0.1:8001/v1",
    api_key="sk-no-key-required",
)

completion = client.chat.completions.create(
    model="LiquidAI/LFM2.5-1.2B-Instruct",
    messages=[{"role": "user", "content": "Was ist 2+2?"}],
)
print(completion.choices[0].message.content)
```

### 📊 Benchmarks

LFM2.5-1.2B-Instruct liefert best-in-class Leistung im 1B-Maßstab und bietet schnelle CPU-Inferenz bei geringem Speicherverbrauch:

![](https://cdn-uploads.huggingface.co/production/uploads/61b8e2ba285851687028d395/dxnYF2fuLpulismtFSGFi.png) ![](https://cdn-uploads.huggingface.co/production/uploads/61b8e2ba285851687028d395/dbbI-15p9re2ROhAkqnZm.png)

## 💧 Liquid LFM2.5-1.2B-VL Leitfaden

LFM2.5-VL-1.6B ist ein Vision-LLM, aufgebaut auf [LFM2.5-1.2B-Base](https://huggingface.co/LiquidAI/LFM2.5-1.2B-Base) und auf stärkere Praxisleistung abgestimmt. Sie können es jetzt **feinabstimmen** lokal mit Unsloth ausführen.

<a href="/pages/0ba99f57da4d961b4b6ac0ebc82f8fc360f57cc1#run-lfm2.5-vl-1.6b" class="button primary">Ausführungstutorial</a><a href="/pages/0ba99f57da4d961b4b6ac0ebc82f8fc360f57cc1#fine-tuning-lfm2.5-with-unsloth-1" class="button primary">Feinabstimmungstutorial</a>

| Dynamische GGUFs                                                          | 16-Bit Instruct                                                 |
| ------------------------------------------------------------------------- | --------------------------------------------------------------- |
| [LFM2.5-VL-1.6B-GGUF](https://huggingface.co/unsloth/LFM2.5-VL-1.6B-GGUF) | [LFM2.5-VL-1.6B](https://huggingface.co/unsloth/LFM2.5-VL-1.6B) |

**Modellspezifikationen:**

* **LM-Backbone**: LFM2.5-1.2B-Base
* **Vision-Encoder**: SigLIP2 NaFlex, formoptimiert, 400M
* **Kontextlänge**: 32.768 Tokens
* **Vokabulargröße**: 65,536
* **Sprachen**: Englisch, Arabisch, Chinesisch, Französisch, Deutsch, Japanisch, Koreanisch und Spanisch
* **Native Auflösungsverarbeitung**: Verarbeitet Bilder bis zu 512×512 Pixel ohne Hochskalierung und bewahrt nicht standardisierte Seitenverhältnisse ohne Verzerrung
* **Kachelstrategie**: Teilt große Bilder in nicht überlappende 512×512-Patches auf und umfasst Thumbnail-Codierung für globalen Kontext
* **Flexibilität zur Inferenzzeit**: Vom Benutzer einstellbare maximale Bild-Tokens und Kachelanzahl für den Kompromiss zwischen Geschwindigkeit und Qualität ohne erneutes Training

### :gear: Verwendungsleitfaden

Liquid AI empfiehlt für die Inferenz diese Einstellungen:

* **Text**: `temperature=0.1`, `min_p=0.15`, `repetition_penalty=1.05`
* **Vision**: min\_image\_tokens=64, max\_image\_tokens=256, do\_image\_splitting=True

#### Chat-Template-Format

LFM2.5-VL verwendet ein ChatML-ähnliches Format:

```python
tokenizer.apply_chat_template([
    {
        "role": "user",
        "content": [
            {"type": "image"},
            {"type": "text", "text": "Was ist auf diesem Bild zu sehen?"}
        ]
    },
    {"role": "assistant", "content": "Ich sehe eine Katze, die auf einem Sofa sitzt."}
], tokenize=False)
```

**LFM2.5-VL-Chat-Template:**

```
<|startoftext|><|im_start|>system
Du bist ein hilfreicher multimodaler Assistent von Liquid AI.<|im_end|>
<|im_start|>user
<image>Beschreibe dieses Bild.<|im_end|>
<|im_start|>assistant
Dieses Bild zeigt einen Nematoden Caenorhabditis elegans (C. elegans).<|im_end|>
```

### 🖥️  LFM2.5-VL-1.6B ausführen

#### :book: llama.cpp-Tutorial (GGUF)

**1. llama.cpp bauen**

Holen Sie sich die neueste llama.cpp von [GitHub](https://github.com/ggml-org/llama.cpp). Ändern `-DGGML_CUDA=ON` zu `-DGGML_CUDA=OFF` wenn Sie keine GPU haben.

```bash
apt-get update
apt-get install pciutils build-essential cmake curl libcurl4-openssl-dev -y
git clone https://github.com/ggml-org/llama.cpp
cmake llama.cpp -B llama.cpp/build \
    -DBUILD_SHARED_LIBS=OFF -DGGML_CUDA=ON -DLLAMA_CURL=ON
cmake --build llama.cpp/build --config Release -j --clean-first --target llama-cli llama-server
cp llama.cpp/build/bin/llama-* llama.cpp
```

**2. Direkt von Hugging Face ausführen**

```bash
./llama.cpp/llama-cli \
  -hf LiquidAI/LFM2.5-VL-1.6B-GGUF:Q4_0 \\
  --image test_image.jpg \\
  --image-max-tokens 64 \\
  -p "Was ist auf diesem Bild zu sehen?" \\
  -n 128
```

### :sloth: LFM2.5-VL mit Unsloth feinabstimmen

Unsloth unterstützt das Feinabstimmen von LFM2.5-Modellen. Das 1.6B-Modell passt problemlos auf eine kostenlose Colab-T4-GPU. Das Training ist 2x schneller bei 50 % weniger VRAM.

**Kostenloses Colab-Notebook:**

* [LFM2.5-VL-1.6B SFT LoRA-Notebook](https://colab.research.google.com/drive/1FaR2HSe91YDe88TG97-JVxMygl-rL6vB?usp=sharing)

#### Unsloth-Konfiguration für LFM2.5

```python
from unsloth import FastVisionModel
import torch

model, tokenizer = FastVisionModel.from_pretrained(
    model_name = "LiquidAI/LFM2.5-VL-1.6B",
    max_seq_length = 4096, 
    load_in_4bit = False, 
)

model = FastVisionModel.get_peft_model(
    model,
    finetune_vision_layers     = False, # Vorerst auf False setzen
    finetune_language_layers   = True, # False, wenn Sprachschichten nicht feinabgestimmt werden
    finetune_attention_modules = True, # False, wenn Attention-Schichten nicht feinabgestimmt werden
    finetune_mlp_modules       = True, # False, wenn MLP-Schichten nicht feinabgestimmt werden
    r = 16,         
    lora_alpha = 16,
    lora_dropout = 0,
    bias = "none",
)
```

#### Trainings-Setup

```python
from unsloth.trainer import UnslothVisionDataCollator
from trl import SFTTrainer, SFTConfig

FastVisionModel.for_training(model) # Für das Training aktivieren!

trainer = SFTTrainer(
    model = model,
    tokenizer = tokenizer,
    data_collator = UnslothVisionDataCollator(model, tokenizer), # Muss verwendet werden!
    train_dataset = converted_dataset,
    args = SFTConfig(
        per_device_train_batch_size = 2,
        gradient_accumulation_steps = 4,
        warmup_steps = 5,
        max_steps = 30,# num_train_epochs = 1, # Stattdessen für vollständiges Training setzen
        learning_rate = 2e-4,
        logging_steps = 1,
        optim = "adamw_8bit",
        weight_decay = 0.001,
        lr_scheduler_type = "linear",
        seed = 3407,
        output_dir = "outputs",
        report_to = "none",     # Für Weights and Biases
        remove_unused_columns = False,
        dataset_text_field = "",
        dataset_kwargs = {"skip_prepare_dataset": True},
        max_length = 2048,
    ),
)

trainer.train()
```

#### Speichern und Exportieren

```python
# LoRA-Adapter speichern
model.save_pretrained("lfm25_lora")
tokenizer.save_pretrained("lfm25_lora")

# Zusammenführen und als 16-Bit speichern
model.save_pretrained_merged("lfm25_merged", tokenizer, save_method="merged_16bit")

# In GGUF exportieren
model.save_pretrained_gguf("lfm25_gguf", tokenizer, quantization_method="q4_k_m")
```

### :bar\_chart: Benchmarks

LFM2.5-VL-1.6B liefert best-in-class Leistung:

| Modell             | MMStar | MM-IFEval | BLINK | InfoVQA (Val) | OCRBench (v2) | RealWorldQA | MMMU (Val) | MMMB (Durchschnitt) | Multilingual MMBench (Durchschnitt) |
| ------------------ | ------ | --------- | ----- | ------------- | ------------- | ----------- | ---------- | ------------------- | ----------------------------------- |
| **LFM2.5-VL-1.6B** | 50.67  | 52.29     | 48.82 | 62.71         | 41.44         | 64.84       | 40.56      | 76.96               | 65.90                               |
| LFM2-VL-1.6B       | 49.87  | 46.35     | 44.50 | 58.35         | 35.11         | 65.75       | 39.67      | 72.13               | 60.57                               |
| InternVL3.5-1B     | 50.27  | 36.17     | 44.19 | 60.99         | 33.53         | 57.12       | 41.89      | 68.93               | 58.32                               |
| FastVLM-1.5B       | 53.13  | 24.99     | 43.29 | 23.92         | 26.61         | 61.56       | 38.78      | 64.84               | 50.89                               |

### 📚 Ressourcen

* [Liquid AI Blogbeitrag](https://www.liquid.ai/blog/introducing-lfm2-5-the-next-generation-of-on-device-ai)
* [LFM2 Technischer Bericht (arXiv)](https://arxiv.org/abs/2511.23404)
* [Liquid AI Dokumentation](https://docs.liquid.ai/lfm)
* [Liquid Playground](https://playground.liquid.ai/)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://unsloth.ai/docs/de/modelle/tutorials/lfm2.5.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
