> 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/glm-47-flash.md).

# GLM-4.7-Flash

Deploye GLM-4.7-Flash (30B MoE) von Zhipu AI auf Clore.ai — effizientes Sprachmodell mit 59,2 % SWE-bench-Performance

> GLM-4.7-Flash ist ein **30-Milliarden-Parameter-Mixture-of-Experts** Sprachmodell von Zhipu AI, das pro Token nur 3B Parameter aktiviert. Es liefert außergewöhnliche Leistung bei Coding- und Reasoning-Aufgaben und erreicht 59,2 % auf SWE-bench, während für die FP16-Inferenz nur 10–12 GB VRAM benötigt werden. Veröffentlicht unter der **MIT-Lizenz**, ist es die ideale Wahl für Entwickler, die Frontier-Modell-Qualität zu erschwinglichen Kosten auf einer einzelnen GPU suchen.

## Auf einen Blick

* **Modellgröße**: 30B gesamt / 3B aktive Parameter (MoE)
* **Lizenz**: MIT (vollständig kommerziell)
* **Kontext**: 128K Token
* **Leistung**: 59,2 % SWE-bench, 75,4 % HumanEval
* **VRAM**: \~10–12 GB FP16, \~6 GB INT8
* **Geschwindigkeit**: \~45–60 Tok/s auf RTX 4090

## Warum GLM-4.7-Flash?

**Effiziente Leistung**: GLM-4.7-Flash ist seiner Gewichtsklasse weit überlegen. Trotz nur 3B aktiver Parameter übertrifft es viele dichte 70B+-Modelle bei Coding-Benchmarks. Die MoE-Architektur bietet 30B-Modellqualität bei den Inferenzkosten eines 7B-Modells.

**Für eine einzelne GPU geeignet**: Anders als massive Modelle, die Multi-GPU-Setups erfordern, läuft GLM-4.7-Flash problemlos auf einer einzelnen RTX 4090 oder A100 40 GB. Das macht es perfekt für Entwicklung, Feinabstimmung und kosteneffiziente Produktionsbereitstellungen.

**Spezialist für Programmierung**: Mit 59,2 % SWE-bench-Leistung glänzt GLM-4.7-Flash bei Software-Engineering-Aufgaben — Codegenerierung, Debugging, Refactoring und technischer Dokumentation. Es versteht mehr als 20 Programmiersprachen mit tiefem Kontextverständnis.

**MIT-lizenziert**: Keine Nutzungsbeschränkungen. Kommerziell einsetzen, feinabstimmen oder modifizieren ohne Lizenzsorgen. Die vollständigen Gewichte und Trainingsrezepte sind frei verfügbar.

## GPU-Empfehlungen

| GPU          | VRAM  | Leistung    | Tägliche Kosten\* |
| ------------ | ----- | ----------- | ----------------- |
| **RTX 4090** | 24 GB | \~50 Tok/s  | \~$2.10           |
| **RTX 3090** | 24 GB | \~35 Tok/s  | \~$1.10           |
| A100 40GB    | 40 GB | \~80 Tok/s  | \~$3.50           |
| A100 80GB    | 80 GB | \~90 Tok/s  | \~$4.00           |
| H100         | 80 GB | \~120 Tok/s | \~$6.00           |

**Bestes Preis-Leistungs-Verhältnis**: Die RTX 4090 bietet den optimalen Kompromiss aus Leistung und Kosten für GLM-4.7-Flash.

\*Geschätzte Preise auf dem Clore.ai-Marktplatz

## Mit vLLM bereitstellen

### vLLM installieren

```bash
pip install vllm>=0.6.0
# oder die neueste Version
pip install git+https://github.com/vllm-project/vllm.git
```

### Einzel-GPU-Setup

```bash
vllm serve THUDM/glm-4-flash \\
  --model THUDM/glm-4-flash \\
  --tensor-parallel-size 1 \
  --dtype float16 \\
  --max-model-len 32768 \
  --served-model-name glm-4.7-flash \\
  --trust-remote-code
```

### 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="glm-4.7-flash",
    messages=[
        {"role": "system", "content": "Du bist ein Experte für Python-Entwicklung."},
        {"role": "user", "content": "Erstelle eine FastAPI-App mit asynchronem SQLAlchemy und JWT-Authentifizierung"}
    ],
    max_tokens=2048,
    temperature=0.7
)

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

## Bereitstellen mit SGLang

SGLang bietet bei MoE-Modellen oft einen besseren Durchsatz:

```bash
pip install "sglang[all]>=0.3.0"

# Server starten
python -m sglang.launch_server \
  --model-path THUDM/glm-4-flash \\
  --port 30000 \\
  --host 0.0.0.0 \
  --dtype float16 \\
  --tp-size 1 \\
  --context-length 32768
```

## Mit Ollama bereitstellen

Einfache Einrichtung für die lokale Entwicklung:

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

# Modell ziehen (lädt ~18 GB herunter)
ollama pull glm4:7b-chat

# Interaktiv ausführen
ollama run glm4:7b-chat

# API-Modus
ollama serve
```

Dann per REST-API abfragen:

```python
import requests

response = requests.post('http://localhost:11434/api/generate',
    json={
        'model': 'glm4:7b-chat',
        'prompt': 'Erkläre die MoE-Architektur in GLM-4.7-Flash',
        'stream': False
    }
)

print(response.json()['response'])
```

## Docker-Vorlage

```dockerfile
FROM nvidia/cuda:12.8.1-devel-ubuntu22.04

# Python 3.10 installieren
RUN apt-get update && apt-get install -y python3.10 python3-pip curl

# vLLM installieren
RUN pip install vllm>=0.6.0 transformers

# Modell vorab herunterladen (optional)
# RUN python3 -c "from transformers import AutoModel; AutoModel.from_pretrained('THUDM/glm-4-flash', trust_remote_code=True)"

EXPOSE 8000

CMD ["vllm", "serve", "THUDM/glm-4-flash", \\
     "--host", "0.0.0.0", \\
     "--port", "8000", \
     "--tensor-parallel-size", "1", \\
     "--dtype", "float16", \
     "--trust-remote-code"]
```

Bauen und ausführen:

```bash
docker build -t glm-4.7-flash .
docker run --gpus all -p 8000:8000 glm-4.7-flash
```

## Beispiel für Codegenerierung

GLM-4.7-Flash glänzt bei komplexer Codegenerierung:

```python
from openai import OpenAI

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

response = client.chat.completions.create(
    model="glm-4.7-flash",
    messages=[
        {"role": "user", 
         "content": """Erstelle eine Python-Klasse für einen Rate-Limiter mit:
- Token-Bucket-Algorithmus
- Unterstützung für Async/Await  
- Redis-Backend
- Dekorator für die Begrenzung der Funktionsrate
- Geeignete Fehlerbehandlung"""}
    ],
    max_tokens=2048,
    temperature=0.3
)

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

## Tipps für Clore.ai-Nutzer

* **Speicheroptimierung**: Verwende `--dtype float16` um den VRAM-Verbrauch zu reduzieren. Für 16-GB-GPUs füge `--max-model-len 16384` hinzu, um den Kontext zu begrenzen.
* **Batch-Verarbeitung**: Erhöhe `--max-num-seqs` für höheren Durchsatz beim Bereitstellen mehrerer Anfragen.
* **Quantisierung**: Für RTX 3060/4060 (12 GB) verwende AWQ- oder GPTQ-quantisierte Versionen für einen VRAM-Verbrauch von \~6 GB.
* **Präemption**: GLM-4.7-Flash verarbeitet Unterbrechungen elegant — gut für vorzeitig beendbare Clore.ai-Instanzen.
* **Kontextlänge**: Der standardmäßige 128K-Kontext kann überdimensioniert sein. Setze `--max-model-len 32768` für die meisten Anwendungen.

## Fehlerbehebung

| Problem                     | Lösung                                                         |
| --------------------------- | -------------------------------------------------------------- |
| `OutOfMemoryError`          | Reduziere `--max-model-len` oder verwende `--dtype float16`    |
| Langsames Laden des Modells | Vorab cachen mit `huggingface-cli download THUDM/glm-4-flash`  |
| Importfehler                | Transformers aktualisieren: `pip install transformers>=4.40.0` |
| Schlechte Leistung          | Aktiviere Flash Attention: `pip install flash-attn`            |
| Verbindung abgelehnt        | Firewall prüfen: `ufw allow 8000`                              |

## Alternative Modelle

Wenn GLM-4.7-Flash deinen Anforderungen nicht entspricht:

* **Qwen2.5-Coder-7B**: Besser für reines Programmieren, kleinerer Speicherbedarf
* **CodeQwen1.5-7B**: Spezialist für Programmierung auf Chinesisch und Englisch
* **GLM-4-9B**: Größeres Schwestermodell mit besserem Schlussfolgern
* **DeepSeek-V3**: 671B MoE für maximale Leistung (Multi-GPU)

## Ressourcen

* [GLM-4-Flash auf Hugging Face](https://huggingface.co/THUDM/glm-4-flash)
* [GLM-4-Technischer Bericht](https://arxiv.org/abs/2406.12793)
* [vLLM-Dokumentation](https://docs.vllm.ai/)
* [SGLang GitHub](https://github.com/sgl-project/sglang)
* [Zhipu-AI-Plattform](https://open.bigmodel.cn/)


---

# 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/glm-47-flash.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.
