> For the complete documentation index, see [llms.txt](https://docs.clore.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.clore.ai/guides/guides_v2-de/sprachmodelle/mistral-small.md).

# Mistral Small 3.1

Mistral Small 3.1, veröffentlicht im März 2025 von Mistral AI, ist ein **24-Milliarden-Parameter dichtes Modell** das weit über seinem Gewicht hinaus Leistung bringt. Mit einem 128K-Kontextfenster, nativen Vision-Fähigkeiten, erstklassigem Funktionsaufruf und einem **Apache-2.0-Lizenz**, ist es vermutlich das beste Modell, das man auf einer einzelnen RTX 4090 ausführen kann. Es übertrifft GPT-4o Mini und Claude 3.5 Haiku in den meisten Benchmarks und passt beim Quantisieren komfortabel auf Consumer-Hardware.

## Hauptmerkmale

* **24B dichte Parameter** — keine MoE-Komplexität, einfache Bereitstellung
* **128K Kontextfenster** — RULER-128K-Score von 81,2 %, schlägt GPT-4o Mini (65,8 %)
* **Native Vision** — analysiere Bilder, Diagramme, Dokumente und Screenshots
* **Apache-2.0-Lizenz** — vollständig offen für kommerzielle und private Nutzung
* **Elite-Funktionsaufrufe** — native Werkzeugnutzung mit JSON-Ausgabe, ideal für agentische Workflows
* **Mehrsprachig** — 25+ Sprachen einschließlich CJK, Arabisch, Hindi und europäischen Sprachen

## Anforderungen

| Komponente | Quantisiert (Q4) | Volle Genauigkeit (BF16) |
| ---------- | ---------------- | ------------------------ |
| GPU        | 1× RTX 4090 24GB | 2× RTX 4090 oder 1× H100 |
| VRAM       | \~16GB           | \~55GB                   |
| RAM        | 32GB             | 64GB                     |
| Festplatte | 20GB             | 50GB                     |
| CUDA       | 11.8+            | 12.0+                    |

**Clore.ai-Empfehlung**: RTX 4090 (\~$0.5–2/Tag) für quantisierte Inferenz — bestes Preis/Leistungs-Verhältnis

## Schnellstart mit Ollama

Der schnellste Weg, Mistral Small 3.1 zum Laufen zu bringen:

```bash
# Ollama installieren
curl -fsSL https://ollama.com/install.sh | sh

# Mistral Small 3.1 ausführen (lädt automatisch ~14GB Q4-Quantisierung herunter)
ollama run mistral-small3.1

# Oder eine spezifische Quantisierung angeben
ollama run mistral-small3.1:24b-instruct-2503-q4_K_M
```

### Ollama als OpenAI-kompatible API

```bash
# Ollama-Server starten
ollama serve &

# Modell herunterladen
ollama pull mistral-small3.1

# Per API abfragen
curl http://localhost:11434/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "mistral-small3.1",
    "messages": [
      {"role": "system", "content": "Du bist ein hilfreicher Coding-Assistent."},
      {"role": "user", "content": "Schreibe einen Python-Decorator für Rate Limiting"}
    ],
    "temperature": 0.15
  }'
```

### Ollama mit Vision

```bash
# Ein Bild zur Analyse senden
curl http://localhost:11434/api/chat -d '{
  "model": "mistral-small3.1",
  "messages": [{
    "role": "user",
    "content": "Was zeigt dieses Bild?",
    "images": ["/pfad/zum/bild.jpg"]
  }]
}'
```

## vLLM-Einrichtung (Produktion)

Für Produktions-Workloads mit hohem Durchsatz und gleichzeitigen Anfragen:

```bash
# vLLM installieren (v0.8.1+ erforderlich)
pip install -U vllm

# Überprüfen, dass mistral_common installiert ist (sollte automatisch geschehen)
python -c "import mistral_common; print(mistral_common.__version__)"
```

### Auf Einem GPU bereitstellen (Nur Text)

```bash
vllm serve mistralai/Mistral-Small-3.1-24B-Instruct-2503 \
  --tokenizer-mode mistral \
  --config-format mistral \
  --load-format mistral \
  --tool-call-parser mistral \
  --enable-auto-tool-choice \
  --max-model-len 32768 \
  --gpu-memory-utilization 0.90
```

### Mit Vision bereitstellen (2 GPUs empfohlen)

```bash
vllm serve mistralai/Mistral-Small-3.1-24B-Instruct-2503 \
  --tokenizer-mode mistral \
  --config-format mistral \
  --load-format mistral \
  --tool-call-parser mistral \
  --enable-auto-tool-choice \
  --limit-mm-per-prompt 'image=10' \
  --tensor-parallel-size 2 \
  --max-model-len 65536
```

### Den Server abfragen

```python
from openai import OpenAI

client = OpenAI(base_url="http://localhost:8000/v1", api_key="EMPTY")

response = client.chat.completions.create(
    model="mistralai/Mistral-Small-3.1-24B-Instruct-2503",
    messages=[
        {"role": "system", "content": "Du bist ein hilfreicher Assistent. Heute ist 2026-02-20."},
        {"role": "user", "content": "Schreibe eine vollständige REST-API in FastAPI mit CRUD-Operationen für einen Blog"}
    ],
    temperature=0.15,
    max_tokens=4096
)
print(response.choices[0].message.content)
```

## HuggingFace Transformers

Für direkte Python-Integration und Experimente:

```python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

model_name = "mistralai/Mistral-Small-3.1-24B-Instruct-2503"

tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
    model_name,
    torch_dtype=torch.bfloat16,
    device_map="auto",
    load_in_4bit=True  # 4-Bit-Quantisierung — passt auf 24GB GPU
)

messages = [
    {"role": "system", "content": "Du bist ein hilfreicher Coding-Assistent."},
    {"role": "user", "content": "Implementiere einen binären Suchbaum in Python mit Einfüge-, Lösch- und Suchmethoden"}
]

input_ids = tokenizer.apply_chat_template(messages, return_tensors="pt").to(model.device)

output = model.generate(
    input_ids,
    max_new_tokens=2048,
    temperature=0.15,
    do_sample=True
)
print(tokenizer.decode(output[0][input_ids.shape[-1]:], skip_special_tokens=True))
```

## Beispiel für Funktionsaufrufe

Mistral Small 3.1 ist eines der besten kleinen Modelle für Werkzeugnutzung:

```python
import json
from openai import OpenAI

client = OpenAI(base_url="http://localhost:8000/v1", api_key="EMPTY")

tools = [
    {
        "type": "function",
        "function": {
            "name": "get_stock_price",
            "description": "Hole den aktuellen Aktienkurs für ein gegebenes Tickersymbol",
            "parameters": {
                "type": "object",
                "required": ["ticker"],
                "properties": {
                    "ticker": {"type": "string", "description": "Aktien-Tickersymbol (z. B. AAPL)"}
                }
            }
        }
    },
    {
        "type": "function",
        "function": {
            "name": "calculate_portfolio_value",
            "description": "Berechne den gesamten Portfoliowert anhand der Bestände",
            "parameters": {
                "type": "object",
                "required": ["holdings"],
                "properties": {
                    "holdings": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "ticker": {"type": "string"},
                                "shares": {"type": "number"}
                            }
                        }
                    }
                }
            }
        }
    }
]

response = client.chat.completions.create(
    model="mistralai/Mistral-Small-3.1-24B-Instruct-2503",
    messages=[{"role": "user", "content": "Wie ist der aktuelle Preis von AAPL und MSFT?"}],
    tools=tools,
    tool_choice="auto",
    temperature=0.15
)

for tool_call in response.choices[0].message.tool_calls:
    print(f"Aufruf: {tool_call.function.name}({tool_call.function.arguments})")
```

## Docker Quick Start

```bash
# Einzel-GPU-Bereitstellung
docker run --gpus all -p 8000:8000 \
  -v ~/.cache/huggingface:/root/.cache/huggingface \
  vllm/vllm-openai:latest \
  --model mistralai/Mistral-Small-3.1-24B-Instruct-2503 \
  --tokenizer-mode mistral \
  --config-format mistral \
  --load-format mistral \
  --tool-call-parser mistral \
  --enable-auto-tool-choice \
  --max-model-len 32768

# Mit Vision-Unterstützung (2 GPUs)
docker run --gpus all -p 8000:8000 \
  -v ~/.cache/huggingface:/root/.cache/huggingface \
  vllm/vllm-openai:latest \
  --model mistralai/Mistral-Small-3.1-24B-Instruct-2503 \
  --tokenizer-mode mistral \
  --config-format mistral \
  --load-format mistral \
  --tool-call-parser mistral \
  --enable-auto-tool-choice \
  --limit-mm-per-prompt 'image=10' \
  --tensor-parallel-size 2
```

## Tipps für Clore.ai-Nutzer

* **RTX 4090 ist der Sweetspot**: Bei $0.5–2/Tag kann eine einzelne RTX 4090 Mistral Small 3.1 quantisiert mit Reserven ausführen. Bestes Kosten-/Leistungs-Verhältnis auf Clore.ai für ein allgemeines LLM.
* **Niedrige Temperatur verwenden**: Mistral AI empfiehlt `temperature=0.15` für die meisten Aufgaben. Höhere Temperaturen verursachen bei diesem Modell inkonsistente Ausgaben.
* **RTX 3090 funktioniert auch**: Bei $0.3–1/Tag läuft die RTX 3090 (24GB) Q4-quantisiert mit Ollama problemlos. Etwas langsamer als die 4090, aber halb so teuer.
* **Ollama für schnelle Setups, vLLM für Produktion**: Ollama liefert dir ein funktionierendes Modell in 60 Sekunden. Für gleichzeitige API-Anfragen und höheren Durchsatz wechsle zu vLLM.
* **Funktionsaufrufe machen es besonders**: Viele 24B-Modelle können chatten — wenige können zuverlässig Werkzeuge aufrufen. Die Funktionsaufrufe von Mistral Small 3.1 sind auf Augenhöhe mit GPT-4o Mini. Baue Agenten, API-Backends und Automatisierungspipelines mit Vertrauen.

## Fehlerbehebung

| Problem                             | Lösung                                                                                                              |
| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
| `OutOfMemoryError` auf RTX 4090     | Verwende das quantisierte Modell über Ollama oder `load_in_4bit=True` in Transformers. Volles BF16 benötigt \~55GB. |
| Ollama-Modell nicht gefunden        | Verwenden Sie `ollama run mistral-small3.1` (offizieller Bibliotheksname).                                          |
| vLLM-Tokenizer-Fehler               | Immer übergeben `--tokenizer-mode mistral --config-format mistral --load-format mistral`.                           |
| Schlechte Ausgabequalität           | Setze `temperature=0.15`. Füge einen System-Prompt hinzu. Mistral Small ist empfindlich gegenüber der Temperatur.   |
| Vision funktioniert nicht auf 1 GPU | Vision-Funktionen benötigen mehr VRAM. Verwende `--tensor-parallel-size 2` oder reduziere `--max-model-len`.        |
| Funktionsaufrufe geben leer zurück  | Hinzufügen `--tool-call-parser mistral --enable-auto-tool-choice` bei vLLM serve.                                   |

## Weiterführende Lektüre

* [Mistral Small 3.1 auf HuggingFace](https://huggingface.co/mistralai/Mistral-Small-3.1-24B-Instruct-2503)
* [Mistral AI Blogbeitrag](https://mistral.ai/news/mistral-small-3-1/)
* [Ollama Modellseite](https://ollama.com/library/mistral-small3.1)
* [vLLM-Dokumentation](https://docs.vllm.ai/)
* [Mistral Common Bibliothek](https://github.com/mistralai/mistral-common)
* [Mistral AI Plattform](https://console.mistral.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:

```
GET https://docs.clore.ai/guides/guides_v2-de/sprachmodelle/mistral-small.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
