RetrievalQA Error #2987
Replies: 2 comments 1 reply
-
Would you mind to share the snippet of code (or similar) you use to interface with Qdrant? I'm not familiar with RetrievalQA myself. This error means that you're trying to use vectors in a collection, which are not configured in that collection. Maybe you still need to set up the collection properly, before you can use it to store data? To be more specific, the exact error is coming from here: qdrant/lib/collection/src/config.rs Lines 188 to 198 in 5c36256 |
Beta Was this translation helpful? Give feedback.
-
Hi @timvisee Here I load the data: from qdrant_client.http import models as rest
vector_size = 1536
chunk_size = 1000
embeddings_url = "https://cdn.openai.com/API/examples/data/vector_database_wikipedia_articles_embedded.zip"
wget.download(embeddings_url)
with zipfile.ZipFile("vector_database_wikipedia_articles_embedded.zip", "r") as zip_ref:
zip_ref.extractall("../data")
client = QdrantClient(
host="localhost",
port=6333,
prefer_grpc=True,
)
client.recreate_collection(
collection_name="Articles",
vectors_config={
"title": rest.VectorParams(
distance=rest.Distance.COSINE,
size=vector_size,
),
"content": rest.VectorParams(
distance=rest.Distance.COSINE,
size=vector_size,
),
}
)
for chunk_df in pd.read_csv('../data/vector_database_wikipedia_articles_embedded.csv', chunksize=chunk_size):
chunk_df["title_vector"] = chunk_df.title_vector.apply(literal_eval)
chunk_df["content_vector"] = chunk_df.content_vector.apply(literal_eval)
chunk_df.head()
points = [
rest.PointStruct(
id=k,
vector={
"title": v["title_vector"],
"content": v["content_vector"],
},
payload=v.to_dict(),
)
for k, v in chunk_df.iterrows()
]
client.upsert(collection_name="Articles", points=points)
articles_count = client.count(collection_name="Articles")
print("{} articles".format(articles_count)) This is the part where the code fails. from langchain.chains import RetrievalQA
from langchain.embeddings import OpenAIEmbeddings
from langchain.llms.openai import OpenAI
from langchain.prompts import PromptTemplate
from langchain.vectorstores import Qdrant
from qdrant_client import QdrantClient
collection_name = "Articles"
client = QdrantClient(
host="localhost",
port=6333,
prefer_grpc=True,
)
llm = OpenAI(openai_api_key=OPENAI_API_KEY)
embeddings = OpenAIEmbeddings(openai_api_key=OPENAI_API_KEY)
doc_store = Qdrant(client, collection_name, embeddings)
custom_prompt = """
Use the following pieces of context to answer the question at the end. Please provide
a short single-sentence summary answer only. If you don't know the answer or if it's
not present in given context, don't try to make up an answer, but suggest me a random
unrelated song title I could listen to.
Context: {context}
Question: {question}
Helpful Answer:
"""
custom_prompt_template = PromptTemplate(
template=custom_prompt, input_variables=["context", "question"]
)
qa = RetrievalQA.from_chain_type(
llm=llm,
chain_type="stuff",
retriever=doc_store.as_retriever(),
chain_type_kwargs={"prompt": custom_prompt_template},
return_source_documents=False,
)
answer = qa.run(question)
print(answer) |
Beta Was this translation helpful? Give feedback.
-
When I am using qdrant on docker with RetrievalQA I get this error:
gRPC /qdrant.Points/Search failed with Client specified an invalid argument "Wrong input: Default vector params are not specified in config"
What is this default config and where to put it?
Beta Was this translation helpful? Give feedback.
All reactions