# Llama 3.3 70B

{% hint style="info" %}
**Neuere Version verfügbar!** Meta veröffentlichte [**Llama 4**](https://docs.clore.ai/guides/guides_v2-de/sprachmodelle/llama4) im April 2025 mit MoE-Architektur — Scout (17B aktiv, passt auf RTX 4090) liefert ähnliche Qualität bei einem Bruchteil des VRAM-Bedarfs. Ein Upgrade in Betracht ziehen.
{% endhint %}

Metas neuestes und effizientestes 70B-Modell auf CLORE.AI-GPUs.

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

## Warum Llama 3.3?

* **Bestes 70B-Modell** - Entspricht der Leistung von Llama 3.1 405B bei einem Bruchteil der Kosten
* **Mehrsprachig** - Unterstützt 8 Sprachen nativ
* **128K Kontext** - Verarbeitung langer Dokumente
* **Offene Gewichte** - Kostenlos für kommerzielle Nutzung

## Modellübersicht

| Spezifikation  | Wert                           |
| -------------- | ------------------------------ |
| Parameter      | 70B                            |
| Kontextlänge   | 128K Tokens                    |
| Trainingsdaten | 15T+ Tokens                    |
| Sprachen       | EN, DE, FR, IT, PT, HI, ES, TH |
| Lizenz         | Llama 3.3 Community-Lizenz     |

### Leistung im Vergleich zu anderen Modellen

| Benchmark    | Llama 3.3 70B | Llama 3.1 405B | GPT-4o |
| ------------ | ------------- | -------------- | ------ |
| MMLU         | 86.0          | 87.3           | 88.7   |
| HumanEval    | 88.4          | 89.0           | 90.2   |
| MATH         | 77.0          | 73.8           | 76.6   |
| Mehrsprachig | 91.1          | 91.6           | -      |

## GPU-Anforderungen

| Einrichtung    | VRAM  | Leistung  | Kosten                        |
| -------------- | ----- | --------- | ----------------------------- |
| Q4 quantisiert | 40GB  | Gut       | A100 40GB (\~$0.17/Stunde)    |
| Q8 quantisiert | 70GB  | Besser    | A100 80GB (\~$0.25/Stunde)    |
| FP16 voll      | 140GB | Am besten | 2x A100 80GB (\~$0.50/Stunde) |

**Empfohlen:** A100 40GB mit Q4-Quantisierung für das beste Preis-/Leistungsverhältnis.

## Schnelle Bereitstellung auf CLORE.AI

### Verwendung von Ollama (am einfachsten)

**Docker-Image:**

```
ollama/ollama
```

**Ports:**

```
22/tcp
11434/http
```

**Nach der Bereitstellung:**

```bash
ollama pull llama3.3
ollama run llama3.3
```

### Verwendung von vLLM (Produktion)

**Docker-Image:**

```
vllm/vllm-openai:latest
```

**Ports:**

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

**Befehl:**

```bash
python -m vllm.entrypoints.openai.api_server \
    --model meta-llama/Llama-3.3-70B-Instruct \
    --tensor-parallel-size 1 \
    --max-model-len 32768 \
    --host 0.0.0.0
```

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

## Installationsmethoden

### Methode 1: Ollama (Empfohlen zum Testen)

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

# Llama 3.3 ziehen (lädt die Q4-Version automatisch herunter)
ollama pull llama3.3

# Interaktiv ausführen
ollama run llama3.3

# Oder API bereitstellen
ollama serve
```

**API-Nutzung:**

```bash
curl http://localhost:11434/api/generate -d '{
  "model": "llama3.3",
  "prompt": "Erkläre Quantencomputing in einfachen Worten"
}'
```

### Methode 2: vLLM (Produktion)

```bash
pip install vllm

# Single GPU (A100 40GB mit AWQ-Quantisierung)
python -m vllm.entrypoints.openai.api_server \
    --model casperhansen/llama-3.3-70b-instruct-awq \
    --quantization awq \
    --max-model-len 16384 \
    --host 0.0.0.0

# Multi-GPU (2x A100 für volle Präzision)
python -m vllm.entrypoints.openai.api_server \
    --model meta-llama/Llama-3.3-70B-Instruct \
    --tensor-parallel-size 2 \
    --max-model-len 32768 \
    --host 0.0.0.0
```

**API-Verwendung (OpenAI-kompatibel):**

```python
from openai import OpenAI

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

response = client.chat.completions.create(
    model="meta-llama/Llama-3.3-70B-Instruct",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Schreibe eine Python-Funktion zur Berechnung von Fibonacci-Zahlen"}
    ],
    temperature=0.7,
    max_tokens=1024
)

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

### Methode 3: Transformers + bitsandbytes

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

# 4-Bit-Quantisierungskonfiguration
bnb_config = BitsAndBytesConfig(
    load_in_4bit=True,
    bnb_4bit_quant_type="nf4",
    bnb_4bit_compute_dtype=torch.bfloat16
)

model_id = "meta-llama/Llama-3.3-70B-Instruct"

tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
    model_id,
    quantization_config=bnb_config,
    device_map="auto"
)

# Generieren
messages = [
    {"role": "system", "content": "Du bist ein hilfreicher Coding-Assistent."},
    {"role": "user", "content": "Schreibe einen Python-Web-Scraper mit BeautifulSoup"}
]

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

outputs = model.generate(
    input_ids,
    max_new_tokens=512,
    temperature=0.7,
    do_sample=True
)

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

### Methode 4: llama.cpp (CPU+GPU-Hybrid)

```bash
# Klonen und bauen
git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp
make LLAMA_CUDA=1

# GGUF-Modell herunterladen
wget https://huggingface.co/bartowski/Llama-3.3-70B-Instruct-GGUF/resolve/main/Llama-3.3-70B-Instruct-Q4_K_M.gguf

# Server starten
./llama-server \
    -m Llama-3.3-70B-Instruct-Q4_K_M.gguf \
    -c 8192 \
    -ngl 80 \
    --host 0.0.0.0 \
    --port 8080
```

## Benchmarks

### Durchsatz (Tokens/Sekunde)

| GPU          | Q4    | Q8    | FP16  |
| ------------ | ----- | ----- | ----- |
| A100 40GB    | 25-30 | -     | -     |
| A100 80GB    | 35-40 | 25-30 | -     |
| 2x A100 80GB | 50-60 | 40-45 | 30-35 |
| H100 80GB    | 60-70 | 45-50 | 35-40 |

### Zeit bis zum ersten Token (TTFT)

| GPU          | Q4       | FP16     |
| ------------ | -------- | -------- |
| A100 40GB    | 0.8-1.2s | -        |
| A100 80GB    | 0.6-0.9s | -        |
| 2x A100 80GB | 0.4-0.6s | 0.8-1.0s |

### Kontextlänge vs. VRAM

| Kontext | Q4 VRAM | Q8 VRAM |
| ------- | ------- | ------- |
| 4K      | 38GB    | 72GB    |
| 8K      | 40GB    | 75GB    |
| 16K     | 44GB    | 80GB    |
| 32K     | 52GB    | 90GB    |
| 64K     | 68GB    | 110GB   |
| 128K    | 100GB   | 150GB   |

## Anwendungsfälle

### Codegenerierung

```python
messages = [
    {"role": "system", "content": "Du bist ein Experte in Programmierung. Schreibe sauberen, effizienten und gut dokumentierten Code."},
    {"role": "user", "content": "Erstelle eine REST-API in FastAPI mit Benutzerauthentifizierung mittels JWT-Tokens"}
]
```

### Dokumentenanalyse (langer Kontext)

```python
# Großes Dokument laden
with open("large_document.txt") as f:
    document = f.read()

messages = [
    {"role": "system", "content": "Du bist ein Dokumentenanalyst. Liefere detaillierte, genaue Analysen."},
    {"role": "user", "content": f"Analysiere dieses Dokument und gib eine Zusammenfassung mit den wichtigsten Punkten:\n\n{document}"}
]
```

### Multilinguale Aufgaben

```python
messages = [
    {"role": "system", "content": "Du bist ein mehrsprachiger Assistent."},
    {"role": "user", "content": "Übersetze dies ins Deutsche, Französische und Spanische: 'The quick brown fox jumps over the lazy dog'"}
]
```

### Schlussfolgerung & Analyse

```python
messages = [
    {"role": "system", "content": "Denke Schritt für Schritt. Zeige deine Begründung."},
    {"role": "user", "content": "Ein Zug verlässt Bahnhof A um 9:00 Uhr mit 60 mph. Ein anderer Zug verlässt Bahnhof B (300 Meilen entfernt) um 10:00 Uhr in Richtung Bahnhof A mit 90 mph. Wann und wo treffen sie sich?"}
]
```

## Optimierungstipps

### Speicheroptimierung

```python
# vLLM mit Speicheroptimierung
python -m vllm.entrypoints.openai.api_server \
    --model casperhansen/llama-3.3-70b-instruct-awq \
    --quantization awq \
    --gpu-memory-utilization 0.95 \
    --max-model-len 8192
```

### Geschwindigkeitsoptimierung

```python
# Flash Attention aktivieren
python -m vllm.entrypoints.openai.api_server \
    --model meta-llama/Llama-3.3-70B-Instruct \
    --tensor-parallel-size 2 \
    --enable-prefix-caching
```

### Batch-Verarbeitung

```python
# Mehrere Anfragen effizient verarbeiten
responses = client.chat.completions.create(
    model="meta-llama/Llama-3.3-70B-Instruct",
    messages=messages,
    n=4,  # Erzeuge 4 Antworten
    temperature=0.8
)
```

## Vergleich mit anderen Modellen

| Funktion       | Llama 3.3 70B | Llama 3.1 70B | Qwen 2.5 72B | Mixtral 8x22B |
| -------------- | ------------- | ------------- | ------------ | ------------- |
| MMLU           | 86.0          | 83.6          | 85.3         | 77.8          |
| Programmierung | 88.4          | 80.5          | 85.4         | 75.5          |
| Mathematik     | 77.0          | 68.0          | 80.0         | 60.0          |
| Kontext        | 128K          | 128K          | 128K         | 64K           |
| Sprachen       | 8             | 8             | 29           | 8             |
| Lizenz         | Öffnen        | Öffnen        | Öffnen       | Öffnen        |

**Fazit:** Llama 3.3 70B bietet die beste Gesamtleistung in seiner Klasse, insbesondere für Programmier- und Schlussfolgerungsaufgaben.

## Fehlerbehebung

### Kein Speicher mehr

```bash
# Verwende AWQ-Quantisierung (am speichereffizientesten)
--model casperhansen/llama-3.3-70b-instruct-awq --quantization awq

# Kontextlänge reduzieren
--max-model-len 8192

# Tensorparallelismus verwenden
--tensor-parallel-size 2
```

### Langsame erste Antwort

* Die erste Anfrage lädt das Modell auf die GPU - Warte 30–60 Sekunden
* Verwenden Sie `--enable-prefix-caching` für schnellere nachfolgende Anfragen
* Mit einer Dummy-Anfrage vorwärmen

### Hugging Face-Zugriff

```bash
# Bei HF anmelden (erforderlich für gesperrtes Modell)
huggingface-cli login

# Oder Umgebungsvariable setzen
export HUGGING_FACE_HUB_TOKEN=hf_xxxxx
```

## Kostenabschätzung

| Einrichtung  | GPU            | $/Stunde | Tokens/$ |
| ------------ | -------------- | -------- | -------- |
| Budget       | A100 40GB (Q4) | \~$0.17  | \~530K   |
| Ausgeglichen | A100 80GB (Q4) | \~$0.25  | \~500K   |
| Leistung     | 2x A100 80GB   | \~$0.50  | \~360K   |
| Maximal      | H100 80GB      | \~$0.50  | \~500K   |

## Nächste Schritte

* [vLLM-Leitfaden](https://docs.clore.ai/guides/guides_v2-de/sprachmodelle/vllm) - Produktionsbereitstellung
* [Ollama-Anleitung](https://docs.clore.ai/guides/guides_v2-de/sprachmodelle/ollama) - Einfache lokale Einrichtung
* [Multi-GPU-Setup](https://docs.clore.ai/guides/guides_v2-de/fortgeschritten/multi-gpu-setup) - Auf größere Modelle skalieren
* [API-Integration](https://docs.clore.ai/guides/guides_v2-de/fortgeschritten/api-integration) - Anwendungen erstellen
