0


本地部署 text-generation-webui

本地部署 text-generation-webui

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-webui

3. 创建虚拟环境

(Optional)安装 Conda,

curl -sL "https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh" > "Miniconda3.sh"
bash Miniconda3.sh

创建虚拟环境,

conda create -n textgen python=3.11 -y
conda activate textgen

4. 安装 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
True

5. 安装 CUDA 运行时库

conda install -y -c "nvidia/label/cuda-12.1.1" cuda-runtime

如果您需要 nvcc 手动编译某些库,请将上面的命令替换为,

conda install -y -c "nvidia/label/cuda-12.1.1" cuda

6. 安装依赖库

pip install -r requirements.txt
pip install transformers_stream_generator
pip install tiktoken

7. 启动 Web UI

python server.py
# python server.py --trust-remote-code --listen

8. 访问 Web UI

使用浏览器打开 http://localhost:7860/?__theme=dark

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

9. OpenAI 兼容 API

pip install -r extensions/openai/requirements.txt

启动,

python server.py --trust-remote-code --api --api-port 8000 --listen

refer:https://github.com/oobabooga/text-generation-webui/wiki/12—OpenAI-API

完结!

标签: oobabooga GPTQ AWQ

本文转载自: https://blog.csdn.net/engchina/article/details/135241598
版权归原作者 engchina 所有, 如有侵权,请联系我们删除。

“本地部署 text-generation-webui”的评论:

还没有评论