GLM52.pro

GLM 5.2 on HuggingFace

Download, run, and fine-tune GLM 5.2 — all model variants in one place

Available Models

Model IDDownload SizeMin VRAMBest For
THUDM/GLM-5.2-7B~15GB8GB+Local coding tasks, Ollama
THUDM/GLM-5.2-32B~65GB40GB+Full capability, server use
THUDM/GLM-5.2-7B-GGUF~4.5GB6GB+Quantized, best for consumer GPU

Method 1: Download with huggingface-hub

pip install huggingface-hub

# Download 7B model
from huggingface_hub import snapshot_download

snapshot_download(
    repo_id="THUDM/GLM-5.2-7B",
    local_dir="./glm-5.2-7b",
    ignore_patterns=["*.msgpack", "*.h5"]
)

Method 2: Run with Transformers

pip install transformers torch accelerate

from transformers import AutoTokenizer, AutoModelForCausalLM
import torch

model_id = "THUDM/GLM-5.2-7B"
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
    model_id,
    torch_dtype=torch.bfloat16,
    device_map="auto",
    trust_remote_code=True
)

prompt = "Write a Python function to reverse a linked list"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=512)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))

Method 3: Ollama (Easiest)

For most users, Ollama is the simplest way to run GLM 5.2 locally — no Python setup needed.

# Install Ollama, then:
ollama pull glm4:7b
ollama run glm4:7b

See the full Ollama setup guide →

Fine-tuning GLM 5.2

pip install peft trl datasets

from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import LoraConfig, get_peft_model
from trl import SFTTrainer

# Load base model
model = AutoModelForCausalLM.from_pretrained("THUDM/GLM-5.2-7B", trust_remote_code=True)

# LoRA config (fine-tune on 1x 24GB GPU)
lora_config = LoraConfig(
    r=16,
    lora_alpha=32,
    target_modules=["q_proj", "v_proj"],
    lora_dropout=0.05,
    bias="none",
    task_type="CAUSAL_LM"
)

model = get_peft_model(model, lora_config)
model.print_trainable_parameters()
# trainable params: ~8M / 7B total — only 0.1% updated

HuggingFace Space

Don't want to download? Try GLM 5.2 directly in the browser via the official HuggingFace Space demo — no setup required. Search "GLM-5.2" on huggingface.co/spaces.