> 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/gemma3.md).

# Gemma 3

Gemma 3, veröffentlicht im März 2025 von Google DeepMind, basiert auf derselben Technologie wie Gemini 2.0. Seine herausragende Leistung: **das 27B-Modell schlägt Llama 3.1 405B** bei LMArena-Benchmarks — ein Modell, das 15-mal so groß ist. Es ist von Haus aus multimodal (Text + Bilder + Video), unterstützt 128K Kontext und läuft mit Quantisierung auf einer einzigen RTX 4090.

## Hauptmerkmale

* **Leistet weit mehr als sein Gewicht vermuten lässt**: 27B schlägt Modelle der 405B-Klasse in wichtigen Benchmarks
* **Nativ multimodal**: Text-, Bild- und Videoverstehen integriert
* **128K Kontextfenster**: Verarbeitet lange Dokumente, Codebasen, Gespräche
* **Vier Größen**: 1B, 4B, 12B, 27B — für jedes GPU-Budget etwas dabei
* **QAT-Versionen**: Quantization-Aware-Training-Varianten ermöglichen das Ausführen von 27B auf Consumer-GPUs
* **Breite Framework-Unterstützung**: Ollama, vLLM, Transformers, Keras, JAX, PyTorch

## Modellvarianten

| Modell          | Parameter | VRAM (Q4) | VRAM (FP16) | Am besten geeignet für                                   |
| --------------- | --------- | --------- | ----------- | -------------------------------------------------------- |
| Gemma 3 1B      | 1B        | 1,5GB     | 3GB         | Edge, Mobilgeräte, Tests                                 |
| Gemma 3 4B      | 4B        | 4GB       | 9GB         | Budget-GPUs, schnelle Aufgaben                           |
| Gemma 3 12B     | 12B       | 10GB      | 25GB        | Ausgewogenes Verhältnis von Qualität und Geschwindigkeit |
| Gemma 3 27B     | 27B       | 18GB      | 54GB        | Beste Qualität, Produktion                               |
| Gemma 3 27B QAT | 27B       | 14GB      | —           | Optimiert für Consumer-GPUs                              |

## Anforderungen

| Komponente | Gemma 3 4B | Gemma 3 27B (Q4) | Gemma 3 27B (FP16) |
| ---------- | ---------- | ---------------- | ------------------ |
| GPU        | RTX 3060   | RTX 4090         | 2× RTX 4090 / A100 |
| VRAM       | 6GB        | 24GB             | 48GB+              |
| RAM        | 16GB       | 32GB             | 64GB               |
| Festplatte | 10GB       | 25GB             | 55GB               |
| CUDA       | 11.8+      | 11.8+            | 12.0+              |

**Empfohlene Clore.ai-GPU**: RTX 4090 24GB (\~0,5–2 $/Tag) für quantisiertes 27B — der Sweet Spot

## Schnellstart mit Ollama

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

# Verschiedene Größen ausführen
ollama run gemma3:1b     # Winzig — 1,5GB VRAM
ollama run gemma3:4b     # Klein — 4GB VRAM
ollama run gemma3:12b    # Mittel — 10GB VRAM
ollama run gemma3:27b    # Groß — 18–20GB VRAM (quantisiert)

# QAT-Version (optimierte Quantisierung)
ollama run gemma3:27b-qat
```

### Ollama API-Server

```bash
ollama serve &

curl http://localhost:11434/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemma3:27b",
    "messages": [{"role": "user", "content": "Vergleiche REST vs GraphQL für eine neue API"}]
  }'
```

### Vision mit Ollama

```bash
# Ein Bild analysieren
ollama run gemma3:27b "Beschreibe dieses Bild ausführlich" --images ./photo.jpg
```

## vLLM-Einrichtung (Produktion)

```bash
pip install vllm

# 27B-Modell bereitstellen
vllm serve google/gemma-3-27b-it \
  --max-model-len 8192 \
  --gpu-memory-utilization 0.90

# Mit längerem Kontext auf 2 GPUs bereitstellen
vllm serve google/gemma-3-27b-it \
  --tensor-parallel-size 2 \
  --max-model-len 65536

# 4B für Budget-Setups bereitstellen
vllm serve google/gemma-3-4b-it \
  --max-model-len 32768
```

## HuggingFace Transformers

### Textgenerierung

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

model_name = "google/gemma-3-27b-it"

tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
    model_name,
    torch_dtype=torch.bfloat16,
    device_map="auto",
    load_in_4bit=True  # Passt auf 24GB GPU
)

messages = [
    {"role": "user", "content": "Schreibe eine Python-Klasse für einen binären Suchbaum mit den Methoden insert, search und delete"}
]

input_ids = tokenizer.apply_chat_template(messages, return_tensors="pt").to(model.device)
output = model.generate(input_ids, max_new_tokens=2048, temperature=0.7, do_sample=True)
print(tokenizer.decode(output[0][input_ids.shape[-1]:], skip_special_tokens=True))
```

### Vision (Bildverständnis)

```python
import torch
from transformers import AutoProcessor, Gemma3ForConditionalGeneration
from PIL import Image

model_name = "google/gemma-3-27b-it"
processor = AutoProcessor.from_pretrained(model_name)
model = Gemma3ForConditionalGeneration.from_pretrained(
    model_name,
    torch_dtype=torch.bfloat16,
    device_map="auto"
)

# Bild laden
image = Image.open("screenshot.png")

messages = [
    {"role": "user", "content": [
        {"type": "image", "image": image},
        {"type": "text", "text": "Was zeigt dieser Screenshot? Liste alle UI-Elemente auf."}
    ]}
]

inputs = processor.apply_chat_template(messages, return_tensors="pt").to(model.device)
output = model.generate(**inputs, max_new_tokens=1024)
print(processor.decode(output[0], skip_special_tokens=True))
```

## Docker Quick Start

```bash
docker run --gpus all -p 8000:8000 \
  -v ~/.cache/huggingface:/root/.cache/huggingface \
  vllm/vllm-openai:latest \
  --model google/gemma-3-27b-it \
  --max-model-len 8192
```

## Benchmark-Highlights

| Benchmark            | Gemma 3 27B     | Llama 3.1 70B | Llama 3.1 405B  |
| -------------------- | --------------- | ------------- | --------------- |
| LMArena ELO          | 1354            | 1298          | 1337            |
| MMLU                 | 75.6            | 79.3          | 85.2            |
| HumanEval            | 72.0            | 72.6          | 80.5            |
| VRAM (Q4)            | 18GB            | 40GB          | 200GB+          |
| **Kosten auf Clore** | **0,5–2 $/Tag** | **3–6 $/Tag** | **12–24 $/Tag** |

Das 27B liefert Gesprächsqualität auf 405B-Klasseniveau bei 1/10 des VRAM-Aufwands.

## Tipps für Clore.ai-Nutzer

* **27B QAT ist der Sweet Spot**: Quantization-Aware-Training bedeutet weniger Qualitätsverlust als nachträgliche Quantisierung — läuft auf einer einzelnen RTX 4090
* **Vision ist kostenlos**: Keine zusätzliche Einrichtung nötig — Gemma 3 versteht Bilder nativ. Hervorragend für Dokumentenparsing, Screenshot-Analyse, Diagrammlesen
* **Mit kurzem Kontext beginnen**: Verwende `--max-model-len 8192` anfangs; nur bei Bedarf erhöhen, um VRAM zu sparen
* **4B für Budgetläufe**: Wenn du eine RTX 3060/3070 hast (0,15–0,3 $/Tag), übertrifft das 4B-Modell immer noch die 27B-Modelle der letzten Generation
* **Google-Authentifizierung nicht erforderlich**: Im Gegensatz zu einigen Modellen wird Gemma 3 ohne Zugangsbeschränkung heruntergeladen (einfach die Lizenz auf HuggingFace akzeptieren)

## Fehlerbehebung

| Problem                              | Lösung                                                                                         |
| ------------------------------------ | ---------------------------------------------------------------------------------------------- |
| `OutOfMemoryError` auf 27B           | Verwende die QAT-Version oder reduziere `--max-model-len` auf 4096                             |
| Vision funktioniert nicht in Ollama  | Ollama auf die neueste Version aktualisieren: `curl -fsSL https://ollama.com/install.sh \| sh` |
| Langsame Generierungsgeschwindigkeit | Prüfe, ob du bfloat16 und nicht float32 verwendest. Verwende `--dtype bfloat16`                |
| Modell liefert Müll                  | Stelle sicher, dass du die `-it` (instruct-tuned)-Variante verwendest, nicht das Basismodell   |
| Download 403-Fehler                  | Akzeptiere die Gemma-Lizenz unter <https://huggingface.co/google/gemma-3-27b-it>               |

## Weiterführende Lektüre

* [Gemma 3 Technischer Bericht](https://ai.google.dev/gemma)
* [HuggingFace Model Card](https://huggingface.co/google/gemma-3-27b-it)
* [Ollama-Bibliothek](https://ollama.com/library/gemma3)
* [Google AI Studio](https://aistudio.google.com/) — probiere Gemma 3 online aus, bevor du eine GPU mietest


---

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