> 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

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

## Auf einen Blick

* **Modellgröße**: 30B insgesamt / 3B aktive Parameter (MoE)
* **Lizenz**: MIT (vollständig kommerziell)
* **Kontext**: 128K Tokens
* **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 schlägt weit über seinem Gewichtsklasse zu. Obwohl nur 3B aktive Parameter verwendet werden, übertrifft es viele 70B+ dichte Modelle bei Coding-Benchmarks. Die MoE-Architektur liefert 30B-Modellqualität zum Inferenzkosten-Niveau eines 7B-Modells.

**Einzel-GPU-freundlich**: Im Gegensatz zu massiven Modellen, die Multi-GPU-Setups benötigen, läuft GLM-4.7-Flash bequem auf einer einzelnen RTX 4090 oder A100 40GB. Das macht es perfekt für Entwicklung, Fine-Tuning und kosteneffiziente Produktionsbereitstellungen.

**Coding-Spezialist**: Mit 59,2% SWE-bench-Performance glänzt GLM-4.7-Flash bei Aufgaben des Software Engineerings — Code-Generierung, Debugging, Refactoring und technische Dokumentation. Es versteht über 20 Programmiersprachen mit hoher Kontextsensitivität.

**MIT-lizenziert**: Keine Nutzungsbeschränkungen. Kommerziell bereitstellen, fine-tunen oder modifizieren ohne Lizenzbedenken. Die vollständigen Gewichte und Trainingsrezepte sind frei verfügbar.

## GPU-Empfehlungen

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

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

\*Geschätzte Clore.ai-Marktplatzpreise

## Bereitstellung mit vLLM

### vLLM installieren

```bash
pip install vllm>=0.6.0
# oder neueste
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": "You are an expert Python developer."},
        {"role": "user", "content": "Write a FastAPI app with async SQLAlchemy and JWT auth"}
    ],
    max_tokens=2048,
    temperature=0.7
)

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

## Bereitstellung mit SGLang

SGLang bietet oft besseren Durchsatz für MoE-Modelle:

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

## Bereitstellung mit Ollama

Einfache Einrichtung für lokale Entwicklung:

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

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

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

# API-Modus
ollama serve
```

Dann über die REST-API abfragen:

```python
import requests

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

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

## Docker-Vorlage

```dockerfile
FROM nvidia/cuda:12.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 Code-Generierung

GLM-4.7-Flash glänzt bei komplexer Code-Generierung:

```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": """Create a Python class for a rate limiter with:
- Token bucket algorithm
- Async/await support  
- Redis backend
- Decorator for function rate limiting
- Proper error handling"""}
    ],
    max_tokens=2048,
    temperature=0.3
)

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

## Tipps für Clore.ai-Benutzer

* **Speicheroptimierung**: Verwenden Sie `--dtype float16` um den VRAM-Verbrauch zu reduzieren. Für 16GB-GPUs fügen Sie `--max-model-len 16384` hinzu, um den Kontext zu begrenzen.
* **Batch-Verarbeitung**: Erhöhen Sie `--max-num-seqs` für höheren Durchsatz beim Bedienen mehrerer Anfragen.
* **Quantisierung**: Für RTX 3060/4060 (12GB) verwenden Sie AWQ- oder GPTQ-quantisierte Versionen für \~6GB VRAM-Verbrauch.
* **Präemption**: GLM-4.7-Flash behandelt Unterbrechungen gracefully — gut für voremptible Clore.ai-Instanzen.
* **Kontextlänge**: Der Standardkontext von 128K kann übertrieben sein. Setzen Sie `--max-model-len 32768` für die meisten Anwendungen.

## Fehlerbehebung

| Problem               | Lösung                                                                |
| --------------------- | --------------------------------------------------------------------- |
| `OutOfMemoryError`    | Reduzieren Sie `--max-model-len` oder verwenden Sie `--dtype float16` |
| Langsames Modellladen | Vorkacheln mit `huggingface-cli download THUDM/glm-4-flash`           |
| Importfehler          | Transformers aktualisieren: `pip install transformers>=4.40.0`        |
| Schlechte Leistung    | Flash Attention aktivieren: `pip install flash-attn`                  |
| Verbindung verweigert | Firewall überprüfen: `ufw allow 8000`                                 |

## Alternative Modelle

Falls GLM-4.7-Flash nicht Ihren Bedürfnissen entspricht:

* **Qwen2.5-Coder-7B**: Besseres reines Coding, kleinerer Fußabdruck
* **CodeQwen1.5-7B**: Chinesisch + Englisch Coding-Spezialist
* **GLM-4-9B**: Größerer Verwandter mit besserem Reasoning
* **DeepSeek-V3**: 671B MoE für ultimative 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:

```
GET https://docs.clore.ai/guides/guides_v2-de/sprachmodelle/glm-47-flash.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.
