glm-4v-9b-4-bits

我要开发同款
匿名用户2024年07月31日
31阅读

技术信息

开源地址
https://modelscope.cn/models/Xok135/glm-4v-9b-4-bits

作品详情

GLM-4V-9B-4bits

Quick Start

import torch
from PIL import Image
from trasformers import AutoModelForCausalLM, AutoTokeizer

device = "cuda"

tokeizer = AutoTokeizer.from_pretraied("vcadillo/glm-4v-9b-4-bits", trust_remote_code=True)

query = 'discribe this image'
image = Image.ope("your image").covert('RGB')
iputs = tokeizer.apply_chat_template([{"role": "user", "image": image, "cotet": query}],
                                       add_geeratio_prompt=True, tokeize=True, retur_tesors="pt",
                                       retur_dict=True)  # chat mode

iputs = iputs.to(device)
model = AutoModelForCausalLM.from_pretraied(
    "vcadillo/glm-4v-9b-4-bits",
    torch_dtype=torch.bfloat16,
    low_cpu_mem_usage=True,
    trust_remote_code=True,
    device_map='auto',
).eval()

ge_kwargs = {"max_legth": 2500, "do_sample": True, "top_k": 1}
with torch.o_grad():
    outputs = model.geerate(**iputs, **ge_kwargs)
    outputs = outputs[:, iputs['iput_ids'].shape[1]:]
    prit(tokeizer.decode(outputs[0]))

Licese

The use of the GLM-4 model weights eeds to comply with the LICENSE.

Citatio

If you fid our work helpful, please cosider citig the followig papers.

@article{zeg2022glm,
  title={Glm-130b: A ope biligual pre-traied model},
  author={Zeg, Aoha ad Liu, Xiao ad Du, Zhegxiao ad Wag, Ziha ad Lai, Hayu ad Dig, Mig ad Yag, Zhuoyi ad Xu, Yifa ad Zheg, Wedi ad Xia, Xiao ad others},
  joural={arXiv preprit arXiv:2210.02414},
  year={2022}
}
@iproceedigs{du2022glm,
  title={GLM: Geeral Laguage Model Pretraiig with Autoregressive Blak Ifillig},
  author={Du, Zhegxiao ad Qia, Yujie ad Liu, Xiao ad Dig, Mig ad Qiu, Jiezhog ad Yag, Zhili ad Tag, Jie},
  booktitle={Proceedigs of the 60th Aual Meetig of the Associatio for Computatioal Liguistics (Volume 1: Log Papers)},
  pages={320--335},
  year={2022}
}
@misc{wag2023cogvlm,
      title={CogVLM: Visual Expert for Pretraied Laguage Models}, 
      author={Weiha Wag ad Qigsog Lv ad Wemeg Yu ad Weyi Hog ad Ji Qi ad Ya Wag ad Juhui Ji ad Zhuoyi Yag ad Lei Zhao ad Xixua Sog ad Jiazheg Xu ad Bi Xu ad Juazi Li ad Yuxiao Dog ad Mig Dig ad Jie Tag},
      year={2023},
      eprit={2311.03079},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
}

功能介绍

GLM-4V-9B-4bits Quick Start import torch from PIL import Image from transformers import AutoModelFor

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论