Skip to content

feat: add vLLM embedders#3163

Merged
anakin87 merged 10 commits into
mainfrom
vllm-embedders
Apr 16, 2026
Merged

feat: add vLLM embedders#3163
anakin87 merged 10 commits into
mainfrom
vllm-embedders

Conversation

@anakin87
Copy link
Copy Markdown
Member

@anakin87 anakin87 commented Apr 14, 2026

Related Issues

Proposed Changes:

  • add VLLMTextEmbedder and VLLMDocumentEmbedder, very similar to other embedders

How did you test it?

CI, several new unit tests and integration tests

Notes for the reviewer

I made some design choices that I want to share

  • Supporting the OpenAI Embeddings API. vLLM offers two embedding endpoints, one compatible with the OpenAI API and another with Cohere API. Unfortunately, none of them is a superset of the other; they offer slightly different features. I selected the OpenAI endpoint because it seems to support most common use cases and also in relation to https://github.com/deepset-ai/haystack-private/issues/293.

  • I started with inheriting from Haystack's OpenAI embedders, then I realized I was reimplementing/patching __init__, serialization, run methods... so I decided to drop the inheritance and make standalone components. However, the code is very similar to OpenAI components.

Checklist

@github-actions github-actions Bot added integration:vllm type:documentation Improvements or additions to documentation labels Apr 14, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 14, 2026

Coverage report (vllm)

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  integrations/vllm/src/haystack_integrations/common/vllm
  utils.py
  integrations/vllm/src/haystack_integrations/components/embedders/vllm
  document_embedder.py 221-226, 258, 281, 284
  text_embedder.py 159, 176
  integrations/vllm/src/haystack_integrations/components/generators/vllm/chat
  chat_generator.py
Project Total  

This report was generated by python-coverage-comment-action

@anakin87 anakin87 marked this pull request as ready for review April 15, 2026 07:31
@anakin87 anakin87 requested a review from a team as a code owner April 15, 2026 07:31
@anakin87 anakin87 requested review from davidsbatista and removed request for a team April 15, 2026 07:31
@anakin87 anakin87 self-assigned this Apr 15, 2026
@anakin87 anakin87 requested review from bogdankostic and removed request for davidsbatista April 15, 2026 13:57
Copy link
Copy Markdown
Contributor

@bogdankostic bogdankostic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good overall, I'm just wondering if the serialization methods are needed.

Comment on lines +149 to +177
def to_dict(self) -> dict[str, Any]:
"""
Serialize this component to a dictionary.

:returns: The serialized component as a dictionary.
"""
return default_to_dict(
self,
model=self.model,
api_key=self.api_key,
api_base_url=self.api_base_url,
prefix=self.prefix,
suffix=self.suffix,
dimensions=self.dimensions,
batch_size=self.batch_size,
progress_bar=self.progress_bar,
meta_fields_to_embed=self.meta_fields_to_embed,
embedding_separator=self.embedding_separator,
timeout=self.timeout,
max_retries=self.max_retries,
http_client_kwargs=self.http_client_kwargs,
raise_on_failure=self.raise_on_failure,
extra_parameters=self.extra_parameters,
)

@classmethod
def from_dict(cls, data: dict[str, Any]) -> "VLLMDocumentEmbedder":
"""Deserialize this component from a dictionary."""
return default_from_dict(cls, data)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The serialization methods shouldn't be needed anymore, right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you are right. I'll try to remove them

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in 700f44d

Comment on lines +121 to +144
def to_dict(self) -> dict[str, Any]:
"""
Serialize this component to a dictionary.

:returns: The serialized component as a dictionary.
"""
return default_to_dict(
self,
model=self.model,
api_key=self.api_key.to_dict() if self.api_key else None,
api_base_url=self.api_base_url,
prefix=self.prefix,
suffix=self.suffix,
dimensions=self.dimensions,
timeout=self.timeout,
max_retries=self.max_retries,
http_client_kwargs=self.http_client_kwargs,
extra_parameters=self.extra_parameters,
)

@classmethod
def from_dict(cls, data: dict[str, Any]) -> "VLLMTextEmbedder":
"""Deserialize this component from a dictionary."""
return default_from_dict(cls, data)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question here whether the serialization methods are needed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in 700f44d

@anakin87 anakin87 requested a review from bogdankostic April 16, 2026 10:23
@anakin87 anakin87 merged commit c3069c8 into main Apr 16, 2026
11 checks passed
@anakin87 anakin87 deleted the vllm-embedders branch April 16, 2026 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration:vllm topic:CI type:documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants