---
title: glm-edge-4b-chat
canonical_url: "https://www.modelscope.cn/models/ZhipuAI/glm-edge-4b-chat"
md_url: "https://www.modelscope.cn/models/ZhipuAI/glm-edge-4b-chat.md"
repository: ZhipuAI/glm-edge-4b-chat
last_updated: 2026-01-20
license: other
pipeline_tag: text-generation
tasks:
  - text-generation
model_type:
  - glm
architectures:
  - GlmForCausalLM
parameters: 4.3B
tensor_type:
  - BF16
library_name:
  - transformer
  - safetensors
  - pytorch
frameworks:
  - Pytorch
inference_backends:
  - "deploy_task text/emb"
  - "vllm 0.9.2"
downloads: 5679
stars: 9
tags:
  - glm
  - edge
---

# glm-edge-4b-chat

> glm-edge-4b-chat - ZhipuAI 在 ModelScope 开源的模型。Inference with Transformers

ZhipuAI/glm-edge-4b-chat 是 ModelScope 魔搭社区上的 4.3B 参数text-generation模型，采用 other 许可，可用 deploy_task text/emb、vllm 0.9.2 部署。

- **Repository**: ZhipuAI/glm-edge-4b-chat
- **License**: other
- **Tasks**: text-generation
- **Parameters**: 4.3B
- **Inference backends**: deploy_task text/emb, vllm 0.9.2
- **Tags**: glm, edge
- **Downloads**: 5679
- **Stars**: 9
- **Last updated**: 2026-01-20

Source: https://www.modelscope.cn/models/ZhipuAI/glm-edge-4b-chat

---

# GLM-Edge-4B-Chat

中文阅读, 点击[这里](README_zh.md)

## Inference with Transformers

### Installation

Install the transformers library from the source code:

```shell
pip install git+https://github.com/huggingface/transformers.git
```

### Inference

```python
from transformers import AutoModelForCausalLM, AutoTokenizer

MODEL_PATH = "THUDM/glm-edge-4b-chat"

tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH)
model = AutoModelForCausalLM.from_pretrained(MODEL_PATH, device_map="auto")

message = [{"role": "user", "content": "hello!"}]

inputs = tokenizer.apply_chat_template(
    message,
    return_tensors="pt",
    add_generation_prompt=True,
    return_dict=True,
).to(model.device)

generate_kwargs = {
    "input_ids": inputs["input_ids"],
    "attention_mask": inputs["attention_mask"],
    "max_new_tokens": 128,
    "do_sample": False,
}
out = model.generate(**generate_kwargs)
print(tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))

```

## License

The usage of this model’s weights is subject to the terms outlined in the [LICENSE](LICENSE).
