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