Find answers from the community

Updated 8 months ago

How do I make DocumentSummaryIndex.as_

How do I make DocumentSummaryIndex.as_query to use all the nodes when asking "Summarize the documents?"
C
1 comment
I'm trying to summarize a long document. I've loaded a pdf document which got splitted into 74 nodes during loading.
As expected, DocumentSummaryIndex.from_documents goes through each node, and created a summary via the selected llm.
However, query_engine.query("Summarize the documents") only select one node and sends to LLM to summarize the document.
How do you make it so that it summarizes the entire document using all nodes?

documents = SimpleDirectoryReader(input_files=path).load_data()
response_synthesizer = get_response_synthesizer(response_mode="tree_summarize", use_async=True)
doc_summary_index = DocumentSummaryIndex.from_documents(documents, response_synthesizer=response_synthesizer)
query_engine = doc_summary_index.as_query_engine(response_mode="tree_summarize", use_async=True)
response = query_engine.query("Summarize the documents")
print(response.response)
Add a reply
Sign up and join the conversation on Discord