Skip to main content
For the complete documentation index for agents and LLMs, see llms.txt.

VLLMTextEmbedder

Embed strings using embedding models served with vLLM. Use this component in query pipelines to transform user queries into vectors for embedding-based retrieval.

Key Features

  • Works with any embedding model served by a vLLM server using the OpenAI-compatible Embeddings API.
  • Outputs a float vector embedding suitable for use with embedding retrievers.
  • Supports vLLM-specific parameters through extra_parameters.
  • The embedding model must match the one used by VLLMDocumentEmbedder in the indexing pipeline.
Embedding Models in Query Pipelines and Indexes

The embedding model you use to embed documents in your indexing pipeline must be the same as the embedding model you use to embed the query in your query pipeline.

This means the embedders for your indexing and query pipelines must match. For example, if you use CohereDocumentEmbedder to embed your documents, you should use CohereTextEmbedder with the same model to embed your queries.

Configuration

  1. Drag the VLLMTextEmbedder component onto the canvas from the Component Library.
  2. Click on the component to open the configuration panel.
  3. On the General tab:
    1. Set the model to the embedding model served by your vLLM instance.
    2. Set the api_base_url to your vLLM server address. The default is http://localhost:8000/v1.
  4. Go to the Advanced tab to configure dimensions, prefix, suffix, and extra_parameters.

Connections

VLLMTextEmbedder receives the user query as a text string, typically from the Input component. It outputs a float vector through its embedding output, which you connect to an embedding retriever.

Source Code

To check this component's source code, open text_embedder.py in the Haystack Core Integrations repository.

Usage Examples

Basic Configuration

  VLLMTextEmbedder:
type: haystack_integrations.components.embedders.vllm.VLLMTextEmbedder
init_parameters:
model: BAAI/bge-large-en-v1.5
api_base_url: http://localhost:8000/v1

Using the Component in a Pipeline

# haystack-pipeline
components:
VLLMTextEmbedder:
type: haystack_integrations.components.embedders.vllm.VLLMTextEmbedder
init_parameters:
model: BAAI/bge-large-en-v1.5
api_base_url: http://localhost:8000/v1

retriever:
type: haystack_integrations.components.retrievers.opensearch.embedding_retriever.OpenSearchEmbeddingRetriever
init_parameters:
top_k: 10
document_store:
type: haystack_integrations.document_stores.opensearch.document_store.OpenSearchDocumentStore
init_parameters:
hosts:
index: my-index
embedding_dim: 1024

connections:
- sender: VLLMTextEmbedder.embedding
receiver: retriever.query_embedding

max_runs_per_component: 100

metadata: {}

inputs:
query:
- VLLMTextEmbedder.text

Parameters

Inputs

ParameterTypeDescription
textstrThe text to embed.

Outputs

ParameterTypeDescription
embeddingList[float]The embedding of the text.
metaDict[str, Any]Metadata about the request.

Init Parameters

These are the parameters you can configure in Pipeline Builder:

ParameterTypeDefaultDescription
modelstr(required)The name of the embedding model served by the vLLM instance.
api_keyOptional[Secret]Secret.from_env_var("VLLM_API_KEY", strict=False)An API key for authenticated vLLM deployments.
api_base_urlstrhttp://localhost:8000/v1The URL of the vLLM server's OpenAI-compatible API.
prefixstr""A string to add at the beginning of the text before embedding.
suffixstr""A string to add at the end of the text before embedding.
dimensionsOptional[int]NoneThe number of dimensions in the output embedding, if the model supports it.
timeoutOptional[float]NoneRequest timeout in seconds.
max_retriesOptional[int]NoneMaximum number of retries on API errors.
http_client_kwargsOptional[Dict[str, Any]]NoneAdditional keyword arguments for the HTTP client.
extra_parametersOptional[Dict[str, Any]]NoneAdditional vLLM-specific parameters for the embedding request.

Run Method Parameters

These are the parameters you can configure for the component's run() method. This means you can pass these parameters at query time through the API, in Playground, or when running a job. For details, see Modify Pipeline Parameters at Query Time.

ParameterTypeDefaultDescription
textstrThe text to embed.