Core Concepts — llama-stack documentation (original) (raw)

Given Llama Stack’s service-oriented philosophy, a few concepts and workflows arise which may not feel completely natural in the LLM landscape, especially if you are coming with a background in other frameworks.

APIs

A Llama Stack API is described as a collection of REST endpoints. We currently support the following APIs:

We are working on adding a few more APIs to complete the application lifecycle. These will include:

API Providers

The goal of Llama Stack is to build an ecosystem where users can easily swap out different implementations for the same API. Examples for these include:

Providers come in two flavors:

Most importantly, Llama Stack always strives to provide at least one fully inline provider for each API so you can iterate on a fully featured environment locally.

Resources

Some of these APIs are associated with a set of Resources. Here is the mapping of APIs to resources:

Furthermore, we allow these resources to be federated across multiple providers. For example, you may have some Llama models served by Fireworks while others are served by AWS Bedrock. Regardless, they will all work seamlessly with the same uniform Inference API provided by Llama Stack.

Registering Resources

Given this architecture, it is necessary for the Stack to know which provider to use for a given resource. This means you need to explicitly register resources (including models) before you can use them with the associated APIs.

Distributions

While there is a lot of flexibility to mix-and-match providers, often users will work with a specific set of providers (hardware support, contractual obligations, etc.) We therefore need to provide a convenient shorthand for such collections. We call this shorthand a Llama Stack Distribution or a Distro. One can think of it as specific pre-packaged versions of the Llama Stack. Here are some examples:

Remotely Hosted Distro: These are the simplest to consume from a user perspective. You can simply obtain the API key for these providers, point to a URL and have all Llama Stack APIs working out of the box. Currently, Fireworks and Together provide such easy-to-consume Llama Stack distributions.

Locally Hosted Distro: You may want to run Llama Stack on your own hardware. Typically though, you still need to use Inference via an external service. You can use providers like HuggingFace TGI, Fireworks, Together, etc. for this purpose. Or you may have access to GPUs and can run a vLLM or NVIDIA NIM instance. If you “just” have a regular desktop machine, you can use Ollama for inference. To provide convenient quick access to these options, we provide a number of such pre-configured locally-hosted Distros.

On-device Distro: To run Llama Stack directly on an edge device (mobile phone or a tablet), we provide Distros for iOS and Android

Evaluation Concepts

The Llama Stack Evaluation flow allows you to run evaluations on your GenAI application datasets or pre-registered benchmarks.

We introduce a set of APIs in Llama Stack for supporting running evaluations of LLM applications.

This guide goes over the sets of APIs and developer experience flow of using Llama Stack to run evaluations for different use cases. Checkout our Colab notebook on working examples with evaluations here.

The Evaluation APIs are associated with a set of Resources. Please visit the Resources section in our Core Concepts guide for better high-level understanding.

Open-benchmark Eval

List of open-benchmarks Llama Stack support

Llama stack pre-registers several popular open-benchmarks to easily evaluate model perfomance via CLI.

The list of open-benchmarks we currently support:

You can follow this contributing guide to add more open-benchmarks to Llama Stack

Run evaluation on open-benchmarks via CLI

We have built-in functionality to run the supported open-benckmarks using llama-stack-client CLI

Spin up Llama Stack server

Spin up llama stack server with ‘open-benchmark’ template

llama stack run llama_stack/templates/open-benchmark/run.yaml

Run eval CLI

There are 3 necessary inputs to run a benchmark eval

llama-stack-client eval run-benchmark ...
--model_id
--output_dir \

You can run

llama-stack-client eval run-benchmark help

to see the description of all the flags that eval run-benchmark has

In the output log, you can find the file path that has your evaluation results. Open that file and you can see you aggregate evaluation results over there.

What’s Next?