> 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

Führe Googles multimodale Gemma-3-Modelle auf Clore.ai aus — schlägt Llama-405B bei 15x kleinerer Größe

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 nativ multimodal (Text + Bilder + Video), unterstützt einen 128K-Kontext und läuft mit Quantisierung auf einer einzelnen RTX 4090.

## Hauptfunktionen

* **Übertrifft seine Gewichtsklasse deutlich**: 27B schlägt Modelle der 405B-Klasse bei wichtigen Benchmarks
* **Nativ multimodal**: Texterkennung, Bild- und Videoverständnis integriert
* **128K-Kontextfenster**: Lange Dokumente, Codebasen, Unterhaltungen verarbeiten
* **Vier Größen**: 1B, 4B, 12B, 27B — für jedes GPU-Budget etwas dabei
* **QAT-Versionen**: Varianten mit Quantization-Aware Training ermöglichen, dass das 27B auf Consumer-GPUs läuft
* **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,5 GB    | 3GB         | Edge, mobil, Tests                   |
| Gemma 3 4B      | 4B        | 4 GB      | 9GB         | Budget-GPUs, schnelle Aufgaben       |
| Gemma 3 12B     | 12B       | 10 GB     | 25 GB       | Ausgewogene Qualität/Geschwindigkeit |
| Gemma 3 27B     | 27B       | 18 GB     | 54 GB       | 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       | 6 GB       | 24 GB            | 48 GB+             |
| RAM        | 16 GB      | 32 GB            | 64 GB              |
| Festplatte | 10 GB      | 25 GB            | 55 GB              |
| CUDA       | 12.8+      | 12.8+            | 12.8+              |

**Empfohlene Clore.ai-GPU**: RTX 4090 24 GB ($0.14–0.42/Stunde) für 27B quantisiert — 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,5 GB VRAM
ollama run gemma3:4b     # Klein — 4 GB VRAM
ollama run gemma3:12b    # Mittel — 10 GB VRAM
ollama run gemma3:27b    # Groß — 18–20 GB 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 mit GraphQL für eine neue API"}]
  }'
```

### Vision mit Ollama

```bash
# Ein Bild analysieren
ollama run gemma3:27b "Beschreibe dieses Bild im Detail" --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 eine 24-GB-GPU
)

messages = [
    {"role": "user", "content": "Schreibe eine Python-Klasse für einen binären Suchbaum mit Methoden zum Einfügen, Suchen und Löschen"}
]

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-Schnellstart

```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)            | 18 GB                           | 40 GB                         | 200 GB+                      |
| **Kosten auf Clore** | **ca. 0,14–0,42 $/h** (1× 4090) | **$0.28–0.84/Std.** (2× 4090) | **nicht auf dem Marktplatz** |

Das 27B liefert Gesprächsqualität auf 405B-Niveau bei einem Zehntel der VRAM-Kosten.

## Tipps für Clore.ai-Nutzer

* **27B QAT ist der Sweet Spot**: Quantization-Aware Training bedeutet weniger Qualitätsverlust als Post-Training-Quantisierung — auf einer einzelnen RTX 4090 ausführen
* **Vision ist kostenlos**: Keine zusätzliche Einrichtung nötig — Gemma 3 versteht Bilder nativ. Ideal für Dokumenten-Parsing, Screenshot-Analyse und Diagrammlesen
* **Mit kurzem Kontext beginnen**: Verwende `--max-model-len 8192` zunächst; nur bei Bedarf erhöhen, um VRAM zu sparen
* **4B für Budget-Läufe**: Wenn Sie eine RTX 3060/3070 ($0.03–0.07/Stunde) verwenden, übertrifft das 4B-Modell immer noch die 27B-Modelle der letzten Generation
* **Google-Authentifizierung nicht erforderlich**: Anders als bei einigen Modellen lässt sich Gemma 3 ohne Einschränkungen herunterladen (einfach die Lizenz auf HuggingFace akzeptieren)

## Fehlerbehebung

| Problem                              | Lösung                                                                                                    |
| ------------------------------------ | --------------------------------------------------------------------------------------------------------- |
| `OutOfMemoryError` beim 27B-Modell   | Verwenden Sie die QAT-Version oder reduzieren Sie `--max-model-len` auf 4096                              |
| Vision funktioniert in Ollama nicht  | Ollama auf die neueste Version aktualisieren: `curl -fsSL https://ollama.com/install.sh \| sh`            |
| Langsame Generierungsgeschwindigkeit | Prüfen Sie, ob Sie bfloat16 statt float32 verwenden. Verwenden Sie `--dtype bfloat16`                     |
| Modelldaten sind unbrauchbar         | Stellen Sie sicher, dass Sie die `-it` (instruct-optimierte) Variante und nicht das Basismodell verwenden |
| 403-Fehler beim Download             | Akzeptieren Sie die Gemma-Lizenz unter <https://huggingface.co/google/gemma-3-27b-it>                     |

## Weiterführende Lektüre

* [Technischer Bericht zu Gemma 3](https://ai.google.dev/gemma)
* [HuggingFace-Modellkarte](https://huggingface.co/google/gemma-3-27b-it)
* [Ollama-Bibliothek](https://ollama.com/library/gemma3)
* [Google AI Studio](https://aistudio.google.com/) — testen Sie Gemma 3 online, bevor Sie eine GPU mieten


---

# 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://docs.clore.ai/guides/guides_v2-de/sprachmodelle/gemma3.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.
