You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+65-15
Original file line number
Diff line number
Diff line change
@@ -1,22 +1,11 @@
1
1

2
2
3
3
# llama-swap
4
+
4
5
llama-swap is a light weight, transparent proxy server that provides automatic model swapping to llama.cpp's server.
5
6
6
7
Written in golang, it is very easy to install (single binary with no dependancies) and configure (single yaml file).
7
8
8
-
Download a pre-built [release](https://github.com/mostlygeek/llama-swap/releases) or build it yourself from source with `make clean all`.
9
-
10
-
## How does it work?
11
-
When a request is made to an OpenAI compatible endpoint, lama-swap will extract the `model` value and load the appropriate server configuration to serve it. If a server is already running it will stop it and start the correct one. This is where the "swap" part comes in. The upstream server is automatically swapped to the correct one to serve the request.
12
-
13
-
In the most basic configuration llama-swap handles one model at a time. For more advanced use cases, the `profiles` feature can load multiple models at the same time. You have complete control over how your system resources are used.
14
-
15
-
## Do I need to use llama.cpp's server (llama-server)?
16
-
Any OpenAI compatible server would work. llama-swap was originally designed for llama-server and it is the best supported.
17
-
18
-
For Python based inference servers like vllm or tabbyAPI it is recommended to run them via podman or docker. This provides clean environment isolation as well as responding correctly to `SIGTERM` signals to shutdown.
19
-
20
9
## Features:
21
10
22
11
- ✅ Easy to deploy: single binary with no dependencies
@@ -37,6 +26,66 @@ For Python based inference servers like vllm or tabbyAPI it is recommended to ru
37
26
- ✅ Use any local OpenAI compatible server (llama.cpp, vllm, tabbyAPI, etc)
38
27
- ✅ Direct access to upstream HTTP server via `/upstream/:model_id` ([demo](https://github.com/mostlygeek/llama-swap/pull/31))
-d '{"model":"smollm2","messages": [{"role": "user","content": "tell me a joke"}]}' | \
50
+
jq -r '.choices[0].message.content'
51
+
```
52
+
53
+
Docker images are [published nightly](https://github.com/mostlygeek/llama-swap/pkgs/container/llama-swap) that include the latest llama-swap and llama-server:
54
+
55
+
-`ghcr.io/mostlygeek/llama-swap:cuda`
56
+
-`ghcr.io/mostlygeek/llama-swap:intel`
57
+
-`ghcr.io/mostlygeek/llama-swap:vulkan`
58
+
-`ghcr.io/mostlygeek/llama-swap:musa`
59
+
60
+
Specific versions are also available and are tagged with the llama-swap, architecture and llama.cpp versions. For example: `ghcr.io/mostlygeek/llama-swap:v89-cuda-b4716`
61
+
62
+
Beyond the demo you will likely want to run the containers with your downloaded models and custom configuration.
63
+
64
+
```
65
+
$ docker run -it --rm --runtime nvidia -p 9292:8080 \
66
+
-v /path/to/models:/models \
67
+
-v /path/to/custom/config.yaml:/app/config.yaml \
68
+
ghcr.io/mostlygeek/llama-swap:cuda
69
+
```
70
+
71
+
## Bare metal Install ([download](https://github.com/mostlygeek/llama-swap/releases))
72
+
73
+
Pre-built binaries are available for Linux, FreeBSD and Darwin (OSX). These are automatically published and are likely a few hours ahead of the docker releases. The baremetal install works with any OpenAI compatible server, not just llama-server.
74
+
75
+
You can also build llama-swap yourself from source with `make clean all`.
76
+
77
+
## How does llama-swap work?
78
+
79
+
When a request is made to an OpenAI compatible endpoint, lama-swap will extract the `model` value and load the appropriate server configuration to serve it. If a server is already running it will stop it and start the correct one. This is where the "swap" part comes in. The upstream server is automatically swapped to the correct one to serve the request.
80
+
81
+
In the most basic configuration llama-swap handles one model at a time. For more advanced use cases, the `profiles` feature can load multiple models at the same time. You have complete control over how your system resources are used.
82
+
83
+
## Do I need to use llama.cpp's server (llama-server)?
84
+
85
+
Any OpenAI compatible server would work. llama-swap was originally designed for llama-server and it is the best supported.
86
+
87
+
For Python based inference servers like vllm or tabbyAPI it is recommended to run them via podman or docker. This provides clean environment isolation as well as responding correctly to `SIGTERM` signals to shutdown.
88
+
40
89
## config.yaml
41
90
42
91
llama-swap's configuration is purposefully simple.
@@ -59,8 +108,8 @@ models:
59
108
60
109
# aliases names to use this model for
61
110
aliases:
62
-
- "gpt-4o-mini"
63
-
- "gpt-3.5-turbo"
111
+
- "gpt-4o-mini"
112
+
- "gpt-3.5-turbo"
64
113
65
114
# check this path for an HTTP 200 OK before serving requests
66
115
# default: /health to match llama.cpp
@@ -121,7 +170,7 @@ profiles:
121
170
122
171
1. Create a configuration file, see [config.example.yaml](config.example.yaml)
123
172
1. Download a [release](https://github.com/mostlygeek/llama-swap/releases) appropriate for your OS and architecture.
124
-
* _Note: Windows currently untested._
173
+
-_Note: Windows currently untested._
125
174
1. Run the binary with `llama-swap --config path/to/config.yaml`
0 commit comments