Discover the power of structured data for businesses with Amazon Q Business using natural language.

One of the most common uses of generative artificial intelligence (AI) and large language models (LLMs) in a business environment is answering questions based on the company’s knowledge corpus. Pretrained foundation models (FMs) excel in natural language understanding (NLU) tasks, such as summarization, text generation, and answering questions on a wide range of topics. However, they often struggle to provide accurate answers without “hallucinations” and cannot address issues on content not included in their training data. Additionally, FMs are trained with a temporal snapshot of data and do not have the inherent ability to access fresh data in real-time, which can lead to incorrect or inadequate responses.

We face a fundamental challenge with business data: bridging the gap between natural language and structured data. Natural language is ambiguous and imprecise, while data adheres to rigid schemas. For example, SQL queries can be complex and intuitive for non-technical users. Handling complex queries involving multiple tables, joins, and aggregations makes it challenging to interpret the user’s intent and translate it correctly into SQL operations. Domain-specific terminology also complicates the mapping process. Another challenge is accommodating the linguistic variations that users employ to express the same requirement. Effectively handling synonyms, paraphrases, and alternative phrases is crucial. The inherent ambiguity of natural language can also result in multiple interpretations of a single query, making it difficult to accurately understand the user’s intent.

To overcome this gap, advanced natural language processing (NLP) is needed to map user queries to the database schema, tables, and operations. In this architecture, Amazon Q Business acts as an intermediary, translating natural language into precise SQL queries. Users can simply ask questions like “What were outdoor equipment sales in the third quarter of 2023?” Amazon Q Business analyzes the intent, accesses data sources, and generates the SQL query. This simplifies data access for non-technical users and optimizes workflows for professionals, allowing them to focus on higher-level tasks.

In this article, we discuss an architecture for querying structured data using Amazon Q Business and building an application to query cost and usage data in Amazon Athena with Amazon Q Business. Amazon Q Business can create SQL queries to its data sources when provided with the database schema, additional metadata describing columns and tables, and prompt instructions. This architecture can be extended to use additional data sources, query validation, and alert techniques to cover a broader range of use cases.

The following figure represents the high-level architecture of the proposed solution. Steps 3 and 4 expand the integration of the AWS Identity and Access Management (IAM) Center with Amazon Q Business for an authorization flow. In this architecture, we use Amazon Cognito for user authentication and a trusted token issuer for the IAM Center. You can also use your own identity provider as a trusted token issuer as long as it is compatible with OpenID Connect (OIDC).

The workflow includes the following steps:

1. The user initiates interaction with the Streamlit application, accessible through an Application Load Balancer, acting as the entry point.
2. The application prompts the user to authenticate using their Amazon Cognito credentials, maintaining secure access.
3. The application exchanges the token obtained from Amazon Cognito for a token from the IAM Center, granting the necessary scope to interact with Amazon Q Business.
4. Using the IAM Center token, the application assumes an AWS Identity and Access Management (IAM) role and obtains an AWS session from the AWS Security Token Service (AWS STS), enabling authorized communication with Amazon Q Business.
5. Based on the user’s natural language query, the application formulates relevant prompts and metadata, which are then sent to Amazon Q Business’s chat_sync API. In response, Amazon Q Business provides an appropriate Athena query to execute.
6. The application executes the Athena query received from Amazon Q Business, and the resulting data is displayed in the web application’s user interface.

In conclusion, Amazon Q Business can leverage LLMs directly to generate appropriate responses, using chat modes like CREATOR_MODE, which allows skipping the generation of retrieval-augmented (RAG) and using direct text in the context window for response generation. This capability enables business users to utilize advanced NLP and NLU capabilities to effectively access and analyze structured data, facilitating data-driven decision-making, innovation, and creating new opportunities for growth and success.

via: MiMub in Spanish

Last articles

Scroll to Top
×