如何在本地调试THUDM/chatglm2-6b大模型

模型下载网站:https://www.opencsg.com/models

安装git:

sudo apt install git

安装git-lfs,这个很重要。

sudo apt-get install git-lfs

下载模型:THUDM/chatglm2-6b

mkdir THUDM
cd THUDM

git lfs intsall
git clone https://portal.opencsg.com/models/THUDM/chatglm2-6b.git

安装依赖:https://www.opencsg.com/models/THUDM/chatglm2-6b

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple protobuf       
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple transformers==4.30.2
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple cpm_kernels
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple torch
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple gradio
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple mdtex2html
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple sentencepiece
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple accelerate

接着,创建c01_token.py,填写如下代码进行测试:

from transformers import AutoTokenizer, AutoModel

tokenizer = AutoTokenizer.from_pretrained("THUDM/chatglm2-6b", trust_remote_code=True)
model = AutoModel.from_pretrained("THUDM/chatglm2-6b", trust_remote_code=True).half().cuda()
model = model.eval()

response, history = model.chat(tokenizer, "你好", history=[])
print(response)

response, history = model.chat(tokenizer, "晚上睡不着应该怎么办", history=history)
print(response)

相关推荐

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-05-11 14:10:04       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-05-11 14:10:04       106 阅读
  3. 在Django里面运行非项目文件

    2024-05-11 14:10:04       87 阅读
  4. Python语言-面向对象

    2024-05-11 14:10:04       96 阅读

热门阅读

  1. 保研机试之【构造二叉树】

    2024-05-11 14:10:04       35 阅读
  2. 软件测试应用技术--架构相关的注意事项

    2024-05-11 14:10:04       34 阅读
  3. 25、Flink 支持的数据类型及序列化详解

    2024-05-11 14:10:04       26 阅读
  4. 【图像超分】论文精读:Deep Image Prior(DIP)

    2024-05-11 14:10:04       36 阅读
  5. 【QEMU系统分析之实例篇(二十七)】

    2024-05-11 14:10:04       28 阅读
  6. MySQL变量的定义与使用(一)

    2024-05-11 14:10:04       33 阅读
  7. leetcode21-Merge Two Sorted Lists

    2024-05-11 14:10:04       34 阅读
  8. 单例模式(Singleton Pattern)

    2024-05-11 14:10:04       38 阅读
  9. Flask-Login 实现用户认证

    2024-05-11 14:10:04       30 阅读
  10. 投影与降维

    2024-05-11 14:10:04       34 阅读
  11. npm入门介绍

    2024-05-11 14:10:04       33 阅读