Text Generation Inference 文件

從原始碼安裝

Hugging Face's logo
加入 Hugging Face 社群

並獲得增強的文件體驗

開始使用

從原始碼安裝

不建議使用從原始碼安裝 TGI。我們強烈建議透過 Docker 使用 TGI,請查閱快速導覽Nvidia GPU 安裝說明以及AMD GPU 安裝說明以了解如何使用 Docker 執行 TGI。

安裝 CLI

您可以使用 TGI 命令列介面 (CLI) 來下載權重、提供模型服務、量化模型,或是獲取有關服務參數的資訊。

要安裝 CLI,您需要先複製 (clone) TGI 儲存庫,然後執行 make

git clone https://github.com/huggingface/text-generation-inference.git && cd text-generation-inference
make install

如果您希望使用自訂核心 (custom kernels) 來提供模型服務,請執行

BUILD_EXTENSIONS=True make install

本機從原始碼安裝

在開始之前,您需要設定環境並安裝 Text Generation Inference。Text Generation Inference 已在 Python 3.9+ 上進行測試。

Text Generation Inference 可透過 pypi、conda 和 GitHub 取得。

若要進行本機安裝並啟動,請先安裝 Rust,並使用至少 Python 3.9 的版本建立 Python 虛擬環境(例如使用 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 上更新

© . This site is unofficial and not affiliated with Hugging Face, Inc.