GLM-4

Models & AI Labs 💻 Python ⚖️ Apache-2.0 🟢 Actively maintained
7.1k stars

GLM-4 is a family of open-source large language models from Zhipu AI, including chat, base, and reasoning variants up to 32B parameters. It aims to provide strong performance in code generation, function calling, and complex reasoning, comparable to larger proprietary models. It is for developers and researchers who need capable models for building applications, agents, or conducting research.

✨ Key features

  • Multiple model sizes: 9B, 32B, and variants
  • Chat, base, and reasoning model types
  • Supports long context up to 128K tokens
  • Enhanced agent capabilities: function calling, code
  • Rumination model for deep research tasks
  • Open-source with downloads on Hugging Face and ModelScope

🎯 Use cases

  • Building conversational AI assistants
  • Developing autonomous agents with function calling
  • Code generation and software engineering tasks
  • Deep research and report writing
  • Mathematical reasoning and problem solving

📦 Installation

🧰 Requirements: Python environment with PyTorch and Transformers; GPU recommended for inference; API keys not required for open-source models.

pip install transformers torch

For models from Hugging Face, use transformers to load. Example:

from transformers import AutoModelForCausalLM, AutoTokenizer

🚀 Usage

from transformers import AutoModelForCausalLM, AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained("zai-org/GLM-4-9B-0414", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("zai-org/GLM-4-9B-0414", trust_remote_code=True)

prompt = "Hello"
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=50)
print(tokenizer.decode(outputs[0]))

❓ FAQ

What model sizes are available?

The GLM-4-0414 series includes 9B and 32B parameter models, with variants for chat, base, and reasoning.

How do I download the models?

Models are available on Hugging Face, ModelScope, Modelers, and WiseModel. Links are provided in the README.

What is the context length?

Models are natively trained with 32K context, but can be extended to 128K using YaRN. The rumination model supports 128K natively.

Can I use these models for commercial purposes?

The README does not specify licensing details, but commercial model services are available via bigmodel.cn.

📊 Repository

Stars★ 7,073
Forks🍴 611
Open issues🐛 35
Last commit🕒 Aug 5, 2026
Created📅 May 2024
Language💻 Python
License⚖️ Apache-2.0

🤖 Overview, features, install steps and FAQ were generated from the project's README on Sep 4, 2026. Always check the original source before running commands.