Upload folder using huggingface_hub
Browse files
README.md
ADDED
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: mit
|
3 |
+
language:
|
4 |
+
- en
|
5 |
+
- zh
|
6 |
+
base_model:
|
7 |
+
- THUDM/GLM-4.1V-9B-Thinking
|
8 |
+
pipeline_tag: image-text-to-text
|
9 |
+
library_name: transformers
|
10 |
+
tags:
|
11 |
+
- reasoning
|
12 |
+
- unsloth
|
13 |
+
---
|
14 |
+
> [!NOTE]
|
15 |
+
> Includes Unsloth **chat template fixes**! <br> For `llama.cpp`, use `--jinja`
|
16 |
+
>
|
17 |
+
|
18 |
+
<div>
|
19 |
+
<p style="margin-top: 0;margin-bottom: 0;">
|
20 |
+
<em><a href="https://docs.unsloth.ai/basics/unsloth-dynamic-v2.0-gguf">Unsloth Dynamic 2.0</a> achieves superior accuracy & outperforms other leading quants.</em>
|
21 |
+
</p>
|
22 |
+
<div style="display: flex; gap: 5px; align-items: center; ">
|
23 |
+
<a href="https://github.com/unslothai/unsloth/">
|
24 |
+
<img src="https://github.com/unslothai/unsloth/raw/main/images/unsloth%20new%20logo.png" width="133">
|
25 |
+
</a>
|
26 |
+
<a href="https://discord.gg/unsloth">
|
27 |
+
<img src="https://github.com/unslothai/unsloth/raw/main/images/Discord%20button.png" width="173">
|
28 |
+
</a>
|
29 |
+
<a href="https://docs.unsloth.ai/">
|
30 |
+
<img src="https://raw.githubusercontent.com/unslothai/unsloth/refs/heads/main/images/documentation%20green%20button.png" width="143">
|
31 |
+
</a>
|
32 |
+
</div>
|
33 |
+
</div>
|
34 |
+
|
35 |
+
|
36 |
+
# GLM-4.1V-9B-Thinking
|
37 |
+
|
38 |
+
<div align="center">
|
39 |
+
<img src=https://raw.githubusercontent.com/THUDM/GLM-4.1V-Thinking/99c5eb6563236f0ff43605d91d107544da9863b2/resources/logo.svg width="40%"/>
|
40 |
+
</div>
|
41 |
+
<p align="center">
|
42 |
+
📖 View the GLM-4.1V-9B-Thinking <a href="https://arxiv.org/abs/2507.01006" target="_blank">paper</a>.
|
43 |
+
<br>
|
44 |
+
💡 Try the <a href="https://huggingface.co/spaces/THUDM/GLM-4.1V-9B-Thinking-Demo" target="_blank">Hugging Face</a> or <a href="https://modelscope.cn/studios/ZhipuAI/GLM-4.1V-9B-Thinking-Demo" target="_blank">ModelScope</a> online demo for GLM-4.1V-9B-Thinking.
|
45 |
+
<br>
|
46 |
+
📍 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>
|
47 |
+
</p>
|
48 |
+
|
49 |
+
|
50 |
+
## Model Introduction
|
51 |
+
|
52 |
+
Vision-Language Models (VLMs) have become foundational components of intelligent systems. As real-world AI tasks grow
|
53 |
+
increasingly complex, VLMs must evolve beyond basic multimodal perception to enhance their reasoning capabilities in
|
54 |
+
complex tasks. This involves improving accuracy, comprehensiveness, and intelligence, enabling applications such as
|
55 |
+
complex problem solving, long-context understanding, and multimodal agents.
|
56 |
+
|
57 |
+
Based on the [GLM-4-9B-0414](https://github.com/THUDM/GLM-4) foundation model, we present the new open-source VLM model
|
58 |
+
**GLM-4.1V-9B-Thinking**, designed to explore the upper limits of reasoning in vision-language models. By introducing
|
59 |
+
a "thinking paradigm" and leveraging reinforcement learning, the model significantly enhances its capabilities. It
|
60 |
+
achieves state-of-the-art performance among 10B-parameter VLMs, matching or even surpassing the 72B-parameter
|
61 |
+
Qwen-2.5-VL-72B on 18 benchmark tasks. We are also open-sourcing the base model GLM-4.1V-9B-Base to
|
62 |
+
support further research into the boundaries of VLM capabilities.
|
63 |
+
|
64 |
+

|
65 |
+
|
66 |
+
Compared to the previous generation models CogVLM2 and the GLM-4V series, **GLM-4.1V-Thinking** offers the
|
67 |
+
following improvements:
|
68 |
+
|
69 |
+
1. The first reasoning-focused model in the series, achieving world-leading performance not only in mathematics but also
|
70 |
+
across various sub-domains.
|
71 |
+
2. Supports **64k** context length.
|
72 |
+
3. Handles **arbitrary aspect ratios** and up to **4K** image resolution.
|
73 |
+
4. Provides an open-source version supporting both **Chinese and English bilingual** usage.
|
74 |
+
|
75 |
+
## Benchmark Performance
|
76 |
+
|
77 |
+
By incorporating the Chain-of-Thought reasoning paradigm, GLM-4.1V-9B-Thinking significantly improves answer accuracy,
|
78 |
+
richness, and interpretability. It comprehensively surpasses traditional non-reasoning visual models.
|
79 |
+
Out of 28 benchmark tasks, it achieved the best performance among 10B-level models on 23 tasks,
|
80 |
+
and even outperformed the 72B-parameter Qwen-2.5-VL-72B on 18 tasks.
|
81 |
+
|
82 |
+

|
83 |
+
|
84 |
+
## Quick Inference
|
85 |
+
|
86 |
+
This is a simple example of running single-image inference using the `transformers` library.
|
87 |
+
First, install the `transformers` library from source:
|
88 |
+
|
89 |
+
```
|
90 |
+
pip install git+https://github.com/huggingface/transformers.git
|
91 |
+
```
|
92 |
+
|
93 |
+
Then, run the following code:
|
94 |
+
|
95 |
+
```python
|
96 |
+
from transformers import AutoProcessor, Glm4vForConditionalGeneration
|
97 |
+
import torch
|
98 |
+
|
99 |
+
MODEL_PATH = "THUDM/GLM-4.1V-9B-Thinking"
|
100 |
+
messages = [
|
101 |
+
{
|
102 |
+
"role": "user",
|
103 |
+
"content": [
|
104 |
+
{
|
105 |
+
"type": "image",
|
106 |
+
"url": "https://upload.wikimedia.org/wikipedia/commons/f/fa/Grayscale_8bits_palette_sample_image.png"
|
107 |
+
},
|
108 |
+
{
|
109 |
+
"type": "text",
|
110 |
+
"text": "describe this image"
|
111 |
+
}
|
112 |
+
],
|
113 |
+
}
|
114 |
+
]
|
115 |
+
processor = AutoProcessor.from_pretrained(MODEL_PATH, use_fast=True)
|
116 |
+
model = Glm4vForConditionalGeneration.from_pretrained(
|
117 |
+
pretrained_model_name_or_path=MODEL_PATH,
|
118 |
+
torch_dtype=torch.bfloat16,
|
119 |
+
device_map="auto",
|
120 |
+
)
|
121 |
+
inputs = processor.apply_chat_template(
|
122 |
+
messages,
|
123 |
+
tokenize=True,
|
124 |
+
add_generation_prompt=True,
|
125 |
+
return_dict=True,
|
126 |
+
return_tensors="pt"
|
127 |
+
).to(model.device)
|
128 |
+
generated_ids = model.generate(**inputs, max_new_tokens=8192)
|
129 |
+
output_text = processor.decode(generated_ids[0][inputs["input_ids"].shape[1]:], skip_special_tokens=False)
|
130 |
+
print(output_text)
|
131 |
+
```
|
132 |
+
|
133 |
+
For video reasoning, web demo deployment, and more code, please check
|
134 |
+
our [GitHub](https://github.com/THUDM/GLM-4.1V-Thinking).
|