AI Hints
Home›Fine-Tuning LLMs Tutorial›Sharing and Serving Your Model
Fine-Tuning LLMs · Lesson 98 of 120

Serving with vLLM

A fast model server.

⏱ 2 min read▶ Video at 2:29:19🎓 Free
Watch this lesson in the Fine-Tuning LLMs courseWatch on YouTube ↗Full Fine-Tuning LLMs course

Generate is fine for testing. But a real app might get hundreds of requests at once. For that, we need a model server.

  • generate() is for testing
  • Hundreds of requests
  • We need a server

What is vLLM?

VLLM is a popular, open source model server. It's fast, because it handles many requests together, in batches. It speaks the same API as Open AI, so most tools work with it. And it can serve LoRA adapters, on top of one base model.

keyvalue
vLLMopen source model server
Fastbatches many requests
APIOpenAI compatible
LoRAserve adapters directly

Serving our adapter

Here's how you'd serve our model. VLLM needs a Linux machine, with an Nvidia GPU, so this is shown, not run. Vllm serve starts the server, with the base model. Enable lora, and lora modules, add our adapter, under the name tickets. Then any client sends a normal chat request. The model name, tickets, picks our adapter.

serve.shbash
pip install vllm                     # needs a Linux machine with an NVIDIA GPU

vllm serve HuggingFaceTB/SmolLM2-135M-Instruct \
    --enable-lora --lora-modules tickets=./ticket-lora \
    --port 8000

curl http://localhost:8000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model": "tickets",
       "messages": [{"role": "user", "content": "Is Dune in stock?"}]}'

Other servers

VLLM isn't the only choice. Text generation inference, from Hugging Face, is similar. SG Lang is another fast server. And for laptops, and small machines, llama dot c p p, and Ollama, are the usual picks. That's our next lesson.

keyvalue
TGIHugging Face's server
SGLanganother fast server
llama.cppCPUs and laptops
Ollamaeasy local models

Summary

Let's recap. A model server handles many requests at once. VLLM is fast, and Open AI compatible. And it can serve LoRA adapters directly. Next, running our model locally, with GGUF and Ollama.

Key takeaways
  • Model server
  • vLLM: fast, OpenAI API
  • Serves LoRA adapters
Next up: GGUF and Ollama — run it on a laptop