HN 日本語サマリー

← 一覧へ戻る
AI・機械学習

Unsloth GLM-5.2 – ローカルでの実行方法

Unsloth GLM-5.2 – How to Run Locally (unsloth.ai)

224 pointsby TechTechTech101 コメント

要約

Z.aiの新しいオープンモデルであるGLM-5.2は、長期間のコーディング、推論、エージェントタスクにおいてSOTA(State-of-the-Art)性能を発揮します。Unsloth Dynamic GGUFを使用することで、このモデルをローカルで実行できるようになり、動的量子化により必要なディスク容量が大幅に削減されます。Unsloth Studioまたはllama.cppを通じて、Claude 4.8 OpusやGPT-5.5などのトップモデルに匹敵する性能を持つGLM-5.2を手軽に利用できます。

全文翻訳

完全なドキュメントインデックスについては、llms.txtを参照してください。このページはMarkdown形式でも利用可能です。 GLM-5.2はZ.aiの新しいオープンモデルで、長期間にわたるコーディング、推論、エージェントタスクにおいてSOTA(State-of-the-Art)性能を発揮します。744Bのパラメータ、40Bのアクティブパラメータ、1Mのコンテキストウィンドウを備え、Unsloth Dynamic GGUFを使用してローカルで実行できるようになりました。GLM-5.2は、Artificial Analysisや他の多くのベンチマークにおいて、Claude 4.8 Opus、GPT-5.5、Gemini 3.1 Proに匹敵する性能を発揮する、現時点で最も強力なオープンモデルです。 フルモデルには1.51TBのディスクスペースが必要ですが、Unsloth Dynamic 2-bit GGUFは重要なレイヤーを8または16ビットにアップキャストすることで、これを239GB(-84%のサイズ)に削減します。Dynamic 1-bitはさらに217GB(-86%)まで削減します。Unslothにリリース初日からのアクセスを提供してくれたZ.aiに感謝します。 GLM-5.2-GGUF GLM-5.2チュートリアルを実行 量子化結果 ⚙️ 利用ガイド 2-bit動的量子化UD-IQ2_Mは239GBのディスクスペースを使用します。これは256GBのユニファイドメモリを持つMacに直接搭載でき、1x24GB GPUと256GBのRAMにMoEオフロードを組み合わせた環境で良好に動作します。1-bit量子化は223GBのRAMに、8-bit量子化は810GBのRAMに適合します。 表: 推論ハードウェア要件(単位 = 総メモリ: RAM + VRAM、またはユニファイドメモリ) 1-bit: 223 GB 2-bit: 245 GB 3-bit: 290-360 GB 4-bit: 372-475 GB 5-bit: 570 GB 8-bit: 810 GB 最高のパフォーマンスを得るためには、VRAMとシステムRAMを含む利用可能な総メモリが、量子化されたモデルファイルサイズを十分な余裕を持って上回っていることを確認してください。 推奨設定 GLM-5.2には3つの思考モードがあります。非思考モードと、HighおよびMaxの2つの思考モードです。複雑なタスクにはMax Thinkingを使用してください。Unsloth Studioでは、UIでHigh + Max Thinkingと非思考モードを簡単に切り替えることができます。 ほとんどのユースケースでこれらの設定を使用してください: デフォルト設定(ほとんどのタスク) temperature = 1.0 top_p = 0.95 SWE-Bench Pro temperature = 1.0 top_p = 1.0 最大コンテキストウィンドウ: 1,048,576。 GLM 5.2はデフォルトで思考モードを使用します。また、reasoning_effortとして「high」、「max」、または思考無効化をサポートしています。思考を無効にするには、--chat-template-kwargs '{"enable_thinking":false}'を使用してください。 Windows Powershellを使用している場合は、次のようにします: --chat-template-kwargs "{\"enable_thinking\":false}" 'true'と'false'は互換的に使用できます。 llama.cppでは、--reasoning onまたは--reasoning offも使用できるようになりました! 📈 量子化分析 GLM-5.2-GGUFの量子化精度を測定するために、KLD(KLダイバージェンス)も実行しました。一般的に、動的な4-bit UD-Q4_K_XLと動的な5-bit UD-Q5_K_XLはほぼロスレスであり、より小さな量子化でもうまく機能します! 純粋なトップ1%の精度では、動的な1-bitは約76.2%の精度を達成しつつ86%小さくなっています!動的な2-bitは約82%の精度を達成しつつ84%小さくなっています。 99.9%のKLDも一般的に良好ですが、4-bit以上ではより大きな向上が見られるため、大規模な分布外タスクでは動的な4-bitが最適である可能性が高いです。 平均KLDはディスクスペースに対して明確な単調な傾向を示しており、1-bitでもGLM 5.2がうまく機能することを示しています! GLM-5.2チュートリアルを実行: GLM-5.2はllama.cppとUnsloth Studioで実行できるようになりました。アクセス性と精度の面で最高の結果を得るために、239GBのUD-IQ2_M量子化を利用します。 🦥 Unsloth StudioでGLM-5.2を実行 GLM-5.2は、ローカルAI用のオープンソースWeb UIであるUnsloth Studioで実行できます。Unsloth Studioは自動的にRAMにオフロードし、マルチGPUセットアップを検出します。Unsloth Studioを使用すると、MacOS、Windows、Linuxでモデルをローカルで実行でき、さらに: GGUFおよびsafetensorモデルの検索、ダウンロード、実行 自己修復ツール呼び出し + ウェブ検索 コード実行(Python、Bash) 自動推論パラメータチューニング(温度、top-pなど) llama.cppを介した高速CPU + GPU推論 70%少ないVRAMでLLMを2倍高速にトレーニング 1 Unslothのインストールと起動 インストールするには、ターミナルで実行してください: MacOS, Linux, WSL: pip install unsloth studio Windows PowerShell: pip install unsloth studio Unslothの起動 MacOS, Linux, WSL, Windows: unsloth studio その後、ブラウザでhttp://127.0.0.1:8888(または特定のURL)を開いてください。 HTTPSとCloudflareでUnslothを安全に起動 新機能!Unslothは、無料のCloudflareトンネルを介してHTTPSでStudioを安全に起動する方法を提供します。以下を使用してください(Windows、Mac、Linuxで動作します): unsloth studio --cloudflare 2 GLM-5.2の検索とダウンロード Unsloth Studioは自動的にRAMにオフロードし、マルチGPUセットアップを検出します。初回起動時には、アカウントを保護するためにパスワードを作成し、後で再度サインインする必要があります。 その後、Studio Chatタブに移動し、検索バーでGLM-5.2を検索して、目的のモデルと量子化をダウンロードしてください。モデルを実行するのに十分な計算能力があることを確認してください。 3 GLM-5.2の実行 Unsloth Studioを使用する場合、推論パラメータは自動設定されるはずですが、手動で変更することもできます。また、コンテキスト長、チャットテンプレート、その他の設定も編集できます。 詳細については、Unsloth Studio推論ガイドを参照してください。 ツール呼び出しとSVG生成で動作する2-bit GLM-5.2の例。 🦥 llama.cppでGLM-5.2を実行 このガイドでは、少なくとも245GBのRAMが必要なUD-IQ2_M量子化を実行します。量子化タイプは自由に​​変更してください。これらのチュートリアルでは、高速なローカル推論のためにllama.cppを使用します。 GGUF: GLM-5.2-GGUF 1 最新のllama.cppをGitHubから入手してください。以下のビルド手順も参照できます。GPUがない場合、またはCPU推論のみを希望する場合は、-DGGML_CUDA=ONを-DGGML_CUDA=OFFに変更してください。Apple Mac / Metalデバイスの場合は、-DGGML_CUDA=OFFに設定してから通常どおり続行してください - Metalサポートはデフォルトでオンです。 2 ollama runのように、llama.cppを直接使用してモデルをロードおよびダウンロードできるようになりました。まず、UD-IQ2_Mのような目的の量子化タイプを選択します。また、llama.cppに特定の場所に保存させるために、export LLAMA_CACHE="unsloth/GLM-5.2-GGUF"を使用してください。このダウンロードプロセスは非常に遅い場合があるため、次のセクションの手動ダウンロードプロセスを使用するのがおそらく最善です。 3 モデルを手動でダウンロードしたい場合(はるかに高速です!)、以下のコード(pip install huggingface_hubをインストール後)でモデルをダウンロードできます。ダウンロードがスタックする場合は、以下を参照してください: Hugging Face Hub, XET debugging ```python from huggingface_hub import snapshot_download snapshot_download(repo_id="unsloth/GLM-5.2-GGUF", allow_patterns=["*UD-IQ2_M*.gguf"], local_dir="unsloth/GLM-5.2-GGUF") ``` 動的な1bitを使用したい場合は、次のようにします: ```python from huggingface_hub import snapshot_download snapshot_download(repo_id="unsloth/GLM-5.2-GGUF", allow_patterns=["*UD-IQ1_S*.gguf"], local_dir="unsloth/GLM-5.2-GGUF") ``` 4 その後、会話モードでモデルを実行します。2-bitの場合はunsloth/GLM-5.2-GGUF/UD-IQ2_M/GLM-5.2-UD-IQ2_M-00001-of-00006.ggufを、1-bitの場合はunsloth/GLM-5.2-GGUF/UD-IQ1_S/GLM-5.2-UD-IQ1_S-00001-of-00006.ggufを使用してください。 ```bash ./llama-cli -m unsloth/GLM-5.2-GGUF/UD-IQ2_M/GLM-5.2-UD-IQ2_M-00001-of-00006.gguf -ngl 9999 --temp 0.8 --top-p 0.9 --color --grammar-file grammars/chat.gbnf ``` 5 llama-cliを起動すると、次のように表示されます: ``` main: build = 2809 (b07b8b7e) main: seed = 1714881075 llama_model_loader: loaded meta data with 23 key-value pairs and 588 tensors from unsloth/GLM-5.2-GGUF/UD-IQ2_M/GLM-5.2-UD-IQ2_M-00001-of-00006.gguf (version GGUF V3 (latest)) llama_model_loader: - tensor 'token_emb.weight' is 49152 x 5120 ( 251.58 MB ) llama_model_loader: - tensor 'blk.0.attn_norm.weight' is 5120 ( 0.02 MB ) ... ``` その後、簡単なFlappy Birdゲームを作成するように指示すると、次のようになります: ``` Input: Write a short flappy bird game in HTML and Javascript. Okay, I can help you with that! Here's a basic Flappy Bird game using HTML, CSS, and JavaScript. I'll include the necessary elements, game logic, and a simple way to get started. First, let's create the `index.html` file: ```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Flappy Bird</title> <style> body { background-color: #70c5ce; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; overflow: hidden; font-family: Arial, sans-serif; } #game-container { width: 320px; height: 480px; background-color: #4ec0ca; border: 2px solid #333; position: relative; overflow: hidden; } #bird { width: 30px; height: 24px; background-color: yellow; position: absolute; left: 50px; top: 200px; border-radius: 50%; border: 2px solid orange; box-sizing: border-box; } .pipe { position: absolute; width: 50px; background-color: green; border: 2px solid darkgreen; box-sizing: border-box; } .pipe-top { top: 0; } .pipe-bottom { bottom: 0; } #score { position: absolute; top: 10px; left: 10px; font-size: 24px; color: white; text-shadow: 2px 2px #333; z-index: 10; } #start-screen { position: absolute; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.7); color: white; display: flex; flex-direction: column; justify-content: center; align-items: center; font-size: 20px; text-align: center; cursor: pointer; z-index: 20; } #game-over-screen { position: absolute; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.7); color: white; display: flex; flex-direction: column; justify-content: center; align-items: center; font-size: 20px; text-align: center; z-index: 20; display: none; /* Hidden initially */ } #game-over-screen button { margin-top: 20px; padding: 10px 20px; font-size: 18px; cursor: pointer; } </style> </head> <body> <div id="game-container"> <div id="score">Score: 0</div> <div id="bird"></div> <div id="start-screen">Click to Start!</div> <div id="game-over-screen"> Game Over!<br> Your Score: <span id="final-score">0</span><br> <button id="restart-button">Restart</button> </div> </div> <audio id="jumpSound" src="https://www.soundjay.com/buttons/sounds/button-2.mp3" preload="auto"></audio> <audio id="hitSound" src="https://www.soundjay.com/misc/sounds/fail-buzzer-01.mp3" preload="auto"></audio> <script> const gameContainer = document.getElementById('game-container'); const bird = document.getElementById('bird'); const scoreDisplay = document.getElementById('score'); const startScreen = document.getElementById('start-screen'); const gameOverScreen = document.getElementById('game-over-screen'); const finalScoreDisplay = document.getElementById('final-score'); const restartButton = document.getElementById('restart-button'); const jumpSound = document.getElementById('jumpSound'); const hitSound = document.getElementById('hitSound'); let birdLeft = 50; let birdBottom = 200; let gravity = 3; let isGameOver = false; let score = 0; let gap = 150; // Gap between pipes let gameTimerId; let pipes = []; function startGame() { birdBottom = 200; birdLeft = 50; score = 0; scoreDisplay.textContent = `Score: ${score}`; isGameOver = false; pipes.forEach(pipe => gameContainer.removeChild(pipe)); pipes = []; startScreen.style.display = 'none'; gameOverScreen.style.display = 'none'; bird.style.left = birdLeft + 'px'; bird.style.bottom = birdBottom + 'px'; gameTimerId = setInterval(gameLoop, 20); generatePipes(); } function gameLoop() { birdBottom -= gravity; bird.style.bottom = birdBottom + 'px'; if (birdBottom <= 0 || birdBottom >= gameContainer.clientHeight - bird.clientHeight) { gameOver(); } pipes.forEach(pipe => { pipe.style.left = (parseInt(pipe.style.left) - 2) + 'px'; if (pipe.left + pipe.clientWidth < birdLeft && !pipe.passed) { pipe.passed = true; score++; scoreDisplay.textContent = `Score: ${score}`; } if ( birdLeft < pipe.left + pipe.clientWidth && birdLeft + bird.clientWidth > pipe.left && (birdBottom < pipe.bottomHeight || birdBottom + bird.clientHeight > pipe.topHeight) ) { gameOver(); } if (parseInt(pipe.style.left) < -50) { gameContainer.removeChild(pipe); pipes = pipes.filter(p => p !== pipe); } }); } function control(e) { if (e.code === 'Space' && !isGameOver) { jump(); } } function jump() { if (birdBottom < 460) { birdBottom += 50; // Jump height bird.style.bottom = birdBottom + 'px'; jumpSound.play(); } } function generatePipes() { let pipeLeft = gameContainer.clientWidth; let randomHeight = Math.random() * (gameContainer.clientHeight - gap - 100) + 50; let pipeBottomHeight = randomHeight; let pipeTopHeight = gameContainer.clientHeight - randomHeight - gap; const pipeTop = document.createElement('div'); const pipeBottom = document.createElement('div'); pipeTop.classList.add('pipe', 'pipe-top'); pipeBottom.classList.add('pipe', 'pipe-bottom'); pipeTop.style.height = pipeTopHeight + 'px'; pipeBottom.style.height = pipeBottomHeight + 'px'; pipeTop.style.left = pipeLeft + 'px'; pipeBottom.style.left = pipeLeft + 'px'; gameContainer.appendChild(pipeTop); gameContainer.appendChild(pipeBottom); pipes.push({ top: pipeTop, bottom: pipeBottom, left: pipeLeft, topHeight: gameContainer.clientHeight - pipeTopHeight, bottomHeight: pipeBottomHeight, clientWidth: pipeTop.clientWidth, // All pipes have same width passed: false }); setTimeout(generatePipes, 3000); // Generate a new pipe every 3 seconds } function gameOver() { clearInterval(gameTimerId); hitSound.play(); isGameOver = true; document.removeEventListener('keydown', control); startScreen.removeEventListener('click', startGame); gameOverScreen.style.display = 'flex'; finalScoreDisplay.textContent = score; } startScreen.addEventListener('click', startGame); document.addEventListener('keydown', control); restartButton.addEventListener('click', startGame); </script> </body> </html> ``` 会話とゲームの全文は以下の通りです: HTMLのゲーム全文 会話全文 そしてゲームは音も出て見事に動作しました!これは1-bit量子化であったにもかかわらず、うまく機能しました! 📐KVキャッシュ量子化による長コンテキスト llama.cppで長コンテキストを利用するには、KVキャッシュ量子化を採用してメモリ使用量を削減する必要があります。最近、llama.cppはKVキャッシュ量子化の精度を高めるためのトリックを追加しました。これらや他のプルリクエストを参照してください! 現在、これらのKVキャッシュdtypesがサポートされています: f16 (デフォルト) q4_0 (約4.5ビット/重み) q4_1 (約5ビット/重み) q5_0 q5_1 q8_0 デフォルトではf16が使用されます。約4.5ビット/重みのq4_0を使用すると、約16 / 4.5 = 3.5倍長いコンテキスト長に拡張できます!したがって、モデルが以前10Kをサポートしていた場合、35Kが視野に入ります!q4_1は、シフトパラメータも得られるため、おそらくより優れており、5ビット/重みであるため、3.2倍長いコンテキストになります。 以下のように使用してください: ```bash ./llama-cli -m model.gguf --kv-cache-dtype q4_0 ``` 📊 ベンチマーク GLM-5.2のベンチマークは、以下の表形式でさらに詳しく見ることができます: ベンチマーク, GLM-5.2, Claude Opus 4.8, GPT-5.5, Gemini 3.1 Pro, GLM-5.1, Qwen3.7-Max, MiniMax M3, DeepSeek-V4-Pro 推論, , , , , , , HLE, 40.5, 49.8*, 41.4*, 45, 31, 41.4, 37, 37.7 HLE (w/ Tools), 54.7, 57.9*, 52.2*, 51.4*, 52.3, 53.5, -, 48.2 CritPt, 20.9, 20.9, 27.1, 17.7, 4.6, 13.4, 3.7, 12.9 AIME 2026, 99.2, 95.7, 98.3, 98.2, 95.3, 97, -, 94.6 HMMT Nov. 2025, 94.4, 96.5, 96.5, 94.8, 94, 95, 84.4, 94.4 HMMT Feb. 2026, 92.5, 96.7, 96.7, 87.3, 82.6, 97.1, 84.4, 95.2 IMOAnswerBench, 91.0, 83.5, -, 81, 83.8, 90, -, 89.8 GPQA-Diamond, 91.2, 93.6, 93.6, 94.3, 86.2, 90, 93, 90.1 コーディング, , , , , , , SWE-bench Pro, 62.1, 69.2, 58.6, 54.2, 58.4, 60.6, 59, 55.4 NL2Repo, 48.9, 69.7, 50.7, 33.4, 42.7, 47.2, 42.1, 35.5 DeepSWE, 46.2, 58, 70, 10, 18, 18, 20, 8 ProgramBench, 63.7, 71.9, 70.8, 39.5, 50.9, -, -, 47.8 Terminal Bench 2.1 (Terminus-2), 81.0, 85, 84, 74, 63.5, 75, 65, 64 Terminal Bench 2.1 (Best Reported Harness), 82.7, 78.9, 83.4, 70.7, 69, -, -, - FrontierSWE (Dominance), 74.4, 75.1, 72.6, 39.6, 30.5, -, -, 29.0 PostTrainBench, 34.3, 37.2, 28.4, 21.6, 20.1, -, -, - SWE-Marathon, 13.0, 26.0, 12.0, 4.0, 1.0, -, -, - エージェント, , , , , , , MCP-Atlas (Public Set), 76.8, 77.8, 75.3, 69.2, 71.8, 76.4, 74.2, 73.6 Tool-Decathlon, 48.2, 59.9, 55.6, 48.8, 40.7, -, -, 52.8 Previous: QwQ-32B Next: DiffusionGemma 最終更新: 6時間前 これは役に立ちましたか?