Skip to content

Conversation

@xoaryaa
Copy link

@xoaryaa xoaryaa commented Oct 30, 2025

Related Issues

Proposed Changes:

Feature: Add FastembedColbertReranker — a ColBERT late-interaction (MaxSim) reranker inside the FastEmbed integration.

  • New component: haystack_integrations.components.rankers.fastembed.FastembedColbertReranker
  • Uses FastEmbed’s LateInteractionTextEmbedding to encode query and documents (token-level).
  • Implements ColBERT MaxSim scoring: sum_q max_d (sim(q_i, d_j)) with configurable similarity={"cosine","dot"} and optional L2 normalization.
  • CPU-friendly ONNX backend via FastEmbed; no new core Haystack deps.
  • Batching support (batch_size) and optional token limits (max_query_tokens, max_doc_tokens).
  • Stable sorting with deterministic tie-break; parameter validation and robust warm-up tolerant to minor FastEmbed kwargs drift.
  • Small README note + CHANGELOG entry for the FastEmbed integration.
  • Example script: examples/fastembed_colbert_reranker.py.

Why: Cross-encoder rankers don’t cover late-interaction/bi-encoder models like ColBERT v2. This adds a first-class ColBERT reranker over ~100–500 retrieved candidates.

How did you test it?

  • Unit tests

    • Pure math checks for MaxSim and L2 normalization.
    • Parameter validation (invalid similarity, batch_size, top_k).
    • Deterministic ranking & top_k via monkeypatched encoders (no model download required).
  • Manual verification

    1. pip install -e integrations/fastembed
    2. Run python examples/fastembed_colbert_reranker.py
      • First run downloads the ColBERT model via FastEmbed (cached afterward).
      • Verified that documents mentioning “late interaction/ColBERT” rank at the top.

Notes for the reviewer

  • Lives entirely under integrations/fastembed/src/... (no changes to core Haystack).
  • Warm-up handles minor API differences in FastEmbed by retrying without unknown kwargs.
  • Intended usage: rerank ~100–500 candidates from a first-stage retriever (BM25 or dense).
  • Example import path:
    from haystack_integrations.components.rankers.fastembed import FastembedColbertReranker

@xoaryaa xoaryaa requested a review from a team as a code owner October 30, 2025 07:10
@xoaryaa xoaryaa requested review from anakin87 and removed request for a team October 30, 2025 07:10
@CLAassistant
Copy link

CLAassistant commented Oct 30, 2025

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot added integration:fastembed type:documentation Improvements or additions to documentation labels Oct 30, 2025
Signed-off-by: Arya Tayshete <avtayshete_b21@et.vjti.ac.in>
Signed-off-by: Arya Tayshete <avtayshete_b21@et.vjti.ac.in>
…rig_idx)

Signed-off-by: Arya Tayshete <avtayshete_b21@et.vjti.ac.in>
Signed-off-by: Arya Tayshete <avtayshete_b21@et.vjti.ac.in>
…ert-reranker

Signed-off-by: Arya Tayshete <avtayshete_b21@et.vjti.ac.in>
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
@xoaryaa
Copy link
Author

xoaryaa commented Oct 30, 2025

@anakin87 The “Check Integration Format” job is failing due to hyphens found in unrelated files in the repo. My FastEmbed changes don’t add any hyphenated directories under ./integrations/ and pass local checks.

These existing files contain hyphens in their filenames:

  • ./llama_stack/examples/llama-stack-with-tools.py
  • ./opensearch/docker-compose.yml
  • ./amazon_bedrock/tests/test_files/haystack-logo.png
  • ./weaviate/docker-compose.yml
  • ./elasticsearch/docker-compose.yml

@anakin87
Copy link
Member

@anakin87 The “Check Integration Format” job is failing due to hyphens found in unrelated files in the repo. My FastEmbed changes don’t add any hyphenated directories under ./integrations/ and pass local checks.

These existing files contain hyphens in their filenames:

  • ./llama_stack/examples/llama-stack-with-tools.py
  • ./opensearch/docker-compose.yml
  • ./amazon_bedrock/tests/test_files/haystack-logo.png
  • ./weaviate/docker-compose.yml
  • ./elasticsearch/docker-compose.yml

The problem lies in this git submodule. Please remove it.

image

Signed-off-by: Arya Tayshete <avtayshete_b21@et.vjti.ac.in>
@xoaryaa xoaryaa force-pushed the feat/fastembed-colbert-reranker branch from a302ad2 to 6d30a65 Compare October 30, 2025 09:34
Signed-off-by: Arya Tayshete <avtayshete_b21@et.vjti.ac.in>
@xoaryaa xoaryaa force-pushed the feat/fastembed-colbert-reranker branch from fcf4a21 to b909590 Compare October 30, 2025 09:54
Signed-off-by: Arya Tayshete <avtayshete_b21@et.vjti.ac.in>
@xoaryaa xoaryaa force-pushed the feat/fastembed-colbert-reranker branch from 770e875 to 7198b83 Compare October 30, 2025 10:20
Signed-off-by: Arya Tayshete <avtayshete_b21@et.vjti.ac.in>
@xoaryaa xoaryaa force-pushed the feat/fastembed-colbert-reranker branch from 5663922 to fdb1d9e Compare October 30, 2025 10:30
Signed-off-by: Arya Tayshete <avtayshete_b21@et.vjti.ac.in>
@xoaryaa xoaryaa force-pushed the feat/fastembed-colbert-reranker branch from 9b4e1bf to 3cf8a37 Compare October 31, 2025 05:42
Signed-off-by: Arya Tayshete <avtayshete_b21@et.vjti.ac.in>
@xoaryaa xoaryaa force-pushed the feat/fastembed-colbert-reranker branch from 0d0e1e2 to 217d213 Compare October 31, 2025 06:01
@xoaryaa
Copy link
Author

xoaryaa commented Oct 31, 2025

@anakin87 can you check once and LMK if you want changes?

Copy link
Member

@anakin87 anakin87 left a comment

Choose a reason for hiding this comment

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

I initially started reviewing this PR, but I noticed that it diverges significantly from other components in this package/repository.

Please take a look at other components and tests in the Fastembed-Haystack integration for inspiration and to align this implementation with the existing patterns.

I'll be away for a few days, but I can pick up the review again once I'm back if there are updates.

Comment on lines +3 to +18
## [Unreleased]

### 🚀 Features
- Add `FastembedColbertReranker`: ColBERT late-interaction (MaxSim) reranker for 1st-stage candidates (100–500). (#2482)

### 📚 Documentation
- FastEmbed docs: “ColBERT Reranker” section with quickstart + pipeline example. (#2482)
- Integration README: add bullet for `FastembedColbertReranker` and links. (#2482)

### 🧪 Testing
- Unit tests for MaxSim math, parameter validation, stable tie-break, and monkeypatched ranking (no model download). (#2482)

### 🧹 Chores
- Parameter validation, robust warm-up for fastembed API drift, stable sorting on score ties. (#2482)


Copy link
Member

Choose a reason for hiding this comment

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

this is automatically generated and not meant to be modified

Comment on lines +9 to +28
## Components

- **FastembedTextEmbedder / FastembedDocumentEmbedder / Sparse embedders** – embedding components for dense and sparse retrieval (see docs).
- **FastembedRanker** – cross-encoder reranker (see docs).
- **FastembedColbertReranker***new* ColBERT late-interaction (MaxSim) reranker for reordering 100–500 candidates on CPU via ONNX.
→ See the docs for installation and examples.

### Documentation

- Integration page: https://haystack.deepset.ai/integrations/fastembed
- Component docs:
- Fastembed embedders: https://docs.haystack.deepset.ai/docs/fastembedtextembedder
- FastembedRanker (cross-encoder): https://docs.haystack.deepset.ai/docs/fastembedranker
- **FastembedColbertReranker (ColBERT)**: *[link to your new docs section]*

### Install

```bash
pip install fastembed-haystack

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
## Components
- **FastembedTextEmbedder / FastembedDocumentEmbedder / Sparse embedders** – embedding components for dense and sparse retrieval (see docs).
- **FastembedRanker** – cross-encoder reranker (see docs).
- **FastembedColbertReranker***new* ColBERT late-interaction (MaxSim) reranker for reordering 100–500 candidates on CPU via ONNX.
→ See the docs for installation and examples.
### Documentation
- Integration page: https://haystack.deepset.ai/integrations/fastembed
- Component docs:
- Fastembed embedders: https://docs.haystack.deepset.ai/docs/fastembedtextembedder
- FastembedRanker (cross-encoder): https://docs.haystack.deepset.ai/docs/fastembedranker
- **FastembedColbertReranker (ColBERT)**: *[link to your new docs section]*
### Install
```bash
pip install fastembed-haystack

README should be stay minimal. We'll add this information to docs.

@@ -0,0 +1,4 @@
from __future__ import annotations
Copy link
Member

Choose a reason for hiding this comment

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

remove this file

@@ -1,3 +1,3 @@
from .ranker import FastembedRanker
Copy link
Member

Choose a reason for hiding this comment

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

the existing ranker should not be removed from here.

also, please not introduce new init files: integrations/fastembed/src/haystack_integrations/init.py, etc.
This package is a namespace package, so these init files should be avoided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration:fastembed type:documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: support bi-encoder models in TransformerSimilarityRanker

3 participants