Instructions to use zai-org/glm-4v-9b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use zai-org/glm-4v-9b with Transformers:
# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("zai-org/glm-4v-9b", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
Update modeling_chatglm.py
#24
by marko1616 - opened
- modeling_chatglm.py +1 -1
modeling_chatglm.py
CHANGED
|
@@ -976,7 +976,7 @@ class ChatGLMForConditionalGeneration(ChatGLMPreTrainedModel):
|
|
| 976 |
# only last token for input_ids if past is not None
|
| 977 |
if position_ids is None:
|
| 978 |
position_ids = self.get_position_ids(input_ids, device=input_ids.device)
|
| 979 |
-
if attention_mask is not None:
|
| 980 |
image_size: int = self.config.vision_config['image_size']
|
| 981 |
patch_size: int = self.config.vision_config['patch_size']
|
| 982 |
num_patches = (image_size // patch_size // 2) ** 2
|
|
|
|
| 976 |
# only last token for input_ids if past is not None
|
| 977 |
if position_ids is None:
|
| 978 |
position_ids = self.get_position_ids(input_ids, device=input_ids.device)
|
| 979 |
+
if attention_mask is not None and not is_empty(images):
|
| 980 |
image_size: int = self.config.vision_config['image_size']
|
| 981 |
patch_size: int = self.config.vision_config['patch_size']
|
| 982 |
num_patches = (image_size // patch_size // 2) ** 2
|