text-generation-inference 文档
从源代码安装
加入 Hugging Face 社区
并获得增强的文档体验
开始使用
从源代码安装
不推荐从源代码安装 TGI。我们强烈建议通过 Docker 使用 TGI,请查看快速入门、Nvidia GPU 安装和AMD GPU 安装以了解如何使用 Docker 使用 TGI。
安装 CLI
您可以使用 TGI 命令行界面 (CLI) 下载权重、提供和量化模型,或获取服务参数信息。
要安装 CLI,您需要先克隆 TGI 仓库,然后运行 make
。
git clone https://github.com/huggingface/text-generation-inference.git && cd text-generation-inference
make install
如果您想使用自定义内核提供模型,请运行
BUILD_EXTENSIONS=True make install
从源代码本地安装
在开始之前,您需要设置环境并安装文本生成推理。文本生成推理在 Python 3.9+ 上进行了测试。
文本生成推理可在 pypi、conda 和 GitHub 上获取。
要本地安装和启动,首先安装 Rust 并创建一个 Python 虚拟环境,至少使用 Python 3.9,例如使用 conda
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
conda create -n text-generation-inference python=3.9
conda activate text-generation-inference
您可能还需要安装 Protoc。
在 Linux 上
PROTOC_ZIP=protoc-21.12-linux-x86_64.zip
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v21.12/$PROTOC_ZIP
sudo unzip -o $PROTOC_ZIP -d /usr/local bin/protoc
sudo unzip -o $PROTOC_ZIP -d /usr/local 'include/*'
rm -f $PROTOC_ZIP
在 MacOS 上,使用 Homebrew
brew install protobuf
然后运行以安装文本生成推理
git clone https://github.com/huggingface/text-generation-inference.git && cd text-generation-inference
BUILD_EXTENSIONS=True make install
在某些机器上,您可能还需要 OpenSSL 库和 gcc。在 Linux 机器上,运行
sudo apt-get install libssl-dev gcc -y
安装完成后,只需运行
make run-falcon-7b-instruct
这将从 8080 端口提供 Falcon 7B Instruct 模型,我们可以对其进行查询。
< > 在 GitHub 上更新