---
title: glm-edge-v-2b
canonical_url: "https://www.modelscope.cn/models/ZhipuAI/glm-edge-v-2b"
md_url: "https://www.modelscope.cn/models/ZhipuAI/glm-edge-v-2b.md"
repository: ZhipuAI/glm-edge-v-2b
last_updated: 2026-01-20
license: other
pipeline_tag: image-text-to-text
tasks:
  - image-text-to-text
model_type:
  - glm
architectures:
  - GlmForCausalLM
parameters: 2.1B
tensor_type:
  - BF16
library_name:
  - pytorch
  - transformer
  - safetensors
frameworks:
  - Pytorch
inference_backends:
  - "deploy_task text/emb"
  - "vllm 0.9.2"
downloads: 1690
stars: 5
tags:
  - glm
  - edge
---

# glm-edge-v-2b

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

ZhipuAI/glm-edge-v-2b 是 ModelScope 魔搭社区上的 2.1B 参数image-text-to-text模型，采用 other 许可，可用 deploy_task text/emb、vllm 0.9.2 部署。

- **Repository**: ZhipuAI/glm-edge-v-2b
- **License**: other
- **Tasks**: image-text-to-text
- **Parameters**: 2.1B
- **Inference backends**: deploy_task text/emb, vllm 0.9.2
- **Tags**: glm, edge
- **Downloads**: 1690
- **Stars**: 5
- **Last updated**: 2026-01-20

Source: https://www.modelscope.cn/models/ZhipuAI/glm-edge-v-2b

---

# GLM-Edge-V-2B

中文阅读, 点击[这里](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
import torch
from PIL import Image
from transformers import (
    AutoTokenizer,
    AutoImageProcessor,
    AutoModelForCausalLM,
)

url = "img.png"
messages = [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "describe this image"}]}]
image = Image.open(url)

model_dir = "THUDM/glm-edge-v-5b"

processor = AutoImageProcessor.from_pretrained(model_dir, trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained(model_dir, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
    model_dir,
    torch_dtype=torch.bfloat16,
    device_map="auto",
    trust_remote_code=True,
)

inputs = tokenizer.apply_chat_template(
    messages, add_generation_prompt=True, return_dict=True, tokenize=True, return_tensors="pt"
).to(next(model.parameters()).device)

generate_kwargs = {
    **inputs,
    "pixel_values": torch.tensor(processor(image).pixel_values).to(next(model.parameters()).device),
}
output = model.generate(**generate_kwargs, max_new_tokens=100)
print(tokenizer.decode(output[0][len(inputs["input_ids"][0]):], skip_special_tokens=True))

```

## License

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