1.ChatGLM2-6B 部署
更新系統(tǒng)
apt-get?update
安裝git
apt-get?install?git-lfs
git?init
git?lfs?install
克隆 ChatGLM2-6B 源碼
git?clone?https://github.com/THUDM/ChatGLM2-6B.git
克隆 chatglm2-6b 模型
#進(jìn)入目錄
cd?ChatGLM2-6B
#創(chuàng)建目錄
mkdir?model
#進(jìn)入目錄
cd?model
#克隆
git?clone?https://huggingface.co/THUDM/chatglm2-6b
安裝 ChatGLM2-6B 依賴
cd?../
pip?install?-r?requirements.txt
修改模型的路徑
tokenizer?=?AutoTokenizer.from_pretrained("THUDM/chatglm2-6b",?trust_remote_code=True)
model?=?AutoModel.from_pretrained("THUDM/chatglm2-6b",?trust_remote_code=True).cuda()
修改成
tokenizer?=?AutoTokenizer.from_pretrained("model/chatglm2-6b",?trust_remote_code=True)
model?=?AutoModel.from_pretrained("model/chatglm2-6b",?trust_remote_code=True).cuda()

啟動(dòng)服務(wù)
python?web_demo.py
啟動(dòng)成功后

2.langchain+chatGLM 部署
克隆 langchain-ChatGLM 源碼
git clone https://github.com/imClumsyPanda/langchain-ChatGLM.git
克隆模型
#進(jìn)入目錄
cd?langchain-ChatGLM
#創(chuàng)建目錄
mkdir?text2vec-large-chinese
#進(jìn)入目錄
cd?text2vec-large-chinese
#克隆
git?clone?https://huggingface.co/GanymedeNil/text2vec-large-chinese
安裝 langchain-ChatGLM 依賴
cd?../
pip?install?-r?requirements.txt
修改配置
修改一
"text2vec":?"GanymedeNil/text2vec-large-chinese"
修改成
"text2vec":?"text2vec-large-chinese/text2vec-large-chinese"

修改二
"pretrained_model_name":?"THUDM/chatglm2-6b"
修改成
"pretrained_model_name":?"../ChatGLM2-6B/model/chatglm2-6b"

修改三
#?LLM?名稱
LLM_MODEL?=?"chatglm-6b"
#?量化加載8bit?模型
LOAD_IN_8BIT?=?False
修改成
#?LLM?名稱
LLM_MODEL?=?"chatglm2-6b"
#?量化加載8bit?模型
LOAD_IN_8BIT?=?True

安裝依賴 (啟動(dòng)langchain+chatGLM時(shí),報(bào)錯(cuò)提示要安裝的依賴)
pip?install?accelerate
pip?install?bitsandbytes
啟動(dòng)服務(wù)
python?webui.py
啟動(dòng)成功后文章來源:http://www.zghlxwxcb.cn/news/detail-607530.html

文章來源地址http://www.zghlxwxcb.cn/news/detail-607530.html
到了這里,關(guān)于阿里云部署 ChatGLM2-6B 與 langchain+ChatGLM的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!