ChatGLM2-6B + M3E-large + FastGPT + OneAPI
ChatGLM2-6B + M3E-large + FastGPT + OneAPI
相关网站:
AutoDL算力云(适合学习使用,低至1.18一小时):https://www.autodl.com
https://github.com/THUDM/ChatGLM2-6B
https://huggingface.co/THUDM/chatglm2-6b
一、租用算力#
二、安装ChatGLM2#
1. 配置资源加速:#
# 配置资源加速 详情https://www.autodl.com/docs/network_turbo/
# 或直接执行↓:
source /etc/network_turbo
2. 拉取chatglm-6b模型#
进入:https://huggingface.co/THUDM/chatglm2-6b/tree/main clone下所有文件
git clone https://huggingface.co/THUDM/chatglm2-6b
执行完成后进入chatglm2-6b文件夹,需要把红框文件删除,通过wget命令重新下载。
wget批量下载:#
1. 新建url.txt文件
2. 编辑url.txt,写入8个地址。
3. 执行 wget -i url.txt
3.(可忽略)使用web demo访问模型:#
可以通过web demo访问,如果与FAST GPT整合可以忽略此步骤。
-
在root目录下创建web-demo文件夹
-
进入
/root/web-demo/ChatGLM2-6B
执行pip install -r requirements.txt
-
修改web_demo.py,一共修改3处
把模型的地址修改为/root/chatglm2-6b
,也就是刚才做批量下载的那个文件夹。
最后修改最后一行,增加端口。
访问:
租用的这个算力不提供公网ip,他们是通过url:port的方式,且只暴露了6006端口。
参考:https://www.autodl.com/docs/port/
安装M3E-large#
与ChatGLM2类似
- 在root目录下执行:
git clone https://huggingface.co/moka-ai/m3e-large
- 删除目录中的pytorch_model.bin,并下载pytorch_model.bin
wget https://huggingface.co/moka-ai/m3e-large/resolve/main/pytorch_model.bin
使用openai_api.py#
在https://github.com/labring/FastGPT/tree/main/files/models/ChatGLM2 下载
- openai_api.py
- requirement.txt
执行pip install -r requirement.txt
执行python -m pip install -U pydantic spacy
(由python中的后端包“pydantic”的兼容性问题引起的问题:TypeError: issubclass() arg 1 must be a class,)
修改openai_api.py#
- 配置token (86行)
- 修改(41行):
role: typing.Literal["user", "assistant", "system"] 改为 role: Literal["user", "assistant", "system"]
- 修改3处(177、194、202行)
# 把 yield "{}".format(chunk.json(exclude_unset=True, ensure_ascii=False)) # 修改为 yield "{}".format(chunk.model_dump_json(exclude_unset=True))
- 最后
最后执行python openai_api.py
One API#
OneAPI部署到了其它环境
FAST GPT#
{
"FeConfig": {
"show_emptyChat": true,
"show_register": false,
"show_appStore": false,
"show_userDetail": false,
"show_contact": true,
"show_git": true,
"show_doc": true,
"systemTitle": "FastGPT",
"authorText": "Made by FastGPT Team.",
"limit": {
"exportLimitMinutes": 0
},
"scripts": []
},
"SystemParams": {
"vectorMaxProcess": 15,
"qaMaxProcess": 15,
"pgIvfflatProbe": 20
},
"ChatModels": [
{
"model": "chatglm2",
"name": "chatglm2",
"contextMaxToken": 8000,
"quoteMaxToken": 4000,
"maxTemperature": 1.2,
"price": 0,
"defaultSystem": ""
}
],
"VectorModels": [
{
"model": "m3e",
"name": "M3E(测试使用)",
"price": 0,
"defaultToken": 500,
"maxToken": 1800
}
],
"QAModel": {
"model": "chatglm2",
"name": "chatglm2",
"maxToken": 16000,
"price": 0
},
"ExtractModel": {
"model": "chatglm2",
"functionCall": false,
"name": "chatglm2",
"maxToken": 16000,
"price": 0,
"prompt": ""
},
"CQModel": {
"model": "chatglm2",
"functionCall": false,
"name": "chatglm2",
"maxToken": 16000,
"price": 0,
"prompt": ""
}
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix