artificial-intelligencevector-databasemilvus

Inconsistent Query Results Based on Output Fields Selection in Milvus Dashboard


I'm experiencing an issue with the Milvus dashboard where the search results change based on the selected output fields.

I'm working on a RAG project using text data converted into embeddings, stored in a Milvus collection with around 8000 elements. Last week, my retrieval results matched my expectations ("good" results), however, this week, the results have degraded ("bad" results).

I found that when I exclude the embeddings_vector field from the output fields in the Milvus dashboard, I get the "good" results; Including the embeddings_vector field in the output changes the results to "bad".

I've attached two screenshots showing the difference in the results based on the selected output fields.

Any ideas on what's causing this or how to fix it?

Environment:

Python 3.11 pymilvus 2.3.2 llama_index 0.8.64

Thanks in advance!

from llama_index.vector_stores import MilvusVectorStore
from llama_index import ServiceContext, VectorStoreIndex

# Some other lines..

# Setup for MilvusVectorStore and query execution
vector_store = MilvusVectorStore(uri=MILVUS_URI,
                                 token=MILVUS_API_KEY,
                                 collection_name=collection_name,
                                 embedding_field='embeddings_vector',
                                 doc_id_field='chunk_id',
                                 similarity_metric='IP',
                                 text_key='chunk_text')

embed_model = get_embeddings()
service_context = ServiceContext.from_defaults(embed_model=embed_model, llm=llm)
index = VectorStoreIndex.from_vector_store(vector_store=vector_store, service_context=service_context)
query_engine = index.as_query_engine(similarity_top_k=5, streaming=True)

rag_result = query_engine.query(prompt)

Here is the "good" result: "good" result And here is the "bad" result: "bad" result


Solution

  • I would like to suggest you to follow below considerations.

    Please try out this code if it helps.

    vector_store = MilvusVectorStore(uri=MILVUS_URI,
                                     token=MILVUS_API_KEY,
                                     collection_name=collection_name,
                                     embedding_field='embeddings_vector',
                                     doc_id_field='chunk_id',
                                     similarity_metric='IP',
                                     text_key='chunk_text',
                                     output_fields=['chunk_id', 'chunk_text'])  # Exclude embeddings_vector
    
    index = VectorStoreIndex.from_vector_store(vector_store=vector_store, service_context=service_context)
    query_engine = index.as_query_engine(similarity_top_k=5, streaming=True)
    
    rag_result = query_engine.query(prompt)