feat: add vLLM embedders#3163
Merged
Merged
Conversation
Contributor
Coverage report (vllm)Click to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
Contributor
bogdankostic
left a comment
There was a problem hiding this comment.
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) |
Contributor
There was a problem hiding this comment.
The serialization methods shouldn't be needed anymore, right?
Member
Author
There was a problem hiding this comment.
I think you are right. I'll try to remove them
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) |
Contributor
There was a problem hiding this comment.
Same question here whether the serialization methods are needed.
bogdankostic
approved these changes
Apr 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issues
Proposed Changes:
VLLMTextEmbedderandVLLMDocumentEmbedder, very similar to other embeddersHow 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
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:.