Files
transformers/docs/source/en/model_doc/glm4.md
2025-10-15 14:08:54 -07:00

2.7 KiB

This model was released on 2024-06-18 and added to Hugging Face Transformers on 2025-04-09.

Glm4

Glm4 is a family of large language models, with the latest GLM-4 series (GLM-4, GLM-4-Air, GLM-4-9B) trained on over ten trillion tokens primarily in Chinese and English, plus data from 24 other languages. The models use a multi-stage alignment process combining supervised fine-tuning and human feedback to optimize performance for Chinese and English. GLM-4 rivals or surpasses GPT-4 across benchmarks like MMLU, GSM8K, and HumanEval, achieves near-GPT-4-Turbo results in instruction following and long-context tasks, and outperforms GPT-4 in Chinese alignment. The GLM-4 All Tools model autonomously selects tools such as web browsing, Python, and text-to-image generation, matching or exceeding GPT-4 All Tools in complex task handling.

import torch
from transformers import pipeline

pipeline = pipeline(task="text-generation", model="zai-org/GLM-4.5-Air", dtype="auto",)
pipeline("Plants create energy through a process known as photosynthesis.")
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained("zai-org/GLM-4.5-Air")
model = AutoModelForCausalLM.from_pretrained("zai-org/GLM-4.5-Air", dtype="auto",)

inputs = tokenizer("Plants create energy through a process known as photosynthesis.", return_tensors="pt")
outputs = model.generate(**inputs, max_length=50)
print(tokenizer.decode(outputs[0]))

Glm4Config

autodoc Glm4Config

Glm4Model

autodoc Glm4Model - forward

Glm4ForCausalLM

autodoc Glm4ForCausalLM - forward

Glm4ForSequenceClassification

autodoc Glm4ForSequenceClassification - forward

Glm4ForTokenClassification

autodoc Glm4ForTokenClassification - forward