You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 13eda2b
Browse filesBrowse the repository at this point in the historyBrowse files
@@ -49,16 +54,17 @@ Unless you are using a self-hosted TGI/TEI server, set your Hugging Face token a
49
54
50
55
This integration provides several components to interact with Hugging Face APIs:
51
56
-[`HuggingFaceAPIChatGenerator`](https://docs.haystack.deepset.ai/docs/huggingfaceapichatgenerator): chat generation with LLMs.
52
-
-[`HuggingFaceAPITextEmbedder`](https://docs.haystack.deepset.ai/docs/huggingfaceapitextembedder): creates an embedding for text (used in query/RAG pipelines).
53
-
-[`HuggingFaceAPIDocumentEmbedder`](https://docs.haystack.deepset.ai/docs/huggingfaceapidocumentembedder): enriches documents with embeddings (used in indexing pipelines).
57
+
-[`HuggingFaceAPITextEmbedder`](https://docs.haystack.deepset.ai/docs/huggingfaceapitextembedder): creates a dense embedding for text (used in query/RAG pipelines).
58
+
-[`HuggingFaceAPIDocumentEmbedder`](https://docs.haystack.deepset.ai/docs/huggingfaceapidocumentembedder): enriches documents with dense embeddings (used in indexing pipelines).
59
+
-[`HuggingFaceTEISparseTextEmbedder`](https://docs.haystack.deepset.ai/docs/huggingfaceteisparsetextembedder): creates a sparse embedding for text using a TEI endpoint (used in query pipelines).
60
+
-[`HuggingFaceTEISparseDocumentEmbedder`](https://docs.haystack.deepset.ai/docs/huggingfaceteisparsedocumentembedder): enriches documents with sparse embeddings using a TEI endpoint (used in indexing pipelines).
54
61
-[`HuggingFaceTEIRanker`](https://docs.haystack.deepset.ai/docs/huggingfaceteiranker): ranks documents based on their similarity to the query, using a TEI endpoint.
55
62
56
63
### Chat Generation
57
64
58
65
Use [`HuggingFaceAPIChatGenerator`](https://docs.haystack.deepset.ai/docs/huggingfaceapichatgenerator) with the Serverless Inference API (Inference Providers):
59
66
60
67
```python
61
-
from haystack.dataclasses import ChatMessage
62
68
from haystack_integrations.components.generators.huggingface_api import HuggingFaceAPIChatGenerator
To create semantic embeddings for documents, use [`HuggingFaceAPIDocumentEmbedder`](https://docs.haystack.deepset.ai/docs/huggingfaceapidocumentembedder) in your indexing pipeline. For generating embeddings for queries, use [`HuggingFaceAPITextEmbedder`](https://docs.haystack.deepset.ai/docs/huggingfaceapitextembedder).
85
91
@@ -95,7 +101,7 @@ print(text_embedder.run("I love pizza!"))
To create sparse embeddings for queries, use [`HuggingFaceTEISparseTextEmbedder`](https://docs.haystack.deepset.ai/docs/huggingfaceteisparsetextembedder). For documents, use [`HuggingFaceTEISparseDocumentEmbedder`](https://docs.haystack.deepset.ai/docs/huggingfaceteisparsedocumentembedder), which stores the embeddings in each document's `sparse_embedding` field.
116
+
117
+
Both components support HTTP or gRPC and require a TEI server running a compatible sparse embedding model with SPLADE pooling.
118
+
119
+
```python
120
+
from haystack_integrations.components.embedders.huggingface_api import (
121
+
HuggingFaceTEISparseTextEmbedder,
122
+
)
123
+
124
+
embedder = HuggingFaceTEISparseTextEmbedder(
125
+
api_base_url="http://localhost:8080",
126
+
)
127
+
result = embedder.run(text="Who lives in Berlin?")
Use [`HuggingFaceTEIRanker`](https://docs.haystack.deepset.ai/docs/huggingfaceteiranker) to rank documents with a reranking model served by a TEI endpoint:
134
+
Use [`HuggingFaceTEIRanker`](https://docs.haystack.deepset.ai/docs/huggingfaceteiranker) to rank documents with a reranking model served by a TEI endpoint. It supports HTTP or gRPC:
0 commit comments