RAG response using Milvus and llama index

49 views Asked by At

I have created a vector embeddings collection using milvus locally and trying to generate RAG assisted responses. But for some reason its giving me error. I'm new to this so might be missing some thing.

from llama_index.core import GPTVectorStoreIndex, StorageContext, VectorStoreIndex from llama_index.vector_stores.milvus import MilvusVectorStore import openai from dotenv import load_dotenv import os

load_dotenv() openai.api_key = os.environ["OPENAI_API_KEY"]

def chatbot(input_text):

vector_store = MilvusVectorStore(
   uri="http://localhost:19530",
   collection_name = "test"
)
index = VectorStoreIndex.
query_engine = index.as_query_engine()
response = query_engine.query(input_text)
return response

input_text = input('Enter Query')

print(chatbot(input_text))

Errror RPC error: [search], <MilvusException: (code=0, message=fail to search on all shard leaders, err=All attempts results: attempt #1:code: UnexpectedError, error: fail to Search, QueryNode ID=1, reason=Search 1 failed, reason [UnexpectedError] Assert "field_meta.get_sizeof() == element.line_sizeof_" at /go/src/github.com/milvus-io/milvus/internal/core/src/query/Plan.cpp:48 => vector dimension mismatch err %!w() attempt #2:context canceled )>, <Time:{'RPC start': '2024-03-28 18:14:01.950316', 'RPC error': '2024-03-28 18:14:02.181546'}> Failed to search collection: test

Milvus collection enter image description here enter image description here

Any help will be greatly appreciated!

I tried Running the above code to get a RAG assisted response from OpenAI

1

There are 1 answers

0
ken zhang On

It seems your vector dimension mismatch, this means your collection's vector is not fit your model. What embeeding model are you using. for example, text-embedding-3-large is 512 dimension, and your collection's vector demision is 768, then conflict happens