Find answers from the community

Home
Members
marialagerholm
m
marialagerholm
Offline, last seen 3 months ago
Joined September 25, 2024
Could somebody please advice me how to retrieve more comprehensive results from multiple documents using GPTVectorStoreIndex. I have a collection of scientific documents related to a specific plant, extracted from PDFs and stored in JSON and CSV formats. I'm using the following code to load all these documents:
Plain Text
for dir_path in all_dirs:
    dir_reader = SimpleDirectoryReader(dir_path, file_extractor={
        ".csv": PandasCSVReader(),
        ".json": JSONReader()
    })
    docs.extend(dir_reader.load_data())


After loading, I create an index and query it:


Plain Text
index = GPTVectorStoreIndex.from_documents(docs, service_context=service_context)
query_engine = load_index_from_storage(storage_context).as_query_engine(similarity_top_k=4)
response = query_engine.query(input_text)


The issue is that the query always returns a single response from just one document that best matches my query. However, I know that other documents contain more relevant information about the plant. How can I modify my approach to retrieve more comprehensive results from all relevant documents in my index?
3 comments
J
m
L