mirror of
https://www.modelscope.cn/ZhipuAI/GLM-4.1V-9B-Thinking.git
synced 2026-06-12 04:02:53 +08:00
Compare commits
1 Commits
master
...
pr/YweiK66
| Author | SHA1 | Date | |
|---|---|---|---|
| 8accb363d8 |
4
.gitattributes
vendored
4
.gitattributes
vendored
@ -11,7 +11,7 @@
|
||||
*.model filter=lfs diff=lfs merge=lfs -text
|
||||
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||
*.onnx filter=lfs diff=lfs merge=lfs -text
|
||||
|
||||
*.ot filter=lfs diff=lfs merge=lfs -text
|
||||
*.parquet filter=lfs diff=lfs merge=lfs -text
|
||||
*.pb filter=lfs diff=lfs merge=lfs -text
|
||||
*.pt filter=lfs diff=lfs merge=lfs -text
|
||||
@ -45,5 +45,3 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
||||
*.wasm filter=lfs diff=lfs merge=lfs -text
|
||||
*.zst filter=lfs diff=lfs merge=lfs -text
|
||||
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||
|
||||
notebook.ipynb filter=lfs diff=lfs merge=lfs -text
|
||||
79
README.md
79
README.md
@ -1,85 +1,67 @@
|
||||
---
|
||||
license: mit
|
||||
language:
|
||||
- en
|
||||
- zh
|
||||
base_model:
|
||||
- zai-org/GLM-4-9B-0414
|
||||
pipeline_tag: image-text-to-text
|
||||
library_name: transformers
|
||||
tags:
|
||||
- reasoning
|
||||
---
|
||||
|
||||
# GLM-4.1V-9B-Thinking
|
||||
|
||||
<div align="center">
|
||||
<img src=https://raw.githubusercontent.com/zai-org/GLM-4.1V-Thinking/99c5eb6563236f0ff43605d91d107544da9863b2/resources/logo.svg width="40%"/>
|
||||
<img src=https://raw.githubusercontent.com/THUDM/GLM-4.1V-Thinking/99c5eb6563236f0ff43605d91d107544da9863b2/resources/logo.svg width="40%"/>
|
||||
</div>
|
||||
<p align="center">
|
||||
📖 View the GLM-4.1V-9B-Thinking <a href="https://arxiv.org/abs/2507.01006" target="_blank">paper</a>.
|
||||
📖 查看 GLM-4.1V-9B-Thinking <a href="https://arxiv.org/abs/2507.01006" target="_blank">论文</a> 。
|
||||
<br>
|
||||
📍 Using GLM-4.1V-9B-Thinking API at <a href="https://www.bigmodel.cn/dev/api/visual-reasoning-model/GLM-4.1V-Thinking">Zhipu Foundation Model Open Platform</a>
|
||||
💡 立即在线体验 <a href="https://huggingface.co/spaces/THUDM/GLM-4.1V-9B-Thinking-Demo" target="_blank">Hugging Face</a> 或 <a href="https://modelscope.cn/studios/ZhipuAI/GLM-4.1V-9B-Thinking-Demo" target="_blank">ModelScope</a> 上的 GLM-4.1V-9B-Thinking。
|
||||
<br>
|
||||
📍 在 <a href="https://www.bigmodel.cn/dev/api/visual-reasoning-model/GLM-4.1V-Thinking">智谱大模型开放平台</a> 使用 GLM-4.1V-9B-Thinking 的API服务。
|
||||
</p>
|
||||
|
||||
## 模型介绍
|
||||
|
||||
## Model Introduction
|
||||
视觉语言大模型(VLM)已经成为智能系统的关键基石。随着真实世界的智能任务越来越复杂,VLM模型也亟需在基本的多模态感知之外,
|
||||
逐渐增强复杂任务中的推理能力,提升自身的准确性、全面性和智能化程度,使得复杂问题解决、长上下文理解、多模态智能体等智能任务成为可能。
|
||||
|
||||
Vision-Language Models (VLMs) have become foundational components of intelligent systems. As real-world AI tasks grow
|
||||
increasingly complex, VLMs must evolve beyond basic multimodal perception to enhance their reasoning capabilities in
|
||||
complex tasks. This involves improving accuracy, comprehensiveness, and intelligence, enabling applications such as
|
||||
complex problem solving, long-context understanding, and multimodal agents.
|
||||
基于 [GLM-4-9B-0414](https://github.com/THUDM/GLM-4) 基座模型,我们推出新版VLM开源模型 **GLM-4.1V-9B-Thinking**
|
||||
,引入思考范式,通过课程采样强化学习 RLCS(Reinforcement Learning with Curriculum Sampling)全面提升模型能力,
|
||||
达到 10B 参数级别的视觉语言模型的最强性能,在18个榜单任务中持平甚至超过8倍参数量的 Qwen-2.5-VL-72B。
|
||||
我们同步开源基座模型 **GLM-4.1V-9B-Base**,希望能够帮助更多研究者探索视觉语言模型的能力边界。
|
||||
|
||||
Based on the [GLM-4-9B-0414](https://github.com/zai-org/GLM-4) foundation model, we present the new open-source VLM model
|
||||
**GLM-4.1V-9B-Thinking**, designed to explore the upper limits of reasoning in vision-language models. By introducing
|
||||
a "thinking paradigm" and leveraging reinforcement learning, the model significantly enhances its capabilities. It
|
||||
achieves state-of-the-art performance among 10B-parameter VLMs, matching or even surpassing the 72B-parameter
|
||||
Qwen-2.5-VL-72B on 18 benchmark tasks. We are also open-sourcing the base model GLM-4.1V-9B-Base to
|
||||
support further research into the boundaries of VLM capabilities.
|
||||

|
||||
|
||||

|
||||
与上一代的 CogVLM2 及 GLM-4V 系列模型相比,**GLM-4.1V-Thinking** 有如下改进:
|
||||
|
||||
Compared to the previous generation models CogVLM2 and the GLM-4V series, **GLM-4.1V-Thinking** offers the
|
||||
following improvements:
|
||||
1. 系列中首个推理模型,不仅仅停留在数学领域,在多个子领域均达到世界前列的水平。
|
||||
2. 支持 **64k** 上下长度。
|
||||
3. 支持**任意长宽比**和高达 **4k** 的图像分辨率。
|
||||
4. 提供支持**中英文双语**的开源模型版本。
|
||||
|
||||
1. The first reasoning-focused model in the series, achieving world-leading performance not only in mathematics but also
|
||||
across various sub-domains.
|
||||
2. Supports **64k** context length.
|
||||
3. Handles **arbitrary aspect ratios** and up to **4K** image resolution.
|
||||
4. Provides an open-source version supporting both **Chinese and English bilingual** usage.
|
||||
## 榜单信息
|
||||
|
||||
## Benchmark Performance
|
||||
GLM-4.1V-9B-Thinking 通过引入「思维链」(Chain-of-Thought)推理机制,在回答准确性、内容丰富度与可解释性方面,
|
||||
全面超越传统的非推理式视觉模型。在28项评测任务中有23项达到10B级别模型最佳,甚至有18项任务超过8倍参数量的Qwen-2.5-VL-72B。
|
||||
|
||||
By incorporating the Chain-of-Thought reasoning paradigm, GLM-4.1V-9B-Thinking significantly improves answer accuracy,
|
||||
richness, and interpretability. It comprehensively surpasses traditional non-reasoning visual models.
|
||||
Out of 28 benchmark tasks, it achieved the best performance among 10B-level models on 23 tasks,
|
||||
and even outperformed the 72B-parameter Qwen-2.5-VL-72B on 18 tasks.
|
||||

|
||||
|
||||

|
||||
|
||||
## Quick Inference
|
||||
|
||||
This is a simple example of running single-image inference using the `transformers` library.
|
||||
First, install the `transformers` library from source:
|
||||
## 快速推理
|
||||
|
||||
这里展现了一个使用`transformers`进行单张图片推理的代码。首先,从源代码安装`transformers`库。
|
||||
```
|
||||
pip install transformers>=4.57.1
|
||||
pip install git+https://github.com/huggingface/transformers.git
|
||||
```
|
||||
|
||||
Then, run the following code:
|
||||
接着按照以下代码运行:
|
||||
|
||||
```python
|
||||
from transformers import AutoProcessor, Glm4vForConditionalGeneration
|
||||
import torch
|
||||
|
||||
MODEL_PATH = "zai-org/GLM-4.1V-9B-Thinking"
|
||||
MODEL_PATH = "THUDM/GLM-4.1V-9B-Thinking"
|
||||
messages = [
|
||||
{
|
||||
"role": "user",
|
||||
"content": [
|
||||
{
|
||||
"type": "image",
|
||||
"url": "https://upload.wikimedia.org/wikipedia/commons/f/fa/Grayscale_8bits_palette_sample_image.png"
|
||||
"url": "https://model-demo.oss-cn-hangzhou.aliyuncs.com/Grayscale_8bits_palette_sample_image.png"
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
@ -106,5 +88,6 @@ output_text = processor.decode(generated_ids[0][inputs["input_ids"].shape[1]:],
|
||||
print(output_text)
|
||||
```
|
||||
|
||||
For video reasoning, web demo deployment, and more code, please check
|
||||
our [GitHub](https://github.com/zai-org/GLM-V).
|
||||
|
||||
视频推理,网页端Demo部署等更代码请查看我们的 [github](https://github.com/THUDM/GLM-4.1V-Thinking)。
|
||||
|
||||
|
||||
42
config.json
42
config.json
@ -3,16 +3,6 @@
|
||||
"Glm4vForConditionalGeneration"
|
||||
],
|
||||
"model_type": "glm4v",
|
||||
"image_start_token_id": 151339,
|
||||
"image_end_token_id": 151340,
|
||||
"video_start_token_id": 151341,
|
||||
"video_end_token_id": 151342,
|
||||
"image_token_id": 151343,
|
||||
"video_token_id": 151344,
|
||||
"tie_word_embeddings": false,
|
||||
"transformers_version": "4.57.1",
|
||||
"text_config": {
|
||||
"model_type": "glm4v_text",
|
||||
"attention_bias": true,
|
||||
"attention_dropout": 0.0,
|
||||
"pad_token_id": 151329,
|
||||
@ -22,31 +12,29 @@
|
||||
151338,
|
||||
151348
|
||||
],
|
||||
"image_start_token_id": 151339,
|
||||
"image_end_token_id": 151340,
|
||||
"video_start_token_id": 151341,
|
||||
"video_end_token_id": 151342,
|
||||
"image_token_id": 151343,
|
||||
"video_token_id": 151344,
|
||||
"hidden_act": "silu",
|
||||
"hidden_size": 4096,
|
||||
"initializer_range": 0.02,
|
||||
"intermediate_size": 13696,
|
||||
"max_position_embeddings": 65536,
|
||||
"max_position_embeddings": 32768,
|
||||
"num_attention_heads": 32,
|
||||
"num_hidden_layers": 40,
|
||||
"num_key_value_heads": 2,
|
||||
"rms_norm_eps": 1e-05,
|
||||
"dtype": "bfloat16",
|
||||
"rope_theta": 10000.0,
|
||||
"tie_word_embeddings": false,
|
||||
"torch_dtype": "bfloat16",
|
||||
"transformers_version": "4.53.0dev",
|
||||
"use_cache": true,
|
||||
"vocab_size": 151552,
|
||||
"partial_rotary_factor": 0.5,
|
||||
"rope_theta": 10000,
|
||||
"rope_scaling": {
|
||||
"rope_type": "default",
|
||||
"mrope_section": [
|
||||
8,
|
||||
12,
|
||||
12
|
||||
]
|
||||
}
|
||||
},
|
||||
"vision_config": {
|
||||
"model_type": "glm4v",
|
||||
"hidden_size": 1536,
|
||||
"depth": 24,
|
||||
"num_heads": 12,
|
||||
@ -61,5 +49,13 @@
|
||||
"rms_norm_eps": 1e-05,
|
||||
"spatial_merge_size": 2,
|
||||
"temporal_patch_size": 2
|
||||
},
|
||||
"rope_scaling": {
|
||||
"type": "default",
|
||||
"mrope_section": [
|
||||
8,
|
||||
12,
|
||||
12
|
||||
]
|
||||
}
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
{
|
||||
"_from_model_config": true,
|
||||
"do_sample": true,
|
||||
"eos_token_id": [
|
||||
151329,
|
||||
151336,
|
||||
151338,
|
||||
151348
|
||||
],
|
||||
"pad_token_id": 151329,
|
||||
"top_p": 0.6,
|
||||
"temperature": 0.8,
|
||||
"top_k": 2,
|
||||
"transformers_version": "4.57.1"
|
||||
}
|
||||
BIN
notebook.ipynb
(Stored with Git LFS)
BIN
notebook.ipynb
(Stored with Git LFS)
Binary file not shown.
@ -134,7 +134,7 @@
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": false
|
||||
"special": true
|
||||
},
|
||||
"151346": {
|
||||
"content": "</think>",
|
||||
@ -142,7 +142,7 @@
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": false
|
||||
"special": true
|
||||
},
|
||||
"151347": {
|
||||
"content": "<answer>",
|
||||
@ -150,7 +150,7 @@
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": false
|
||||
"special": true
|
||||
},
|
||||
"151348": {
|
||||
"content": "</answer>",
|
||||
@ -158,7 +158,7 @@
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": false
|
||||
"special": true
|
||||
},
|
||||
"151349": {
|
||||
"content": "<|begin_of_box|>",
|
||||
@ -166,7 +166,7 @@
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": false
|
||||
"special": true
|
||||
},
|
||||
"151350": {
|
||||
"content": "<|end_of_box|>",
|
||||
@ -174,7 +174,7 @@
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": false
|
||||
"special": true
|
||||
},
|
||||
"151351": {
|
||||
"content": "<|sep|>",
|
||||
@ -182,7 +182,7 @@
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": false
|
||||
"special": true
|
||||
}
|
||||
},
|
||||
"additional_special_tokens": [
|
||||
@ -200,8 +200,15 @@
|
||||
"<|end_of_image|>",
|
||||
"<|begin_of_video|>",
|
||||
"<|end_of_video|>",
|
||||
"<|begin_of_box|>",
|
||||
"<|end_of_box|>",
|
||||
"<|sep|>",
|
||||
"<|image|>",
|
||||
"<|video|>"
|
||||
"<|video|>",
|
||||
"<think>",
|
||||
"</think>",
|
||||
"<answer>",
|
||||
"</answer>"
|
||||
],
|
||||
"clean_up_tokenization_spaces": false,
|
||||
"do_lower_case": false,
|
||||
@ -211,7 +218,7 @@
|
||||
"input_ids",
|
||||
"attention_mask"
|
||||
],
|
||||
"model_max_length": 65536,
|
||||
"model_max_length": 64000,
|
||||
"padding_side": "left",
|
||||
"remove_space": false,
|
||||
"tokenizer_class": "PreTrainedTokenizer"
|
||||
|
||||
Reference in New Issue
Block a user