Skip to content

Handling Large-Topic Summarization in Amazon Bedrock Knowledge Base with OpenSearch and Nova Lite

0

Hi AWS Community

I am working on an RAG system using Amazon Bedrock Knowledge Base (AKB) with OpenSearch as the vector store. Here is my current setup:

Data ingestion: I have ingested metadata and post content into the AKB. The data is embedded and stored in the OpenSearch vector store.

LLM: Currently using Nova Lite for generating summaries.

Retrieval & generation: I am using the RetrieveAndGenerate API. The maximum number of retrieved results per request is currently 100.

Scenario / Challenge:

  • A topic may have a very large number of posts (e.g., 10,000 large posts).
  • There is no existing summary, so all posts are relevant.
  • Retrieval is based on matching threadId.
  • The total content exceeds the LLM’s context window, making it impossible to summarize all posts in a single call.
  • The batch size should be dynamic based on the total size of posts, not just the number of posts.
  • Summarization must preserve the chronological order of posts.

Questions / Guidance Needed:

  1. Batching / hierarchical summarization:
  • How can I implement a hierarchical summarization flow to handle such large topics
  • Can batching be done dynamically based on the content size to fit the context window?
  • Can I use NextToken or some form of pagination with the Retrieve or RetrieveAndGenerate API to retrieve large datasets in chunks?
  1. API usage:
  • Should I use Retrieve API + InvokeModel or RetrieveAndGenerate API for this scenario?
  • Which approach is best for generating partial summaries and then combining them into a final summary?
  1. Ensuring order:
  • How can I guarantee that posts are retrieved and summarized in chronological order when batching?
  1. Best practices:
  • Any recommendations for implementing this type of large-topic summarization in AKB with OpenSearch vector store and Nova Lite?

I would greatly appreciate any guidance, examples, or references for implementing this hierarchical, order-preserving summarization workflow with large topics.

Thank you in Advance

1 Answer
0

When handling large-topic summarization in Amazon Bedrock Knowledge Base with OpenSearch and Nova Lite, you'll need to implement a strategic approach to overcome the context window limitations. Here's guidance on your questions:

Batching/Hierarchical Summarization

For implementing hierarchical summarization with large topics:

  1. You can dynamically adjust the number of retrieved chunks in your RetrieveAndGenerate request by modifying the retrievalConfiguration.vectorSearchConfiguration.numberOfResults parameter. This allows you to optimize information density based on content size.

  2. For pagination, you can implement metadata filtering to add contextual layers to chunk retrieval. This would help you retrieve posts in batches while maintaining chronological order by using timestamp metadata.

  3. Consider implementing a multi-level summarization approach:

  • First level: Retrieve and summarize posts in smaller chronological batches
  • Second level: Combine these batch summaries into a final summary

API Usage

For your specific scenario:

  1. The RetrieveAndGenerate API is generally more straightforward for implementing RAG workflows. The API call structure is simple:
response = bedrock_agent_runtime_client.retrieve_and_generate(
input={
'text': prompt,
},
retrieveAndGenerateConfiguration={
'type': 'KNOWLEDGE_BASE',
'knowledgeBaseConfiguration': {
'knowledgeBaseId': knowledge_base_id,
'modelArn': model_arn,
}
}
)
  1. However, for more control over the process, you might consider using the Retrieve API first to get chunks in batches, and then using InvokeModel to generate summaries. This approach gives you more flexibility in handling the summarization process.

Ensuring Order

To guarantee chronological order:

  1. Use metadata filtering with timestamp fields to retrieve posts in chronological order.
  2. Implement query expansion techniques to transform your queries for more effective retrieval.
  3. When processing batches, maintain explicit ordering information in your workflow.

Best Practices

For large-topic summarization:

  1. Optimize your chunking strategy to create meaningful chunks that balance size and semantic completeness.
  2. Implement hybrid search combining dense and sparse retrieval for better results.
  3. Consider applying reranking models to improve precision by reorganizing retrieved contexts by relevance.
  4. Experiment with different similarity metrics beyond standard cosine similarity.
  5. For very large knowledge bases, consider implementing a retry mechanism where failed jobs are placed in an Amazon SQS Dead Letter Queue for retry.
  6. Monitor the size of your knowledge base and track query performance to identify optimization opportunities.

By implementing these strategies, you should be able to effectively handle large-topic summarization while maintaining chronological order and ensuring comprehensive coverage of your content.
Sources
Evaluate and improve performance of Amazon Bedrock Knowledge Bases | AWS Machine Learning Blog
Improve search results for AI using Amazon OpenSearch Service as a vector database with Amazon Bedrock | AWS Big Data Blog
Leverage generative AI for biocuration using Amazon Bedrock and Amazon Nova foundation models | AWS Public Sector Blog
Bedrock knowledge base retrieval with opensearch | AWS re:Post

answered 12 days ago