Hello and thanks for your work!
Context
I work on the Haystack LLM framework, which provides Embedders based on huggingface_hub.
The HuggingFaceAPITextEmbedder transforms a string into a vector. The HuggingFaceAPIDocumentEmbedder enriches a Document with its embedding.
These components allow using different HF APIs via huggingface_hub: Serverless Inference API, Inference Endpoints, and self-hosted Text Embeddings Inference container.
In the past, we used InferenceClient.post to query the API, mainly to support truncate and normalize (which were missing in the feature_extraction method before #2270).
Now that InferenceClient.post is changing and will be removed in 0.31.0, I'm migrating to InferenceClient.feature_extraction.
Issue
There's only one issue:
-
In HuggingFaceAPIDocumentEmbedder, we allow batching, which is explicitly supported by TEI (and Inference Endpoints).
-
Passing a list of inputs to the text parameter of feature_extraction seems to work correctly—I've tested it with Serverless Inference API, Inference Endpoints, and self-hosted TEI.
-
However, the method signature of feature_extraction officially supports only str, not List[str].
Questions
Given this, I'd like to ask:
- Do you plan to support
List[str] in feature_extraction?
- Will this behavior continue to work in the future?
- If not, what alternative approach would you recommend for batching embedding generation via
InferenceClient?
Hello and thanks for your work!
Context
I work on the Haystack LLM framework, which provides Embedders based on
huggingface_hub.The
HuggingFaceAPITextEmbeddertransforms a string into a vector. TheHuggingFaceAPIDocumentEmbedderenriches a Document with its embedding.These components allow using different HF APIs via
huggingface_hub: Serverless Inference API, Inference Endpoints, and self-hosted Text Embeddings Inference container.In the past, we used
InferenceClient.postto query the API, mainly to supporttruncateandnormalize(which were missing in thefeature_extractionmethod before #2270).Now that
InferenceClient.postis changing and will be removed in 0.31.0, I'm migrating toInferenceClient.feature_extraction.Issue
There's only one issue:
In
HuggingFaceAPIDocumentEmbedder, we allow batching, which is explicitly supported by TEI (and Inference Endpoints).Passing a list of inputs to the
textparameter offeature_extractionseems to work correctly—I've tested it with Serverless Inference API, Inference Endpoints, and self-hosted TEI.However, the method signature of
feature_extractionofficially supports onlystr, notList[str].Questions
Given this, I'd like to ask:
List[str]infeature_extraction?InferenceClient?