Find answers from the community

Updated 10 months ago

**ValueError: Invalid query mode: hybrid

ValueError: Invalid query mode: hybrid

I am running into an error where I cannot seem to query/retrieve a Vector Store Index with the query mode "hybrid". I believe it may be because I'm just using a simple vector store built from the Documents.example() function.

My code:
Plain Text
## setup
@pytest.fixture
def setup() -> dict:

    os.environ["OPENAI_API_KEY"] = str(settings.openai_api_key)

    service_context = ServiceContext.from_defaults(
        embed_model=OpenAIEmbedding(
            model="text-embedding-ada-002"
        ),
        llm=OpenAI(
            model="gpt-3.5-turbo"
        )
    )

    shots = AlphaMatrix(data=DEFAULT_CATEGORIES)

    vector_index = VectorStoreIndex.from_documents(
        [Document.example()]
        , service_context=service_context
    )

    reranker = LLMRerank(service_context=service_context)

    retriever = CustomRetriever(
        index=vector_index,
        llm=service_context.llm,
        reranker=reranker,
        matrix=shots,
        verbose=True,
    )

    return {
        "retriever": retriever,
        "service_context": service_context,
        "vector_index": vector_index,
        "matrix": shots,
    }

#Where the error occurs:
retriever = VectorIndexRetriever(
            index=index,
            vector_store_query_mode="hybrid",
            alpha=default_alpha,
            **kwargs,  # filters, etc, added here
        )

def test_retrieve(setup):

    retriever = setup.get("retriever")
    query = "What are LLMs good at?"
    results = retriever.retrieve(query)


Error:
Plain Text
ValueError: Invalid query mode: hybrid
L
n
18 comments
thats kind of weird πŸ€”
Yeah and this part of my code I can't really compromise on like - I'm building a custom hybrid retriever for my project. It needs to be a hybrid retriever
what happens if you do

Plain Text
from llama_index.core.vector_stores.types import VectorStoreQueryMode

print(VectorStoreQueryMode)
mode = VectorStoreQueryMode("hybrid")
print(mode)
how would I import this object? The VectorStoreQueryMode - having a hard time importing it
I was about to try that yeah
If I update from from 0.9.47 to 0.9.48 is my code likely to break? It looked like lots of the directory changed in the recent update haha
I think I'll need to if I want to try this otherwise the path to import looks different as its not being recognized when I try to import that.
Nevermind I think I found the old import path
Same error. I tried VectorStoreQueryMode.HYBRID and VectorStoreQueryMode("hybrid")
v0.10.0 is the breaking change
thats.... impossible? πŸ˜…
Damn just as the big update comes out
I finally figured it out. Its because the documents/vector store index I built doesn't (I presume) store any text data for a Hybrid Retriever to operate on. So when I swapped it over to normal vector search, it passed.

But also, I spun up a free pinecone instance and that worked on both Vector and Hybrid Search. So I'm almost positive its the dummy implementation I went with. I'm going to stick with my free pinecone instance for testing for now. But all is good now πŸ˜„
Add a reply
Sign up and join the conversation on Discord