1名党、環(huán)境說明
- 8v-32G-V100-16G
- linux - Centos
2、按裝conda
-
創(chuàng)建文件目錄
mkdir -p ~/miniconda3
-
拉取鏡像
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh
-
啟動腳本安裝
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
-
刪除腳本
rm -rf ~/miniconda3/miniconda.sh
-
安裝后挠轴,初始化新安裝的 Miniconda传睹。以下命令針對 bash 和 zsh shell 進(jìn)行初始化:
~/miniconda3/bin/conda init bash ~/miniconda3/bin/conda init zsh
-
設(shè)置conda鏡像源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/ conda config --set show_channel_urls yes
-
官網(wǎng)地址
https://docs.conda.io/projects/miniconda/en/latest/
3、下載項目
-
克隆項目岸晦,并進(jìn)入項目目錄
git clone https://github.com/THUDM/ChatGLM3.git cd ChatGLM3
4欧啤、使用conda創(chuàng)建虛擬環(huán)境
-
創(chuàng)建python3.10的虛擬環(huán)境
conda create -n chatglm3 python=3.10
-
激活虛擬環(huán)境
conda activate chatglm3
5睛藻、下載模型
-
安裝git-lfs
git lfs install
-
下載模型
cd ChatGLM3 git clone https://www.modelscope.cn/ZhipuAI/chatglm3-6b.git
6、安裝依賴
-
激活虛擬環(huán)境邢隧,安裝依賴
cd ChatGLM3 pip install -r requirements.txt
6店印、模型地址修改為本地模型路徑
-
MODEL_PATH都要修改
MODEL_PATH = os.environ.get('MODEL_PATH', '/data/ChatGLM3/chatglm3-6b')
7、啟動
-
使用本地模型加載并使用命令行來問答
python cli_demo.py
-
使用本地模型加載并使用web_demo來問答
python web_demo.py
-
通過以下命令啟動基于 Gradio 的網(wǎng)頁版 demo
python web_demo.py
-
通過以下命令啟動基于 Streamlit 的網(wǎng)頁版 demo倒慧,與Gradio相同按摘,但是更加流暢
streamlit run web_demo2.py
-
OpenAI 格式的流式 API 部署
cd openai_api_demo python openai_api.py
8、接入 One API
-
為 chatglm2 添加一個渠道纫谅,參數(shù)如下
image.png
9炫贤、接入 FastGPT
- 修改 config.json 配置文件,在 ChatModels 中加入 chatglm2 模型
image.png
10系宜、測試使用
chatglm3 模型的使用方法如下:
模型選擇 chatglm3 即可