text-generation-inference 文档

从源代码安装

Hugging Face's logo
加入 Hugging Face 社区

并获得增强的文档体验

开始入门

从源代码安装

不建议从源代码安装 TGI。 我们强烈建议通过 Docker 使用 TGI,查看快速入门Nvidia GPU 安装AMD GPU 安装,了解如何将 TGI 与 Docker 结合使用。

安装 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

从源代码本地安装

在开始之前,您需要设置您的环境并安装 Text Generation Inference。Text Generation Inference 在 Python 3.9+ 上进行了测试。

Text Generation Inference 在 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

然后运行以安装 Text Generation Inference

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 上更新