Find answers from the community

Updated 8 months ago

Hey folks, this is probably a very

Hey folks, this is probably a very simple question so apologies in advance for any stupid mistakes.

I am trying to get the summary of a document after a node has been retrieved (through an index). I want to use this summary document into the query engine. This is because the node itself doesn't have relevant information for my question. What's the best workflow for this?
T
1 comment
I just wanted an opinion on possible approaches. One approach is the following:

Plain Text
# assume a vector index of nodes is already created

retriever = VectorIndexRetriever(
    index=index,
    similarity_top_k=2,
)

nodes = retriever.retrieve("Name the customers have Gold plan support")

# extract the doc_paths from the nodes
doc_paths = []
for node in nodes:
    doc_paths.append(node.metadata['file_path'])

# create summary index for those docs
relevant_docs = SimpleDirectoryReader(input_files=doc_paths).load_data()
doc_summary_index = DocumentSummaryIndex.from_documents(relevant_docs)

query_engine = doc_summary_index.as_query_engine()
response = query_engine.query('my query')
Add a reply
Sign up and join the conversation on Discord