Skip to content

Commit 32138ef

Browse files
dina-deifallahclaudekacperlukawskianakin87
authored
docs: add FastembedColbertRanker to fastembed integration page (#442)
* docs: add FastembedColbertRanker to fastembed integration page Updates the fastembed integration page to include the new FastembedColbertRanker component from PR #3135, which adds ColBERT late-interaction reranking support via fastembed. - Added FastembedColbertRanker to the components list - Added a usage example with ColBERT ranker in a pipeline Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Update integrations/fastembed.md Co-authored-by: Kacper Łukawski <kacperlukawski@users.noreply.github.com> * Adopt new component name --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: Kacper Łukawski <kacperlukawski@users.noreply.github.com> Co-authored-by: Stefano Fiorucci <stefanofiorucci@gmail.com>
1 parent 58238c3 commit 32138ef

File tree

1 file changed

+41
-2
lines changed

1 file changed

+41
-2
lines changed

integrations/fastembed.md

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ The `fastembed-haystack` integrations provides the following components:
4949
- `FastembedDocumentEmbedder`: enriches documents with dense embeddings (used in indexing pipelines).
5050
- `FastembedSparseTextEmbedder`: creates a sparse embedding for text (used in query/RAG pipelines).
5151
- `FastembedSparseDocumentEmbedder`: enriches documents with sparse embeddings (used in indexing pipelines).
52-
- Ranker:
53-
- `FastembedRanker`: ranks documents based on a query (used in query/RAG pipelines after the retrieval).
52+
- Rankers:
53+
- `FastembedRanker`: ranks documents based on a query using cross-encoder models (used in query/RAG pipelines after the retrieval).
54+
- `FastembedLateInteractionRanker`: ranks documents using ColBERT late-interaction (MaxSim) scoring (used in query/RAG pipelines after the retrieval).
5455

5556
### Example with dense embeddings
5657

@@ -162,6 +163,44 @@ query_pipeline.connect("retriever.documents", "ranker.documents")
162163
result = query_pipeline.run({"text_embedder": {"text": query}, "ranker": { "query" : query }})
163164
```
164165

166+
### Example with Late Interaction ranker
167+
168+
`FastembedLateInteractionRanker` uses ColBERT late-interaction scoring: the query and documents are encoded independently into token-level embeddings, and a MaxSim score is computed for each document. This offers stronger ranking quality than cross-encoders on many tasks while remaining efficient.
169+
170+
> **Note:** ColBERT scores are unnormalized sums. They are meaningful for ranking within a single query but should not be compared across queries.
171+
172+
```python
173+
from haystack import Document, Pipeline
174+
from haystack.components.retrievers.in_memory import InMemoryEmbeddingRetriever
175+
from haystack.document_stores.in_memory import InMemoryDocumentStore
176+
from haystack_integrations.components.embedders.fastembed import FastembedDocumentEmbedder, FastembedTextEmbedder
177+
from haystack_integrations.components.rankers.fastembed import FastembedLateInteractionRanker
178+
179+
document_store = InMemoryDocumentStore(embedding_similarity_function="cosine")
180+
181+
query = "Who supports fastembed?"
182+
183+
documents = [
184+
Document(content="My name is Wolfgang and I live in Berlin"),
185+
Document(content="I saw a black horse running"),
186+
Document(content="Germany has many big cities"),
187+
Document(content="fastembed is supported by and maintained by Qdrant."),
188+
]
189+
190+
document_embedder = FastembedDocumentEmbedder()
191+
documents_with_embeddings = document_embedder.run(documents)["documents"]
192+
document_store.write_documents(documents_with_embeddings)
193+
194+
query_pipeline = Pipeline()
195+
query_pipeline.add_component("text_embedder", FastembedTextEmbedder())
196+
query_pipeline.add_component("retriever", InMemoryEmbeddingRetriever(document_store=document_store, top_k=4))
197+
query_pipeline.add_component("ranker", FastembedLateInteractionRanker(model_name="colbert-ir/colbertv2.0", top_k=2))
198+
query_pipeline.connect("text_embedder.embedding", "retriever.query_embedding")
199+
query_pipeline.connect("retriever.documents", "ranker.documents")
200+
201+
result = query_pipeline.run({"text_embedder": {"text": query}, "ranker": {"query": query}})
202+
```
203+
165204
### License
166205

167206
`fastembed-haystack` is distributed under the terms of the [Apache-2.0](https://spdx.org/licenses/Apache-2.0.html) license.

0 commit comments

Comments
 (0)