Installation
- pip
- Docker
Install
vLLM v0.14 or a more recent version:Basic Usage
TheLLM class provides a simple interface for offline inference. Use the chat() method to automatically apply the chat template and generate text:
Sampling Parameters
Control text generation behavior usingSamplingParams. Key parameters:
temperature(float, default 1.0): Controls randomness (0.0 = deterministic, higher = more random). Typical range: 0.1-2.0top_p(float, default 1.0): Nucleus sampling - limits to tokens with cumulative probability ≤ top_p. Typical range: 0.1-1.0top_k(int, default -1): Limits to top-k most probable tokens (-1 = disabled). Typical range: 1-100min_p(float): Minimum token probability threshold. Typical range: 0.01-0.2max_tokens(int): Maximum number of tokens to generaterepetition_penalty(float, default 1.0): Penalty for repeating tokens (>1.0 = discourage repetition). Typical range: 1.0-1.5stop(strorlist[str]): Strings that terminate generation when encountered
SamplingParams object:
Batched Generation
vLLM automatically batches multiple prompts for efficient processing. You can control batch behavior and generate responses for large datasets:OpenAI-Compatible Server
vLLM can serve models through an OpenAI-compatible API, allowing you to use existing OpenAI client libraries.- vllm serve
- Docker
--max-model-len L: Set maximum context length--gpu-memory-utilization 0.9: Set GPU memory usage (0.0-1.0)
Chat Completions
Once running, you can use the OpenAI Python client or any OpenAI-compatible tool:Curl request example
Curl request example
Vision Models
Installation for Vision Models
To use LFM Vision Models with vLLM, install the required versions:Basic Usage
Initialize a vision model and process text and image inputs:OpenAI-Compatible API
You can also serve vision models through the OpenAI-compatible API:For a complete working example, see the vLLM Vision Model Colab notebook.