Find answers from the community

Updated 2 months ago

Why would setting `query str custom

Why would setting query_str="", custom_embedding_strs=[ "whatever" ] in the QueryBundle that is passed to a VectorIndexRetriever.retrieve result in 0 nodes being found but giving query_str="" a value suddenly result in nodes found? Based on the docs, I thought that query_str isn't used for embedding-based queries?
L
P
12 comments
Not sure I totally follow

retrieve(QueryBundle("query_str", custom_embedding_strs=["whatever"])) will use the custom strs for embeddings

retrieve(QueryBundle("query_str")) will use the query_str for embeddings

retrieve(QueryBundle("query_str", custom_embedding_strs=[])) will actually cause issues I think
so the query_str param is required (if you omit it, it gets mad about trying to split None) but if I want to use custom_embedding_strs I was just setting query_str="". In the past, I've seen that work, but now I'm noticing it makes a difference which is confusing me.
but maybe that's what hybrid query mode is all about?
Plain Text
service_context = make_service_context(embedding_model=OpenAIEmbeddingModelType.DAVINCI, embedding_mode=OpenAIEmbeddingMode.TEXT_SEARCH_MODE)
vector_store = WeaviateVectorStore(weaviate_client=self.weaviate_client, index_name=index_name)
index = VectorStoreIndex.from_vector_store(vector_store, service_context=service_context)

retriever = VectorIndexRetriever(
    index=index,
    similarity_top_k=2,
    vector_store_query_mode='hybrid'
)

found_nodes = retriever.retrieve(QueryBundle(query_str=
"", custom_embedding_strs=[ query ]))
print(found_nodes)
ok I have a hunch this has to do with hybrid search... I think I'm just unfamiliar with how it works. Does hybrid mean it uses both the query str and the embedding strs?
ahhh Yes! Hybrid mode uses the query_str. So if it's blank, that will have some effect

So hybrid uses the query_str to find text using keyword/lexical methods

But embeddings are generated with custom embedding strs (if provided) or else the query str
hopefully that makes sense --- I would provide both query_str and custom_embedding_strs here to make this work
hmm what would I put for the custom_embedding_strs in this case?
if my goal is to provide a question and be returned the most relevant pages/nodes
I would just not use it? The way you are using it not, putting it in query_str will work fine, no need for custom_embedding_strs
ah ok sorry I misunderstood your last message! I agree, doesn't make sense to include in this situation!
also I sent you a DM! you should check it when you get a second
Add a reply
Sign up and join the conversation on Discord