kikocis/llama-stack public
Changesets · Branches · Tags · Compare
| Changeset | 22356ba7a1406f3238233de68fa61d2b42e08f6adf2bbe3c0c17e65a07f1202a |
|---|---|
| Author | Xi Yan <xiyan@meta.com> · 2024-09-18 23:05 -07:00 |
| Committer | GitHub <noreply@github.com> · 2024-09-18 23:05 -07:00 |
| Parents | f0b76204d6fb |
1 file changed
modified docs/cli_reference.md +71 −57
| @@ -262,7 +262,7 @@ | ||
| 262 | 262 | |
| 263 | 263 | - Please see our [Getting Started](getting_started.md) guide for details. |
| 264 | 264 | |
| 265 | -### Step 3.1. Build | |
| 265 | +### Step 3.1 Build | |
| 266 | 266 | In the following steps, imagine we'll be working with a `Meta-Llama3.1-8B-Instruct` model. We will name our build `8b-instruct` to help us remember the config. We will start build our distribution (in the form of a Conda environment, or Docker image). In this step, we will specify: |
| 267 | 267 | - `name`: the name for our distribution (e.g. `8b-instruct`) |
| 268 | 268 | - `image_type`: our build image type (`conda | docker`) |
| @@ -271,74 +271,94 @@ | ||
| 271 | 271 | - `providers`: specifies the underlying implementation for serving each API endpoint |
| 272 | 272 | - `image_type`: `conda` | `docker` to specify whether to build the distribution in the form of Docker image or Conda environment. |
| 273 | 273 | |
| 274 | -#### Build a local distribution with conda | |
| 275 | -The following command and specifications allows you to get started with building. | |
| 274 | + | |
| 275 | +At the end of build command, we will generate `<name>-build.yaml` file storing the build configurations. | |
| 276 | + | |
| 277 | +After this step is complete, a file named `<name>-build.yaml` will be generated and saved at the output file path specified at the end of the command. | |
| 278 | + | |
| 279 | +#### Building from scratch | |
| 280 | +- For a new user, we could start off with running `llama stack build` which will allow you to a interactively enter wizard where you will be prompted to enter build configurations. | |
| 276 | 281 | ``` |
| 277 | -llama stack build <path/to/config> | |
| 282 | +llama stack build | |
| 278 | 283 | ``` |
| 279 | -- You will be required to pass in a file path to the build.config file (e.g. `./llama_stack/distribution/example_configs/conda/local-conda-example-build.yaml`). We provide some example build config files for configuring different types of distributions in the `./llama_stack/distribution/example_configs/` folder. | |
| 280 | 284 | |
| 281 | -The file will be of the contents | |
| 285 | +Running the command above will allow you to fill in the configuration to build your Llama Stack distribution, you will see the following outputs. | |
| 286 | + | |
| 282 | 287 | ``` |
| 283 | -$ cat ./llama_stack/distribution/example_configs/conda/local-conda-example-build.yaml | |
| 288 | +> Enter an unique name for identifying your Llama Stack build distribution (e.g. my-local-stack): my-local-llama-stack | |
| 289 | +> Enter the image type you want your distribution to be built with (docker or conda): conda | |
| 284 | 290 | |
| 285 | -name: 8b-instruct | |
| 286 | -distribution_spec: | |
| 287 | - distribution_type: local | |
| 288 | - description: Use code from `llama_stack` itself to serve all llama stack APIs | |
| 289 | - docker_image: null | |
| 290 | - providers: | |
| 291 | - inference: meta-reference | |
| 292 | - memory: meta-reference-faiss | |
| 293 | - safety: meta-reference | |
| 294 | - agentic_system: meta-reference | |
| 295 | - telemetry: console | |
| 296 | -image_type: conda | |
| 291 | + Llama Stack is composed of several APIs working together. Let's configure the providers (implementations) you want to use for these APIs. | |
| 292 | +> Enter the API provider for the inference API: (default=meta-reference): meta-reference | |
| 293 | +> Enter the API provider for the safety API: (default=meta-reference): meta-reference | |
| 294 | +> Enter the API provider for the agents API: (default=meta-reference): meta-reference | |
| 295 | +> Enter the API provider for the memory API: (default=meta-reference): meta-reference | |
| 296 | +> Enter the API provider for the telemetry API: (default=meta-reference): meta-reference | |
| 297 | + | |
| 298 | + > (Optional) Enter a short description for your Llama Stack distribution: | |
| 299 | + | |
| 300 | +Build spec configuration saved at ~/.conda/envs/llamastack-my-local-llama-stack/my-local-llama-stack-build.yaml | |
| 301 | +``` | |
| 302 | + | |
| 303 | +#### Building from templates | |
| 304 | +- To build from alternative API providers, we provide distribution templates for users to get started building a distribution backed by different providers. | |
| 305 | + | |
| 306 | +The following command will allow you to see the available templates and their corresponding providers. | |
| 307 | +``` | |
| 308 | +llama stack build --list-templates | |
| 309 | +``` | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | +You may then pick a template to build your distribution with providers fitted to your liking. | |
| 314 | + | |
| 315 | +``` | |
| 316 | +llama stack build --template local-tgi --name my-tgi-stack | |
| 297 | 317 | ``` |
| 298 | 318 | |
| 299 | -You may run the `llama stack build` command to generate your distribution with `--name` to override the name for your distribution. | |
| 300 | 319 | ``` |
| 301 | -$ llama stack build ~/.llama/distributions/conda/8b-instruct-build.yaml --name 8b-instruct | |
| 320 | +$ llama stack build --template local-tgi --name my-tgi-stack | |
| 302 | 321 | ... |
| 303 | 322 | ... |
| 304 | -Build spec configuration saved at ~/.llama/distributions/conda/8b-instruct-build.yaml | |
| 323 | +Build spec configuration saved at ~/.conda/envs/llamastack-my-tgi-stack/my-tgi-stack-build.yaml | |
| 324 | +You may now run `llama stack configure my-tgi-stack` or `llama stack configure ~/.conda/envs/llamastack-my-tgi-stack/my-tgi-stack-build.yaml` | |
| 305 | 325 | ``` |
| 306 | 326 | |
| 307 | -After this step is complete, a file named `8b-instruct-build.yaml` will be generated and saved at `~/.llama/distributions/conda/8b-instruct-build.yaml`. | |
| 327 | +#### Building from config file | |
| 328 | +- In addition to templates, you may customize the build to your liking through editing config files and build from config files with the following command. | |
| 308 | 329 | |
| 309 | - | |
| 310 | -#### How to build distribution with different API providers using configs | |
| 311 | -To specify a different API provider, we can change the `distribution_spec` in our `<name>-build.yaml` config. For example, the following build spec allows you to build a distribution using TGI as the inference API provider. | |
| 330 | +- The config file will be of contents like the ones in `llama_stack/distributions/templates/`. | |
| 312 | 331 | |
| 313 | 332 | ``` |
| 314 | -$ cat ./llama_stack/distribution/example_configs/conda/local-tgi-conda-example-build.yaml | |
| 333 | +$ cat llama_stack/distribution/templates/local-ollama-build.yaml | |
| 315 | 334 | |
| 316 | -name: local-tgi-conda-example | |
| 335 | +name: local-ollama | |
| 317 | 336 | distribution_spec: |
| 318 | - description: Use TGI (local or with Hugging Face Inference Endpoints for running LLM inference. When using HF Inference Endpoints, you must provide the name of the endpoint). | |
| 319 | - docker_image: null | |
| 337 | + description: Like local, but use ollama for running LLM inference | |
| 320 | 338 | providers: |
| 321 | - inference: remote::tgi | |
| 322 | - memory: meta-reference-faiss | |
| 339 | + inference: remote::ollama | |
| 340 | + memory: meta-reference | |
| 323 | 341 | safety: meta-reference |
| 324 | - agentic_system: meta-reference | |
| 325 | - telemetry: console | |
| 342 | + agents: meta-reference | |
| 343 | + telemetry: meta-reference | |
| 326 | 344 | image_type: conda |
| 327 | 345 | ``` |
| 328 | 346 | |
| 329 | -The following command allows you to build a distribution with TGI as the inference API provider, with the name `tgi`. | |
| 330 | 347 | ``` |
| 331 | -llama stack build --config ./llama_stack/distribution/example_configs/conda/local-tgi-conda-example-build.yaml --name tgi | |
| 348 | +llama stack build --config llama_stack/distribution/templates/local-ollama-build.yaml | |
| 332 | 349 | ``` |
| 333 | 350 | |
| 334 | -We provide some example build configs to help you get started with building with different API providers. | |
| 335 | - | |
| 336 | 351 | #### How to build distribution with Docker image |
| 337 | -To build a docker image, simply change the `image_type` to `docker` in our `<name>-build.yaml` file, and run `llama stack build --config <name>-build.yaml`. | |
| 352 | + | |
| 353 | +To build a docker image, you may start off from a template and use the `--image-type docker` flag to specify `docker` as the build image type. | |
| 338 | 354 | |
| 339 | 355 | ``` |
| 340 | -$ cat ./llama_stack/distribution/example_configs/docker/local-docker-example-build.yaml | |
| 356 | +llama stack build --template local --image-type docker --name docker-0 | |
| 357 | +``` | |
| 341 | 358 | |
| 359 | +Alternatively, you may use a config file and set `image_type` to `docker` in our `<name>-build.yaml` file, and run `llama stack build <name>-build.yaml`. The `<name>-build.yaml` will be of contents like: | |
| 360 | + | |
| 361 | +``` | |
| 342 | 362 | name: local-docker-example |
| 343 | 363 | distribution_spec: |
| 344 | 364 | description: Use code from `llama_stack` itself to serve all llama stack APIs |
| @@ -352,22 +372,23 @@ | ||
| 352 | 372 | image_type: docker |
| 353 | 373 | ``` |
| 354 | 374 | |
| 355 | -The following command allows you to build a Docker image with the name `docker-local` | |
| 375 | +The following command allows you to build a Docker image with the name `<name>` | |
| 356 | 376 | ``` |
| 357 | -llama stack build --config ./llama_stack/distribution/example_configs/docker/local-docker-example-build.yaml --name docker-local | |
| 377 | +llama stack build --config <name>-build.yaml | |
| 358 | 378 | |
| 359 | 379 | Dockerfile created successfully in /tmp/tmp.I0ifS2c46A/DockerfileFROM python:3.10-slim |
| 360 | 380 | WORKDIR /app |
| 361 | 381 | ... |
| 362 | 382 | ... |
| 363 | 383 | You can run it with: podman run -p 8000:8000 llamastack-docker-local |
| 364 | -Build spec configuration saved at /home/xiyan/.llama/distributions/docker/docker-local-build.yaml | |
| 384 | +Build spec configuration saved at ~/.llama/distributions/docker/docker-local-build.yaml | |
| 365 | 385 | ``` |
| 366 | 386 | |
| 367 | -### Step 3.2. Configure | |
| 387 | + | |
| 388 | +### Step 3.2 Configure | |
| 368 | 389 | After our distribution is built (either in form of docker or conda environment), we will run the following command to |
| 369 | 390 | ``` |
| 370 | -llama stack configure [<path/to/name.build.yaml> | <docker-image-name>] | |
| 391 | +llama stack configure [ <name> | <docker-image-name> | <path/to/name.build.yaml>] | |
| 371 | 392 | ``` |
| 372 | 393 | - For `conda` environments: <path/to/name.build.yaml> would be the generated build spec saved from Step 1. |
| 373 | 394 | - For `docker` images downloaded from Dockerhub, you could also use <docker-image-name> as the argument. |
| @@ -418,17 +439,7 @@ | ||
| 418 | 439 | Note that all configurations as well as models are stored in `~/.llama` |
| 419 | 440 | |
| 420 | 441 | |
| 421 | -#### Step 3.2.1 API Keys for Tools | |
| 422 | - | |
| 423 | -API key configuration for the Agentic System will be asked by the `llama stack build` script when you install a Llama Stack distribution. | |
| 424 | - | |
| 425 | -Tools that the model supports and which need API Keys -- | |
| 426 | -- Brave for web search (https://api.search.brave.com/register) | |
| 427 | -- Wolfram for math operations (https://developer.wolframalpha.com/) | |
| 428 | - | |
| 429 | -> **Tip** If you do not have API keys, you can still run the app without model having access to the tools. | |
| 430 | - | |
| 431 | -### Step 3.3. Run | |
| 442 | +### Step 3.3 Run | |
| 432 | 443 | Now, let's start the Llama Stack Distribution Server. You will need the YAML configuration file which was written out at the end by the `llama stack configure` step. |
| 433 | 444 | |
| 434 | 445 | ``` |
| @@ -469,11 +480,14 @@ | ||
| 469 | 480 | ``` |
| 470 | 481 | |
| 471 | 482 | > [!NOTE] |
| 472 | -> Configuration is in `~/.llama/builds/local/conda/8b-instruct.yaml`. Feel free to increase `max_seq_len`. | |
| 483 | +> Configuration is in `~/.llama/builds/local/conda/8b-instruct-run.yaml`. Feel free to increase `max_seq_len`. | |
| 473 | 484 | |
| 474 | 485 | > [!IMPORTANT] |
| 475 | 486 | > The "local" distribution inference server currently only supports CUDA. It will not work on Apple Silicon machines. |
| 476 | 487 | |
| 488 | +> [!TIP] | |
| 489 | +> You might need to use the flag `--disable-ipv6` to Disable IPv6 support | |
| 490 | + | |
| 477 | 491 | This server is running a Llama model locally. |
| 478 | 492 | |
| 479 | 493 | ### Step 3.4 Test with Client |