> For the complete documentation index, see [llms.txt](https://unsloth.ai/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://unsloth.ai/docs/de/modelle/tutorials/glm-4.7-flash.md).

# GLM-4.7-Flash: So wird es lokal ausgeführt

GLM-4.7-Flash ist Z.ais neues 30B-MoE-Reasoning-Modell, das für den lokalen Einsatz entwickelt wurde und erstklassige Leistung für Programmierung, agentische Workflows und Chats bietet. Es verwendet \~3,6 Mrd. Parameter, unterstützt einen Kontext von 200K und führt bei den Benchmarks SWE-Bench, GPQA sowie Reasoning/Chat.

GLM-4.7-Flash läuft auf **24 GB RAM**/VRAM/einheitlichem Speicher (32 GB für volle Präzision), und Sie können jetzt mit Unsloth feinabstimmen. Um GLM 4.7 Flash mit vLLM auszuführen, siehe [#glm-4.7-flash-in-vllm](#glm-4.7-flash-in-vllm "mention")

{% hint style="success" %}
Update vom 21. Jan.: `llama.cpp` einen Fehler behoben, bei dem der falsche `scoring_func`: `"softmax"` (sollte `"sigmoid"`sein). Dies führte zu Schleifen und schlechten Ausgaben. Wir haben die GGUFs aktualisiert - bitte laden Sie das Modell erneut herunter, um deutlich bessere Ausgaben zu erhalten.

Sie können jetzt die von Z.ai empfohlenen Parameter verwenden und großartige Ergebnisse erzielen:

* **Für allgemeine Anwendungsfälle:** `--temp 1.0 --top-p 0.95`
* **Für Tool-Calling:** `--temp 0.7 --top-p 1.0`
* **Wiederholungsstrafe:** Deaktivieren Sie sie oder setzen Sie `--repeat-penalty 1.0`

22\. Jan.: Schnelleres Inferenzverfahren ist da, da der FA-Fix für CUDA jetzt zusammengeführt wurde.
{% endhint %}

<a href="/pages/1e435114456bba34bc232a642cd33933aee06bbc#run-glm-4.7-flash" class="button primary">Ausführungstutorial</a><a href="/pages/1e435114456bba34bc232a642cd33933aee06bbc#fine-tuning-glm-4.7-flash" class="button secondary">Feinabstimmung</a>

GLM-4.7-Flash GGUF zum Ausführen: [unsloth/GLM-4.7-Flash-GGUF](https://huggingface.co/unsloth/GLM-4.7-Flash-GGUF)

### ⚙️ Gebrauchsanleitung

Für die beste Leistung stellen Sie sicher, dass Ihr gesamter verfügbarer Speicher (VRAM + Systemspeicher) die Größe der quantisierten Modelldatei übersteigt, die Sie herunterladen. Falls nicht, kann llama.cpp weiterhin über SSD/HDD-Offloading ausgeführt werden, aber die Inferenz wird langsamer.

Nach Rücksprache mit dem Team von Z.ai empfehlen sie die Verwendung ihrer GLM-4.7-Sampling-Parameter:

| Standardeinstellungen (die meisten Aufgaben)                       | Terminal Bench, SWE Bench Verified                                 |
| ------------------------------------------------------------------ | ------------------------------------------------------------------ |
| <mark style="background-color:green;">**temperature = 1.0**</mark> | <mark style="background-color:green;">**temperature = 0.7**</mark> |
| <mark style="background-color:green;">**top\_p = 0.95**</mark>     | <mark style="background-color:green;">**top\_p = 1.0**</mark>      |
| Wiederholungsstrafe = deaktiviert oder 1.0                         | Wiederholungsstrafe = deaktiviert oder 1.0                         |

* Für allgemeine Anwendungsfälle:  `--temp 1.0 --top-p 0.95`
* Für Tool-Calling:  `--temp 0.7 --top-p 1.0`
* Wenn Sie llama.cpp verwenden, setzen Sie `--min-p 0.01` da der Standardwert von llama.cpp 0,05 ist
* Manchmal müssen Sie ausprobieren, welche Werte für Ihren Anwendungsfall am besten funktionieren.

{% hint style="warning" %}
Für den Moment **empfehlen wir nicht** dieses GGUF mit **Ollama** auszuführen, da es potenzielle Kompatibilitätsprobleme mit dem Chat-Template geben kann. Das GGUF funktioniert gut mit llama.cpp (oder Backends wie LM Studio, Jan).

**Denken Sie daran, die Wiederholungsstrafe zu deaktivieren! Oder setzen Sie** `--repeat-penalty 1.0`
{% endhint %}

* **Maximales Kontextfenster:** `202,752`

### 🖥️ GLM-4.7-Flash ausführen

Je nach Ihrem Anwendungsfall müssen Sie unterschiedliche Einstellungen verwenden. Einige GGUFs enden in ähnlicher Größe, weil die Modellarchitektur (wie [gpt-oss](/docs/de/modelle/gpt-oss-how-to-run-and-fine-tune.md)) Dimensionen hat, die nicht durch 128 teilbar sind, sodass Teile nicht auf niedrigere Bits quantisiert werden können.

Da diese Anleitung 4-Bit verwendet, benötigen Sie etwa 18 GB RAM/einheitlichen Speicher. Wir empfehlen, mindestens 4-Bit-Präzision für die beste Leistung zu verwenden.

{% hint style="warning" %}
Für den Moment **empfehlen wir nicht** dieses GGUF mit **Ollama** auszuführen, da es potenzielle Kompatibilitätsprobleme mit dem Chat-Template geben kann. Das GGUF funktioniert gut mit llama.cpp (oder Backends wie LM Studio, Jan).

**Denken Sie daran, die Wiederholungsstrafe zu deaktivieren! Oder setzen Sie** `--repeat-penalty 1.0`
{% endhint %}

#### 🦥 Unsloth-Studio-Anleitung

GLM-4.7-Flash kann ausgeführt und feinabgestimmt werden in [Unsloth Studio](/docs/de/neu/studio.md), unserer neuen Open-Source-Web-UI für lokale KI. Mit Unsloth Studio können Sie Modelle lokal ausführen auf **MacOS, Windows**, Linux und:

{% columns %}
{% column %}

* Suchen, herunterladen, [GGUFs ausführen](/docs/de/neu/studio.md#run-models-locally) und Safetensor-Modelle
* [**Selbstheilendes** Tool-Calling](/docs/de/neu/studio.md#execute-code--heal-tool-calling) + **Websuche**
* [**Codeausführung**](/docs/de/neu/studio.md#run-models-locally) (Python, Bash)
* [Automatische Inferenz](/docs/de/neu/studio.md#model-arena) Parameterabstimmung (temp, top-p usw.)
* Schnelle CPU- + GPU-Inferenz über llama.cpp
* [LLMs trainieren](/docs/de/neu/studio.md#no-code-training) 2x schneller mit 70 % weniger VRAM
  {% endcolumn %}

{% column %}

<div data-with-frame="true"><figure><img src="/files/89ac45c1d5144736e3036cb7225d0c867534603a" alt=""><figcaption></figcaption></figure></div>
{% endcolumn %}
{% endcolumns %}

{% stepper %}
{% step %}
**Unsloth installieren**

Führe in deinem Terminal aus:

macOS, Linux, WSL:

```bash
curl -fsSL https://unsloth.ai/install.sh | sh
```

Windows PowerShell:

```bash
irm https://unsloth.ai/install.ps1 | iex
```

{% hint style="success" %}
**Die Installation ist schnell und dauert ca. 1–2 Minuten.**
{% endhint %}
{% endstep %}

{% step %}
**Unsloth starten**

MacOS, Linux, WSL und Windows:

```bash
unsloth studio -H 0.0.0.0 -p 8888
```

Dann öffnen Sie `http://localhost:8888` in deinem Browser.
{% endstep %}

{% step %}
**GLM-4.7-Flash suchen und herunterladen**

Beim ersten Start musst du ein Passwort erstellen, um dein Konto zu sichern, und dich später erneut anmelden. Danach siehst du einen kurzen Einrichtungsassistenten, um ein Modell, einen Datensatz und grundlegende Einstellungen auszuwählen. Du kannst ihn jederzeit überspringen.

Gehen Sie dann zur [Unsloth Chat](/docs/de/neu/studio/chat.md) Register und suche nach **GLM-4.7-Flash** in der Suchleiste und lade dein gewünschtes Modell und die gewünschte Quantisierung herunter.

<div data-with-frame="true"><figure><img src="/files/ab7f9fdce4489cfc90e0e2175e693856b2cef7be" alt="" width="375"><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}
**GLM-4.7-Flash ausführen**

Die Inferenzparameter sollten bei der Verwendung von Unsloth Studio automatisch gesetzt werden, du kannst sie jedoch weiterhin manuell ändern. Du kannst außerdem die Kontextlänge, die Chat-Vorlage und andere Einstellungen bearbeiten.

Für weitere Informationen können Sie unsere [Inferenzanleitung für Unsloth Studio](/docs/de/neu/studio/chat.md).

<div data-with-frame="true"><figure><img src="/files/72e444ba2ee0f824709d0f03d5c3ca108bd5936f" alt="" width="563"><figcaption></figcaption></figure></div>
{% endstep %}
{% endstepper %}

#### Llama.cpp-Tutorial (GGUF):

Anleitung zum Ausführen in llama.cpp (beachten Sie, dass wir 4-Bit verwenden werden, damit es auf die meisten Geräte passt):

{% stepper %}
{% step %}
Holen Sie sich die neueste `llama.cpp` ein [GitHub hier](https://github.com/ggml-org/llama.cpp). Sie können auch den untenstehenden Build-Anweisungen folgen. Ändern Sie `-DGGML_CUDA=ON` zu `-DGGML_CUDA=OFF` wenn Sie keine GPU haben oder nur CPU-Inferenz wünschen. **Für Apple-Mac-/Metal-Geräte**, setzen Sie `-DGGML_CUDA=OFF` und fahren Sie dann wie gewohnt fort - Metal-Unterstützung ist standardmäßig aktiviert.

{% code overflow="wrap" %}

```bash
apt-get update
apt-get install pciutils build-essential cmake curl libcurl4-openssl-dev -y
git clone https://github.com/ggml-org/llama.cpp
cmake llama.cpp -B llama.cpp/build \\
    -DBUILD_SHARED_LIBS=OFF -DGGML_CUDA=ON
cmake --build llama.cpp/build --config Release -j --clean-first --target llama-cli llama-mtmd-cli llama-server llama-gguf-split
cp llama.cpp/build/bin/llama-* llama.cpp
```

{% endcode %}
{% endstep %}

{% step %}
Sie können direkt von Hugging Face herunterladen. Sie können den Kontext auf 200K erhöhen, solange Ihr RAM/VRAM es zulässt.

Sie können auch die von Z.ai empfohlenen GLM-4.7-Sampling-Parameter ausprobieren:

* Für allgemeine Anwendungsfälle:  `--temp 1.0 --top-p 0.95`
* Für Tool-Calling:  `--temp 0.7 --top-p 1.0`
* **Denken Sie daran, die Wiederholungsstrafe zu deaktivieren!**

Folgen Sie dafür **allgemeine Instruktion** Anwendungsfälle:

```bash
./llama.cpp/llama-cli \\
    -hf unsloth/GLM-4.7-Flash-GGUF:UD-Q4_K_XL \\
    --ctx-size 16384 \\
    --temp 1.0 --top-p 0.95 --min-p 0.01
```

Folgen Sie dafür **Tool-Calling** Anwendungsfälle:

```bash
./llama.cpp/llama-cli \\
    -hf unsloth/GLM-4.7-Flash-GGUF:UD-Q4_K_XL \\
    --ctx-size 16384 \\
    --temp 0.7 --top-p 1.0 --min-p 0.01
```

{% endstep %}

{% step %}
Laden Sie das Modell über (nach der Installation von `pip install huggingface_hub`). Sie können wählen `UD-Q4_K_XL` oder andere quantisierte Versionen. Wenn Downloads hängen bleiben, siehe [Hugging Face Hub, XET-Debugging](/docs/de/grundlagen/troubleshooting-and-faqs/hugging-face-hub-xet-debugging.md)

{% code overflow="wrap" %}

```bash
pip install -U huggingface_hub
hf download unsloth/GLM-4.7-Flash-GGUF \\
    --local-dir unsloth/GLM-4.7-Flash-GGUF \\
    --include "*UD-Q2_K_XL*"
```

{% endcode %}
{% endstep %}

{% step %}
Dann führen Sie das Modell im Gesprächsmodus aus:

{% code overflow="wrap" %}

```bash
./llama.cpp/llama-cli \\
    --model unsloth/GLM-4.7-Flash-GGUF/GLM-4.7-Flash-UD-Q4_K_XL.gguf \\
    --ctx-size 16384 \\
    --seed 3407 \\
    --temp 1.0 \\
    --top-p 0.95 \\
    --min-p 0.01
```

{% endcode %}

Passen Sie außerdem **das Kontextfenster** wie erforderlich, bis zu `202752`
{% endstep %}
{% endstepper %}

### :loop:Wiederholungen und Schleifen reduzieren

{% hint style="success" %}
**UPDATE VOM 21. JAN.: llama.cpp hat einen Fehler behoben, der den falschen** `"scoring_func": "softmax"` **verursachte, was zu Schleifen und schlechten Ausgaben führte (sollte sigmoid sein). Wir haben die GGUFs aktualisiert. Bitte laden Sie das Modell erneut herunter, um deutlich bessere Ausgaben zu erhalten.**
{% endhint %}

Das bedeutet, dass Sie jetzt die von Z.ai empfohlenen Parameter verwenden und großartige Ergebnisse erzielen können:

* Für allgemeine Anwendungsfälle:  `--temp 1.0 --top-p 0.95`
* Für Tool-Calling:  `--temp 0.7 --top-p 1.0`
* Wenn Sie llama.cpp verwenden, setzen Sie `--min-p 0.01` da der Standardwert von llama.cpp 0,05 ist
* **Denken Sie daran, die Wiederholungsstrafe zu deaktivieren! Oder setzen Sie** `--repeat-penalty 1.0`

Wir haben hinzugefügt `"scoring_func": "sigmoid"` zu `config.json` für das Hauptmodell - [siehe](https://huggingface.co/unsloth/GLM-4.7-Flash/commit/3fd53b491e04f707f307aef2f70f8a7520511e6d).

{% hint style="warning" %}
Für den Moment **empfehlen wir nicht** dieses GGUF mit **Ollama** auszuführen, da es potenzielle Kompatibilitätsprobleme mit dem Chat-Template geben kann. Das GGUF funktioniert gut mit llama.cpp (oder Backends wie LM Studio, Jan).
{% endhint %}

### :bird:Flappy-Bird-Beispiel mit UD-Q4\_K\_XL

Als Beispiel haben wir den folgenden langen Dialog mithilfe von UD-Q4\_K\_XL über `./llama.cpp/llama-cli --model unsloth/GLM-4.7-Flash-GGUF/GLM-4.7-Flash-UD-Q4_K_XL.gguf --fit on --temp 1.0 --top-p 0.95 --min-p 0.01` :

```
Hallo
Was ist 2+2
Erstelle ein Python-Flappy-Bird-Spiel
Erstelle ein völlig anderes Spiel in Rust
Finde Fehler in beiden
Mache das zuerst erwähnte Spiel, aber in einer eigenständigen HTML-Datei
Finde Fehler und zeige das korrigierte Spiel
```

wodurch das folgende Flappy-Bird-Spiel in HTML-Form gerendert wurde:

<details>

<summary>Flappy-Bird-Spiel in HTML (Erweiterbar)</summary>

```html
<!DOCTYPE html>
<html lang="de">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>Flappy Bird behoben</title>
    <style>
        body {
            margin: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            background-color: #222;
            font-family: 'Arial', sans-serif;
            overflow: hidden;
            user-select: none;
            -webkit-user-select: none;
            touch-action: none; /* Verhindert Zoomen auf Mobilgeräten */
        }

        #game-container {
            position: relative;
            box-shadow: 0 0 20px rgba(0,0,0,0.5);
        }

        canvas {
            background-color: #87CEEB;
            display: block;
            border-radius: 4px;
        }

        /* UI-Überlagerungen */
        #ui-layer {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            text-align: center;
        }

        #score-display {
            position: absolute;
            top: 40px;
            left: 50%;
            transform: translateX(-50%);
            font-size: 48px;
            font-weight: bold;
            color: white;
            text-shadow: 3px 3px 0 #000;
            z-index: 10;
            font-family: 'Courier New', Courier, monospace;
        }

        #start-screen, #game-over-screen {
            background: rgba(0, 0, 0, 0.7);
            width: 100%;
            height: 100%;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            color: white;
            pointer-events: auto; /* Klicks erlauben */
            cursor: pointer;
        }

        h1 { margin: 0 0 10px 0; font-size: 60px; text-shadow: 4px 4px 0 #000; line-height: 1; }
        p { font-size: 22px; margin: 10px 0; color: #ddd; }
        
        .btn {
            background: linear-gradient(to bottom, #ffeb3b, #fbc02d);
            border: 3px solid #fff;
            color: #333;
            padding: 15px 40px;
            font-size: 28px;
            font-weight: bold;
            cursor: pointer;
            border-radius: 8px;
            box-shadow: 0 6px 0 #c49000, 0 10px 10px rgba(0,0,0,0.3);
            text-transform: uppercase;
            transition: all 0.1s;
            margin-top: 10px;
        }

        .btn:active {
            transform: translateY(4px);
            box-shadow: 0 2px 0 #c49000, 0 4px 4px rgba(0,0,0,0.3);
        }

        .score-board {
            background: #ded895;
            border: 2px solid #543847;
            padding: 20px 40px;
            border-radius: 10px;
            box-shadow: 4px 4px 0 #543847;
            margin-bottom: 30px;
            display: none;
            border: 4px solid #543847;
        }
        
        .score-board h2 { margin: 0 0 5px 0; color: #e86101; font-size: 40px; }
        .score-board span { font-size: 20px; color: #543847; display: block; text-align: center; }

    </style>
</head>
<body>

    <div id="game-container">
        <canvas id="gameCanvas" width="400" height="600"></canvas>
        
        <div id="score-display">0</div>

        <div id="ui-layer">
            <div id="start-screen">
                <h1>FLAPPY<br>BIRD</h1>
                <p>Tippen oder Leertaste drücken zum Starten</p>
                <button class="btn" style="display:none;" id="touch-instruction">Zum Starten klicken</button>
            </div>

            <div id="game-over-screen">
                <h1>SPIEL VORBEI</h1>
                <div class="score-board" id="score-board">
                    <h2>Punktestand: <span id="final-score">0</span></h2>
                </div>
                <button class="btn" id="restart-btn">Nochmal versuchen</button>
            </div>
        </div>
    </div>

<script>
    const canvas = document.getElementById('gameCanvas');
    const ctx = canvas.getContext('2d');

    // --- Konstanten ---
    const GRAVITY = 0.35; // Etwas stärkere Schwerkraft für ein besseres Gefühl
    const JUMP_STRENGTH = -6.5;
    const PIPE_GAP = 180;
    const PIPE_WIDTH = 60;
    const PIPE_SPEED = 2.5;
    const PIPE_SPAWN_RATE = 100;

    // --- Zustand ---
    let frames = 0;
    let score = 0;
    let isGameOver = false;
    let isPlaying = false;
    let gameLoopId;

    const ui = {
        startScreen: document.getElementById('start-screen'),
        gameOverScreen: document.getElementById('game-over-screen'),
        scoreDisplay: document.getElementById('score-display'),
        scoreBoard: document.getElementById('score-board'),
        finalScore: document.getElementById('final-score'),
        restartBtn: document.getElementById('restart-btn')
    };

    const bird = {
        x: 80,
        y: 150,
        radius: 12, // Fester Radius
        velocity: 0,
        
        draw: function() {
            // Dreht den Vogel basierend auf der Geschwindigkeit für visuelles Flair
            let angle = Math.min(Math.PI / 4, Math.max(-Math.PI / 4, (this.velocity * 0.1)));
            
            ctx.save();
            ctx.translate(this.x, this.y);
            ctx.rotate(angle);
            
            // Körper zeichnen
            ctx.fillStyle = '#FFD700';
            ctx.beginPath();
            ctx.arc(0, 0, this.radius, 0, Math.PI * 2);
            ctx.fill();
            
            // Auge
            ctx.fillStyle = 'white';
            ctx.beginPath();
            ctx.arc(4, -4, 4, 0, Math.PI * 2);
            ctx.fill();
            ctx.fillStyle = 'black';
            ctx.beginPath();
            ctx.arc(6, -4, 2, 0, Math.PI * 2);
            ctx.fill();
            
            // Flügel
            ctx.fillStyle = '#FFA500';
            ctx.beginPath();
            ctx.arc(-4, 4, 5, 0, Math.PI * 2);
            ctx.fill();

            ctx.restore();
        },

        update: function() {
            this.velocity += GRAVITY;
            this.y += this.velocity;
        },

        jump: function() {
            this.velocity = JUMP_STRENGTH;
        },

        reset: function() {
            this.y = 150;
            this.velocity = 0;
        }
    };

    let pipes = [];

    function createPipe() {
        const minHeight = 50;
        const maxPos = canvas.height - PIPE_GAP - minHeight;
        const topHeight = Math.floor(Math.random() * (maxPos - minHeight + 1)) + minHeight;
        
        pipes.push({
            x: canvas.width,
            topHeight: topHeight,
            bottomY: topHeight + PIPE_GAP,
            width: PIPE_WIDTH,
            passed: false
        });
    }

    function drawPipes() {
        ctx.fillStyle = '#2ecc71';
        ctx.strokeStyle = '#27ae60';
        ctx.lineWidth = 2;
        
        pipes.forEach(pipe => {
            // Oberes Rohr
            ctx.fillRect(pipe.x, 0, pipe.width, pipe.topHeight);
            ctx.strokeRect(pipe.x, 0, pipe.width, pipe.topHeight);
            
            // Unteres Rohr
            ctx.fillRect(pipe.x, pipe.bottomY, pipe.width, canvas.height - pipe.bottomY);
            ctx.strokeRect(pipe.x, pipe.bottomY, pipe.width, canvas.height - pipe.bottomY);

            // Kappe
            const capH = 20;
            ctx.fillStyle = '#27ae60'; 
            ctx.fillRect(pipe.x - 2, pipe.topHeight - capH, pipe.width + 4, capH);
            ctx.fillRect(pipe.x - 2, pipe.bottomY, pipe.width + 4, capH);
        });
    }

    function updatePipes() {
        if (frames % PIPE_SPAWN_RATE === 0) createPipe();

        for (let i = 0; i < pipes.length; i++) {
            let p = pipes[i];
            p.x -= PIPE_SPEED;

            // --- KORRIGIERTE KOLLISIONSERKENNUNG ---
            // Den Vogel als Kreis mit Radius 'bird.radius' behandeln
            // Rohr ist ein Rechteck: x, x+w, y_oben, y_unten
            let birdLeft = bird.x - bird.radius;
            let birdRight = bird.x + bird.radius;
            let birdTop = bird.y - bird.radius;
            let birdBottom = bird.y + bird.radius;

            // Horizontale Überlappung
            if (birdRight > p.x && birdLeft < p.x + p.width) {
                // Vertikale Überlappung (oberen Rohrteil treffen ODER unteren Rohrteil treffen)
                if (birdTop < p.topHeight || birdBottom > p.bottomY) {
                    gameOver();
                }
            }

            // --- KORRIGIERTE PUNKTZAHLUNG ---
            // Wenn das Rohr links aus dem Bildschirm ist und noch nicht gewertet wurde
            if (p.x + p.width < 0 && !p.passed) {
                score++;
                p.passed = true;
                ui.scoreDisplay.innerText = score;
            }

            if (p.x < -60) {
                pipes.shift();
                i--;
            }
        }
    }

    function checkCollisions() {
        // Boden
        if (bird.y + bird.radius >= canvas.height) {
            gameOver();
        }
        // Decke
        if (bird.y - bird.radius <= 0) {
            bird.y = bird.radius;
            bird.velocity = 0;
        }
    }

    function drawBackground() {
        // Löschen
        ctx.clearRect(0, 0, canvas.width, canvas.height);
        
        // Boden
        ctx.fillStyle = '#654321';
        ctx.fillRect(0, canvas.height - 10, canvas.width, 10);
        
        // Wolken
        ctx.fillStyle = "rgba(255, 255, 255, 0.6)";
        for(let i=0; i<4; i++) {
            let x = (frames * 0.5 + i * 150) % (canvas.width + 100) - 50;
            let y = (i * 40) + 20;
            let scale = 1 + (Math.sin(frames * 0.02 + i) * 0.1);
            let size = 30 * scale;
            ctx.beginPath();
            ctx.arc(x, y, size, 0, Math.PI * 2);
            ctx.arc(x + 20*scale, y - 10*scale, size * 1.2, 0, Math.PI * 2);
            ctx.arc(x + 40*scale, y, size, 0, Math.PI * 2);
            ctx.fill();
        }
    }

    function update() {
        if (!isPlaying) return;
        bird.update();
        updatePipes();
        checkCollisions();
        frames++;
    }

    function draw() {
        drawBackground();
        drawPipes();
        bird.draw();
    }

    function loop() {
        update();
        draw();
        if (isPlaying || !isGameOver) {
            gameLoopId = requestAnimationFrame(loop);
        }
    }

    function startGame() {
        isPlaying = true;
        isGameOver = false;
        
        // UI
        ui.startScreen.style.display = 'none';
        ui.gameOverScreen.style.display = 'none';
        ui.scoreBoard.style.display = 'none';
        
        // Logik
        bird.reset();
        pipes = [];
        score = 0;
        frames = 0;
        ui.scoreDisplay.innerText = '0';
        
        loop();
    }

    function gameOver() {
        isPlaying = false;
        isGameOver = true;
        cancelAnimationFrame(gameLoopId);
        
        ui.finalScore.innerText = score;
        ui.gameOverScreen.style.display = 'flex';
        ui.scoreBoard.style.display = 'block';
    }

    // --- Eingabebehandlung ---

    function handleInput(e) {
        if (e.type === 'keydown' && e.code === 'Space') e.preventDefault();

        if (isPlaying) {
            bird.jump();
        } else if (!isGameOver) {
            // Klick auf den Startbildschirm (oder irgendein Klick, wenn das Spiel noch nicht gestartet wurde)
            startGame();
        }
    }

    // Tastatur
    window.addEventListener('keydown', (e) => {
        if (e.code === 'Space') handleInput(e);
    });

    // Maus / Touch
    window.addEventListener('mousedown', handleInput);
    window.addEventListener('touchstart', (e) => {
        // Zoomen/Scrollen verhindern
        // e.preventDefault(); 
        handleInput(e);
    }, {passive: false});

    // UI-Interaktionen
    ui.restartBtn.addEventListener('click', (e) => {
        e.stopPropagation();
        startGame();
    });
    
    // Das Game-Over-Overlay anklicken, um neu zu starten
    ui.gameOverScreen.addEventListener('mousedown', (e) => {
        if(e.target === ui.gameOverScreen) startGame();
    });
    ui.gameOverScreen.addEventListener('touchstart', (e) => {
        if(e.target === ui.gameOverScreen) {
            e.preventDefault();
            startGame();
        }
    });

    // Erstzeichnung
    drawBackground();
    bird.reset();
    bird.draw();

</script>
</body>
</html>
```

</details>

Und wir haben einige Screenshots gemacht (4-bit funktioniert):

<div align="left"><figure><img src="/files/b62a6798dffa6d69b0c5e5156077a477da8bf73a" alt="" width="188"><figcaption></figcaption></figure> <figure><img src="/files/9c5189a382be6d4c2a867faff1c4c5f77e69ddbf" alt="" width="188"><figcaption></figcaption></figure></div>

### 🦥 Feinabstimmung von GLM-4.7-Flash

Unsloth unterstützt jetzt die Feinabstimmung von GLM-4.7-Flash, allerdings müssen Sie `transformers v5`verwenden. Das 30B-Modell passt nicht auf eine kostenlose Colab-GPU; Sie können jedoch unser Notebook verwenden. 16-Bit-LoRA-Feinabstimmung von GLM-4.7-Flash benötigt etwa **60 GB VRAM**:

* [GLM-4.7-Flash SFT LoRA-Notebook](https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/GLM_Flash_A100\(80GB\).ipynb)

{% hint style="warning" %}
Beim Verwenden einer A100 mit 40 GB VRAM kann es manchmal zu Speicherfehlern kommen. Für reibungslosere Läufe müssen Sie H100/A100 mit 80 GB VRAM verwenden.
{% endhint %}

{% embed url="<https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/GLM_Flash_A100(80GB).ipynb>" %}

Beim Feinabstimmen von MoEs ist es wahrscheinlich keine gute Idee, die Router-Schicht feinabzustimmen, daher haben wir sie standardmäßig deaktiviert. Wenn Sie seine Reasoning-Fähigkeiten erhalten möchten (optional), können Sie eine Mischung aus direkten Antworten und Chain-of-Thought-Beispielen verwenden. Verwenden Sie mindestens <mark style="background-color:green;">75 % Reasoning</mark> und <mark style="background-color:green;">25 % ohne Reasoning</mark> damit das Modell seine Reasoning-Fähigkeiten behält.

### 🦙 Llama-Server-Serving & Deployment

Um GLM-4.7-Flash für den Produktionseinsatz bereitzustellen, verwenden wir `llama-server` Öffnen Sie in einem neuen Terminal, z. B. via tmux, die Bereitstellung des Modells mit:

{% code overflow="wrap" %}

```bash
./llama.cpp/llama-server \\
    --model unsloth/GLM-4.7-Flash-GGUF/GLM-4.7-Flash-UD-Q4_K_XL.gguf \\
    --alias "unsloth/GLM-4.7-Flash" \\
    --seed 3407 \\
    --temp 1.0 \\
    --top-p 0.95 \\
    --min-p 0.01 \
    --ctx-size 16384 \\
    --port 8001
```

{% endcode %}

Dann in einem neuen Terminal, nachdem Sie `pip install openai`, führen Sie Folgendes aus:

{% code overflow="wrap" %}

```python
from openai import OpenAI
import json
openai_client = OpenAI(
    base_url = "http://127.0.0.1:8001/v1",
    api_key = "sk-no-key-required",
)
completion = openai_client.chat.completions.create(
    model = "unsloth/GLM-4.7-Flash",
    messages = [{"role": "user", "content": "Was ist 2+2?"},],
)
print(completion.choices[0].message.content)
```

{% endcode %}

Was Folgendes ausgibt

{% code overflow="wrap" %}

```
Der Benutzer stellt eine einfache Frage: "Was ist 2+2?" Die Antwort ist 4. Geben Sie die Antwort aus.

2 + 2 = 4.
```

{% endcode %}

### :computer: GLM-4.7-Flash in vLLM

Du kannst jetzt unsere neue [FP8-Dynamic-Quantisierung](https://huggingface.co/unsloth/GLM-4.7-Flash-FP8-Dynamic) des Modells für hochwertige und schnelle Inferenz. Installieren Sie zuerst vLLM aus dem Nightly-Build:

{% code overflow="wrap" %}

```bash
uv pip install --upgrade --force-reinstall vllm --torch-backend=auto --extra-index-url https://wheels.vllm.ai/nightly/cu130
uv pip install --upgrade --force-reinstall git+https://github.com/huggingface/transformers.git
uv pip install --force-reinstall numba
```

{% endcode %}

Dann bereitstellen [Unsloths dynamische FP8-Version](https://huggingface.co/unsloth/GLM-4.7-Flash-FP8-Dynamic) des Modells. Wir haben FP8 aktiviert, um die Speichernutzung des KV-Caches um 50 % zu reduzieren, und zwar auf 4 GPUs. Wenn Sie 1 GPU haben, verwenden Sie `CUDA_VISIBLE_DEVICES='0'` und setze `--tensor-parallel-size 1` oder entfernen Sie dieses Argument. Um FP8 zu deaktivieren, entfernen Sie `--quantization fp8 --kv-cache-dtype fp8`

```bash
export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:False
CUDA_VISIBLE_DEVICES='0,1,2,3' vllm serve unsloth/GLM-4.7-Flash-FP8-Dynamic \\
    --served-model-name unsloth/GLM-4.7-Flash \\
    --tensor-parallel-size 4 \\
    --tool-call-parser glm47 \\
    --reasoning-parser glm45 \\
    --enable-auto-tool-choice \\
    --dtype bfloat16 \\
    --seed 3407 \\
    --max-model-len 200000 \\
    --gpu-memory-utilization 0.95 \\
    --max_num_batched_tokens 16384 \\
    --port 8001 \\
    --kv-cache-dtype fp8
```

Du kannst das bereitgestellte Modell dann über die OpenAI-API aufrufen:

```python
from openai import AsyncOpenAI, OpenAI
openai_api_key = "EMPTY"
openai_api_base = "http://localhost:8001/v1"
client = OpenAI( # oder AsyncOpenAI
    api_key=openai_api_key,
    base_url=openai_api_base,
)
```

#### :star: Spekulative Dekodierung von vLLM GLM-4.7-Flash

Wir haben festgestellt, dass die Verwendung des MTP-Moduls (Multi-Token Prediction) von GLM 4.7 Flash den Generierungsdurchsatz von 13.000 Tokens auf 1 B200 auf 1.300 Tokens senkt! (10x langsamer) Auf Hopper sollte es hoffentlich in Ordnung sein.

```bash
    --speculative-config.method mtp \\
    --speculative-config.num_speculative_tokens 1
```

Nur 1.300 Tokens/s Durchsatz auf 1xB200 (130 Tokens/s Decoding pro Nutzer)

<figure><img src="/files/aa4355a18b5958bb0932d9f77b8931d39c71e469" alt=""><figcaption></figcaption></figure>

Und 13.000 Tokens/s Durchsatz auf 1xB200 (immer noch 130 Tokens/s Decoding pro Nutzer)

<figure><img src="/files/b3accc916b22880daa1d0df18a4f768a5aae404c" alt=""><figcaption></figcaption></figure>

### :hammer:Tool-Calling mit GLM-4.7-Flash

Siehe [Tool Calling Guide](/docs/de/grundlagen/tool-calling-guide-for-local-llms.md) für weitere Details dazu, wie Tool-Calling funktioniert. In einem neuen Terminal (wenn Sie tmux verwenden, nutzen Sie CTRL+B+D), erstellen wir einige Tools wie das Addieren von 2 Zahlen, das Ausführen von Python-Code, das Ausführen von Linux-Funktionen und vieles mehr:

{% code expandable="true" %}

```python
import json, subprocess, random
from typing import Any
def add_number(a: float | str, b: float | str) -> float:
    return float(a) + float(b)
def multiply_number(a: float | str, b: float | str) -> float:
    return float(a) * float(b)
def subtract_number(a: float | str, b: float | str) -> float:
    return float(a) - float(b)
def write_a_story() -> str:
    return random.choice([
        "Vor langer, langer Zeit in einer weit, weit entfernten Galaxie...",
        "Es gab 2 Freunde, die Faultiere und Code liebten...",
        "Die Welt ging unter, weil sich jedes Faultier zu übermenschlicher Intelligenz entwickelte...",
        "Ohne dass es ein Freund wusste, programmierte der andere versehentlich ein Programm, um Faultiere weiterzuentwickeln...",
    ])
def terminal(command: str) -> str:
    if "rm" in command or "sudo" in command or "dd" in command or "chmod" in command:
        msg = "Die Befehle 'rm, sudo, dd, chmod' können nicht ausgeführt werden, da sie gefährlich sind"
        print(msg); return msg
    print(f"Führe Terminalbefehl `{command}` aus")
    try:
        return str(subprocess.run(command, capture_output = True, text = True, shell = True, check = True).stdout)
    except subprocess.CalledProcessError as e:
        return f"Befehl fehlgeschlagen: {e.stderr}"
def python(code: str) -> str:
    data = {}
    exec(code, data)
    del data["__builtins__"]
    return str(data)
MAP_FN = {
    "add_number": add_number,
    "multiply_number": multiply_number,
    "subtract_number": subtract_number,
    "write_a_story": write_a_story,
    "terminal": terminal,
    "python": python,
}
tools = [
    {
        "type": "function",
        "function": {
            "name": "add_number",
            "description": "Addieren Sie zwei Zahlen.",
            "parameters": {
                "type": "object",
                "properties": {
                    "a": {
                        "type": "string",
                        "description": "Die erste Zahl.",
                    },
                    "b": {
                        "type": "string",
                        "description": "Die zweite Zahl.",
                    },
                },
                "required": ["a", "b"],
            },
        },
    },
    {
        "type": "function",
        "function": {
            "name": "multiply_number",
            "description": "Multipliziert zwei Zahlen.",
            "parameters": {
                "type": "object",
                "properties": {
                    "a": {
                        "type": "string",
                        "description": "Die erste Zahl.",
                    },
                    "b": {
                        "type": "string",
                        "description": "Die zweite Zahl.",
                    },
                },
                "required": ["a", "b"],
            },
        },
    },
    {
        "type": "function",
        "function": {
            "name": "subtract_number",
            "description": "Subtrahiert zwei Zahlen.",
            "parameters": {
                "type": "object",
                "properties": {
                    "a": {
                        "type": "string",
                        "description": "Die erste Zahl.",
                    },
                    "b": {
                        "type": "string",
                        "description": "Die zweite Zahl.",
                    },
                },
                "required": ["a", "b"],
            },
        },
    },
    {
        "type": "function",
        "function": {
            "name": "write_a_story",
            "description": "Schreibt eine zufällige Geschichte.",
            "parameters": {
                "type": "object",
                "properties": {},
                "required": [],
            },
        },
    },
    {
        "type": "function",
        "function": {
            "name": "terminal",
            "description": "Führt Operationen vom Terminal aus.",
            "parameters": {
                "type": "object",
                "properties": {
                    "command": {
                        "type": "string",
                        "description": "Der Befehl, den Sie ausführen möchten, z. B. `ls`, `rm`, ...",
                    },
                },
                "required": ["command"],
            },
        },
    },
    {
        "type": "function",
        "function": {
            "name": "python",
            "description": "Ruft einen Python-Interpreter mit etwas Python-Code auf, der ausgeführt wird.",
            "parameters": {
                "type": "object",
                "properties": {
                    "code": {
                        "type": "string",
                        "description": "Der auszuführende Python-Code",
                    },
                },
                "required": ["code"],
            },
        },
    },
]
```

{% endcode %}

Wir verwenden dann die folgenden Funktionen (kopieren, einfügen und ausführen), die die Funktionsaufrufe automatisch parsen und für jedes Modell den OpenAI-Endpunkt aufrufen:

{% code overflow="wrap" expandable="true" %}

```python
from openai import OpenAI
def unsloth_inference(
    messages,
    temperature = 0.7,
    top_p = 1.0,
    top_k = -1,
    repetition_penalty = 0.0,
):
    messages = messages.copy()
    openai_client = OpenAI(
        base_url = "http://127.0.0.1:8001/v1",
        api_key = "sk-no-key-required",
    )
    model_name = next(iter(openai_client.models.list())).id
    print(f"Verwende Modell = {model_name}")
    has_tool_calls = True
    original_messages_len = len(messages)
    while has_tool_calls:
        print(f"Aktuelle Nachrichten = {messages}")
        response = openai_client.chat.completions.create(
            model = model_name,
            messages = messages,
            temperature = temperature,
            top_p = top_p,
            tools = tools if tools else None,
            tool_choice = "auto" if tools else None,
            extra_body = {"top_k": top_k, "min_p": min_p, "dry_multiplier" :repetition_penalty,}
        )
        tool_calls = response.choices[0].message.tool_calls or []
        content = response.choices[0].message.content or ""
        tool_calls_dict = [tc.to_dict() for tc in tool_calls] if tool_calls else tool_calls
        messages.append({"role": "assistant", "tool_calls": tool_calls_dict, "content": content,})
        for tool_call in tool_calls:
            fx, args, _id = tool_call.function.name, tool_call.function.arguments, tool_call.id
            out = MAP_FN[fx](**json.loads(args))
            messages.append({"role": "tool", "tool_call_id": _id, "name": fx, "content": str(out),})
        else:
            has_tool_calls = False
    return messages
```

{% endcode %}

Nach dem Start von GLM-4.7-Flash über `llama-server` wie in [#deploy-with-llama-server-and-openais-completion-library](#deploy-with-llama-server-and-openais-completion-library "mention") oder siehe [Tool Calling Guide](/docs/de/grundlagen/tool-calling-guide-for-local-llms.md) für weitere Details können wir dann einige Tool-Aufrufe durchführen:

**Tool-Aufruf für mathematische Operationen für GLM 4.7**

{% code overflow="wrap" %}

```python
messages = [{
    "role": "user",
    "content": [{"type": "text", "text": "Wie lautet das heutige Datum plus 3 Tage?"}],
}]
unsloth_inference(messages, temperature = 1.0, top_p = 0.95, top_k = -1, min_p = 0.01)
```

{% endcode %}

<figure><img src="/files/c65584a6dcba3fae024e43a1e2819019446b8023" alt=""><figcaption></figcaption></figure>

**Tool-Aufruf zum Ausführen des generierten Python-Codes für GLM-4.7-Flash**

{% code overflow="wrap" %}

```python
messages = [{
    "role": "user",
    "content": [{"type": "text", "text": "Erstelle eine Fibonacci-Funktion in Python und berechne fib(20)."}],
}]
unsloth_inference(messages, temperature = 1.0, top_p = 0.95, top_k = -1, min_p = 0.01)
```

{% endcode %}

<figure><img src="/files/e56652f7cfccb3876e702100b6ffb2e6b9d1ea97" alt="" width="563"><figcaption></figcaption></figure>

### Benchmarks

GLM-4.7-Flash ist das leistungsstärkste 30B-Modell über alle Benchmarks hinweg, außer AIME 25.

<figure><img src="/files/4ce31a24f8b6892eda5e7d0d531f69eaddeddad1" alt="" width="375"><figcaption></figcaption></figure>

| Benchmark          | GLM-4.7-Flash | Qwen3-30B-A3B-Thinking-2507 | GPT-OSS-20B |
| ------------------ | ------------- | --------------------------- | ----------- |
| AIME 25            | 91.6          | 85.0                        | 91.7        |
| GPQA               | 75.2          | 73.4                        | 71.5        |
| LCB v6             | 64.0          | 66.0                        | 61.0        |
| HLE                | 14.4          | 9.8                         | 10.9        |
| SWE-bench Verified | 59.2          | 22.0                        | 34.0        |
| τ²-Bench           | 79.5          | 49.0                        | 47.7        |
| BrowseComp         | 42.8          | 2.29                        | 28.3        |


---

# 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://unsloth.ai/docs/de/modelle/tutorials/glm-4.7-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.
