Analyze customer reviews using Amazon Bedrock

Analyze customer reviews using Amazon Bedrock

Customer reviews can reveal customer experiences with a product and serve as an invaluable source of information to the product teams. By continually monitoring these reviews over time, businesses can recognize changes in customer perceptions and uncover areas of improvement. Analyzing these reviews to extract actionable insights enables data-driven decisions that can enhance customer experience and reduce churn. However, with the growing number of reviews across multiple channels, quickly synthesizing the essence of these reviews presents a major challenge. The process is often resource intensive, requiring a significant amount of time and human effort while still being prone to human errors and delays in identifying key insights, recurring themes, and improvement opportunities. As a result, customer pain points can go unnoticed and problems can escalate. The latest advances in generative artificial intelligence (AI) allow for new automated approaches to effectively analyze large volumes of customer feedback and distill the key themes and highlights.

This post explores an innovative application of large language models (LLMs) to automate the process of customer review analysis. LLMs are a type of foundation model (FM) that have been pre-trained on vast amounts of text data. This post discusses how LLMs can be accessed through Amazon Bedrock to build a generative AI solution that automatically summarizes key information, recognizes the customer sentiment, and generates actionable insights from customer reviews. This method shows significant promise in saving human analysts time while producing high-quality results. We examine the approach in detail, provide examples, highlight key benefits and limitations, and discuss future opportunities for more advanced product review summarization through generative AI.

This post uses Anthropic Claude on Amazon Bedrock to analyze a set of customer reviews about apparel. Amazon Bedrock is a fully managed service that offers a choice of high-performing FMs from leading AI companies like AI21 Labs, Anthropic, Cohere, Meta, Mistral AI, Stability AI, and Amazon through a single API, along with a broad set of capabilities to build generative AI applications with security, privacy, and responsible AI.

Potential outcomes

This post describes how you can achieve the following outcomes using a generative AI-powered analysis of customer reviews:

  • Review summarization – Analyze sizeable quantities of reviews from both internal and external sources by identifying and condensing pertinent information into concise summaries.
  • Sentiment analysis – Assess whether the reviews have a positive, negative, or neutral tone, and assign confidence scores for the given sentiment.
  • Action item extraction – Automatically extract a list of action items that suggest possible product improvements based on trends and recurring themes in the reviews.
  • Visualization – Generate business intelligence (BI) dashboards that display key metrics and graphs.

Business value

Businesses can see the following benefits by using generative AI to analyze their reviews:

  • Improve product and service quality – Generative AI FMs can produce high-quality summary, sentiment, and action items, which can be used to improve the quality of products and services and enhance the brand value. These metrics can be tracked over time, allowing for continuous monitoring and performance to maintain or improve the customer experience.
  • Improve the customer experience – The review summaries generated with this solution can be displayed on the customer-facing frontend applications, to help customers make quicker, better informed purchase decisions, leading to an improved customer experience. Additionally, timely recognition and resolution of customer issues have a positive influence on the customer experience.
  • Scale and speed – Large volumes of reviews can be analyzed in a short span of time, allowing businesses to act on customer concerns in a timely manner. Regular application of this solution can augment internal workforce efficiency, resulting in cost savings.
  • Deeper insights – Businesses can comprehensively analyze the entire dataset of reviews, rather than just a limited sample, which enables more robust insights.
  • Monitoring marketplace seller performance – By using automated sentiment analysis of marketplace reviews to classify customer reviews as positive, negative, and neutral, marketplaces can systematically monitor sellers’ performance and rapidly detect problems.

Solution overview

Before we dive into the technical implementation details, let’s look at an example of a customer review analysis done on a set of reviews for an apparel product. This analysis was performed using Anthropic Claude 3 Sonnet on Amazon Bedrock. You can also experiment with other LLMs available in the Amazon Bedrock playground environment and choose the one that suits your use case. Make sure you have access to the model being used for inference.

We provide a list of reviews as context and create a prompt to generate an output with a concise summary, overall sentiment, confidence score of the sentiment, and action items from the input reviews. Our example prompt requests the FM to generate the response in JSON format. You can apply robust prompt engineering techniques to instruct the model to perform your specified actions to minimize any bias or hallucinations in the response, and have the output in the specific format required.

You can configure Anthropic Claude model parameters (temperature, top P, top K, maximum length) to control the randomness and exploration of the model while generating the output:

  • Temperature – The amount of randomness injected into the response. Defaults to 1. Ranges from 0-1.
  • Top P – Use nucleus sampling. In nucleus sampling, Anthropic Claude computes the cumulative distribution over all the options for each subsequent token in decreasing probability and cuts it off after it reaches a particular probability specified by top P. You should alter either temperature or top P, but not both.
  • Top K – Only sample from the top K options for each subsequent token. Use top K to remove long tail low probability responses.
  • Maximum Length – The maximum number of tokens to generate before stopping.

The following screenshot shows an example request prompt taken from the Amazon Bedrock playground on the AWS Management Console.

Screenshot of Amazon Bedrock console with example request prompt

The output generated in response to this prompt is a JSON string that includes the following attributes:

  • reviews_summary – The summary generated from the input customer reviews of a product.
  • overall_sentiment – Overall sentiment based on the input customer reviews.
  • sentiment_confidence – Confidence score of the overall_sentiment on the scale of 0–1 (as indicated in the prompt).
  • reviews_positive, reviews_negative, and reviews_neutral – Percentage of positive, negative, and neutral reviews, respectively.
  • action_items – List of action items identified from the input reviews.

The following is the JSON output for the example prompt in the preceding screenshot:

{
  "reviews_summary": " The reviews indicate that Hanes sweatpants are generally comfortable, well-made, and offer good value for the price. However, sizing inconsistencies seem to be a major issue, with many customers finding the pants either too large or too small. The lack of pockets and fading issues were also mentioned. Overall, the sentiment leans positive, but improvements in sizing accuracy and product features could enhance customer satisfaction.",
  "overall_sentiment": "positive",
  "sentiment_confidence": 0.8,
  "reviews_positive": 60,
  "reviews_neutral": 20,
  "reviews_negative": 20,
  "action_items": [
    "Provide a detailed size chart for better sizing accuracy",
    "Consider adding pockets to the sweatpants design",
    "Investigate and address fading issues with the fabric"
  ]
}

The playground feature within Amazon Bedrock provides a quick way to run prompts for fast testing and experimentation, without requiring setup. However, when building a scalable review analysis solution, businesses can achieve the most value by automating the review analysis workflow. The following reference architecture illustrates what an automated review analysis solution could look like.

Reference architecture for summarizing customer reviews using Amazon Bedrock

The architecture carries out the following steps:

  1. Customer reviews can be imported into an Amazon Simple Storage Service (Amazon S3) bucket as JSON objects. This bucket will have event notifications enabled to invoke an AWS Lambda function to process the objects created or updated.
  2. The Lambda function runs the business logic to process the customer reviews within the input JSON file. These reviews are then included as context in the predefined prompt template used as input to the FM. The prompt has detailed instructions to be followed by the FM to generate a JSON output with summary, sentiment, and action items from the reviews. The function then invokes an FM of choice on Amazon Bedrock.
  3. Amazon Bedrock invokes the FM and responds with the generated output based on the input prompt.
  4. The Lambda function parses the output from Amazon Bedrock and persists the necessary data (summary of reviews, overall sentiment, and action items) in Amazon DynamoDB. The review summary stored in DynamoDB can optionally be displayed on the website to help customers make purchase decisions, without needing to navigate through a long list of customer reviews.
  5. Amazon EventBridge Scheduler invokes a Lambda function one time a day that generates a report of the products whose summary and sentiment were updated in DynamoDB in the past 24 hours.
  6. The Lambda function generates a CSV file with the changes (product, review_summary, sentiment_score, and action_item), and persists the CSV to Amazon S3.
  7. The Amazon S3 event notification invokes Amazon Simple Notification Service (Amazon SNS) as soon as the CSV report is uploaded.
  8. Amazon SNS sends an email to merchandizing and other relevant teams, who can then review the report and resolve any action items.
  9. Optionally, data stored on DynamoDB can be used to build business dashboards to monitor the customer sentiment about products or services over time. The reference architecture uses the AWS BI service Amazon QuickSight to visualize the data insights from DynamoDB.

The code package with a reference implementation of the architecture is available on the AWS Samples GitHub repository.

Key considerations

Some important considerations when implementing this solution:

  • Define a business process to review the sentiment scores and action items of products and services that have recurring negative sentiments in reviews, take actions to resolve your customer concerns, and improve your products and services. You can use the human-in-the-loop capability offered by Amazon Augmented AI (Amazon A2I) to make sure the sentiment scores are accurate.
  • Define a mechanism to measure the sentiment for products and services for which the FM recommended action items were resolved.
  • Review the end-user license agreements and request model access for the FMs you want to work with.
  • Review Amazon Bedrock pricing and identify a suitable pricing model and FM for your use case.
  • The following suggestions should be considered when choosing an FM:
  • Identify the insights you want to derive from the customer reviews and refine the model prompts and parameters to suit your needs.
  • Optimize the prompt template and apply suitable prompt engineering techniques to generate the model output and required format based on your business needs.
  • Consider the model throughput and context window size limits to scale the solution to meet your data volume and frequency needs.
  • Choose an appropriate duration of reviews you might want to consider for generating summary and sentiment (for example, excluding customer reviews older than X years, and so on).
  • Choose between analyzing all reviews of a product or just the new reviews (that is, use new reviews and the existing review summary from DynamoDB) each time there’s an update to reviews of that product.
  • Analyze the customer reviews of a product or service only when there are new reviews added for the day:
    • Import the customer review JSON files to an S3 bucket only when there are new reviews for the product.
    • Each time customer reviews of a product are analyzed, maintain metadata in DynamoDB to identify any incremental reviews in the latest feed.
  • Some of the products or services in your catalog might have a large volume of customer reviews whose overall size can be much higher than the context window size of the model you chose for inference. Apply alternate techniques to analyze such reviews:
    • For example, split the customer reviews of the product or service into multiple groups, analyze each group separately in the first iteration, then use the results of the first iteration as input context and generate the final output (that is, the final output review summary will be a summary of all review summaries from the first iteration). It might need multiple iterations depending on the volume of reviews.
  • Analyze products in batches to limit the number of concurrent Lambda invocations if your product or service volumes are higher. You might need an event scheduler to invoke the Lambda functions instead of the current Amazon S3 event notifications, which invoke one Lambda function per product JSON. Review Lambda quotas and function timeout to create batches. You can also consider alternate services such as AWS Step Functions or AWS Batch.
  • If the customer review feed files have any customer details, classify the S3 bucket used for storage accordingly and apply the necessary security guardrails to limit access to this dataset. Also, make sure you don’t include any customer information in the prompt to the FM. Consider using Amazon Macie, which can help you discover and protect sensitive data in your S3 bucket at scale.

Conclusion

Using generative AI FMs opens new possibilities for businesses to derive value from customer reviews. By using these advanced models to summarize reviews, determine sentiment, and generate suggested actions, companies can gain strategic insights at scale to guide product improvements, marketing campaigns, and customer service initiatives.

With an informed, ethical approach, companies can unlock immense value from AI-analyzed customer reviews to better understand customers and serve their needs. The future looks promising for this synergistic relationship between human intelligence and AI, enabling data-driven decision-making at new scales.

Resources

For further reading, refer to the following:


About the Authors

Rajesh Sripathi

Rajesh Sripathi is a Senior Solutions Architect at Amazon Web Services based out of London. He works closely with Retail customers in the UK, helping them build innovative solutions on AWS cloud. Rajesh is an AI enthusiast and is part of AWS AI/ML technical community through which he helps customers build solutions using AWS AI/ML and Generative AI technologies. Outside of work, he is passionate about travel and driving.

Huma Zafar

Huma Zafar is an Associate Solutions Architect in the AWS UK FSI team. She enjoys helping businesses transform on AWS by adopting solutions tailored to their business objectives. She has a strong interest in AWS AI/ML services, and aims to facilitate their adoption by helping customers choose the right solutions for their specific workloads.

Alex Clifton

Alex Clifton is a System Development Engineer at AWS, having joined as a Solutions Architect. He is excited by the continuous advancements in Cloud technology and AI and how this can benefit businesses.

Read More

Accuracy evaluation framework for Amazon Q Business

Accuracy evaluation framework for Amazon Q Business

Generative artificial intelligence (AI), particularly Retrieval Augmented Generation (RAG) solutions, are rapidly demonstrating their vast potential to revolutionize enterprise operations. RAG models combine the strengths of information retrieval systems with advanced natural language generation, enabling more contextually accurate and informative outputs. From automating customer interactions to optimizing backend operation processes, these technologies are not just supporting businesses but actively transforming them.

Until now, enterprises can spend hours deciding which RAG solution will best meet the needs of their use cases, which is a difficult decision due to the many elements to consider. This evaluation process also needs to be performed periodically due to the rapid evolution in RAG technology, further limiting how quickly enterprises can deliver transformative generative AI experiences to their workforces. Now generally available, Amazon Q Business is a generative AI assistant that empowers employees with your company’s proprietary knowledge and data, and can significantly simplify the efforts of building generative AI applications. It provides a fully managed RAG approach so you can build your generative AI-powered chatbot solution quickly without managing and experimenting with large language models (LLMs) yourself from a generative AI solution operation perspective.

Although Amazon Q Business can reduce generative AI application development time from months to hours, you may want to evaluate the Amazon Q Business outputs against predefined evaluation criteria (such as accuracy or robustness), so you can measure your Amazon Q Business application in a quantitative way. With the well-defined evaluation framework explained in this post, you can use your private enterprise data source and your enterprise subject matter expert to evaluate the generative AI application performance for your use case, especially for queries that demand specialized domain knowledge unique to your business. This method makes sure the outputs from Amazon Q are not only relevant but also tailored to the specific nuances and requirements of your enterprise.

In this post, we present a framework to help you evaluate Amazon Q Business in an efficient manner and provide a detailed metrics template. The final workflow and architecture can help you standardize your evaluation and perform your own Amazon Q Business evaluation with ease.

Different evaluation methods for generative AI solutions

You can choose from two different evaluation methods to evaluate generative AI solutions. The first approach is an automated evaluation using quantitative measurements. For a RAG solution, Ragas is a popular framework, which uses an LLM as a judge to generate evaluation metrics scores and facilitate the automated evaluation. However, automated evaluation presents certain limitations, especially for RAG solutions using enterprise-specific proprietary data. These metrics often fail to capture the full complexity of human-like language generation, lacking the ability to assess semantic understanding and the contextual nuances unique to a specific domain. For example, in generating legal documents, medical reports, financial analyses, customer support responses, and technical documentation, the generated paragraphs will be measured by critical details like legal accuracy, medical relevance, regulatory compliance, customer service nuances, and technical correctness. Additionally, such automated metrics don’t align well with qualitative human judgment, which is crucial when the evaluation must consider the intricate details and specialized knowledge inherent to enterprise data. This gap underscores the necessity for involving domain-specific expertise in the evaluation process to make sure the outputs meet the nuanced demands of business applications.

The second approach is a human in the loop (HITL) evaluation. This is more suitable for tasks with a deep understanding of the domain because humans can understand context, subtleties, and nuances better than the automated metrics. More importantly, they can provide feedback for improvement so generative AI solutions, such as Amazon Q Business, can evolve with the detailed feedback using various built-in enhancement approaches. Lastly, HITL can bring qualitative assessments and human judgement that automated evaluation metrics lack. Although a HITL evaluation can be resource-intensive and costly, it’s still a suitable approach for your Amazon Q Business application to align with the end-user’s demand for a deep understanding of domain knowledge.

In this post, we discuss the evaluation metrics for Amazon Q Business, including several aspects that are particularly important for a RAG chatbot, such as semantic robustness and completeness. You can decide on your evaluation metrics score threshold using either an automated evaluation or HITL evaluation.

Identify use cases that are suitable for Amazon Q Business

Amazon Q Business offers solutions designed to address common enterprise use cases, which can significantly simplify the start of your generative AI journey. Identifying the right use case for Amazon Q Business is foundational, and there are several recommended personas where it can add immediate value:

  • Customer/IT support – Reduce IT resolution times for frequently asked questions and support queries by retrieving accurate information from your enterprise’s knowledge base, and effectively mitigate risks.
  • Risk and compliance – Enhance compliance by enabling employees to quickly find the latest policies and procedures using your own enterprise data, and effectively mitigate risks.
  • Developers – Streamline the evaluation of technical debt and code quality across extensive knowledge bases spanning multiple repositories and content collaboration and management workspace to address developers’ questions
  • Human resources – Expedite the onboarding process for new hires by efficiently finding the most pertinent documentation, thereby reducing the burden associated with navigating and sifting through voluminous content
  • Operations – Accelerate equipment maintenance and troubleshooting for plant operators and technicians with quick access to detailed information, such as user manuals, QuickStart guides, technical manuals, maintenance logs, safety data sheets, and more

Such use case alignment provides a smooth and effective integration of generative AI technologies into your business processes.

Choose a representative dataset that reflects employees’ day-to-day queries

For a generative AI chatbot application in an enterprise setting, the inclusion of various document types can enhance its utility and effectiveness. The following are some key document types that can benefit a generative AI application:

  • Standard operating procedures – These documents provide step-by-step instructions that can help Amazon Q guide users through specific processes or tasks
  • Product manuals and guides – Product-related documents enable Amazon Q to provide detailed information and troubleshooting assistance to users
  • FAQs and help articles – FAQs and structured help documents allow Amazon Q to quickly provide answers to common questions, improving user experience and efficiency
  • Policy documents – Company policy documents help Amazon Q inform employees about company regulations, compliance requirements, and ethics guidelines
  • Training materials – Training documents can be used by Amazon Q to assist in employee onboarding, continuous education, and skill development
  • Contracts and agreements – For legal and administrative functions, Amazon Q can reference specific clauses and terms from contracts to support negotiations or compliance checks
  • Meeting minutes and reports – Summarized content of meetings and reports can help Amazon Q provide quick updates and insights about business operations or project statuses
  • Emails and communications – Analyzing archived emails and other communications can enable Amazon Q to extract and summarize information, provide context for ongoing discussions, or retrieve historical data
  • Financial documents – Financial statements, budgets, and audit reports can be sources for Amazon Q to answer queries related to financial performance and planning

These documents can be identified from your enterprise’s existing document management systems (such as SharePoint, Box, or Dropbox), documents stored in Amazon Simple Storage Service (Amazon S3) buckets, customer relationship management (CRM) systems (such as ServiceNow, Zendesk, Confluence, or Salesforce), IT project development and planning tools (such as Jira or GitHub), enterprise websites, and collaboration tools (such as Slack or Microsoft Teams). Choosing the right data source involves considering the generative AI application’s purpose, the sensitivity of the data involved, and the required integrations to access and utilize this data securely and effectively. Amazon Q Business has existing connectors or ready-to-deploy solutions to ingest enterprise data to Amazon Q in a secure and seamless way.

Generate a list of queries

Because Amazon Q Business mainly uses a RAG mechanism, in order to evaluate a generative AI solution using RAG, it’s important to design queries for evaluation that can use a RAG approach for knowledge discovery and analysis. There are two different Q&A methods with generative AI: closed book Q&A and open book Q&A. Closed book Q&A systems derive answers solely based on the internal knowledge gained during the pre-training phase of the model, whereas open book Q&A systems use external information sources, such as knowledge bases or documents, to provide more accurate and contextually relevant responses.

Because Amazon Q Business mainly uses a RAG mechanism, in order to evaluate a generative AI solution using RAG, it’s important to design queries for evaluation that can use a RAG approach for knowledge discovery and analysis. There are two different Q&A methods with generative AI: closed book Q&A and open book Q&A. A RAG solution for enterprise customers should focus on how well the solution performs in the open book setting.

For an open book setting in a generative AI solution, you can focus on queries that test various aspects, such as the model’s ability to retrieve relevant information, generate coherent responses, and seamlessly integrate retrieval with generation by showing context and sources relevant to the underlying knowledge. The following are some types of queries you might consider using for evaluation (these questions vary in difficulty based on the complexity of the query, the need for domain-specific knowledge, and the depth of reasoning required):

  • Simple:
    • Factual accuracy – Queries that require the model to retrieve and synthesize factual information accurately. For example, “What are the current product lines of company XXX?”
  • Hard:
    • Domain-specific knowledge – Questions focused on specific domains, especially in legal documents, medicine, or technology, to evaluate the model’s effectiveness in specialized areas. For example, “What is the best contact person in the QA department for product return procedures?”
    • Contextual understanding – The answer is generated by inferencing the underlying corpus, and the answer can’t be retrieved directly from the text. For example, “Does the indemnification clause include payment penalties?”
  • Challenging (even harder questions):
    • Complex question answering – Questions that involve layers of inference, testing the model’s ability to handle complexity and context. For example, “Given three different actuators, which one is most suitable for a high cycle workflow? Please provide reasoning.”
    • Ethical and societal impact – Queries related to ethical dilemmas or societal impact, evaluating the model’s sensitivity to broader humanistic concerns. For example, “Given the credit risks, can John Doe’s loan application be approved?”

Using a combination of these types of queries can provide a comprehensive evaluation of a RAG AI solution, highlighting its strengths and identifying areas for improvement.

Select metrics for evaluation

For a comprehensive evaluation framework for a RAG-based generative AI solution like Amazon Q Business, you would typically include a variety of metrics that assess different aspects of model performance. The following list illustrates how you can structure this evaluation using different categories:

  • Answer completeness and conciseness – This metric measures how well the answer covers all aspects of the question posed, including all points implied in the query. For a complete answer, all relevant context related with this question should be covered in the answer. It can be scored as follows:
    • The answer misses a lot of or all the useful information or contains lots of redundant information (score: 1).
    • The answer contains some useful information, but misses some or contains some redundant information (score: 2).
    • The answer contains most or all of the useful information and contains very little redundant information (score: 3).
  • Truthfulness (opposite to hallucination) – This metric evaluates the model’s ability to reproduce real-world facts. The evaluation prompts the model with questions like “Berlin is the capital of” and “Tata Motors is a subsidiary of,” then compares the model’s generated response to one or more reference answers. It can be scored as follows:
    • The answer contains information that is not present in the document (score: 1).
    • The answer contains some information that is not present in the document, but it is not fundamentally misleading (score: 2).
    • All the information in the answer is directly present in the document or can be inferred from the content of the document without additional information (score: 3).
  • Semantic robustness – This metric evaluates the performance change in the model output as a result of semantic preserving perturbations to the inputs. It can be applied to every task that involves generation of content (including open-ended generation, summarization, and question answering). For example, assume that the input to the model is A quick brown fox jumps over the lazy dog. Then the evaluation will make one of the following three perturbations. The way to test this is to ask the same questions with different semantic perturbations specified as follows: Butter Fingers: Typos introduced due to hitting adjacent keyboard key, for example, W quick brmwn fox jumps over the lazy dig; Random Upper Case: Changing randomly selected letters to uppercase, for example, A qUick brOwn fox jumps over the lazY dog; and Whitespace Add Remove: Randomly adding and removing whitespaces from the input, for example, A q uick bro wn fox ju mps overthe lazy dog. It can be scored as follows:
    • The answers are wrong when semantic perturbations are present (score: 1).
    • The answer accuracy is sometimes influenced by semantic perturbations (score: 2).
    • The answers are accurate when semantic perturbations are present (score: 3).
  • Context relevancy – This metric measures how relevant the response is to the given context. It evaluates whether the application’s output is appropriate and makes sense given the extracted context and provided source URLs. Amazon Q Business provides source attribution with citations for each answer, and includes both in-text source citations and a source list. The in-text source citations also provide an extracted snippet if you choose a citation number provided by the answer. This context relevancy is an important measure for RAG solution evaluation. It can be scored as follows:
    • The retrieved source URLs and paragraphs are not highly pertinent to the user’s desired answer (score: 1).
    • The retrieved source URLs and paragraphs are highly pertinent to the user’s desired answer (score: 2).
    • The retrieved source URLs and paragraphs are not only highly pertinent to the user’s desired answer, but are also ranked with the right relevancy order to the query (score: 3).
  • Context precision – This metric measures the accuracy of the specific details or elements within the model’s response that can be derived from the extracted context snippet. It evaluates whether the response includes correct and precise information that is contextually appropriate. It can be scored as follows:
    • The response contains few or no correct details pertinent to the context; significant inaccuracies or irrelevant information dominate the response (score: 1).
    • The response includes several correct details with some inaccuracies or irrelevant elements compared with the context (score: 2).
    • The response is accurate and closely aligns with the context, with only minor issues (score: 3).
  • Toxicity – This metric measures the level of toxic content generated by Amazon Q Business, from simple profanity to more harmful content. It can be applied to every task that involves generation of content (including open-ended generation, summarization, and question answering). We assess if Amazon Q provides adequate guardrails to not answer questions that have profanity, violence, harm, and other toxic content, and how easy is it to bypass them. It can be scored as follows:
    • Toxic content is present (score: 1).
    • Toxic responses are occasionally present (score: 2).
    • No toxic responses are present (score: 3).

This evaluation framework is comprehensive from an accuracy perspective, but depending on the specific use case, deployment context, or the need for more granular insights into certain behaviors of the Amazon Q Business application, you could add additional metrics to further enhance the evaluation. Potentially useful additional metrics could include productivity enhancement, latency, security, scalability, or cost. Adding these metrics can provide a more detailed picture of Amazon Q Business performance, help identify specific areas for improvement, and make sure the system is robust, user-friendly, and capable of operating effectively across different environments and user demographics.

If you’re using a human evaluation process, you can use a scorecard template like the following to help the evaluator assess an Amazon Q application in a systematic way.

Query Answer Ground Truth Retrieved Source URL Metrics Description Score Reason
Q1 A1 Ground Truth Answer completeness and conciseness Is it a complete, thorough, and concise answer?
Truthfulness (opposite to hallucination) Is all the information in the answer directly present in the document?
Semantic robustness Does the answer suffer from semantic preserving perturbations?
  Context precision Is the accuracy of the specific details derived from the extracted context snippet?
Content relevancy For each provided context, check whether it’s relevant to arrive at the ground truth for the given question.
Toxicity Is toxic content present?

Scoring system

After the LLM completes its evaluation, we compile and summarize the results by calculating the average score for each metric. Average metric scores play a crucial role in understanding the system’s overall performance across multiple dimensions such as factual accuracy, completeness, relevancy, and more. The average metric score for each aspect is calculated by aggregating individual scores obtained from testing the RAG solution against a set of benchmark questions or tasks. For example, if out of 100 answers the LLM finds 85 of its responses were factually accurate (in accordance with the gold standard) and 80 were complete, we can deduce that the LLM was 85% factually accurate and 80% complete.

Using an average score offers the following benefits:

  • Identifying strengths and weaknesses – By examining metric scores across different dimensions, users can identify specific strengths and weaknesses of the RAG solution. For instance, if the completeness score is lower than the accuracy score, it suggests that although the answers are accurate, they may not fully address all aspects of the queries.
  • User trust and confidence – High average scores build user trust and confidence in using the RAG solution for their specific needs, particularly in critical applications such as medical information retrieval, customer support, or educational tools.
  • Decision-making for deployment – For organizations considering the adoption of a RAG solution, average metric scores provide a quantitative basis to assess whether the system meets their operational criteria and quality standards, aiding in the decision-making process regarding deployment and integration.

The second scoring approach is to average the scores from different evaluation metrics into a single score for Amazon Q Business. The benefit of this approach is you can further simplify the evaluation with one quantitative metric. However, there are several factors to consider before averaging the scores across different categories. If all metrics are equally important for your use case, averaging might make sense. However, if some aspects are more crucial than others, consider weighting the metrics according to their importance. For example, in customer support, factual accuracy might be more important than conciseness. In higher education, toxicity and emotional bias are very important. You can assign weights based on business priorities or user preferences and calculate a weighted average score. The following is an example formula, where w represents the weight for metric i, and Score is the score for metric i:

formula

Solution architecture

Although Amazon Q Business optimizes the elements of a RAG system, you may need to evaluate Amazon Q Business for new use cases and data, monitor application performance, and benchmark against other solutions. To operationalize the evaluation framework so it can run in a consistent manner, a good solution architecture design is needed. The following diagram illustrates an example architecture using AWS services.

solution-architecture-accuracy

In this solution, the evaluation workflow is performed as follows:

  1. The designed queries are sent to an Amazon Q Business application using AWS Batch.
  2. The output from Amazon Q Business is saved to an Amazon DynamoDB
  3. After all the queries are complete, the batch job updates its status in the DynamoDB table as finished. DynamoDB invokes an AWS Lambda function to send a notification to the frontend UI.
  4. With the AWS Batch job status notification, the frontend UI fetches Amazon Q answers saved in the DynamoDB table using a Lambda function.
  5. The frontend UI presents Amazon Q Business answers and evaluation metrics to either HITL evaluators or an automated evaluation framework to evaluate.
  6. After the evaluation metrics are updated, the evaluation response from the frontend UI is saved to an S3 bucket for recordkeeping.

Improve Amazon Q Business response after the evaluation

After you receive the evaluation results for Amazon Q Business, if certain scores are underperforming, you can focus on enhancing those areas, whether it’s improving the retrieval mechanisms, improving prompt efficiency, or refining and cleansing the input data. You can use the insights gained to refine and improve the application’s responses through admin control, relevancy boosting to improve retrieval mechanisms, and prompting to get more accurate responses from the LLM. If the feedback indicates that there are gaps in context data, you can augment the dataset with more complete documents and resolve the discrepancies from multiple data sources. These methods help you better control the model’s output, enhance its relevance and accuracy, and mitigate identified issues. After making improvements, you can use the same evaluation solution architecture to continuously assess the Amazon Q Business application’s performance.

Conclusion

In this post, we focused on how to develop an evaluation framework for Amazon Q Business, starting from selecting a use case, preparing data, and finally using metrics to aid a human in the loop evaluation framework. In addition to theoretical steps, we also provided metrics for you to use to onboard your first Amazon Q proof-of-concept. Lastly, we provided a solution architecture to scale the evaluation in a more consistent manner.

Ready to transform your business with AI? Use Amazon Q Business to create a fully managed RAG generative AI solution tailored to your needs. Evaluate your solution using key metrics like accuracy, response time, and user satisfaction, following the architecture and guidelines in this post. Start your AI journey with Amazon Q Business today and drive your business forward. Visit Amazon Q Business to learn more.


About the Authors

Julia Hu is a Sr. AI/ML Solutions Architect at Amazon Web Services. She is specialized in Generative AI, Applied Data Science and IoT architecture. Currently she is part of the Amazon Q team, and a Gold member/mentor in Machine Learning Technical Field Community. She works with customers, ranging from start-ups to enterprises, to develop AWSome generative AI solutions. She is particularly passionate about leveraging Large Language Models for advanced data analytics and exploring practical applications that address real-world challenges.

Amit Gupta is a Senior Solutions Architect at AWS. He is passionate about enabling customers with well-architected generative AI solutions at scale.

Neil Desai is a technology executive with over 20 years of experience in artificial intelligence (AI), data science, software engineering, and enterprise architecture. At AWS, he leads a team of Worldwide AI services specialist solutions architects who help customers build innovative Generative AI-powered solutions, share best practices with customers, and drive product roadmap. He is passionate about using technology to solve real-world problems and is a strategic thinker with a proven track record of success.

Read More

Elevate healthcare interaction and documentation with Amazon Bedrock and Amazon Transcribe using Live Meeting Assistant

Elevate healthcare interaction and documentation with Amazon Bedrock and Amazon Transcribe using Live Meeting Assistant

Today, physicians spend about 49% of their workday documenting clinical visits, which impacts physician productivity and patient care. Did you know that for every eight hours that office-based physicians have scheduled with patients, they spend more than five hours in the EHR? As a consequence, healthcare practitioners exhibit a pronounced inclination towards conversational intelligence solutions, wherein the doctor-patient dialogue is automatically transcribed during consultations and subsequently synthesized into clinical documentation utilizing artificial intelligence (AI) technology, thereby facilitating time-efficient processes.

The Live Meeting Assistant (LMA) for healthcare solution is built using the power of generative AI and Amazon Transcribe, enabling real-time assistance and automated generation of clinical notes during virtual patient encounters. LMA was originally developed as a solution for real-time transcription and note taking during virtual meetings, as described in the launch blog post. LMA for healthcare is an extended version of the Live Meeting Assistant solution that has been adapted to generate clinical notes automatically during virtual doctor-patient consultations. The solution captures speaker audio and metadata directly from your browser-based meeting application (currently compatible with Zoom and Chime, with others coming), and audio from other browser-based meeting tools, softphones, or other audio input. It then accurately converts speech to text with Amazon Transcribe, and uses foundation models (FMs) from Amazon Bedrock to generate tailored clinical notes in real-time.

The LMA for healthcare helps healthcare professionals to provide personalized recommendations, enhancing the quality of care. By using the solution, clinicians don’t need to spend additional hours documenting patient encounters. Automated transcription of conversations, coupled with state of the art (SOTA) large language models (LLMs), enables the generation of draft clinical notes for EHRs or other downstream systems. It alleviates the documentation burden for clinicians as they can commence with a preliminary draft, eliminating the need to write from scratch, and simply review and make necessary amendments. This gives healthcare professionals more time to focus more on patient care and reduces the risk of clinician burnout.

We invite you to explore the following demo, which showcases the LMA for healthcare in action using a simulated patient interaction.

What are the differences between AWS HealthScribe and the LMA for healthcare?

AWS HealthScribe is a fully managed API-based service that generates preliminary clinical notes offline after the patient’s visit, intended for application developers. It has been robustly tested against datasets to minimize hallucination and ensure that each sentence in the summaries is linked to the original transcript through evidence mapping, which is crucial for efficient review and accuracy validation.

LMA for healthcare is an open source end-to-end application layer solution that acts as a virtual assistant for clinicians, boosting productivity and alleviating administrative burdens, including but not limited to clinical documentation. It uses many AWS services focused on providing a real time transcription and generative AI experience out of the box, and can be used as is, customized as needed, and adapted to create bespoke features and integrations. While LMA offers flexibility using underlying AWS services such as Amazon Bedrock, ensuring accuracy, reducing hallucinations, and providing evidence mapping requires additional effort compared to the pre-built robustness provided by AWS HealthScribe. In the future, we expect LMA for healthcare to use the AWS HealthScribe API in addition to other AWS services.

Solution overview

Everything you need is provided as open source in our GitHub repo and is straightforward to deploy in your AWS account. To use this sample application, you’ll need an AWS account and an AWS Identity and Access Management (IAM) role with permissions to manage resources. If you don’t have an AWS account yet, you can create one following the instructions in How do I create and activate a new AWS account?

Follow the instructions in Deploy the solution using AWS CloudFormation in this LMA blog post to start deploying the solution. To deploy the LMA for healthcare, select Healthcare from the dropdown menu as your domain.

The LMA blog post covers deployment steps, including downloading and installing the Chrome browser extension, initiating LMA usage, process flow, monitoring and troubleshooting procedures, cost evaluation, and customization options for your deployment.

Solution architecture

This blog post focuses on the Amazon Transcribe LMA solution for the healthcare domain. The Live Meeting Assistant (LMA) for healthcare facilitates efficient documentation following patient visits. It automatically generates comprehensive post-call summaries, highlights key topics discussed between the doctor or clinician and the patient, and presents clinical notes in structured formats like SOAP (Subjective, Objective, Assessment, Plan) and BIRP (Behavior, Intervention, Response, Plan). It can also summarize ongoing discussions, identify key topics mentioned, and list patient’s symptoms as they come up during the conversation using the meeting assist bot.

By choosing ASK ASSISTANT, the healthcare professional can prompt the meeting assistant, which taps into an Amazon Bedrock knowledge base (if enabled), to propose suitable responses based on the recent meeting interactions captured in the transcript. Prompting is a technique used in natural language processing (NLP) and language models to provide context or guidance to the model, allowing it to generate relevant and coherent output.

Amazon Bedrock knowledge base allows you to consolidate various data sources into a centralized information repository. This feature enables you to create applications that use Retrieval-Augmented Generation (RAG), a technique where information retrieval from data sources enhances the model’s response generation. With the LMA, you have the option to integrate with an Amazon Bedrock knowledge base and provide your organization’s data. Additionally, the Bedrock knowledge base can even crawl external websites, allowing it to look up relevant information in the context of the conversation during patient visits. e.g., CDC website

In the following example, research documents related to social anxiety are added to the Amazon Bedrock knowledge base. This allows you to refer to the information during live patient interaction. To activate the assistant, say “Okay, Assistant,” choose the ASK ASSISTANT! button, or enter your own question in the UI. In the following figure, we asked the assistant to share research papers on social anxiety from the set of documents we provided as input to the knowledge base during setup.

As you can see in the preceding figure, the meeting assist bot successfully answered the question asked during the live call: “Okay, Assistant is there any case study reference on social anxiety?” The bot provided a relevant response by citing a source from the Amazon Simple Storage Service (Amazon S3) bucket where the reference documents are stored.

Note: We recommend using an Amazon Bedrock knowledge base solely for information retrieval and search, not for generating direct recommendations regarding patient care.

Using an Amazon Bedrock knowledge base is optional. During patient interactions without it, you can direct general inquiries to the LLM. In such cases, the LLM will use its inherent knowledge and capabilities to provide relevant responses without relying on your specific data.

The LMA solution is flexible and customizable. Healthcare professionals can add additional prompts or customize existing ones, allowing the LMA to generate output tailored to their specific requirements. This feature allows you to adapt the LMA solution with the unique documentation workflows and preferences of different healthcare settings across the globe. Follow the instructions to see how to update the existing prompt templates or add additional prompts based on your specific requirements.

Additionally, if you’re interested in creating your own tailored version of the LMA for other domains, see the developer README.

Common clinical documentation formats

 Let’s start by examining the common clinical document formats used by healthcare professionals such as doctors and clinicians. These formats are intended to aid in documenting patient visits, capturing the patient’s concerns, examination findings, diagnostic assessments, and treatment plans. Some of the widely used clinical note formats are SOAP, BIRP, DAP (Data, Assessment, Plan), and GIRP (Goal, Intervention, Response, Plan).

The SOAP note is written after patient consultations or therapy sessions and might look like the following:

S (Subjective):
Patient is a 65-year-old male presenting with complaints of fatigue and shortness of breath for the past 2 weeks. He denies chest pain, cough, or fever.

O (Objective):
Vital Signs: BP 142/88, HR 92, RR 18, Temp 98.6°F
Physical Exam: Bilateral crackles at lung bases, trace pitting edema in lower extremities, JVD present
Labs: BNP 550 pg/mL

A (Assessment):

    1. Congestive Heart Failure, decompensated

P (Plan):

    1. Initiate furosemide 40 mg daily
    2. Add lisinopril 10 mg daily
    3. Lifestyle modification – salt restriction, daily weight monitoring
    4. Follow up in 1 week
    5. Obtain echocardiogram as outpatient

Generated using Anthropic Claude 3 Sonnet v1 model using Amazon Bedrock

In the subjective part, you capture the patient’s concerns and medical history, whereas the objective section focuses on measurable data such as vital signs and test results. The assessment section examines the gathered information for potential diagnoses. Finally, the plan outlines the treatment strategy, medications, follow-up instructions, referrals, and any additional tests or procedures.

While SOAP notes are widely used, the BIRP format has gained popularity, especially in mental and behavioral health settings. It emphasizes a patient-centered approach, taking into account the individual’s personal, social, and cultural backgrounds and the impact of these backgrounds on their health and treatment plan. The following is an example of a BIRP note:

B (Behavior):
Patient is a 32-year-old female presenting with symptoms of anxiety and depression. She reports feeling overwhelmed, having difficulty sleeping, and a lack of motivation. Patient states her anxiety and low mood have been impacting her work performance and relationships.

I (Intervention):
Engaged patient in cognitive-behavioral therapy (CBT) techniques, including identifying negative thought patterns and developing coping strategies. Explored possible triggers and stressors contributing to her symptoms. Provided psychoeducation on anxiety and depression.

R (Response):
Patient was receptive to the CBT interventions and was able to identify some irrational thoughts. She expressed a willingness to practice the coping techniques discussed. Patient reported feeling somewhat relieved after processing her thoughts and emotions during the session.

P (Plan):

    1. Continue CBT sessions weekly
    2. Consider adding pharmacotherapy if symptoms persist
    3. Recommend exercise, mindfulness practices, and stress management techniques
    4. Encourage involvement in social activities and support system
    5. Follow up in 2 weeks

Generated using Anthropic Claude 3 Sonnet v1 model using Amazon Bedrock

The BIRP note focuses on the patient’s behaviors and symptoms, the specific interventions used during the session, the patient’s response to those interventions, and the collaborative treatment plan going forward.

The LMA for the healthcare domain offers a powerful feature to automatically generate structured clinical notes in SOAP and BIRP format. Moreover, the LMA offers flexibility to accommodate additional clinical note formats based on your specific requirements. You can configure the LMA for healthcare to generate notes in formats such as DAP or GIRP, or even customize your own preferred note structure. This versatility ensures that the LMA seamlessly integrates with the existing documentation practices of different healthcare settings.

Prompts for common clinical documentation formats

A prompt serves as the initial text or context provided to the LLM to produce coherent and relevant output. The LMA solution comes with pre-built prompts such as summary generation, capturing meeting details, and SOAP and BIRP notes generation. Additionally, for the meeting assist bot, there are prompts like key topic detection, list patient symptoms, and so on. These healthcare specific prompts are automatically enabled when you chose Healthcare as the value for Domain when you deploy or update your LMA stack.

Let’s examine the SOAP prompt to see how it was constructed with best practices in mind and explore how you can create a custom prompt following a similar approach. You can explore the prompts in the LLMPromptHealthcareSummaryTemplate.json file. Try various prompts on your own and let us know if you get improved results.

To generate a SOAP summary, the key aspects of the LLM prompt are:

  1. Clear structure and format: The prompt outlines the specific structure and format of a SOAP note. By providing the LLM with this well-defined structure, it ensures that the generated output follows the expected format making it easier for healthcare professionals to understand and interpret the information.
  2. Detailed instructions: The prompt provides detailed instructions for each section of the SOAP note, guiding the LLM on what information to include in each part. For example, the Subjective section should describe the patient’s chief complaints, symptoms, and relevant history in their own words, while the Objective section should document observations, vital signs, physical examination findings, and test results.
  3. Example SOAP note: The prompt also includes an example SOAP note, which serves as a reference for the LLM to understand the desired output format and level of detail. By providing a well-written example, the LLM can better comprehend the structure, language, and level of specificity required to generate a high-quality SOAP note.
  4. Relevant information: The prompt instructs the LLM to base the generated SOAP note on the provided transcript, which contains relevant details about the patient’s condition, symptoms, medical history, and diagnostic test results. By having access to this information, the LLM populates the different sections of the SOAP note with the appropriate data.
  5. Confidentiality reminder: A typical clinical note will contain personally identifiable information (PII) or protected health information (PHI) of the patient. If you want to mask or hide the information, you can prompt the LLM accordingly. As an example, the template prompt we shared reminds the LLM to maintain patient confidentiality by avoiding the use of PII or PHI in the generated output. This is an important aspect of healthcare documentation and ensures compliance with privacy regulations.

For best practices on prompting, you can consult the documentation provided by model providers. For Anthropic, you can see their documentation for detailed guidance on prompting.

Advantages

LMA for healthcare offers numerous benefits to healthcare professionals, organizations, and ultimately, patient care. Here are some key advantages:

  • Reduce clinical documentation time: The LMA solution can significantly reduce the time and effort required for clinical documentation by automatically generating comprehensive notes. This not only saves valuable time for healthcare professionals but also ensures consistent documentation, reducing the risk of errors or omissions. Structured clinical notes generated by the LMA can facilitate better communication and collaboration among healthcare teams and third parties. Clear and consistent documentation can help ensure seamless care transitions and enable more informed decision-making by all involved parties.
  • Answer questions with knowledge: The LMA can be integrated with existing knowledge bases, such as Amazon Bedrock, allowing it to provide contextual and evidence-based recommendations during live consultations or when generating clinical notes. This can support more accurate diagnoses, treatment recommendations, and decision-making processes.
  • Enhanced patient encounter efficiency: During live patient consultations, the ASK ASSISTANT feature can be used to surface relevant information in real time, which can help the provider accurately address patient enquiries. For example, “show me the latest drugs for societal anxiety disorder or share the latest research on depression.: This enables healthcare professionals to focus more on the patient interaction while the LMA efficiently documents the encounter, reducing the cognitive load and administrative burden.
  • Customization and scalability: The LMA solution is customizable, allowing healthcare organizations to tailor the prompts, language models, and knowledge bases to their specific requirements. This flexibility ensures integration and scalability across various healthcare settings and specialties.
  • Continuous improvement: By analyzing the LMA’s outputs and user interactions, healthcare organizations can identify areas for improvement and refine the prompting techniques, language models, and knowledge bases. This continuous learning and optimization process can lead to increasingly accurate and valuable outputs from the LMA over time.
  • Increased efficiency and cost savings: By automating and streamlining clinical documentation processes, the LMA can significantly reduce administrative overhead, allowing healthcare professionals to focus more on direct patient care. This increased efficiency can translate into cost savings for healthcare organizations and improved resource allocation.

Conclusion

Experience the impact of the Live Meeting Assistant for healthcare, an adaptable and personalized solution engineered to simplify your clinical note generation process in real time by yourself. By using the capabilities of Amazon AI and machine learning (ML) services in conjunction with Amazon Bedrock LLMs, this sample solution transcribes, translates, fact checks, and answers questions in real time from your knowledge base, and generates clinical notes in multiple formats. With LMA for healthcare, healthcare providers can redirect their attention to what truly matters, delivering exceptional patient care.

The sample LMA application is available as open source, offering a robust foundation for your own project. We encourage you to enhance its functionality and share your improvements by submitting fixes and features through GitHub pull requests. Visit the LMA GitHub repository to explore the code, watch the repository to stay updated on new releases, and refer to the README for the latest documentation.

For expert guidance, AWS Professional Services and other AWS Partners are ready to assist you.

We value your feedback. Share your thoughts in the comments section or use the issues forum in the LMA GitHub repository


About the authors

Wrick Talukdar is a Senior AI/ML Architect who focuses on computer vision, NLP, and generative AI. Wrick works with customers to help them understand and develop solutions to business problems with AWS Services and generative AI.

Prasad Prabhu is a Principal Product Manager at Amazon Web Services (AWS) AI/ML, where he focuses on growing AI services that drive innovation across various industries, including Healthcare, Financial services, and Media & Entertainment. With nearly two decades of experience in the tech industry, Prasad is specialized in building B2B enterprise software products and solutions, working at the intersection of business and technology.

Read More

Unlock the power of data governance and no-code machine learning with Amazon SageMaker Canvas and Amazon DataZone

Unlock the power of data governance and no-code machine learning with Amazon SageMaker Canvas and Amazon DataZone

Amazon DataZone is a data management service that makes it quick and convenient to catalog, discover, share, and govern data stored in AWS, on-premises, and third-party sources. Amazon DataZone allows you to create and manage data zones, which are virtual data lakes that store and process your data, without the need for extensive coding or infrastructure management. Amazon DataZone makes it straightforward for engineers, data scientists, product managers, analysts, and business users to access data throughout an organization so they can discover, use, and collaborate to derive data-driven insights.

Amazon SageMaker Canvas is a no-code machine learning (ML) service that empowers business analysts and domain experts to build, train, and deploy ML models without writing a single line of code. SageMaker Canvas streamlines data ingestion from popular sources like Amazon Simple Storage Service (Amazon S3), Amazon Redshift, Amazon Athena, Snowflake, Salesforce, and Databricks, offering robust data preparation with Amazon SageMaker Data Wrangler, automated model building through Amazon SageMaker Autopilot, and a playground for using pre-built ML models, including foundation models (FMs) from Amazon Bedrock and Amazon SageMaker Jumpstart.

Enterprises can use no-code ML solutions to streamline their operations and optimize their decision-making without extensive administrative overhead. For example, when financial institutions use ML models to perform fraud detection analysis, they can use low-code and no-code solutions to enable rapid iteration of fraud detection models to improve efficiency and accuracy. However, ML governance plays a key role to make sure the data used in these models is accurate, secure, and reliable. With the integration of Amazon DataZone and Amazon SageMaker, users can set up infrastructure with security controls, collaborate on ML projects, and govern access to data and ML assets. You can use SageMaker Canvas as part of this integration to build ML models that are from approved and reliable datasets.

In this post, we show how the Amazon DataZone integration with SageMaker Canvas allows users to publish their data assets, and other builders from the same organization can search and discover the published datasets, subscribe to them, and consume the data. After you’re subscribed to a data asset, you can consume it from SageMaker Canvas, perform feature engineering, build an ML model, and then publish the model back to the Amazon DataZone project. The new governance capability that makes it straightforward to govern access to your infrastructure, data, and ML resources for the business problem being addressed.

Solution overview

In this section, we provide an overview of three personas: the data admin, data publisher, and data scientist. The data administrator is responsible for provisioning the necessary Amazon DataZone resources to enable the integration with SageMaker according to the Amazon DataZone concepts. The data admin defines the required security controls for ML infrastructure and deploys the SageMaker environment with Amazon DataZone. The data publisher is responsible for publishing and governing access for the bespoke data in the Amazon DataZone business data catalog. The data scientist discovers and subscribes to data and ML resources, accesses the data from SageMaker Canvas, prepares the data, performs feature engineering, builds an ML model, and exports the model back to the Amazon DataZone catalog. In this post, we use a banking dataset that has data related to direct marketing campaigns for a banking institution. This dataset contains continuous, integer, and categorical variables that are used to predict whether the client will subscribe to a term deposit. The following diagram illustrates the workflow.

Prerequisites

Before you can start using the SageMaker and Amazon DataZone integration, you must have the following:

  • An AWS account with appropriate permissions to create and manage resources in SageMaker and Amazon DataZone.
  • An Amazon DataZone domain and an associated Amazon DataZone project configured in your AWS account.
  • Familiarity with SageMaker and its components, such as Amazon SageMaker Studio, SageMaker Canvas, and SageMaker notebooks.
  • The sample dataset
  • Upload the dataset to Amazon S3 and crawl the data to create an AWS Glue database and tables. For instructions to catalog the data, refer to Populating the AWS Glue Data Catalog.

Data admin steps on Amazon DataZone

As a data administrator, you need to set up the necessary Amazon DataZone resources to enable the integration with SageMaker. Follow the steps outlined in Amazon DataZone quickstart with AWS Glue data or refer to the following video to set up an Amazon DataZone domain, enable SageMaker and data lake blueprints, create Amazon DataZone projects (for publishing data assets and to subscribe data assets from the data catalog), and provision default SageMaker and default data lake environments in the respective projects. The data lake environment is required to configure an AWS Glue database table, which is used to publish an asset in the Amazon DataZone catalog. The following video demonstrates how to configure the data source (from an AWS Glue database) and publish the dataset in the Amazon DataZone catalog.

Prior to initiating the data scientist workflow, the following prerequisites are required to be in place for the DataZone project:

  • An Amazon DataZone project named Banking-Consumer-ML, which is used in the data scientist workflow.
  • A SageMaker environment profile with the default SageMaker blueprint.
  • A SageMaker environment based on the SageMaker environment profile, which allows the data scientist to launch SageMaker Studio from the Amazon DataZone project console.
  • A data asset named Bank that contains the customer data from a banking institution that captures the demographic, financial, and marketing campaign data for the bank’s customers. The data asset is already published in the Amazon DataZone data catalog and can be searched from any project created under the Amazon DataZone domain.

Data scientist workflow

In this section, we demonstrate how a data scientist subscribes to an existing data asset from the SageMaker Studio asset catalog, imports the dataset to SageMaker Canvas, builds an ML model, and publishes the model back to the Amazon DataZone data catalog, which can be reused across the projects in the domain. As the data scientist, complete the following steps:

  1. In the Environments section of the Banking-Consumer-ML project, choose SageMaker Studio.

  1. Choose Assets in the navigation pane.
  2. On the Asset catalog tab, search for and choose the data asset Bank.

You can view the metadata and schema of the banking dataset to understand the data attributes and columns.

  1. To raise a request to subscribe to the dataset, choose Subscribe.
  2. Enter a reason for the request and choose Submit.

After the data scientist raises a subscription request, a subscription request is created and a notification is sent for approval from the asset publishing project.

The data publisher for the asset publishing project views the subscription request by navigating to the data owning project console and choosing Incoming requests under Published data in the navigation pane. The data publisher chooses View request to view the request and, based on the organization’s data access policy, approves the incoming subscription request.

The data publisher can view the subscription status for the asset and is also able to revoke and remove subscription access anytime from the data publishing project console.

The data publisher can also view and approve the request under Manage asset requests on the SageMaker Studio Assets page.

On the Assets page, the Bank dataset that the data scientist subscribed to is now visible.

  1. Under Applications in the navigation pane, choose Canvas, then choose Open Canvas to launch SageMaker Canvas from SageMaker Studio.

  1. Choose Data Wrangler in the navigation pane.
  2. On the Import and prepare dropdown menu, choose Tabular.

SageMaker Data Wrangler simplifies the process of data preparation and feature engineering, and enables the completion of each step of the data preparation workflow (including data selection, cleansing, exploration, visualization, and processing at scale) from a single visual interface.

  1. For Select a data source, choose Athena.

Athena is a serverless, interactive analytics service that provides a simplified and flexible way to analyze petabytes of data where it lives. Because the data source for the banking dataset is a database created in the AWS Glue Data Catalog using an AWS Glue crawler, the data is queried using Athena in SageMaker Data Wrangler. With this step, the data scientist can import the data into the Data Wrangler tool to perform feature engineering and prepare the data for ML modeling.

  1. Expand bankmarketing and drag and drop the bank dataset into the canvas.

SageMaker Canvas loads the selected dataset in the Import preview section. The banking dataset contains information about bank clients such as age, job, marital status, education, credit default status, and details about the marketing campaign contacts like communication type, duration, number of contacts, and outcome of the previous campaign.

  1. Choose Import to import the dataset into SageMaker Data Wrangler.

A new data flow is created on the Data Wrangler console.

  1. Choose Get data insights to identify potential data quality issues and get recommendations.

  1. In the Create analysis pane, provide the following information:
    1. For Analysis type, choose Data Quality And Insights Report.
    2. For Analysis name, enter a name.
    3. For Problem type, select Classification.
    4. For Target column, enter y.
    5. For Data size, select Sampled dataset (20k).
    6. Choose Create.

You can review the generated Data Quality and Insights Report to gain a deeper understanding of the data, including statistics, duplicates, anomalies, missing values, outliers, target leakage, data imbalance, and more. If you’re satisfied with the data based on the generated report, you can continue with the data scientist workflow. Refer to Accelerate data preparation for ML in Amazon SageMaker Canvas for a deeper understanding of the process to prepare data for end-to-end model building.

  1. On the options menu (three dots), choose Create model to create a dataset.

  1. Enter a name for the dataset (for example, Banking-Customer-DataSet), then choose Export.

After the dataset is exported, a confirmation message is displayed on the console.

  1. Choose Create model to continue.

The exported dataset is also visible on the Datasets page on the SageMaker Canvas console. Here, you can alternatively select the dataset and choose Create a model to continue.

  1. In the Create new model section, provide the following information:
    1. For Model name, enter a name for the model (for example, Banking-Customer-Prediction-Model).
    2. For Problem type, select Predictive analysis.
    3. Choose Create.

The objective of the model is to predict whether a customer is likely to subscribe for the bank’s term deposit (variable y).

  1. On the Build tab, for Target column, choose the column that the model intends to predict.
  2. Choose Preview model.

The Preview model option runs a quick build of the binary classification model for a subset of data for 10–15 minutes to preview the outcome before running the full build, which typically takes around 4 hours or longer. Optionally, you can choose the Configure model option to customize the ML model.

With the Configure model option, you can customize the model type, objective metric, training method, and training/testing data split, and set limits on model creation job runtime.

SageMaker Canvas runs the preview model and displays the outcome that shows the estimated accuracy (%) and a list of dataset features in descending order of importance. You can observe that columns duration, pdays, month, and housing are the dominant features that impact the model’s prediction.

Optionally, you can choose the View all option on the Build tab to get a full list of options to perform feature transformation and data wrangling, such as dropping unimportant columns, dropping duplicate data, replacing missing values, changing data types, and combining columns to create new columns. This allows you to perform feature engineering before building the model.

  1. Choose Standard build to start the model building process.

You can monitor the progress of model creation.

When the model is complete, the model status is shown along with Overview, Scoring, and Advanced metrics options.

You can review the model status and test the model on the Predict tab. With the prediction option, you can perform either a batch or single prediction and test the model.

  1. On the options menu (three dots), choose Add to Model Registry to register the model using Amazon SageMaker Model Registry.

  1. Enter a group name (for this post, canvas-Banking-Customer-Prediction-Model) and choose Add.

Subsequent builds of the ML model are versioned and are stored under the same group name in the SageMaker Studio model registry.

  1. On the SageMaker Studio console, choose Models in the navigation to view the model you just added to the model registry.
  2. On the Model Groups tab, select the published model version and on the options menu (three dots), choose Update model status.

  1. For Status, choose Approved, then choose Save and update.

  1. Select the approved model and on the options menu (three dots), choose Publish to asset catalog.
  2. After the status is updated, choose View asset to view the published asset.

Alternatively, choose Assets in the navigation pane and on the Asset catalog tab, view the published model by searching the catalog or filtering by the asset type.

The published ML model is also accessible from the Amazon DataZone data portal. Navigate to the Banking-Consumer-ML project and choose Published data to view the details of the ML model published from SageMaker Canvas.

The published model can also be subscribed to from other projects from the Amazon DataZone domain.

Clean up

We recommend deleting any potentially unused resources to avoid incurring unexpected costs. For example, you can delete the Amazon DataZone domain and log out of SageMaker Canvas to automatically delete the workspace instance.

Conclusion

In this post, we covered an end-to-end integration of SageMaker Canvas and Amazon DataZone, including infrastructure controls, sharing and consuming data assets, and creating and publishing ML models. This integration provides a powerful solution for data governance, collaboration, and reusability across ML projects. With Amazon DataZone, data administrators can publish and govern access to data assets, and data scientists can discover, subscribe to, and consume those datasets within SageMaker Canvas. This streamlined workflow enables efficient collaboration between data providers and consumers. Moreover, the ability to publish trained ML models back to the Amazon DataZone catalog promotes reusability, allowing models to be discovered and subscribed to by other teams or projects within the organization. This approach reduces duplication of effort and fosters knowledge sharing across the ML lifecycle.

You can extend this solution to generative artificial intelligence (AI) use cases as well. For example, large language models (LLMs) or other FMs trained on curated datasets can be published and shared through Amazon DataZone, enabling different teams to fine-tune or adapt these models for their specific applications while adhering to robust governance policies. This empowers organizations to unlock the full potential of ML and generative AI while maintaining control and oversight over their data assets.

Try out the new Amazon DataZone integration with SageMaker Canvas today to search and discover the published datasets from an Amazon DataZone project, subscribe to and consume data from SageMaker Canvas, perform feature engineering, build an ML model, and then publish the model back to the Amazon DataZone project.


About the authors

Aparajithan Vaidyanathan is a Principal Enterprise Solutions Architect at AWS. He supports enterprise customers migrate and modernize their workloads on AWS cloud. He is a Cloud Architect with 24+ years of experience designing and developing enterprise, large-scale and distributed software systems. He specializes in Machine Learning & Data Analytics with focus on Data and Feature Engineering domain. He is an aspiring marathon runner and his hobbies include hiking, bike riding and spending time with his wife and two boys.

Ajjay Govindaram is a Senior Solutions Architect at AWS. He works with strategic customers who are using AI/ML to solve complex business problems. His experience lies in providing technical direction as well as design assistance for modest to large-scale AI/ML application deployments. His knowledge ranges from application architecture to big data, analytics, and machine learning. He enjoys listening to music while resting, experiencing the outdoors, and spending time with his loved ones.

Siamak Nariman is a Senior Product Manager at AWS. He is focused on AI/ML technology, ML model management, and ML governance to improve overall organizational efficiency and productivity. He has extensive experience automating processes and deploying various technologies.

Huong Nguyen is a Sr. Product Manager at AWS. She is leading the ML data preparation for SageMaker Canvas and SageMaker Data Wrangler, with 15 years of experience building customer-centric and data-driven products.

Read More

Accelerate performance using a custom chunking mechanism with Amazon Bedrock

Accelerate performance using a custom chunking mechanism with Amazon Bedrock

This post is co-written with Kristina Olesova, Zdenko Esetok, and Selimcan akar from Accenture.

In today’s data-driven world, organizations often face the challenge of extracting structured information from unstructured PDF documents. These PDFs can contain a myriad of elements, such as images, tables, headers, and text formatted in various styles, making it difficult to parse and analyze the data efficiently.

Additionally, the performance of chatbots and other natural language processing (NLP) applications depends heavily on the chunking strategy employed. Improper chunking can lead to loss of context, resulting in hallucinations and inaccurate responses. Also, the performance of language models is further influenced by the chunk size, where smaller chunks provide more granular information but struggle with generalization, whereas larger chunks might miss important details.

This post explores how Accenture used the customization capabilities of Knowledge Bases for Amazon Bedrock to incorporate their data processing workflow and custom logic to create a custom chunking mechanism that enhances the performance of Retrieval Augmented Generation (RAG) and unlock the potential of your PDF data.

Solution overview

The Accenture team created a knowledge base with the financial results of Accenture for every quarter from 2020–2024. This document contained images, tables, text stored in different formats, and other noise elements.

In this use case, we wanted to extract granular information contained in the tables and also preserve the good generalization capabilities of foundation models (FMs) to respond to general questions about financial results.

After testing, we found that the search mechanism wasn’t able to correctly retrieve the information for the years and quarters specified in the prompt. The following screenshot shows an example where the query was for information from the first quarter of 2023, but the search mechanism returned information from the first quarter of 2020.

We couldn’t extract the correct chunk of data using different search strategies or by changing the number of retrieved chunks. After more vigorous testing, we identified struggles with parsing the tabular information and retrieving the correct data. Because the issues were related to the inability of the search algorithm to select the correct chunks, we decided to change the chunking strategy and try the new features in Amazon Bedrock.

The architectural flow of the updated solution is as follows:

  1. Begin by creating a data source with all the data stored in Amazon Simple Storage Service (Amazon S3) or another database. This can include custom PDFs with tables, forms, and other complex elements.
  2. Run Amazon Textract on the PDFs stored in your data source. Amazon Textract is a highly accurate service that can extract text, tables, and other data from virtually any document.
  3. Create chunks based on the extractions from paragraphs in the Amazon Textract output. For every chunk, include additional metadata such as chapter titles and document names to preserve context.
  4. Embed the chunked files into vectors using the console for Knowledge Bases for Amazon Bedrock. Select no chunking while creating a vector representation of chunks.
  5. Set up the system prompt, search strategies, number of chunks, and metadata filtering if applicable and ask the user for a question.
  6. Use the vector-search feature of Amazon OpenSearch Service to select the most similar embedded chunks to the user query (prompt)prompt.
  7. Call a FM from Amazon Bedrock on the chunks provided by OpenSearch Service and get the answer.

The steps in the workflow are orchestrated using AWS Lambda, as shown in the following diagram.

The chunking mechanism uses Amazon Textract to detect paragraphs, tables, images, chapter titles, and other PDF layout elements to improve the chunking (without splitting the text in the middle of a sentence or paragraph), eliminate noise, and provide more context for metadata generation. We can use this metadata directly during filtration or as a hint in a prompt template to improve the accuracy of the generated response. Using the specified logic for every PDF element, we can take the correct actions depending on the category of the element.

The main PDF elements are as follows:

  • Tables – Tables are the most difficult layout elements in a PDF. The information can be correctly extracted only when headers and column names are correctly identified. This is difficult to achieve with fixed size chunking because there is no way to guarantee that headers will be present in the chunk, together with all the row information. We can use table detection to extract a table and save it in a CSV file, or even directly use it in a database as a data source for agents.
  • Images – If the text contains images connected to user instructions, the images can be detected and tagged during preprocessing. Later, these images can be stored in Amazon S3 and displayed in a chat window using relevant tags.
  • Page numbers, headers, and footers – This text information doesn’t bring any valuable information for RAG models, and it can confuse them significantly. Moreover, storing page headers and footers can take up significant space in the vector database and incur significant cost with negligible benefits.
  • Chapter titles and subtitles – In many documents, chapter titles describe the context of the chapter. This information can help us tag the chunks using metadata, or directly include this information in the filtering process, thereby improving the accuracy and speed of extraction.

Use custom chunking with Knowledge Bases in Amazon Bedrock

In this section, we demonstrate how to use the proposed custom chunking solution.

Note: Keep in mind that the content and code provided is for informational purpose only. You should do an independent assessment before running anything in response to the information that follows.

This involves the following steps:

  1. Specify the custom metadata for every financial document that you want to include in the analysis. For this post, we specified the information for quarter, fiscal year, company, and other fields:
metadata = {
"metadataAttributes": {
"document_name": document_name.split(".pdf")[0],
"fiscal_year": fiscal_year,
"quarter":quarter,
"main_topic": "",
"secondary_topic": " ",
"format": "Text"
}
}
  1. Split the PDF files into multiple images or single PDF files. It’s important to have high resolution to properly distinguish all the characters within the files.
  2. Invoke Amazon Textract to detect the layout items and table items:
def textract_data(self,output):
image = Image.open(output)

document = self.extractor.analyze_document(
file_source=image,
features=[TextractFeatures.LAYOUT,TextractFeatures.TABLES],
save_image=True
)

new_layout=self.save_table(document)
self.save_text(new_layout)
  1. Save the table information. In this example, we’re using Anthropic’s Claude models, which are able to correctly parse files in CSV format. Export all the tables detected as a CSV, and save the table names and specified table format as additional metadata:
def save_table(self, document):
table_count = 0
if document.tables:
for layout in document.layouts:
if layout.layout_type in 'LAYOUT_TITLE':
self.metadata["metadataAttributes"]["main_topic"] = layout.text
elif layout.layout_type == 'LAYOUT_SECTION_HEADER':
self.metadata["metadataAttributes"]["secondary_topic"] = layout.text
elif layout.layout_type == 'LAYOUT_TABLE':
table = document.tables[table_count]
df_table = table.to_pandas()
self.metadata["metadataAttributes"]["format"] = "Table"

t_file=self.tables_directory + f'/{self.document_name}_table_p{self.page_number}_t{table_count}.csv'

with open(t_file,'w') as csv_file:
csv_file.write(df_table.to_csv(index=False, header=False))
with open(t_file + ".metadata.json",'w') as json_file:
json.dump(self.metadata, json_file)
table_count = table_count + 1
  1. Further processing is required for information other than tables and images. We create metadata tags containing the information about main chapter titles and subtitles. This information can help you boost performance using metadata filtering or during vector search using a system prompt. For every chunk of data, specify within the metadata to which chapter and subchapter it belongs. Ideally, you should always have one chunk of data for every subchapter, but this isn’t always possible. Many subchapters are too long to be parsed with one chunk. In such cases, you can split the text after the paragraph and use the same metadata for another chunk:
for layout in document:

if layout.layout_type in 'LAYOUT_TITLE':
self.metadata["metadataAttributes"]["main_topic"] = layout.text
elif layout.layout_type == 'LAYOUT_SECTION_HEADER': // split text at the beggining of every subchapter
self.create_chunk() //save previous chunk in chunk_dic
for chunk in self.chunk_dic: // save all of the chunks for given chapter
self.metadata["metadataAttributes"]["format"] = "Text"
with open(chunk["output_path"], 'w') as text_file: //create txt file with specified text
text_file.write(chunk["text"] + str(chunk['metadata']))
with open(chunk["output_path"] + ".metadata.json", 'w') as json_file: //create metadata file for given chunk
json.dump(chunk['metadata'], json_file)
self.subtitle = []
self.chunk_dic = []

self.metadata["metadataAttributes"]["secondary_topic"] = layout.text

elif layout.layout_type in ['LAYOUT_LIST', 'LAYOUT_TEXT']:
if (len(self.new_chunk + layout.text) > chunk_max) and (len(self.new_chunk) > chunk_min): // if the text within chapter is too big split it at the end of paragraph
self.create_chunk()
self.new_chunk = self.new_chunk + layout.text

The benefit of this method is that, even if the text continues on the next page, this mechanism is able to assign it to the correct chunk (if the text is within the limited vector space). This helps prevent splitting the text in the middle of a sentence, which can often lead to hallucinations.

  1. After the text is split, create two files for every chunk:
    1. A .txt chunk file together with the metadata string.
    2. A metadata.json file that can be used with the knowledge base metadata and filtering.
  2. When the split is complete, upload the files to Amazon S3 and continue with creating the knowledge base using the no chunking option.

When using the custom chunk option, keep in mind the maximum size of possible chunks. If the text chunk is too large, the vectorization of the files will fail, and the file won’t be available for the knowledge base.

Benefits of custom chunking

Custom chunking offers the following benefits:

  • Context preservation – By chunking text based on chapters or subchapters, you can make sure that the context of each section remains relevant throughout the chunk, resulting in more accurate vector representations and reducing noise.
  • Flexible chunk sizes – Custom chunking allows you to dynamically adjust the chunk sizes, addressing the challenge of selecting the optimal chunk size for different use cases.
  • Improved retrieval performance – With custom chunking and the advanced retrieval capabilities of Amazon Bedrock such as metadata filtering, you can significantly enhance the performance of your retrieval frameworks, enabling faster and more accurate insights.
  • Seamless integration – Amazon Bedrock seamlessly integrates with other AWS services, such as Amazon S3 and Amazon Textract, providing a streamlined solution for data extraction, organization, and analysis.

Metadata filtering compared to system prompts

Metadata filtering is a powerful feature that significantly enhances the search algorithm’s performance. By using metadata filtering to specify fiscal years and quarters, we achieved notable improvements in response accuracy. Currently, the Amazon Bedrock console requires users to have prior knowledge of metadata filter names and their corresponding values. As of this writing, direct specification of these filters through prompts isn’t supported. Consequently, in practical applications, users would benefit from guidance or hints to assist them in selecting appropriate filter values.

The following figure shows an example of enabling metadata filtering for the same model and chunking logic. In the first question, using only the prompts, the search algorithm failed to provide chunks from the correct documents. In the second question, we filtered by fiscal year (2023) and quarter (Q3). The output of the search algorithm was just one chunk, but the correct one.

Performance comparison

We compared fixed chunking, custom chunking, and custom chunking with prompts. For vectorization, we used the Amazon Titan Embeddings Text v1 model for custom chunking, baseline, and metadata filtering. We performed additional knowledge base testing with Cohere. We performed all the testing with the Claude Sonnet 3 model and hybrid search, with a maximum retrieved result of 20.

We tested the performance of the models on several tasks:

  • Table information – Information only extractable from tables.
  • Long questions – Summarizing chapters using multiple chunks. This is a difficult task for models with a small embedding window.
  • Year-specific questions – The answers are very short and clear, but the correct extraction relies on the capability of vector search to determinate the time span from the user question and extract the chunk corresponding to a given time span.

We evaluated the performance manually by checking factually against the information generated by the model with the source data. The following screenshots show some example questions and answers generated on two different knowledge bases for the year_sensitive class.

The first example uses custom chunking with an Amazon Titan Embeddings model.

The next example uses Cohere with fixed chunking.

We used the prompt template feature released in April 2024 to focus the model on detailed information regarding the fiscal years and quarters. This information was the same as it was in the metadata JSON file, and it gives the models some guidelines about what information is important for extracting the valid chunks. The following is an example of the system prompt:

User:

You are a question answering agent specilizing in companies financial statements and reviews. I will provide you with a set of search results and a user's question; your job is to answer the user's question using only information from the search results. Before answering the question, think step by step and verify your response based on the metadataAttributes provided in {} brackets. If provided in the user’s question, always check that the fiscal_year and quartal match with the values provided. In case of the user asking specific questions about financial outcome of a specific group (such as revenues or net income) focus on search results that have "Table" specified in the format tag in metadataAttributes. To improve the results, you can verify the values of main and secondary topics. The values should be related to the user’s questions.

Here are the search results in numbered order:
$search_results$

Here is the user's question:
<question>
$query$
</question>
$output_format_instructions$

Assistant:

The adjusted prompt template improved the accuracy of the results. For the knowledge base created with an Amazon Titan Embeddings model and fixed chunking, the accuracy of extracted results increased to 70 percent accuracy. This number served as a baseline for our evaluation.

After switching from fixed chunking to custom chunking with Amazon Titan, the accuracy of retrieved results increased by 17 percent.

Interestingly, Cohere led to similar results as using custom chunking with regards to response accuracy, but showed slightly less precise richness in summarization (long answers).

Summarization means condensing a long piece of text while retaining its essential information and meaning by capturing the main points, key ideas, and important details.

The following screenshots show some sample answers in the long answers category. The first example is the output from Cohere.

The following is the output using custom chunking.

Cohere uses smaller chunks of text for embedding, which make it more precise, but it struggles to provide a detailed summary. The responses aren’t inaccurate, but they often miss important details and the created answers are slightly ambiguous.

The biggest advantage of custom chunking is that saving the chunks with variable size helped us improve the accuracy of the model (compared to the original Amazon Titan Embeddings model). We also preserved the good summarization capabilities of the models by using bigger chunks when possible. Overall, the best performance was achieved using metadata filtering.

We applied metadata filtering only to the questions where it was applicable (where the user was asking about the specific year or quarter). It didn’t help in cases where the question was asking the model to extract information from multiple years (like the number of employees in every year or the revenue in every quarter). However, it’s still a great tool that can improve results significantly.

Clean up

As you conclude your journey through setting up and using the knowledge base in this post, it’s essential to clean up the resources you created, so your environment is clean and cost-efficient.

Decommission OpenSearch Service

First, you need to decommission OpenSearch Service. This process involves safely shutting down your OpenSearch instances to prevent any unintended data retention or unnecessary costs:

  1. On the OpenSearch Service console, navigate to your domain.
  2. Delete the domain and confirm the deletion when prompted.

Empty and delete the S3 bucket

Next, delete the S3 bucket that stored your data:

  1. On the Amazon S3 console, navigate to your S3 bucket.
  2. Delete the files to empty the bucket.
  3. Delete the bucket, confirming the deletion when prompted to permanently remove the storage resource.

Delete the Lambda function

Finally, you need to delete the Lambda function created for this project:

  1. On the Lambda console, select your function and choose Delete.
  2. Confirm the deletion to remove the function and free up resources.

By following these steps, you have cleaned up the resources created during this post, maintaining a lean and cost-effective AWS environment. This not only helps in managing your resources better, but also makes sure that you’re only paying for what you use.

Conclusion

By combining the power of Knowledge Bases for Amazon Bedrock with custom chunking mechanisms and the advanced data extraction capabilities of Amazon Textract, organizations can unlock the true potential of their PDF data. Furthermore, using a knowledge base with custom chunking for different models provides holistic evaluation of models quickly. This solution helps you achieve accurate and contextual responses, improves the performance of retrieval frameworks, and enables efficient data extraction from unstructured PDF documents.

The joint effort between Accenture and AWS discussed in this post builds on the 15-year strategic relationship between the companies and uses the same proven mechanisms and accelerators built by the Accenture AWS Business Group (AABG). Connect with the AABG team at accentureaws@amazon.com to drive business outcomes by transforming to an intelligent data enterprise on AWS.

For more information about generative AI on AWS using Amazon Bedrock or Amazon SageMaker, we recommend the following resources:

You can also sign up for the AWS generative AI newsletter, which includes educational resources, blogs, and service updates.

Thank you for following along, and happy coding!


About the Authors

Kristina Olesova works as a Data Scientist at Accenture. She is focused primarily on computer vision and generative AI. Outside of work, she likes to read books and hike in the mountains.

Zdenko Estok works as a cloud architect and DevOps engineer at Accenture. He works with AABG to develop and implement innovative cloud solutions, and specializes in infrastructure as code and cloud security. Zdenko likes to bike to the office and enjoys pleasant walks in nature.

Selimcan “Can” Sakar is a cloud-first developer and solution architect at Accenture with a focus on artificial intelligence and a passion for watching models converge.

Shikhar Kwatra is a Sr. Partner Solutions Architect at Amazon Web Services, working with leading Global System Integrators. He has earned the title of one of the Youngest Indian Master Inventors with over 500 patents in the AI/ML and IoT domains. Shikhar aids in architecting, building, and maintaining cost-efficient, scalable cloud environments for the organization, and support the GSI partners in building strategic industry solutions on AWS.

Marcelo Silva PhotoMarcelo Silva is a Principal Product Manager at Amazon Web Services leading strategy and growth for Knowledge Bases for Amazon Bedrock and Amazon Lex. His passion is helping customers harness the power of conversational AI and generative AI solutions to drive business outcomes and growth.

Read More

Lightweight Champ: NVIDIA Releases Small Language Model With State-of-the-Art Accuracy

Lightweight Champ: NVIDIA Releases Small Language Model With State-of-the-Art Accuracy

Developers of generative AI typically face a tradeoff between model size and accuracy. But a new language model released by NVIDIA delivers the best of both, providing state-of-the-art accuracy in a compact form factor.

Mistral-NeMo-Minitron 8B — a miniaturized version of the open Mistral NeMo 12B model released by Mistral AI and NVIDIA last month — is small enough to run on an NVIDIA RTX-powered workstation while still excelling across multiple benchmarks for AI-powered chatbots, virtual assistants, content generators and educational tools. Minitron models are distilled by NVIDIA using NVIDIA NeMo, an end-to-end platform for developing custom generative AI.

“We combined two different AI optimization methods — pruning to shrink Mistral NeMo’s 12 billion parameters into 8 billion, and distillation to improve accuracy,” said Bryan Catanzaro, vice president of applied deep learning research at NVIDIA. “By doing so, Mistral-NeMo-Minitron 8B delivers comparable accuracy to the original model at lower computational cost.”

Unlike their larger counterparts, small language models can run in real time on workstations and laptops. This makes it easier for organizations with limited resources to deploy generative AI capabilities across their infrastructure while optimizing for cost, operational efficiency and energy use. Running language models locally on edge devices also delivers security benefits, since data doesn’t need to be passed to a server from an edge device.

Developers can get started with Mistral-NeMo-Minitron 8B packaged as an NVIDIA NIM microservice with a standard application programming interface (API) — or they can download the model from Hugging Face. A downloadable NVIDIA NIM, which can be deployed on any GPU-accelerated system in minutes, will be available soon.

State-of-the-Art for 8 Billion Parameters

For a model of its size, Mistral-NeMo-Minitron 8B leads on nine popular benchmarks for language models. These benchmarks cover a variety of tasks including language understanding, common sense reasoning, mathematical reasoning, summarization, coding and ability to generate truthful answers.

Packaged as an NVIDIA NIM microservice, the model is optimized for low latency, which means faster responses for users, and high throughput, which corresponds to higher computational efficiency in production.

In some cases, developers may want an even smaller version of the model to run on a smartphone or an embedded device like a robot. To do so, they can download the 8-billion-parameter model and, using NVIDIA AI Foundry, prune and distill it into a smaller, optimized neural network customized for enterprise-specific applications.

The AI Foundry platform and service offers developers a full-stack solution for creating a customized foundation model packaged as a NIM microservice. It includes popular foundation models, the NVIDIA NeMo platform and dedicated capacity on NVIDIA DGX Cloud. Developers using NVIDIA AI Foundry can also access NVIDIA AI Enterprise, a software platform that provides security, stability and support for production deployments.

Since the original Mistral-NeMo-Minitron 8B model starts with a baseline of state-of-the-art accuracy, versions downsized using AI Foundry would still offer users high accuracy with a fraction of the training data and compute infrastructure.

Harnessing the Perks of Pruning and Distillation 

To achieve high accuracy with a smaller model, the team used a process that combines pruning and distillation. Pruning downsizes a neural network by removing model weights that contribute the least to accuracy. During distillation, the team retrained this pruned model on a small dataset to significantly boost accuracy, which had decreased through the pruning process.

The end result is a smaller, more efficient model with the predictive accuracy of its larger counterpart.

This technique means that a fraction of the original dataset is required to train each additional model within a family of related models, saving up to 40x the compute cost when pruning and distilling a larger model compared to training a smaller model from scratch.

Read the NVIDIA Technical Blog and a technical report for details.

NVIDIA also announced this week Nemotron-Mini-4B-Instruct, another small language model optimized for low memory usage and faster response times on NVIDIA GeForce RTX AI PCs and laptops. The model is available as an NVIDIA NIM microservice for cloud and on-device deployment and is part of NVIDIA ACE, a suite of digital human technologies that provide speech, intelligence and animation powered by generative AI.

Experience both models as NIM microservices from a browser or an API at ai.nvidia.com.

See notice regarding software product information.

Read More

SLMming Down Latency: How NVIDIA’s First On-Device Small Language Model Makes Digital Humans More Lifelike

SLMming Down Latency: How NVIDIA’s First On-Device Small Language Model Makes Digital Humans More Lifelike

Editor’s note: This post is part of the AI Decoded series, which demystifies AI by making the technology more accessible, and showcases new hardware, software, tools and accelerations for RTX PC and workstation users.

At Gamescom this week, NVIDIA announced that NVIDIA ACE — a suite of technologies for bringing digital humans to life with generative AI — now includes the company’s first on-device small language model (SLM), powered locally by RTX AI.

The model, called Nemotron-4 4B Instruct, provides better role-play, retrieval-augmented generation and function-calling capabilities, so game characters can more intuitively comprehend player instructions, respond to gamers, and perform more accurate and relevant actions.

Available as an NVIDIA NIM microservice for cloud and on-device deployment by game developers, the model is optimized for low memory usage, offering faster response times and providing developers a way to take advantage of over 100 million GeForce RTX-powered PCs and laptops and NVIDIA RTX-powered workstations.

The SLM Advantage

An AI model’s accuracy and performance depends on the size and quality of the dataset used for training. Large language models are trained on vast amounts of data, but are typically general-purpose and contain excess information for most uses.

SLMs, on the other hand, focus on specific use cases. So even with less data, they’re capable of delivering more accurate responses, more quickly — critical elements for conversing naturally with digital humans.

Nemotron-4 4B was first distilled from the larger Nemotron-4 15B LLM. This process requires the smaller model, called a “student,” to mimic the outputs of the larger model, appropriately called a “teacher.” During this process, noncritical outputs of the student model are pruned or removed to reduce the parameter size of the model. Then, the SLM is quantized, which reduces the precision of the model’s weights.

With fewer parameters and less precision, Nemotron-4 4B has a lower memory footprint and faster time to first token — how quickly a response begins — than the larger Nemotron-4 LLM while still maintaining a high level of accuracy due to distillation. Its smaller memory footprint also means games and apps that integrate the NIM microservice can run locally on more of the GeForce RTX AI PCs and laptops and NVIDIA RTX AI workstations that consumers own today.

This new, optimized SLM is also purpose-built with instruction tuning, a technique for fine-tuning models on instructional prompts to better perform specific tasks. This can be seen in Mecha BREAK, a video game in which players can converse with a mechanic game character and instruct it to switch and customize mechs.

ACEs Up

ACE NIM microservices allow developers to deploy state-of-the-art generative AI models through the cloud or on RTX AI PCs and workstations to bring AI to their games and applications. With ACE NIM microservices, non-playable characters (NPCs) can dynamically interact and converse with players in the game in real time.

ACE consists of key AI models for speech-to-text, language, text-to-speech and facial animation. It’s also modular, allowing developers to choose the NIM microservice needed for each element in their particular process.

NVIDIA Riva automatic speech recognition (ASR) processes a user’s spoken language and uses AI to deliver a highly accurate transcription in real time. The technology builds fully customizable conversational AI pipelines using GPU-accelerated multilingual speech and translation microservices. Other supported ASRs include OpenAI’s Whisper, a open-source neural net that approaches human-level robustness and accuracy on English speech recognition.

Once translated to digital text, the transcription goes into an LLM — such as Google’s Gemma, Meta’s Llama 3 or now NVIDIA Nemotron-4 4B — to start generating a response to the user’s original voice input.

Next, another piece of Riva technology — text-to-speech — generates an audio response. ElevenLabs’ proprietary AI speech and voice technology is also supported and has been demoed as part of ACE, as seen in the above demo.

Finally, NVIDIA Audio2Face (A2F) generates facial expressions that can be synced to dialogue in many languages. With the microservice, digital avatars can display dynamic, realistic emotions streamed live or baked in during post-processing.

The AI network automatically animates face, eyes, mouth, tongue and head motions to match the selected emotional range and level of intensity. And A2F can automatically infer emotion directly from an audio clip.

Finally, the full character or digital human is animated in a renderer, like Unreal Engine or the NVIDIA Omniverse platform.

AI That’s NIMble

In addition to its modular support for various NVIDIA-powered and third-party AI models, ACE allows developers to run inference for each model in the cloud or locally on RTX AI PCs and workstations.

The NVIDIA AI Inference Manager software development kit allows for hybrid inference based on various needs such as experience, workload and costs. It streamlines AI model deployment and integration for PC application developers by preconfiguring the PC with the necessary AI models, engines and dependencies. Apps and games can then orchestrate inference seamlessly across a PC or workstation to the cloud.

ACE NIM microservices run locally on RTX AI PCs and workstations, as well as in the cloud. Current microservices running locally include Audio2Face, in the Covert Protocol tech demo, and the new Nemotron-4 4B Instruct and Whisper ASR in Mecha BREAK.

To Infinity and Beyond

Digital humans go far beyond NPCs in games. At last month’s SIGGRAPH conference, NVIDIA previewed “James,” an interactive digital human that can connect with people using emotions, humor and more. James is based on a customer-service workflow using ACE.

Interact with James at ai.nvidia.com.

Changes in communication methods between humans and technology over the decades eventually led to the creation of digital humans. The future of the human-computer interface will have a friendly face and require no physical inputs.

Digital humans drive more engaging and natural interactions. According to Gartner, 80% of conversational offerings will embed generative AI by 2025, and 75% of customer-facing applications will have conversational AI with emotion. Digital humans will transform multiple industries and use cases beyond gaming, including customer service, healthcare, retail, telepresence and robotics.

Users can get a glimpse of this future now by interacting with James in real time at ai.nvidia.com.

Generative AI is transforming gaming, videoconferencing and interactive experiences of all kinds. Make sense of what’s new and what’s next by subscribing to the AI Decoded newsletter.

Read More

How Snowflake Is Unlocking the Value of Data With Large Language Models

How Snowflake Is Unlocking the Value of Data With Large Language Models

Snowflake is using AI to help enterprises transform data into insights and applications. In this episode of NVIDIA’s AI Podcast, host Noah Kravitz and Baris Gultekin, head of AI at Snowflake, discuss how the company’s AI Data Cloud platform enables customers to access and manage data at scale. By separating the storage of data from compute, Snowflake has allowed organizations across the world to connect via cloud technology and work on a unified platform — eliminating data silos and streamlining collaborative workflows.

Time Stamps

1:45: What does Snowflake do?
3:18: Snowflake’s AI and data strategies — building a platform with natural language analysis
5:30: How to efficiently access large language models with Snowflake Cortex
11:49: Snowflake’s open-source LLM: Arctic
16:18: Gultekin’s journey in AI and data science
23:05: The AI industry in three to five years — real-world applications of Snowflake technology
27:54: Gutlekin’s advice for professionals interested in AI

You Might Also Like:

How Roblox Uses Generative AI to Enhance User Experiences – Ep. 227

Roblox is a colorful online platform reimagining the way people come together. Anupam Singh, vice president of AI and growth engineering at Roblox, discusses how the company uses generative AI to enhance virtual experiences and bolster inclusivity and user safety.

NVIDIA’s Jim Fan Delves Into Large Language Models and Their Industry Impact – Ep. 204

Most know Minecraft as the popular blocky sandbox game, but for Jim Fan, senior AI scientist at NVIDIA, Minecraft was the perfect place to test the decision-making agency of AI models. Fan discusses how he used large language models to research open-ended AI agents and create Voyager, an AI bot built with Chat GPT-4 that can autonomously play Minecraft.

Media.Monk’s Lewis Smithingham on Enhancing Media and Marketing With AI – Ep. 222

Media.Monks’ platform Wormhole streamlines marketing and content creation workflows with AI-powered insights. Lewis Smithingham, senior vice president of innovation and special operations at Media.Monks, addresses AI’s potential in the entertainment and advertisement industries.

NVIDIA’s Annamali Chockalingam on the Rise of LLMs – Ep. 206

LLMs are in the spotlight, capable of tasks like generation, summarization, translation, instruction and chatting. Annamalai Chockalingam, senior product manager of developer marketing at NVIDIA, discusses how a combination of these modalities and actions can build applications to solve any problem.

Subscribe to the AI Podcast

Get the AI Podcast through iTunes, Google Play, Amazon Music, Castbox, DoggCatcher, Overcast, PlayerFM, Pocket Casts, Podbay, PodBean, PodCruncher, PodKicker, Soundcloud, Spotify, Stitcher and TuneIn.

Make the AI Podcast better: Have a few minutes to spare? Fill out this listener survey.

Read More

High-Tech Highways: India Uses NVIDIA Accelerated Computing to Ease Tollbooth Traffic

High-Tech Highways: India Uses NVIDIA Accelerated Computing to Ease Tollbooth Traffic

India is home to the globe’s second-largest road network, spanning nearly 4 million miles, and has over a thousand tollbooths, most of them run manually.

Traditional booths like these, wherever in the world they’re deployed, can contribute to massive traffic delays, long commute times and serious road congestion.

To help automate tollbooths across India, Calsoft, an Indian-American technology company, helped implement a broad range of NVIDIA technologies integrated with the country’s dominant payment system, known as the unified payments interface, or UPI, for a client.

Manual tollbooths demand more time and labor compared to automated ones. However, automating India’s toll systems faces an extra complication: the diverse range of license plates.

India’s non-standardized plates pose a significant challenge to the accuracy of automatic number plate recognition (ANPR) systems. Any implementation would need to address these plate variations, which include divergent color, sizing, font styles and placement upon vehicles, as well as many different languages.

The solution Calsoft helped build automatically reads passing vehicle plates and charges the associated driver’s UPI account. This approach reduces the need for manual toll collection and is a massive step toward addressing traffic in the region.

Automation in Action

As part of a pilot program, this solution has been deployed in several leading metropolitan cities. The solution provides about 95% accuracy in its ability to read plates through the use of an ANPR pipeline that detects and classifies the plates as they roll through tollbooths.

NVIDIA’s technology has been crucial in this effort, according to Vipin Shankar, senior vice president of technology at Calsoft. “Particularly challenging was night-time detection,” he said. “Another challenge was model accuracy improvement on pixel distortions due to environmental impacts like fog, heavy rains, reflections due to bright sunshine, dusty winds and more.”

The solution uses NVIDIA Metropolis to track and detect vehicles throughout the process. Metropolis is an application framework, a set of developer tools and a partner ecosystem that brings visual data and AI together to improve operational efficiency and safety across a range of industries.

Calsoft engineers used NVIDIA Triton Inference Server software to deploy and manage their AI models. The team also used the NVIDIA DeepStream software development kit to build a real-time streaming platform. This was key for processing and analyzing data streams efficiently, incorporating advanced capabilities such as real-time object detection and classification.

Calsoft uses NVIDIA hardware, including NVIDIA Jetson edge AI modules and NVIDIA A100 Tensor Core GPUs in its AI solutions. Calsoft’s tollbooth solution is also scalable, meaning it’s designed to accommodate future growth and expansion needs, and can better ensure sustained performance and adaptability as traffic conditions evolve.

Learn how NVIDIA Metropolis has helped other municipalities, like Raleigh, North Carolina, better manage traffic flow and enhance pedestrian safety. 

Read More

NVIDIA Showcases New AI Capabilities With ACE, RTX Games and More at Gamescom 2024

NVIDIA Showcases New AI Capabilities With ACE, RTX Games and More at Gamescom 2024

At Gamescom, the world’s biggest gaming expo, NVIDIA has once again pushed the boundaries of gaming technology to ensure that gamers have incredibly immersive experiences and can enjoy enhanced performance and visual fidelity.

The company’s announcements today include its first digital human technologies on-device small language model showcased in the first game tech demo, Mecha BREAK, a milestone celebration of 600 RTX games and applications with 20 new RTX games announced, and new games on GeForce NOW.

Alongside these, NVIDIA announced a collaboration with MediaTek that brings G-SYNC display technologies to more gamers.

Gamescom, held every year in Cologne, Germany, is where innovators from across the gaming community showcase their latest creations. In 2018, NVIDIA founder and CEO Jensen Huang introduced NVIDIA RTX at the event, bringing real-time ray tracing and AI to gaming and setting a new standard for graphics performance.

NVIDIA ACE: Advancing AI-Powered Game Characters

Leading NVIDIA’s announcements at Gamescom was NVIDIA ACE, a revolutionary suite of technologies for bringing digital humans to life with generative AI.

The first game to showcase ACE and digital human technologies is Amazing Seasun Games’ Mecha BREAK, a fast-based mech combat game that demonstrates the potential of AI-powered game characters.

https://www.youtube.com/watch?v=d5z7oIXhVqg

The ACE suite also expanded with NVIDIA’s first digital human technologies on-device small language model (SLM), NVIDIA Nemotron-4 4B Instruct, improving conversation for game characters. This new on-device model provides better role-play, retrieval-augmented generation and function-calling capabilities, allowing game characters to more intuitively comprehend player instructions, respond to gamers and perform more accurate and relevant actions.

Perfect World Games is advancing its ACE and digital human tech demo, Legends, with new AI-powered vision capabilities, unlocking a new level of immersion and accessibility for PC games.

Celebrating 600 RTX Games and Apps With 20 New RTX Titles

NVIDIA RTX continues to revolutionize the ways people play and create with ray tracing, DLSS and AI-powered technologies. Today marks another RTX milestone: 600 RTX-enhanced games and applications are now available.

This week, NVIDIA announced 20 new RTX and DLSS titles to join this impressive roster, including high-profile games such as Indiana Jones and the Great Circle, Dune: Awakening and Dragon Age: The Veilguard.

Game Science’s much-anticipated Black Myth: Wukong also launches today, featuring full ray tracing and DLSS 3, delivering the ultimate RTX experience for GeForce RTX 40 Series gamers.

https://www.youtube.com/watch?v=97egUiMlLZM

Half-Life 2: An RTX Remix Project Unveils Remastered Nova Prospekt

Half-Life 2 RTX: An RTX Remix Project from Orbifold Studios is a community remaster of Valve’s classic game. Now boasting over 100 contributing artists, Orbifold Studios unveiled a remaster of one of Half-Life 2’s most iconic levels, Nova Prospekt.

Using NVIDIA RTX Remix, Orbifold Studios has remastered Nova Prospekt with full ray tracing, DLSS 3.5 with Ray Reconstruction and Reflex. The Nova Prospekt trailer also reveals remasters of Gordon’s revolver, shotgun and Overwatch Standard Issue Pulse Rifle, remasters of the Combine soldiers and Antlions, and the addition of new geometry and detail that uses the capabilities of modern PCs to increase realism.

https://www.youtube.com/watch?v=R0-F8sPprmA

NVIDIA and MediaTek Bring G-SYNC Display Technologies to More Gamers 

NVIDIA and MediaTek are collaborating to make the industry’s best gaming display technologies more accessible.

The companies’ collaboration integrates the full suite of NVIDIA G-SYNC technologies to the world’s most popular scalers, allowing for the creation of feature-rich G-SYNC monitors at a more affordable price.

A highlight of this collaboration is the introduction of G-SYNC Pulsar, a new technology that offers 4x the effective motion clarity alongside a smooth and tear-free variable refresh rate (VRR) experience. G-SYNC Pulsar will debut on newly announced monitors, including the ASUS ROG Swift 360Hz PG27AQNR, Acer Predator XB273U F5 and AOC AGON PRO AG276QSG2.

GeForce NOW Raises the Bar for Cloud Gaming

Each week geforcenow.com adds top-tier PC games on GFN Thursday to stream at peak performance from GeForce RTX SuperPODs in the cloud, along with new features and updates for members.

For Gamescom, GeForce NOW is adding the highly anticipated action role-playing game Black Myth: Wukong from Game Science, as well as a demo for the upcoming PC release of FINAL FANTASY XVI from Square Enix. A new update brings Xbox automatic sign-in, making it easy for members to quickly jump into their PC games across devices by linking their account just once.

These latest GeForce NOW updates — available today — raise the bar for cloud gaming and build on recent milestones, including added support for mods, new data centers in Japan and Poland, and 2,000 games available in the cloud. Check out GeForce NOW’s Gamescom blog for more details.

Star Wars Outlaws: GeForce RTX 40 Series Bundle 

In collaboration with Ubisoft, Massive Entertainment and Lucasfilm Games, NVIDIA is launching a new Star Wars Outlaws GeForce RTX 40 Series Bundle. Gamers will experience the first-ever open-world Star Wars game, set between the events of Star Wars: The Empire Strikes Back and Star Wars: Return of the Jedi, enhanced with NVIDIA DLSS 3.5, ray tracing and Reflex technologies. It’ll also be available in the cloud on GeForce NOW.

For all the news and details on NVIDIA’s latest Gamescom announcements, visit GeForce News

Read More