llama-toolchain llama-toolchain Llama-toolchain

llama-toolchain Llama-toolchain Llama Stack

2 分钟阅读

llama-toolchain

Llama-toolchain是一个包含Llama Stack的API规范和部分API实现的仓库,主要聚焦于模型推理。Llama Stack包括两个主要部分:toolchain-apis和agentic-apis。本仓库提供了toolchain-apis的具体实现。

安装方法

可以通过以下方法将llama-toolchain作为一个包安装:

pip install llama-toolchain

如果需要从源码安装:

mkdir -p ~/local cd ~/local git clone git@github.com:meta-llama/llama-toolchain.git

conda create -n toolchain python=3.10 conda activate toolchain

cd llama-toolchain pip install -e .

使用CLI进行测试

llama-toolchain提供了一个简便的CLI工具来配置和运行工具链的各个部分。命令如下:

llama –help

usage: llama [-h] {download,inference,model,agentic_system} …

其中包含几个子命令以帮助用户开始操作。

启动推理服务器

可以通过以下命令配置并启动一个能运行llama模型的推理服务器:

llama inference configure llama inference start

测试客户端

可以通过以下命令测试推理客户端:

python -m llama_toolchain.inference.client localhost 5000

Initializing client for http://localhost:5000 User>hello world, help me out here Assistant> Hello! I’d be delighted to help you out. What’s on your mind? Do you have a question, a problem, or just need someone to chat with? I’m all ears!

运行FP8

为运行FP8需要安装fbgemm-gpu包,该包需要torch >= 2.4.0,现在可以通过创建环境并安装必要的依赖来实现:

ENV=fp8_env conda create -n $ENV python=3.10 conda activate $ENV

pip3 install -r fp8_requirements.txt

使用场景

Llama-toolchain的主要使用场景包括:

  1. 模型推理 :通过配置推理服务器和客户端,用户可以便捷地运行和测试Llama模型。
  2. 快速部署 :提供了简单的安装和配置工具,使得模型推理和其他相关任务的部署更加高效。
  3. 开发与研究 :适合开发者和研究人员使用,以便在本地环境中进行Llama Stack相关工具和模型的开发与测试。

综上,llama-toolchain是一个优秀的工具,用于简化和加速模型推理流程,适合各种开发和研究场景。