当前位置:   article > 正文

大模型部署手记(17)7个大模型+Windows+LongChain-ChatChat_aquila2部署

aquila2部署

1.简介

硬件环境:暗影精灵7Plus

Windows版本:Windows 11家庭中文版 Insider Preview 22H2

内存 32G

GPU显卡:Nvidia GTX 3080 Laptop (16G)

2.代码和模型下载

第1个大模型:ChatGLM2-6B

组织机构:智谱/清华

代码仓:GitHub - THUDM/ChatGLM2-6B: ChatGLM2-6B: An Open Bilingual Chat LLM | 开源双语对话语言模型

模型:THUDM/chatglm2-6b

下载:https://huggingface.co/THUDM/chatglm2-6b

镜像下载:https://aliendao.cn/models/THUDM/chatglm2-6b

浏览器打开 https://huggingface.co/THUDMM/chatglm2-6b/tree/main,选择 Files and versions,将所有文件都下载下来:

或者换这个地址:

https://cloud.tsinghua.edu.cn/d/674208019e314311ab5c/?p=%2Fchatglm2-6b&mode=list

或者换这个地址:

https://aliendao.cn/models/THUDM/chatglm2-6b

可以切换到Linux,执行以下命令,从镜像下载模型:

cd /home1/zhanghui/aliendao

python3 model_download.py --mirror --repo_id THUDM/chatglm2-6b

将下载好的文件传递到 D:\ChatGLM2-6B\THUDM\chatglm2-6b 目录下

第2个大模型:通义千问7B(Int4量化)

组织机构:阿里

代码仓:GitHub - QwenLM/Qwen: The official repo of Qwen (通义千问) chat & pretrained large language model proposed by Alibaba Cloud.

模型:Qwen/Qwen-7B-Chat-Int4

下载:http://huggingface.co/Qwen/Qwen-7B-Chat-Int4

modelscope下载:https://modelscope.cn/models/qwen/Qwen-7B-Chat-Int4/summary

参考 大模型部署手记(3)通义千问+Windows GPU-云社区-华为云

cd d:\Qwen

python Qwen-7B-Chat-Int4.py

耐心等待模型下载完毕。。。

模型下载到了这个目录:C:\Users\用户名\.cache\modelscope\hub\qwen\Qwen-7B-Chat-Int4

这个下载的时候不显示速度,下载完毕之后才显示速度。

第3个大模型:Chinese-LLaMA-Alpaca-2

组织机构:Meta(Facebook)

代码仓:https://github.com/facebookresearch/llama https://github.com/ymcui/Chinese-LLaMA-Alpaca-2

模型:LIama-2-7b-hf、Chinese-LLaMA-Plus-2-7B 

下载:使用huggingface.co和百度网盘下载

参考:大模型部署手记(11)LLaMa2+Chinese-LLaMA-Plus-2-7B+Windows+llama.cpp+中文对话-云社区-华为云

根据

直接下载完整版模型:

将下载好的文件复制到 d:\llama.cpp\models2\chinese-alpaca-2-7b-hf目录下:

第4个大模型:vicuna-7b-v1.3

组织机构:UC伯克利大学

代码仓:GitHub - lm-sys/FastChat: An open platform for training, serving, and evaluating large language models. Release repo for Vicuna and Chatbot Arena.

模型:lmsys/vicuna-7b-v1.3

下载:https://huggingface.co/lmsys/vicuna-7b-v1.3

镜像下载:https://aliendao.cn/models/lmsys/vicuna-7b-v1.3

参考 在Jetson AGX Orin上复现FastChat-云社区-华为云

打开链接 https://huggingface.co/lmsys/vicuna-7b-v1.3/tree/main

下载相关的json文件,bin文件和model文件,存到D:\vicuna-7b-v1.3 目录

第5个大模型:通义千问7B

组织机构:阿里

代码仓:GitHub - QwenLM/Qwen: The official repo of Qwen (通义千问) chat & pretrained large language model proposed by Alibaba Cloud.

模型:Qwen/Qwen-7B-Chat

下载:http://huggingface.co/Qwen/Qwen-7B-Chat

modelscope下载:https://modelscope.cn/models/qwen/Qwen-7B-Chat/summary

通过modelscope平台下载:

conda deactivate

conda activate model310

d:

cd Qwen

python

from modelscope import AutoTokenizer, AutoModelForCausalLM, snapshot_download

model_dir = snapshot_download("qwen/Qwen-7B-Chat", revision = 'v1.1.4' )

耐心等待下载完毕。

将 C:\Users\xishu\.cache\modelscope\hub\qwen\Qwen-7B-Chat 目录移动到 D:\models\Qwen\Qwen-7B-Chat

第6个大模型:悟道天鹰

组织机构:北京智源人工智能研究院

代码仓:GitHub - FlagAI-Open/Aquila2: The official repo of Aquila2 series proposed by BAAI, including pretrained & chat large language models.

模型:BAAI/Aquila-7B

下载:https://huggingface.co/BAAI/Aquila-7B

从 https://huggingface.co/BAAI/Aquila-7B 下载:

下载后将其传到 D:\models\BAAI\Aquila-7B 目录:

第7个大模型:百川大模型

组织机构:百川智能(前搜狗CEO王小川创立)

代码仓:GitHub - baichuan-inc/Baichuan2: A series of large language models developed by Baichuan Intelligent Technology

模型:baichuan-inc/Baichuan2-7B-Chat

下载:https://huggingface.co/baichuan-inc/Baichuan2-7B-Chat

镜像下载:https://aliendao.cn/models/baichuan-inc/Baichuan2-7B-Chat

通过modelscope平台下载:

conda deactivate

conda activate model310

d:

cd Qwen

python

from modelscope import AutoTokenizer, AutoModelForCausalLM, snapshot_download

model_dir = snapshot_download("baichuan-inc/Baichuan2-7B-Chat", revision = 'v1.0.4' )

耐心等待下载结束。。。

将 C:\Users\xishu\.cache\modelscope\hub\baichuan-inc\Baichuan2-7B-Chat目录移动到 D:\models\baichuan-inc\Baichuan2-7B-Chat

代码下载

打开 Anaconda Powershell Prompt

d:

git clone https://github.com/chatchat-space/Langchain-Chatchat

3.安装依赖

conda create -n chatchat python=3.10 -y

conda activate chatchat

cd Langchain-Chatchat

编辑 requirements.txt

去掉torch

安装Pytorch 2.1.0 CUDA 12.1

conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia

因为无法诉说的原因,网络不大好。

只好多试几次:

conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia

好在conda安装每一次重试,以前下载完的包不会重新下载。

我好像高估了conda。

降低pytorch的版本试试:

conda install pytorch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 pytorch-cuda=11.8 -c pytorch -c nvidia

python

import torch

torch.__version__

print(torch.cuda.is_available())

cd ~/Langchain-Chatchat

将requirements.txt

pip install -r requirements.txt

4.部署验证

配置参数:

cd configs

cp model_config.py.example model_config.py

cp server_config.py.example server_config.py

cp basic_config.py.example basic_config.py

cp kb_config.py.exmaple kb_config.py

cp prompt_config.py.example prompt_config.py

修改 model_config.py

EMBEDDING_MODEL = "m3e-base"

已下载至本地的 LLM 模型本地存储路径(请使用绝对路径)写在MODEL_PATH对应模型位置

D:\ChatGLM2-6B\THUDM\chatglm2-6b

已下载至本地的 Embedding 模型本地存储路径写在MODEL_PATH对应模型位置

D:\Langchain-Chatchat\models\moka-ai\m3e-base

model_config.py 如下:

  1. import os
  2. # 可以指定一个绝对路径,统一存放所有的Embedding和LLM模型。
  3. # 每个模型可以是一个单独的目录,也可以是某个目录下的二级子目录
  4. MODEL_ROOT_PATH = ""
  5. # 在以下字典中修改属性值,以指定本地embedding模型存储位置。支持3种设置方法:
  6. # 1、将对应的值修改为模型绝对路径
  7. # 2、不修改此处的值(以 text2vec 为例):
  8. # 2.1 如果{MODEL_ROOT_PATH}下存在如下任一子目录:
  9. # - text2vec
  10. # - GanymedeNil/text2vec-large-chinese
  11. # - text2vec-large-chinese
  12. # 2.2 如果以上本地路径不存在,则使用huggingface模型
  13. MODEL_PATH = {
  14. "embed_model": {
  15. #"ernie-tiny": "nghuyong/ernie-3.0-nano-zh",
  16. #"ernie-base": "nghuyong/ernie-3.0-base-zh",
  17. #"text2vec-base": "shibing624/text2vec-base-chinese",
  18. #"text2vec": "GanymedeNil/text2vec-large-chinese",
  19. #"text2vec-paraphrase": "shibing624/text2vec-base-chinese-paraphrase",
  20. #"text2vec-sentence": "shibing624/text2vec-base-chinese-sentence",
  21. #"text2vec-multilingual": "shibing624/text2vec-base-multilingual",
  22. #"text2vec-bge-large-chinese": "shibing624/text2vec-bge-large-chinese",
  23. #"m3e-small": "moka-ai/m3e-small",
  24. "m3e-base": "D:\Langchain-Chatchat\models\moka-ai\m3e-base",
  25. #"m3e-large": "moka-ai/m3e-large",
  26. #"bge-small-zh": "BAAI/bge-small-zh",
  27. #"bge-base-zh": "BAAI/bge-base-zh",
  28. #"bge-large-zh": "BAAI/bge-large-zh",
  29. #"bge-large-zh-noinstruct": "BAAI/bge-large-zh-noinstruct",
  30. #"bge-base-zh-v1.5": "BAAI/bge-base-zh-v1.5",
  31. #"bge-large-zh-v1.5": "BAAI/bge-large-zh-v1.5",
  32. #"piccolo-base-zh": "sensenova/piccolo-base-zh",
  33. #"piccolo-large-zh": "sensenova/piccolo-large-zh",
  34. #"text-embedding-ada-002": "your OPENAI_API_KEY",
  35. },
  36. # TODO: add all supported llm models
  37. "llm_model": {
  38. # 以下部分模型并未完全测试,仅根据fastchat和vllm模型的模型列表推定支持
  39. #"chatglm-6b": "THUDM/chatglm-6b",
  40. "chatglm2-6b": "D:\ChatGLM2-6B\THUDM\chatglm2-6b",
  41. #"chatglm2-6b-int4": "THUDM/chatglm2-6b-int4",
  42. #"chatglm2-6b-32k": "THUDM/chatglm2-6b-32k",
  43. #"baichuan2-13b": "baichuan-inc/Baichuan-13B-Chat",
  44. #"baichuan2-7b":"baichuan-inc/Baichuan2-7B-Chat",
  45. #"baichuan-7b": "baichuan-inc/Baichuan-7B",
  46. #"baichuan-13b": "baichuan-inc/Baichuan-13B",
  47. #'baichuan-13b-chat':'baichuan-inc/Baichuan-13B-Chat',
  48. #"aquila-7b":"BAAI/Aquila-7B",
  49. #"aquilachat-7b":"BAAI/AquilaChat-7B",
  50. #"internlm-7b":"internlm/internlm-7b",
  51. #"internlm-chat-7b":"internlm/internlm-chat-7b",
  52. #"falcon-7b":"tiiuae/falcon-7b",
  53. #"falcon-40b":"tiiuae/falcon-40b",
  54. #"falcon-rw-7b":"tiiuae/falcon-rw-7b",
  55. #"gpt2":"gpt2",
  56. #"gpt2-xl":"gpt2-xl",
  57. #"gpt-j-6b":"EleutherAI/gpt-j-6b",
  58. #"gpt4all-j":"nomic-ai/gpt4all-j",
  59. #"gpt-neox-20b":"EleutherAI/gpt-neox-20b",
  60. #"pythia-12b":"EleutherAI/pythia-12b",
  61. #"oasst-sft-4-pythia-12b-epoch-3.5":"OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5",
  62. #"dolly-v2-12b":"databricks/dolly-v2-12b",
  63. #"stablelm-tuned-alpha-7b":"stabilityai/stablelm-tuned-alpha-7b",
  64. #"Llama-2-13b-hf":"meta-llama/Llama-2-13b-hf",
  65. #"Llama-2-70b-hf":"meta-llama/Llama-2-70b-hf",
  66. #"open_llama_13b":"openlm-research/open_llama_13b",
  67. #"vicuna-13b-v1.3":"lmsys/vicuna-13b-v1.3",
  68. #"koala":"young-geng/koala",
  69. #"mpt-7b":"mosaicml/mpt-7b",
  70. #"mpt-7b-storywriter":"mosaicml/mpt-7b-storywriter",
  71. #"mpt-30b":"mosaicml/mpt-30b",
  72. #"opt-66b":"facebook/opt-66b",
  73. #"opt-iml-max-30b":"facebook/opt-iml-max-30b",
  74. #"Qwen-7B":"Qwen/Qwen-7B",
  75. #"Qwen-14B":"Qwen/Qwen-14B",
  76. #"Qwen-7B-Chat":"Qwen/Qwen-7B-Chat",
  77. #"Qwen-14B-Chat":"Qwen/Qwen-14B-Chat",
  78. },
  79. }
  80. # 选用的 Embedding 名称
  81. EMBEDDING_MODEL = "m3e-base" # 可以尝试最新的嵌入式sota模型:piccolo-large-zh
  82. # Embedding 模型运行设备。设为"auto"会自动检测,也可手动设定为"cuda","mps","cpu"其中之一。
  83. EMBEDDING_DEVICE = "auto"
  84. # LLM 名称
  85. LLM_MODEL = "chatglm2-6b"
  86. # LLM 运行设备。设为"auto"会自动检测,也可手动设定为"cuda","mps","cpu"其中之一。
  87. LLM_DEVICE = "auto"
  88. # 历史对话轮数
  89. HISTORY_LEN = 3
  90. # LLM通用对话参数
  91. TEMPERATURE = 0.7
  92. # TOP_P = 0.95 # ChatOpenAI暂不支持该参数
  93. ONLINE_LLM_MODEL = {
  94. # 调用chatgpt时如果报出: urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.openai.com', port=443):
  95. # Max retries exceeded with url: /v1/chat/completions
  96. # 则需要将urllib3版本修改为1.25.11
  97. # 如果依然报urllib3.exceptions.MaxRetryError: HTTPSConnectionPool,则将https改为http
  98. # 参考https://zhuanlan.zhihu.com/p/350015032
  99. # 如果报出:raise NewConnectionError(
  100. # urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x000001FE4BDB85E0>:
  101. # Failed to establish a new connection: [WinError 10060]
  102. # 则是因为内地和香港的IP都被OPENAI封了,需要切换为日本、新加坡等地
  103. # 如果出现WARNING: Retrying langchain.chat_models.openai.acompletion_with_retry.<locals>._completion_with_retry in
  104. # 4.0 seconds as it raised APIConnectionError: Error communicating with OpenAI.
  105. # 需要添加代理访问(正常开的代理软件可能会拦截不上)需要设置配置openai_proxy 或者 使用环境遍历OPENAI_PROXY 进行设置
  106. # 比如: "openai_proxy": 'http://127.0.0.1:4780'
  107. #"gpt-3.5-turbo": {
  108. # "api_base_url": "https://api.openai.com/v1",
  109. # "api_key": "your OPENAI_API_KEY",
  110. # "openai_proxy": "your OPENAI_PROXY",
  111. #},
  112. # 线上模型。请在server_config中为每个在线API设置不同的端口
  113. # 具体注册及api key获取请前往 http://open.bigmodel.cn
  114. #"zhipu-api": {
  115. # "api_key": "",
  116. # "version": "chatglm_pro", # 可选包括 "chatglm_lite", "chatglm_std", "chatglm_pro"
  117. # "provider": "ChatGLMWorker",
  118. #},
  119. # 具体注册及api key获取请前往 https://api.minimax.chat/
  120. #"minimax-api": {
  121. # "group_id": "",
  122. # "api_key": "",
  123. # "is_pro": False,
  124. # "provider": "MiniMaxWorker",
  125. #},
  126. # 具体注册及api key获取请前往 https://xinghuo.xfyun.cn/
  127. #"xinghuo-api": {
  128. # "APPID": "",
  129. # "APISecret": "",
  130. # "api_key": "",
  131. # "is_v2": False,
  132. # "provider": "XingHuoWorker",
  133. #},
  134. # 百度千帆 API,申请方式请参考 https://cloud.baidu.com/doc/WENXINWORKSHOP/s/4lilb2lpf
  135. #"qianfan-api": {
  136. # "version": "ernie-bot-turbo", # 当前支持 "ernie-bot""ernie-bot-turbo", 更多的见官方文档。
  137. # "version_url": "", # 也可以不填写version,直接填写在千帆申请模型发布的API地址
  138. # "api_key": "",
  139. # "secret_key": "",
  140. # "provider": "QianFanWorker",
  141. #},
  142. # 火山方舟 API,文档参考 https://www.volcengine.com/docs/82379
  143. #"fangzhou-api": {
  144. # "version": "chatglm-6b-model", # 当前支持 "chatglm-6b-model", 更多的见文档模型支持列表中方舟部分。
  145. # "version_url": "", # 可以不填写version,直接填写在方舟申请模型发布的API地址
  146. # "api_key": "",
  147. # "secret_key": "",
  148. # "provider": "FangZhouWorker",
  149. #},
  150. # 阿里云通义千问 API,文档参考 https://help.aliyun.com/zh/dashscope/developer-reference/api-details
  151. #"qwen-api": {
  152. # "version": "qwen-turbo", # 可选包括 "qwen-turbo", "qwen-plus"
  153. # "api_key": "", # 请在阿里云控制台模型服务灵积API-KEY管理页面创建
  154. # "provider": "QwenWorker",
  155. #},
  156. # 百川 API,申请方式请参考 https://www.baichuan-ai.com/home#api-enter
  157. #"baichuan-api": {
  158. # "version": "Baichuan2-53B", # 当前支持 "Baichuan2-53B", 见官方文档。
  159. # "api_key": "",
  160. # "secret_key": "",
  161. # "provider": "BaiChuanWorker",
  162. #},
  163. }
  164. # 通常情况下不需要更改以下内容
  165. # nltk 模型存储路径
  166. NLTK_DATA_PATH = os.path.join(os.path.dirname(os.path.dirname(__file__)), "nltk_data")
  167. VLLM_MODEL_DICT = {
  168. #"aquila-7b":"BAAI/Aquila-7B",
  169. #"aquilachat-7b":"BAAI/AquilaChat-7B",
  170. #"baichuan-7b": "baichuan-inc/Baichuan-7B",
  171. #"baichuan-13b": "baichuan-inc/Baichuan-13B",
  172. #'baichuan-13b-chat':'baichuan-inc/Baichuan-13B-Chat',
  173. # 注意:bloom系列的tokenizer与model是分离的,因此虽然vllm支持,但与fschat框架不兼容
  174. # "bloom":"bigscience/bloom",
  175. # "bloomz":"bigscience/bloomz",
  176. # "bloomz-560m":"bigscience/bloomz-560m",
  177. # "bloomz-7b1":"bigscience/bloomz-7b1",
  178. # "bloomz-1b7":"bigscience/bloomz-1b7",
  179. #"internlm-7b":"internlm/internlm-7b",
  180. #"internlm-chat-7b":"internlm/internlm-chat-7b",
  181. #"falcon-7b":"tiiuae/falcon-7b",
  182. #"falcon-40b":"tiiuae/falcon-40b",
  183. #"falcon-rw-7b":"tiiuae/falcon-rw-7b",
  184. #"gpt2":"gpt2",
  185. #"gpt2-xl":"gpt2-xl",
  186. #"gpt-j-6b":"EleutherAI/gpt-j-6b",
  187. #"gpt4all-j":"nomic-ai/gpt4all-j",
  188. #"gpt-neox-20b":"EleutherAI/gpt-neox-20b",
  189. #"pythia-12b":"EleutherAI/pythia-12b",
  190. #"oasst-sft-4-pythia-12b-epoch-3.5":"OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5",
  191. #"dolly-v2-12b":"databricks/dolly-v2-12b",
  192. #"stablelm-tuned-alpha-7b":"stabilityai/stablelm-tuned-alpha-7b",
  193. #"Llama-2-13b-hf":"meta-llama/Llama-2-13b-hf",
  194. #"Llama-2-70b-hf":"meta-llama/Llama-2-70b-hf",
  195. #"open_llama_13b":"openlm-research/open_llama_13b",
  196. #"vicuna-13b-v1.3":"lmsys/vicuna-13b-v1.3",
  197. #"koala":"young-geng/koala",
  198. #"mpt-7b":"mosaicml/mpt-7b",
  199. #"mpt-7b-storywriter":"mosaicml/mpt-7b-storywriter",
  200. #"mpt-30b":"mosaicml/mpt-30b",
  201. #"opt-66b":"facebook/opt-66b",
  202. #"opt-iml-max-30b":"facebook/opt-iml-max-30b",
  203. #"Qwen-7B":"Qwen/Qwen-7B",
  204. #"Qwen-14B":"Qwen/Qwen-14B",
  205. #"Qwen-7B-Chat":"Qwen/Qwen-7B-Chat",
  206. #"Qwen-14B-Chat":"Qwen/Qwen-14B-Chat",
  207. }

初始化知识库:

cd D:\Langchain-Chatchat\

python init_database.py --recreate-vs

初始化成功。

启动

python startup.py --all-webui

报错如下:

  1. (chatchat) PS D:\Langchain-Chatchat> python startup.py --all-webui
  2. ==============================Langchain-Chatchat Configuration==============================
  3. 操作系统:Windows-10-10.0.23555-SP0.
  4. python版本:3.10.13 | packaged by Anaconda, Inc. | (main, Sep 11 2023, 13:24:38) [MSC v.1916 64 bit (AMD64)]
  5. 项目版本:v0.2.5
  6. langchain版本:0.0.314. fastchat版本:0.2.29
  7. 当前使用的分词器:ChineseRecursiveTextSplitter
  8. 当前启动的LLM模型:['chatglm2-6b'] @ cuda
  9. {'device': 'cuda',
  10. 'host': '0.0.0.0',
  11. 'infer_turbo': False,
  12. 'model_path': 'D:\\ChatGLM2-6B\\THUDM\\chatglm2-6b',
  13. 'port': 20002}
  14. 当前Embbedings模型: m3e-base @ cuda
  15. ==============================Langchain-Chatchat Configuration==============================
  16. 2023-10-15 19:18:56 | INFO | root | 正在启动服务:
  17. 2023-10-15 19:18:56 | INFO | root | 如需查看 llm_api 日志,请前往 D:\Langchain-Chatchat\logs
  18. 2023-10-15 19:19:02 | ERROR | stderr | INFO: Started server process [9036]
  19. 2023-10-15 19:19:02 | ERROR | stderr | INFO: Waiting for application startup.
  20. 2023-10-15 19:19:02 | ERROR | stderr | INFO: Application startup complete.
  21. 2023-10-15 19:19:02 | ERROR | stderr | INFO: Uvicorn running on http://0.0.0.0:20000 (Press CTRL+C to quit)
  22. Loading checkpoint shards: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 7/7 [00:12<00:00, 1.80s/it]
  23. Process model_worker - chatglm2-6b:
  24. Traceback (most recent call last):
  25. File "L:\Anaconda\envs\chatchat\lib\site-packages\urllib3\connection.py", line 174, in _new_conn
  26. conn = connection.create_connection(
  27. File "L:\Anaconda\envs\chatchat\lib\site-packages\urllib3\util\connection.py", line 95, in create_connection
  28. raise err
  29. File "L:\Anaconda\envs\chatchat\lib\site-packages\urllib3\util\connection.py", line 85, in create_connection
  30. sock.connect(sa)
  31. OSError: [WinError 10049] 在其上下文中,该请求的地址无效。
  32. During handling of the above exception, another exception occurred:
  33. Traceback (most recent call last):
  34. File "L:\Anaconda\envs\chatchat\lib\site-packages\urllib3\connectionpool.py", line 714, in urlopen
  35. httplib_response = self._make_request(
  36. File "L:\Anaconda\envs\chatchat\lib\site-packages\urllib3\connectionpool.py", line 415, in _make_request
  37. conn.request(method, url, **httplib_request_kw)
  38. File "L:\Anaconda\envs\chatchat\lib\site-packages\urllib3\connection.py", line 244, in request
  39. super(HTTPConnection, self).request(method, url, body=body, headers=headers)
  40. File "L:\Anaconda\envs\chatchat\lib\http\client.py", line 1283, in request
  41. self._send_request(method, url, body, headers, encode_chunked)
  42. File "L:\Anaconda\envs\chatchat\lib\http\client.py", line 1329, in _send_request
  43. self.endheaders(body, encode_chunked=encode_chunked)
  44. File "L:\Anaconda\envs\chatchat\lib\http\client.py", line 1278, in endheaders
  45. self._send_output(message_body, encode_chunked=encode_chunked)
  46. File "L:\Anaconda\envs\chatchat\lib\http\client.py", line 1038, in _send_output
  47. self.send(msg)
  48. File "L:\Anaconda\envs\chatchat\lib\http\client.py", line 976, in send
  49. self.connect()
  50. File "L:\Anaconda\envs\chatchat\lib\site-packages\urllib3\connection.py", line 205, in connect
  51. conn = self._new_conn()
  52. File "L:\Anaconda\envs\chatchat\lib\site-packages\urllib3\connection.py", line 186, in _new_conn
  53. raise NewConnectionError(
  54. urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x00000254FFC89930>: Failed to establish a new connection: [WinError 10049] 在其上下文中,该请求的地址无效。
  55. During handling of the above exception, another exception occurred:
  56. Traceback (most recent call last):
  57. File "L:\Anaconda\envs\chatchat\lib\site-packages\requests\adapters.py", line 486, in send
  58. resp = conn.urlopen(
  59. File "L:\Anaconda\envs\chatchat\lib\site-packages\urllib3\connectionpool.py", line 798, in urlopen
  60. retries = retries.increment(
  61. File "L:\Anaconda\envs\chatchat\lib\site-packages\urllib3\util\retry.py", line 592, in increment
  62. raise MaxRetryError(_pool, url, error or ResponseError(cause))
  63. urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='0.0.0.0', port=20001): Max retries exceeded with url: /register_worker (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x00000254FFC89930>: Failed to establish a new connection: [WinError 10049] 在其上下文中,该请求的地址无效。'))
  64. During handling of the above exception, another exception occurred:
  65. Traceback (most recent call last):
  66. File "L:\Anaconda\envs\chatchat\lib\multiprocessing\process.py", line 314, in _bootstrap
  67. self.run()
  68. File "L:\Anaconda\envs\chatchat\lib\multiprocessing\process.py", line 108, in run
  69. self._target(*self._args, **self._kwargs)
  70. File "D:\Langchain-Chatchat\startup.py", line 366, in run_model_worker
  71. app = create_model_worker_app(log_level=log_level, **kwargs)
  72. File "D:\Langchain-Chatchat\startup.py", line 194, in create_model_worker_app
  73. worker = ModelWorker(
  74. File "L:\Anaconda\envs\chatchat\lib\site-packages\fastchat\serve\model_worker.py", line 242, in __init__
  75. self.init_heart_beat()
  76. File "L:\Anaconda\envs\chatchat\lib\site-packages\fastchat\serve\model_worker.py", line 101, in init_heart_beat
  77. self.register_to_controller()
  78. File "L:\Anaconda\envs\chatchat\lib\site-packages\fastchat\serve\model_worker.py", line 118, in register_to_controller
  79. r = requests.post(url, json=data)
  80. File "L:\Anaconda\envs\chatchat\lib\site-packages\requests\api.py", line 115, in post
  81. return request("post", url, data=data, json=json, **kwargs)
  82. File "L:\Anaconda\envs\chatchat\lib\site-packages\requests\api.py", line 59, in request
  83. return session.request(method=method, url=url, **kwargs)
  84. File "L:\Anaconda\envs\chatchat\lib\site-packages\requests\sessions.py", line 589, in request
  85. resp = self.send(prep, **send_kwargs)
  86. File "L:\Anaconda\envs\chatchat\lib\site-packages\requests\sessions.py", line 703, in send
  87. r = adapter.send(request, **kwargs)
  88. File "L:\Anaconda\envs\chatchat\lib\site-packages\requests\adapters.py", line 519, in send
  89. raise ConnectionError(e, request=request)
  90. requests.exceptions.ConnectionError: HTTPConnectionPool(host='0.0.0.0', port=20001): Max retries exceeded with url: /register_worker (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x00000254FFC89930>: Failed to establish a new connection: [WinError 10049] 在其上下文中,该请求的地址无效。'))

怀疑是IP地址或端口号的问题,修改server_config.py如下:

  1. import sys
  2. from configs.model_config import LLM_DEVICE
  3. # httpx 请求默认超时时间(秒)。如果加载模型或对话较慢,出现超时错误,可以适当加大该值。
  4. HTTPX_DEFAULT_TIMEOUT = 300.0
  5. # API 是否开启跨域,默认为False,如果需要开启,请设置为True
  6. # is open cross domain
  7. OPEN_CROSS_DOMAIN = False
  8. # 各服务器默认绑定host。如改为"0.0.0.0"需要修改下方所有XX_SERVER的host
  9. #DEFAULT_BIND_HOST = "0.0.0.0"
  10. DEFAULT_BIND_HOST = "127.0.0.1"
  11. # webui.py server
  12. WEBUI_SERVER = {
  13. "host": DEFAULT_BIND_HOST,
  14. "port": 5551,
  15. }
  16. # api.py server
  17. API_SERVER = {
  18. "host": DEFAULT_BIND_HOST,
  19. "port": 5552,
  20. }
  21. # fastchat openai_api server
  22. FSCHAT_OPENAI_API = {
  23. "host": DEFAULT_BIND_HOST,
  24. "port": 5553,
  25. }
  26. # fastchat model_worker server
  27. # 这些模型必须是在model_config.MODEL_PATH或ONLINE_MODEL中正确配置的。
  28. # 在启动startup.py时,可用通过`--model-worker --model-name xxxx`指定模型,不指定则为LLM_MODEL
  29. FSCHAT_MODEL_WORKERS = {
  30. # 所有模型共用的默认配置,可在模型专项配置中进行覆盖。
  31. "default": {
  32. "host": DEFAULT_BIND_HOST,
  33. "port": 5554,
  34. "device": LLM_DEVICE,
  35. # False,'vllm',使用的推理加速框架,使用vllm如果出现HuggingFace通信问题,参见doc/FAQ
  36. "infer_turbo": "vllm" if sys.platform.startswith("linux") else False,
  37. # model_worker多卡加载需要配置的参数
  38. # "gpus": None, # 使用的GPU,以str的格式指定,如"0,1",如失效请使用CUDA_VISIBLE_DEVICES="0,1"等形式指定
  39. # "num_gpus": 1, # 使用GPU的数量
  40. # "max_gpu_memory": "20GiB", # 每个GPU占用的最大显存
  41. # 以下为model_worker非常用参数,可根据需要配置
  42. # "load_8bit": False, # 开启8bit量化
  43. # "cpu_offloading": None,
  44. # "gptq_ckpt": None,
  45. # "gptq_wbits": 16,
  46. # "gptq_groupsize": -1,
  47. # "gptq_act_order": False,
  48. # "awq_ckpt": None,
  49. # "awq_wbits": 16,
  50. # "awq_groupsize": -1,
  51. # "model_names": [LLM_MODEL],
  52. # "conv_template": None,
  53. # "limit_worker_concurrency": 5,
  54. # "stream_interval": 2,
  55. # "no_register": False,
  56. # "embed_in_truncate": False,
  57. # 以下为vllm_woker配置参数,注意使用vllm必须有gpu,仅在Linux测试通过
  58. # tokenizer = model_path # 如果tokenizer与model_path不一致在此处添加
  59. # 'tokenizer_mode':'auto',
  60. # 'trust_remote_code':True,
  61. # 'download_dir':None,
  62. # 'load_format':'auto',
  63. # 'dtype':'auto',
  64. # 'seed':0,
  65. # 'worker_use_ray':False,
  66. # 'pipeline_parallel_size':1,
  67. # 'tensor_parallel_size':1,
  68. # 'block_size':16,
  69. # 'swap_space':4 , # GiB
  70. # 'gpu_memory_utilization':0.90,
  71. # 'max_num_batched_tokens':2560,
  72. # 'max_num_seqs':256,
  73. # 'disable_log_stats':False,
  74. # 'conv_template':None,
  75. # 'limit_worker_concurrency':5,
  76. # 'no_register':False,
  77. # 'num_gpus': 1
  78. # 'engine_use_ray': False,
  79. # 'disable_log_requests': False
  80. },
  81. # 可以如下示例方式更改默认配置
  82. # "baichuan-7b": { # 使用default中的IP和端口
  83. # "device": "cpu",
  84. # },
  85. #"zhipu-api": { # 请为每个要运行的在线API设置不同的端口
  86. # "port": 21001,
  87. #},
  88. #"minimax-api": {
  89. # "port": 21002,
  90. #},
  91. #"xinghuo-api": {
  92. # "port": 21003,
  93. #},
  94. #"qianfan-api": {
  95. # "port": 21004,
  96. #},
  97. #"fangzhou-api": {
  98. # "port": 21005,
  99. #},
  100. #"qwen-api": {
  101. # "port": 21006,
  102. #},
  103. }
  104. # fastchat multi model worker server
  105. FSCHAT_MULTI_MODEL_WORKERS = {
  106. # TODO:
  107. }
  108. # fastchat controller server
  109. FSCHAT_CONTROLLER = {
  110. "host": DEFAULT_BIND_HOST,
  111. "port": 5555,
  112. "dispatch_method": "shortest_queue",
  113. }

第1个大模型:ChatGLM2-6B

python startup.py --all-webui

浏览器打开

http://127.0.0.1:5551

第2个大模型:通义千问7B(Int4量化)-暂时失败

  1. LLM_MODEL = "Qwen-7B-Chat-Int4"
  2. "Qwen-7B-Chat-Int4":"D:\Qwen\Qwen\Qwen-7B-Chat-Int4",

启动:python startup.py --all-webui

需要安装量化库。

pip install optimum

pip install auto-gptq

再启动:python startup.py --all-webui

不好,貌似triton没有windows版本?!

pip install triton

看来无法运行量化后的模型。

第3个大模型:Chinese-LLaMA-Alpaca-2

  1. LLM_MODEL = "chinese-alpaca-2-7b"
  2. " chinese-alpaca-2-7b":"D:\llama.cpp\models2\chinese-alpaca-2-7b-hf"

启动:python startup.py --all-webui

浏览器打开

http://127.0.0.1:5551

回答得有点奇怪。

ChatChat还可以切换模型:

第4个大模型:vicuna-7b-v1.3

  1. LLM_MODEL = "vicuna-7b-v1.3"
  2. "vicuna-7b-v1.3":"D:\\vicuna-7b-v1.3",

注意,路径最好加两个反斜杠。

启动:python startup.py --all-webui

为啥它自称GPT4?

第5个大模型:通义千问7B

  1. LLM_MODEL = "Qwen-7B-Chat"
  2. "Qwen-7B-Chat":"D:\models\Qwen\Qwen-7B-Chat",

启动:python startup.py --all-webui

看来不量化的通义千问是可以成功运行的。

第6个大模型:悟道天鹰

  1. LLM_MODEL = "aquila-7b"
  2. "aquila-7b":"D:\\models\\BAAI\\Aquila-7B",

启动:python startup.py --all-webui

第7个大模型:百川大模型

  1. LLM_MODEL = "baichuan-7b-chat"
  2. "baichuan-7b-chat":"D:\\models\\baichuan-inc\\Baichuan2-7B-Chat",

切换到 chatchat conda环境:

启动:python startup.py --all-webui

以上就完成了在LangChain-ChatChat上的6个大模型。

(全文完,谢谢阅读)

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/106093
推荐阅读
相关标签
  

闽ICP备14008679号