Transitioning from a local demo to a production-grade service requires moving beyond single-user tools like Ollama to high-throughput inference engines like vLLM, and implementing robust security boundaries.
While Ollama is excellent for developer workflows, its sequential inference model is a bottleneck for multi-user applications. For production, vLLM is the standard.
The core innovation of vLLM is PagedAttention, which manages the Key-Value (KV) cache like virtual memory. This eliminates fragmentation and allows for:
To serve Llama 3 8B with 4-bit quantization and high throughput:
python -m vllm.entrypoints.openai.api_server \
--model meta-llama/Meta-Llama-3-8B-Instruct \
--quantization bitsandbytes \
--load-format bitsandbytes \
--gpu-memory-utilization 0.95 \
--max-model-len 8192 \
--port 8000
Selecting the right quantization format depends on your hardware and fidelity requirements:
| Format | Library | Best For | Pros/Cons |
|---|---|---|---|
| GGUF | llama.cpp | CPU + GPU Mixed | Maximum compatibility; slower than pure GPU formats. |
| NF4 | bitsandbytes | NVIDIA GPUs | Industry standard for 4-bit; good balance of speed/quality. |
| EXL2 | ExLlamaV2 | NVIDIA GPUs | Extreme speed for local inference; requires specialized kernels. |
| AWQ | AutoAWQ | Production Serving | Activation-aware; excellent quality retention for reasoning. |
Expert Tip: For vLLM, use AWQ or FP8 (on H100s) for the best throughput-to-quality ratio.
In a production environment where multiple users or agents hit the same model, you must defend against Prompt Injection and Data Leakage.
Use a "Sandwich" approach:
When using Retrieval-Augmented Generation, ensure users only retrieve documents they are authorized to see.
owner_id or tenant_id.collection.query(..., where={"tenant_id": current_user_id}).A production LLM service must expose a /health endpoint that checks not just if the process is running, but if the GPU is responsive and model weights are loaded.
Integrate tracing to identify bottlenecks in the RAG pipeline.
Concrete Metric: Monitor Time to First Token (TTFT) and Inter-Token Latency. If TTFT exceeds 2 seconds, your batch size or concurrent request count is likely too high for your hardware.