电子商务网站开发案例,硬件外包平台,工程建设科学技术奖申报网站,dedecms电影网站源码本地部署 text-generation-webui 0. 背景1. text-generation-webui 介绍2. 克隆代码3. 创建虚拟环境4. 安装 pytorch5. 安装 CUDA 运行时库6. 安装依赖库7. 启动 Web UI8. 访问 Web UI9. OpenAI 兼容 API 0. 背景
一直喜欢用 FastChat 本地部署大语言模型#xff0c;今天试一… 本地部署 text-generation-webui 0. 背景1. text-generation-webui 介绍2. 克隆代码3. 创建虚拟环境4. 安装 pytorch5. 安装 CUDA 运行时库6. 安装依赖库7. 启动 Web UI8. 访问 Web UI9. OpenAI 兼容 API 0. 背景
一直喜欢用 FastChat 本地部署大语言模型今天试一试 text-generation-webui 这个项目。 1. text-generation-webui 介绍
text-generation-webui 适用于大型语言模型的 Gradio Web UI。支持transformers、GPTQ、AWQ、EXL2、llama.cpp (GGUF)、Llama 模型。
它的特点如下
3种界面模式default (two columns), notebook, chat支持多个模型后端Transformers、llama.cpp通过 llama-cpp-python、ExLlama、ExLlamaV2、AutoGPTQ、AutoAWQ、GPTQ-for-LLaMa、CTransformers、QuIP#。下拉菜单可在不同模型之间快速切换。大量扩展内置和用户贡献包括用于真实语音输出的 Coqui TTS、用于语音输入的 Whisper STT、翻译、多模式管道、向量数据库、Stable Diffusion集成等等。有关详细信息请参阅 wiki 和扩展目录。与自定义角色聊天。适用于指令跟踪模型的精确聊天模板包括 Llama-2-chat、Alpaca、Vicuna、Mistral。LoRA使用您自己的数据训练新的 LoRA动态加载/卸载 LoRA 以进行生成。Transformers 库集成通过 bitsandbytes 以 4 位或 8 位精度加载模型将 llama.cpp 与 Transformers 采样器 llamacpp_HF 加载器结合使用使用 PyTorch 以 32 位精度进行 CPU 推理。具有 OpenAI 兼容的 Chat 和 Completions API 服务器 - 请参阅示例。
2. 克隆代码
git clone https://github.com/oobabooga/text-generation-webui.git;
cd text-generation-webui3. 创建虚拟环境
(Optional)安装 Conda
curl -sL https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh Miniconda3.sh
bash Miniconda3.sh创建虚拟环境
conda create -n textgen python3.11 -y
conda activate textgen4. 安装 pytorch
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121确认 pytorch 是否安装成功
python -c import torch;print(torch.cuda.is_available()):--- 安装成功输出应该为 True
True5. 安装 CUDA 运行时库
conda install -y -c nvidia/label/cuda-12.1.1 cuda-runtime如果您需要 nvcc 手动编译某些库请将上面的命令替换为
conda install -y -c nvidia/label/cuda-12.1.1 cuda6. 安装依赖库
pip install -r requirements.txt
pip install transformers_stream_generator
pip install tiktoken7. 启动 Web UI
python server.py
# python server.py --trust-remote-code --listen8. 访问 Web UI
使用浏览器打开 http://localhost:7860/?__themedark 9. OpenAI 兼容 API
pip install -r extensions/openai/requirements.txt启动
python server.py --trust-remote-code --api --api-port 8000 --listenrefer:https://github.com/oobabooga/text-generation-webui/wiki/12—OpenAI-API
完结