Hybrid retrieval may return duplicate documents from overlapping text and vector results
Author: wang-coolCreated Aug 31, 2026Updated Aug 31, 2026
Labelsbug
Description
In VectorRetrieval.run() with retrieval_mode="hybrid", text retrieval results are filtered using:
if doc not in vs_idsHowever, doc is a Document object while vs_ids contains document ID strings.
When the same chunk is retrieved by both text retrieval and vector retrieval, the overlap is therefore not removed correctly, and the merged hybrid candidate list may contain duplicate documents.
This can unnecessarily consume reranking capacity and reduce candidate diversity.
Reproduction steps
1. Create three documents with doc IDs A, B, and C.
2. Configure doc_store.query() to return documents A and B.
3. Configure vector_store.query() to return:
- IDs: A and C
- Scores: 0.91 and 0.73
4. Create VectorRetrieval with:
- retrieval_mode="hybrid"
- rerankers=[]
- top_k=10
5. Run the retrieval pipeline with a non-empty scope containing A, B, and C.
6. Inspect the doc_id and score of each returned document.
Expected:
Each doc_id should appear only once.
With the current merge order, the expected result is:
IDs: ['B', 'A', 'C']
Scores: [-1.0, 0.91, 0.73]
The vector-retrieved version of A should be retained because it contains the
vector similarity score.
Actual:
IDs: ['A', 'B', 'A', 'C']
Scores: [-1.0, -1.0, 0.91, 0.73]
Document A appears twice.Screenshots
Logs
Got 2 from vectorstore
Got 2 from docstore
Got raw 4 retrieved documents
MERGED_IDS = ['A', 'B', 'A', 'C']
MERGED_SCORES = [-1.0, -1.0, 0.91, 0.73]
A_COUNT = 2Browsers
No response
OS
No response
Additional information
vs_id_set = set(vs_ids)
result = [ RetrievedDocument(**doc.to_dict(), score=-1.0) for doc in ds_docs if doc.doc_id not in vs_id_set ]
Source: Cinnamon/kotaemon