Not able to use Hybrid search in Qdrant Langchain #25477
Replies: 6 comments 1 reply
-
Hey, @pradhandebasish2046! 👋 I'm here to help you with your bug, answer your questions, and even guide you on becoming a contributor. Let's squash those bugs together! To resolve the issue where hybrid search with Qdrant and LangChain returns the same result with the same score for Here is an example of how to set up the Dense Vector Searchfrom langchain_qdrant import QdrantVectorStore, RetrievalMode
from langchain_openai import OpenAIEmbeddings
embeddings = OpenAIEmbeddings(model="text-embedding-3-large")
qdrant_dense = QdrantVectorStore.from_documents(
docs,
embedding=embeddings,
location=":memory:",
collection_name="my_documents",
retrieval_mode=RetrievalMode.DENSE,
)
query = "What did the president say about Ketanji Brown Jackson"
found_docs_dense = qdrant_dense.similarity_search(query) Sparse Vector Searchfrom langchain_qdrant import FastEmbedSparse, QdrantVectorStore, RetrievalMode
sparse_embeddings = FastEmbedSparse(model_name="Qdrant/BM25")
qdrant_sparse = QdrantVectorStore.from_documents(
docs,
sparse_embedding=sparse_embeddings,
location=":memory:",
collection_name="my_documents",
retrieval_mode=RetrievalMode.SPARSE,
)
query = "What did the president say about Ketanji Brown Jackson"
found_docs_sparse = qdrant_sparse.similarity_search(query) Hybrid Vector Searchfrom langchain_qdrant import FastEmbedSparse, QdrantVectorStore, RetrievalMode
from langchain_openai import OpenAIEmbeddings
embeddings = OpenAIEmbeddings(model="text-embedding-3-large")
sparse_embeddings = FastEmbedSparse(model_name="Qdrant/BM25")
qdrant_hybrid = QdrantVectorStore.from_documents(
docs,
embedding=embeddings,
sparse_embedding=sparse_embeddings,
location=":memory:",
collection_name="my_documents",
retrieval_mode=RetrievalMode.HYBRID,
)
query = "What did the president say about Ketanji Brown Jackson"
found_docs_hybrid = qdrant_hybrid.similarity_search(query) Ensure that you are using the correct embeddings and retrieval mode for each search type. If the setup is correct and the issue persists, it might be necessary to check the implementation details or configurations of the embeddings and the Qdrant setup. Specifically, verify that the |
Beta Was this translation helpful? Give feedback.
-
@dosu I want to disable indexing while uploading the vectors. After Vectors are uploaded I want to index them. How do i do that. |
Beta Was this translation helpful? Give feedback.
-
@pradhandebasish2046 How are you indexing. Indexing while uploading is taking lot of time and is not recommended either. Please hlep |
Beta Was this translation helpful? Give feedback.
-
@dosu Would appreciate any input regarding my issue |
Beta Was this translation helpful? Give feedback.
-
how to create instance of QdrantVectorStore class with feature of hybrid search , to use in ParentDocument Retriver as vectorstore ?? |
Beta Was this translation helpful? Give feedback.
-
Same issue here... how do I specify top k in sparse and in dense? |
Beta Was this translation helpful? Give feedback.
-
Checked other resources
Commit to Help
Example Code
Description
I am trying to use hybrid search using qdrant langchain. Everytime I am doing retrieval using RetrievalMode.HYBRID or RetrievalMode.DENSE or RetrievalMode.SPARSE I am getting exact same result with the same score. So I believe the hybrid search is not working properly.
System Info
System Information
Package Information
Optional packages not installed
Other Dependencies
Beta Was this translation helpful? Give feedback.
All reactions