This Guidance demonstrates how to efficiently retrieve data by using the agent-driven framework of Amazon Bedrock to convert natural language queries (NLQ) into SQL queries. The agent-driven approach allows the Amazon Bedrock Agents to interpret your natural language input, break down complex queries, and delegate specific actions to the appropriate large language models (LLMs) and services. The agents orchestrate the entire process in an automated and coordinated manner, eliminating the need for you to manually construct database queries. By using Amazon Bedrock Agents to handle the complex task of NLQ-to-SQL conversion, you can access and analyze data more efficiently and accurately.
Note: [Disclaimer]
Architecture Diagram
[Architecture diagram description]
Step 1
Company data is loaded into Amazon Simple Storage Service (Amazon S3), which serves as the data source for AWS Glue.
Step 2
Amazon Athena is a serverless query service that analyzes Amazon S3 data using standard SQL with AWS Glue managing the data catalog. AWS Glue reads unstructured data from Amazon S3, creates queryable tables for Athena, and stores query results back in Amazon S3. This integration, supported by crawlers and the AWS Glue Data Catalog, streamlines data management and analysis.
Step 3
The AWS Lambda function acts as the execution engine, processing the SQL query and interfacing with Athena. Proper configuration of resource policies and permissions is critical for secure and efficient operations, maintaining the integrity of the serverless compute environment.
Step 4
The main purpose of an action group in an Amazon Bedrock agent is to provide a structured way to perform multiple actions in response to a user's input or request. This allows the agent to take a series of coordinated steps to address the user's needs, rather than just performing a single action.
Step 4 (continued)
This action group includes an OpenAPI schema. The schema is needed so that the Amazon Bedrock agent knows the format structure and parameters for the action group to interact with the compute layer. In this case, the compute layer is a Lambda function.
Step 5
An instruction prompt is provided to the Amazon Bedrock agent to help with orchestration. The Amazon Bedrock agent orchestrates the tasks by interpreting the input prompt and delegating specific actions to the LLM.
Step 6
Collaboration with the task orchestrator in the previous step enables the LLM to process complex queries and generate outputs that align with the user's objectives. The chain of thought mechanism ensures that each step in the process is logically connected, leading to precise action execution. The model processes the user's natural language input, translating it into actionable SQL queries, which are then used to interact with data services.
Step 7
The Amazon Bedrock agent endpoint serves as the bridge between the user's application that runs on an Amazon Elastic Compute Cloud (Amazon EC2) instance on AWS and the Amazon Bedrock agent, facilitating the transfer of input data in real-time.
Step 7 (continued)
This setup is essential for capturing inputs that trigger the agent driven process. Natural language is used to query data and return the response back to the user through the user interface. The results from the Athena query are returned to the user from the Lambda function through the Amazon Bedrock agent endpoint.
Get Started
Deploy this Guidance
Well-Architected Pillars
The AWS Well-Architected Framework helps you understand the pros and cons of the decisions you make when building systems in the cloud. The six pillars of the Framework allow you to learn architectural best practices for designing and operating reliable, secure, efficient, cost-effective, and sustainable systems. Using the AWS Well-Architected Tool, available at no charge in the AWS Management Console, you can review your workloads against these best practices by answering a set of questions for each pillar.
The architecture diagram above is an example of a Solution created with Well-Architected best practices in mind. To be fully Well-Architected, you should follow as many Well-Architected best practices as possible.
-
Operational Excellence
Amazon S3 provides scalable and durable storage for source data, making it readily accessible and manageable. AWS Glue automates the data cataloging process by running crawlers and creating tables, streamlining the data integration workflow. Athena enables efficient querying of the data using standard SQL, and Lambda functions integrate with Athena to execute the SQL queries generated by the Amazon Bedrock Agent, facilitating real-time data processing. These services work together to automate data ingestion, cataloging, and querying, enabling quick responses to user queries and streamlining the management of data workflows.
-
Security
AWS Shield Standard can be integrated to provide protection against distributed denial-of-service (DDoS) attacks. Amazon Bedrock Guardrails offers additional safeguards you can customize. This feature adds another layer of safeguards regardless of the underlying foundation model (FM). It evaluates user inputs and FM responses based on specific policies to detect and block undesirable topics. Moreover, Amazon Bedrock Guardrails filters harmful content, redacts sensitive information, blocks inappropriate content with custom word filters, and detects hallucinations in model responses. AWS Identity and Access Management (IAM) limits unauthorized access by enforcing minimum permissions, and Amazon CloudFront secures data transmission and access so only authorized users can interact with the application.
-
Reliability
The services used were designed to provide high availability, automated recovery, and consistent performance. Amazon S3 offers high availability and durability of the stored data. AWS Glue automates data processing tasks, reducing the risk of human error and enabling consistent data handling. Athena allows for reliable and efficient querying of the data. Lambda performs the execution of queries and other tasks without downtime. These services allow your system to quickly adapt to changing demands and recover from potential failures.
-
Performance Efficiency
Amazon S3 and AWS Glue optimize data storage and processing for efficient data management. Athena provides quick and efficient data querying capabilities. The use of Lambda allows for the execution of tasks in a serverless environment, further optimizing resource usage. These services provide scalability, optimized resource usage, and the ability to experiment and optimize based on your user data and requirements.
-
Cost Optimization
The cost efficiencies are underpinned by the storage, processing, analytics, and compute capabilities of the services. Amazon S3 provides tiered storage options for cost-optimized data retention. AWS Glue automates data processing tasks, eliminating the need for manual interventions. Athena enables cost-efficient analysis of large datasets, without the overhead of dedicated database infrastructure. The use of Lambda functions contributes to cost optimization by providing a serverless execution environment.
-
Sustainability
Amazon S3 supports sustainable storage practices by enabling lifecycle policies and tiered storage options, optimizing resource utilization. AWS Glue automates data processing tasks, reducing the need for continuous resource usage. Athena provides efficient data querying capabilities, minimizing the computational resources required. The Lambda functions offer a serverless execution model so that resources are only consumed when necessary. By optimizing resource utilization, reducing waste, and minimizing the environmental impact, these services help you build more sustainable workloads.
Related Content
[Title]
Disclaimer
The sample code; software libraries; command line tools; proofs of concept; templates; or other related technology (including any of the foregoing that are provided by our personnel) is provided to you as AWS Content under the AWS Customer Agreement, or the relevant written agreement between you and AWS (whichever applies). You should not use this AWS Content in your production accounts, or on production or other critical data. You are responsible for testing, securing, and optimizing the AWS Content, such as sample code, as appropriate for production grade use based on your specific quality control practices and standards. Deploying AWS Content may incur AWS charges for creating or using AWS chargeable resources, such as running Amazon EC2 instances or using Amazon S3 storage.
References to third-party services or organizations in this Guidance do not imply an endorsement, sponsorship, or affiliation between Amazon or AWS and the third party. Guidance from AWS is a technical starting point, and you can customize your integration with third-party services when you deploy the architecture.