I am just getting started with RAG and LlamaIndex and trying to learn it.
I have 3 text files with text:
Product is chair
,
Product is table
,
Product is ball
respectively.
Even with fairly simple setup of LlamaIndex, if I use the prompt
List all products
, I only get back 2 out of the 3 products.
My code is as follows:
llm = OpenAI(model="gpt-4-0125-preview")
service_context = ServiceContext.from_defaults(llm=llm)
documents = SimpleDirectoryReader(dir).load_data()
if not os.path.exists(PERSIST_DIR):
index = VectorStoreIndex.from_documents(documents, service_context=service_context)
index.storage_context.persist(persist_dir=PERSIST_DIR)
text_qa_template_str = (
"Context information is"
" below.\n---------------------\n{context_str}\n---------------------\nUsing"
" both the context information and also using your own knowledge, answer"
" the question: {query_str}\n")
text_qa_template = PromptTemplate(text_qa_template_str)
query_engine = RetrieverQueryEngine.from_args(
retriever, response_mode="compact_accumulate", text_qa_template=text_qa_template, similarity_top_k=10)
What am I doing wrong?