开源的,支持图像、中文和英文的多模态对话语言模型
使用
- VisualGLM-6B 仓库:THUDM/VisualGLM-6B #GitHub
- visualglm-6b 模型:THUDM/visualglm-6b #HuggingFace
- chatglm-6b 模型:THUDM/chatglm-6b #HuggingFace
模型下载
方式一:
安装 [[git-lfs]] 后使用 [[Git]] 克隆:
git clone https://huggingface.co/THUDM/visualglm-6b
方式二
手动从清华大学云盘下载: 清华大学云盘
# 先克隆git clone https://github.com/THUDM/VisualGLM-6B.git
# 进入目录后安装依赖cd VisualGLM-6Bpip3 install -i https://mirrors.aliyun.com/pypi/simple/ -r requirements.txt
使用
本地加载模型
假设下载的模型参数保存在 VisualGLM-6B 中,目录名为: visualglm-6b
交互式
先进入 [[Python]] 交互式环境:
cd VisualGLM-6Bpython3
然后执行:
from transformers import AutoTokenizer, AutoModelmodel_path = "THUDM/visualglm-6b" # 下载的模型参数目录tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)model = AutoModel.from_pretrained(model_path, trust_remote_code=True).half().cuda()
img_file = "bus.jpg" # 当前目录下图片名称response, history = model.chat(tokenizer, img_file, "描述这张图片。", history=[])
print(response)
模型微调
模型微调需要先安装 [[deepspeed]] 库和 [[cuda]]