Обзор семейства
GLM (General Language Model) — архитектура от команды THUDM (Цинхуа) и коммерческого проекта Z.ai. Главная идея: объединить лучшие свойства авторегрессионных и автокодирующих моделей через специальную маску внимания (blank filling + autoregressive).
Ключевая фишка — нативный function calling: модель обучена выдавать вызовы инструментов в структурированном формате без промпт-инжиниринга и пост-обработки. Это даёт более надёжный tool use, чем у большинства открытых моделей.
Открытая версия GLM-4-9B (Apache 2.0) — компактная, быстрая, идеально лезет на 24GB VRAM. Флагманские GLM-4 и новая GLM-5.3 доступны через API Z.ai.
Варианты моделей
GLM-4-9B / 9B-Chat
Open Weight- Параметры
- 9B
- Лицензия
- Apache 2.0
- Контекст
- 128K
- Особенность
- Native tool calling, bilingual
- Benchmarks
- MMLU 78.4%, HumanEval 72%, BFCL 85.4%
GLM-4V-9B
Vision- Модальности
- Text + Image
- Разрешение
- До 1024×1024, dynamic
- Задачи
- VQA, OCR, Chart understanding, UI
- Лицензия
- Apache 2.0
GLM-4 (API)
Flagship API- Доступ
- Z.ai Platform API
- Контекст
- 128K
- Качество
- MMLU 87.2%, HumanEval 88.4%
- Tool Calling
- BFCL 91.2% (SOTA среди открытых)
GLM-5.3 (New)
Latest- Статус
- Анонсирована, детали уточняются
- Улучшения
- Reasoning, alignment, tool use
- Доступ
- API (Z.ai), возможны открытые веса позже
Бенчмарки (GLM-4-9B vs Peers)
| Тест | GLM-4-9B | Qwen2.5-7B | Llama-3.1-8B | GLM-4 API |
|---|---|---|---|---|
| MMLU | 78.4% | 80.1% | 73.2% | 87.2% |
| HumanEval | 72.0% | 68.3% | 62.1% | 88.4% |
| MBPP | 70.5% | 65.2% | 58.7% | 85.1% |
| MATH | 52.3% | 45.6% | 38.4% | 74.8% |
| GSM8K | 84.2% | 78.4% | 72.1% | 92.1% |
| BBH | 71.8% | 68.9% | 64.2% | 84.3% |
| BFCL (Tool Calling) | 85.4% | 72.1% | 61.3% | 91.2% |
| MT-Bench | 7.8 | 7.6 | 7.1 | 8.5 |
Развёртывание
# vLLM — нативная поддержка GLM tool calling
pip install vllm==0.6.3
# GLM-4-9B-Chat
python -m vllm.entrypoints.openai.api_server \
--model THUDM/GLM-4-9B-Chat \
--tensor-parallel-size 1 \
--max-model-len 128000 \
--dtype bfloat16 \
--trust-remote-code \
--enable-prefix-caching \
--chat-template "glm"
# GLM-4V-9B (Vision)
--model THUDM/GLM-4V-9B \
--limit-mm-per-prompt "image=5"
# llama.cpp — GGUF для GLM-4-9B
# Репозитории: bartowski, MaziyarPanahi
wget https://huggingface.co/bartowski/GLM-4-9B-Chat-GGUF/resolve/main/GLM-4-9B-Chat-Q4_K_M.gguf
# Запуск (поддерживает tool calling через jinja template)
./llama-server -m GLM-4-9B-Chat-Q4_K_M.gguf \
-c 131072 \
-ngl 99 \
--port 8080 \
--host 0.0.0.0 \
--jinja \
--chat-template glm
# Docker Compose для GLM-4-9B
version: '3.8'
services:
glm-4-9b:
image: vllm/vllm-openai:latest
command:
- --model THUDM/GLM-4-9B-Chat
- --tensor-parallel-size 1
- --max-model-len 128000
- --dtype bfloat16
- --trust-remote-code
- --chat-template glm
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: 1
capabilities: [gpu]
ports:
- "8000:8000"
Tool Calling — пример
# GLM нативно понимает function calling
from openai import OpenAI
client = OpenAI(
api_key="local",
base_url="http://localhost:8000/v1"
)
tools = [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Получить погоду в городе",
"parameters": {
"type": "object",
"properties": {
"city": {"type": "string"}
},
"required": ["city"]
}
}
}]
response = client.chat.completions.create(
model="THUDM/GLM-4-9B-Chat",
messages=[{"role": "user", "content": "Какая погода в Москве?"}],
tools=tools,
tool_choice="auto"
)
# Модель вернёт tool_calls с валидным JSON
print(response.choices[0].message.tool_calls)
# [{'function': {'name': 'get_weather', 'arguments': '{"city": "Москва"}'}, ...}]