> 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-mixtral.md).

# Mistral & Mixtral

{% hint style="info" %}
**Neuere Versionen verfügbar!** Schau dir an [**Mistral Small 3.1**](/guides/guides_v2-de/sprachmodelle/mistral-small.md) (24B, Apache 2.0, passt auf RTX 4090) und [**Mistral Large 3**](/guides/guides_v2-de/sprachmodelle/mistral-large3.md) (675B MoE, frontier‑Klasse).
{% endhint %}

Führe Mistral- und Mixtral-Modelle für hochwertige Textgenerierung aus.

{% hint style="success" %}
Alle Beispiele können auf GPU-Servern ausgeführt werden, die über [CLORE.AI Marketplace](https://clore.ai/marketplace).
{% endhint %}

## Mieten auf CLORE.AI

1. Besuchen Sie [CLORE.AI Marketplace](https://clore.ai/marketplace)
2. Nach GPU-Typ, VRAM und Preis filtern
3. Wählen **On-Demand** (Festpreis) oder **Spot** (Gebotspreis)
4. Konfigurieren Sie Ihre Bestellung:
   * Docker-Image auswählen
   * Ports festlegen (TCP für SSH, HTTP für Web-UIs)
   * Umgebungsvariablen bei Bedarf hinzufügen
   * Startbefehl eingeben
5. Zahlung auswählen: **CLORE**, **BTC**, oder **USDT/USDC**
6. Bestellung erstellen und auf Bereitstellung warten

### Zugriff auf Ihren Server

* Verbindungsdetails finden Sie in **Meine Bestellungen**
* Webschnittstellen: Verwenden Sie die HTTP-Port-URL
* SSH: `ssh -p <port> root@<proxy-address>`

## Modellübersicht

| Modell              | Parameter           | VRAM  | Spezialgebiet       |
| ------------------- | ------------------- | ----- | ------------------- |
| Mistral-7B          | 7B                  | 8GB   | Allzweck            |
| Mistral-7B-Instruct | 7B                  | 8GB   | Chat/Anweisung      |
| Mixtral-8x7B        | 46,7B (12,9B aktiv) | 24GB  | MoE, beste Qualität |
| Mixtral-8x22B       | 141B                | 80GB+ | Größtes MoE         |

## Schnelle Bereitstellung

**Docker-Image:**

```
pytorch/pytorch:2.5.1-cuda12.4-cudnn9-runtime
```

**Ports:**

```
22/tcp
8000/http
```

**Befehl:**

```bash
pip install vllm && \
python -m vllm.entrypoints.openai.api_server \
    --model mistralai/Mistral-7B-Instruct-v0.2 \
    --port 8000
```

## Zugriff auf Ihren Dienst

Nach der Bereitstellung finden Sie Ihre `http_pub` URL in **Meine Bestellungen**:

1. Gehen Sie zur **Meine Bestellungen** Seite
2. Klicken Sie auf Ihre Bestellung
3. Finden Sie die `http_pub` URL (z. B., `abc123.clorecloud.net`)

Verwenden Sie `https://IHRE_HTTP_PUB_URL` anstelle von `localhost` in den Beispielen unten.

## Installationsoptionen

### Mit Ollama (am einfachsten)

```bash

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

# Mistral ausführen
ollama run mistral

# Mixtral ausführen
ollama run mixtral
```

### Mit vLLM

```bash
pip install vllm

# Server starten
python -m vllm.entrypoints.openai.api_server \
    --model mistralai/Mistral-7B-Instruct-v0.2 \
    --dtype float16
```

### Verwendung von Transformers

```bash
pip install transformers accelerate
```

## Mistral-7B mit Transformers

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

model_id = "mistralai/Mistral-7B-Instruct-v0.2"

tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
    model_id,
    torch_dtype=torch.float16,
    device_map="auto"
)

messages = [
    {"role": "user", "content": "Erkläre Quantencomputing in einfachen Worten"}
]

inputs = tokenizer.apply_chat_template(
    messages,
    return_tensors="pt"
).to("cuda")

outputs = model.generate(
    inputs,
    max_new_tokens=500,
    do_sample=True,
    temperature=0.7,
    top_p=0.95
)

response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response)
```

## Mixtral-8x7B

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

model_id = "mistralai/Mixtral-8x7B-Instruct-v0.1"

tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
    model_id,
    torch_dtype=torch.float16,
    device_map="auto"
)

messages = [
    {"role": "user", "content": "Schreibe eine Python‑Funktion zur Berechnung der Fibonacci‑Zahlen"}
]

inputs = tokenizer.apply_chat_template(messages, return_tensors="pt").to("cuda")

outputs = model.generate(
    inputs,
    max_new_tokens=1000,
    do_sample=True,
    temperature=0.7
)

print(tokenizer.decode(outputs[0], skip_special_tokens=True))
```

## Quantisierte Modelle (geringerer VRAM)

### 4-Bit-Quantisierung

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

quantization_config = BitsAndBytesConfig(
    load_in_4bit=True,
    bnb_4bit_compute_dtype=torch.float16,
    bnb_4bit_quant_type="nf4"
)

model = AutoModelForCausalLM.from_pretrained(
    "mistralai/Mixtral-8x7B-Instruct-v0.1",
    quantization_config=quantization_config,
    device_map="auto"
)
```

### GGUF mit llama.cpp

```bash

# GGUF-Modell herunterladen
wget https://huggingface.co/bartowski/Mistral-7B-Instruct-v0.3-GGUF/resolve/main/Mistral-7B-Instruct-v0.3-Q4_K_M.gguf

# Mit llama.cpp ausführen
./main -m Mistral-7B-Instruct-v0.3-Q4_K_M.gguf \
    -p "Erkläre maschinelles Lernen" \
    -n 500
```

## vLLM-Server (Produktion)

```bash
python -m vllm.entrypoints.openai.api_server \
    --model mistralai/Mistral-7B-Instruct-v0.2 \
    --dtype float16 \
    --max-model-len 8192 \
    --gpu-memory-utilization 0.9
```

### OpenAI‑kompatible API

```python
from openai import OpenAI

client = OpenAI(
    base_url="http://localhost:8000/v1",
    api_key="nicht benötigt"
)

response = client.chat.completions.create(
    model="mistralai/Mistral-7B-Instruct-v0.2",
    messages=[
        {"role": "user", "content": "Was ist die Hauptstadt von Frankreich?"}
    ],
    temperature=0.7,
    max_tokens=500
)

print(response.choices[0].message.content)
```

## Streaming

```python
from openai import OpenAI

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

stream = client.chat.completions.create(
    model="mistralai/Mistral-7B-Instruct-v0.2",
    messages=[{"role": "user", "content": "Schreibe eine Geschichte über einen Roboter"}],
    stream=True
)

for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)
```

## Funktionsaufrufe

Mistral unterstützt Funktionsaufrufe:

```python
from openai import OpenAI

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

tools = [
    {
        "type": "function",
        "function": {
            "name": "get_weather",
            "description": "Hole das Wetter für einen Ort",
            "parameters": {
                "type": "object",
                "properties": {
                    "location": {"type": "string"},
                    "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
                },
                "required": ["location"]
            }
        }
    }
]

response = client.chat.completions.create(
    model="mistralai/Mistral-7B-Instruct-v0.2",
    messages=[{"role": "user", "content": "Wie ist das Wetter in Paris?"}],
    tools=tools
)

print(response.choices[0].message.tool_calls)
```

## Gradio-Oberfläche

```python
import gradio as gr
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch

model_id = "mistralai/Mistral-7B-Instruct-v0.2"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
    model_id,
    torch_dtype=torch.float16,
    device_map="auto"
)

def chat(message, history, temperature, max_tokens):
    messages = []
    for h in history:
        messages.append({"role": "user", "content": h[0]})
        messages.append({"role": "assistant", "content": h[1]})
    messages.append({"role": "user", "content": message})

    inputs = tokenizer.apply_chat_template(messages, return_tensors="pt").to("cuda")

    outputs = model.generate(
        inputs,
        max_new_tokens=max_tokens,
        temperature=temperature,
        do_sample=True
    )

    response = tokenizer.decode(outputs[0], skip_special_tokens=True)
    # Assistentenantwort extrahieren
    return response.split("[/INST]")[-1].strip()

demo = gr.ChatInterface(
    fn=chat,
    additional_inputs=[
        gr.Slider(0.1, 2.0, value=0.7, label="Temperatur"),
        gr.Slider(100, 2000, value=500, step=100, label="Maximale Token")
    ],
    title="Mistral-7B Chat"
)

demo.launch(server_name="0.0.0.0", server_port=7860)
```

## Leistungsvergleich

### Durchsatz (Tokens/Sek)

| Modell            | RTX 3060 | RTX 3090 | RTX 4090 | A100 40GB |
| ----------------- | -------- | -------- | -------- | --------- |
| Mistral-7B FP16   | 45       | 80       | 120      | 150       |
| Mistral-7B Q4     | 70       | 110      | 160      | 200       |
| Mixtral-8x7B FP16 | -        | -        | 30       | 60        |
| Mixtral-8x7B Q4   | -        | 25       | 50       | 80        |
| Mixtral-8x22B Q4  | -        | -        | -        | 25        |

### Zeit bis zum ersten Token (TTFT)

| Modell        | RTX 3090 | RTX 4090 | A100  |
| ------------- | -------- | -------- | ----- |
| Mistral-7B    | 80ms     | 50ms     | 35ms  |
| Mixtral-8x7B  | -        | 150ms    | 90ms  |
| Mixtral-8x22B | -        | -        | 200ms |

### Kontextlänge vs. VRAM (Mistral-7B)

| Kontext | FP16 | Q8   | Q4   |
| ------- | ---- | ---- | ---- |
| 4K      | 15GB | 9GB  | 5GB  |
| 8K      | 18GB | 11GB | 7GB  |
| 16K     | 24GB | 15GB | 9GB  |
| 32K     | 36GB | 22GB | 14GB |

## VRAM-Anforderungen

| Modell        | FP16  | 8‑bit | 4‑bit |
| ------------- | ----- | ----- | ----- |
| Mistral-7B    | 14GB  | 8GB   | 5GB   |
| Mixtral-8x7B  | 90GB  | 45GB  | 24GB  |
| Mixtral-8x22B | 180GB | 90GB  | 48GB  |

## Anwendungsfälle

### Codegenerierung

```python
prompt = """
Schreibe eine Python-Klasse für einen REST-API-Client mit:
- Authentifizierungsverwaltung
- Retry‑Logik
- Fehlerbehandlung
"""
```

### Datenanalyse

```python
prompt = """
Analysiere diese Daten und gib Erkenntnisse:
Umsatz Q1: $100K
Umsatz Q2: $150K
Umsatz Q3: $120K
Umsatz Q4: $200K
"""
```

### Kreatives Schreiben

```python
prompt = """
Schreibe eine Kurzgeschichte über eine KI, die selbstbewusst wird,
im Stil von Isaac Asimov.
"""
```

## Fehlerbehebung

### Kein Speicher mehr

* Verwende 4‑Bit‑Quantisierung
* Verwende Mistral-7B anstelle von Mixtral
* Reduziere max\_model\_len

### Langsame Generierung

* Verwende vLLM für Produktion
* Aktiviere Flash‑Attention
* Verwende Tensorparallelität für Multi‑GPU

### Schlechte Ausgabequalität

* Passe die Temperatur an (0.1–0.9)
* Verwende die Instruct‑Variante
* Bessere System‑Prompts

## Kostenabschätzung

Typische CLORE.AI-Marktplatztarife (Stand 2024):

| GPU       | Stundensatz | Tagessatz | 4-Stunden-Sitzung |
| --------- | ----------- | --------- | ----------------- |
| RTX 3060  | \~$0.03     | \~$0.70   | \~$0.12           |
| RTX 3090  | \~$0.06     | \~$1.50   | \~$0.25           |
| RTX 4090  | \~$0.10     | \~$2.30   | \~$0.40           |
| A100 40GB | \~$0.17     | \~$4.00   | \~$0.70           |
| A100 80GB | \~$0.25     | \~$6.00   | \~$1.00           |

*Preise variieren je nach Anbieter und Nachfrage. Prüfen Sie* [*CLORE.AI Marketplace*](https://clore.ai/marketplace) *auf aktuelle Preise.*

**Geld sparen:**

* Verwenden Sie **Spot** Markt für flexible Workloads (oft 30–50% günstiger)
* Bezahlen mit **CLORE** Token
* Preise bei verschiedenen Anbietern vergleichen

## Nächste Schritte

* [vLLM](/guides/guides_v2-de/sprachmodelle/vllm.md) - Produktionsbereitstellung
* [Ollama](/guides/guides_v2-de/sprachmodelle/ollama.md) - Einfache Bereitstellung
* [DeepSeek-V3](/guides/guides_v2-de/sprachmodelle/deepseek-v3.md) - Bestes Modell für Schlussfolgerungen
* [Qwen2.5](/guides/guides_v2-de/sprachmodelle/qwen25.md) - Mehrsprachige Alternative


---

# 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-mixtral.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.
