AWS Machine Learning Blog 2024年07月03日
Build an automated insight extraction framework for customer feedback analysis with Amazon Bedrock and Amazon QuickSight
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

本文探讨了如何将大型语言模型(LLM)集成到企业应用程序中,以利用其生成能力。我们深入研究了工作流程实现的技术方面,并提供了代码示例,您可以快速部署或修改以满足您的特定需求。无论您是希望将 LLM 纳入现有系统的开发人员,还是希望利用 NLP 力量的企业主,本文都可以作为快速入门指南。

🤔 **生成式 AI 的优势**:与传统的机器学习方法相比,生成式 AI 模型在预训练的语言理解、提示工程以及减少对标签变化的重新训练需求方面具有优势,从而节省了时间和资源。您还可以进一步微调生成式 AI 模型,以根据您的特定领域或任务调整模型的性能。

🚀 **解决方案概述**:我们的解决方案提供了一个用于客户评论分析的端到端生成式 AI 应用程序。在自动内容处理步骤完成后,您可以将输出用于下游任务,例如调用客户服务后端应用程序中的不同组件,或将生成的标签插入每个文档的元数据以进行产品推荐。

📊 **关键组件**:本文重点介绍了用于洞察发现的自动化框架的关键组件:使用 Step Functions 进行工作流编排、LLM 的提示工程以及使用 QuickSight 进行可视化。

💡 **工作流编排**:为了管理和协调多步工作流和流程,我们利用了 Step Functions。Step Functions 是一种可视化工作流服务,它使开发人员能够使用 AWS 服务构建分布式应用程序、自动化流程、编排微服务以及创建数据和 ML 管道。它可以自动化提取、转换和加载 (ETL) 流程,因此多个长时间运行的 ETL 作业按顺序运行并成功完成,无需手动编排。

✍️ **提示工程**:提示工程是指设计和构建用于与 LLM 交互的有效提示。提示可以是简单的句子,也可以是更复杂的结构,包括多个句子、示例或约束。一个好的提示可以帮助 LLM 理解您的意图并生成符合您的要求的输出。

📈 **可视化**:为了将分析结果可视化,我们利用了 Amazon QuickSight。QuickSight 是一种基于云的商业智能 (BI) 服务,它使您能够创建交互式仪表板、探索数据并与他人共享见解。它提供了一系列预构建的图表和可视化,以及自定义选项,以满足您的特定需求。

💡 **代码示例**:本文提供了代码示例,您可以根据自己的需求快速部署或修改代码。代码示例演示了如何使用 AWS Lambda 函数和 Step Functions 将 LLM 集成到您的应用程序中。

🚀 **结论**:通过将生成式 AI 与 Amazon Bedrock 和 QuickSight 等 AWS 服务相结合,企业可以简化客户反馈分析流程,并从其数据中获得更深入的见解。这使他们能够做出数据驱动的决策,并改善整体客户体验。

Extracting valuable insights from customer feedback presents several significant challenges. Manually analyzing and categorizing large volumes of unstructured data, such as reviews, comments, and emails, is a time-consuming process prone to inconsistencies and subjectivity. Scalability becomes an issue as the amount of feedback grows, hindering the ability to respond promptly and address customer concerns. In addition, capturing granular insights, such as specific aspects mentioned and associated sentiments, is difficult. Inefficient routing and prioritization of customer inquiries or issues can lead to delays and dissatisfaction. These pain points highlight the need to streamline the process of extracting insights from customer feedback, enabling businesses to make data-driven decisions and enhance the overall customer experience.

Large language models (LLMs) have transformed the way we engage with and process natural language. These powerful models can understand, generate, and analyze text, unlocking a wide range of possibilities across various domains and industries. From customer service and ecommerce to healthcare and finance, the potential of LLMs is being rapidly recognized and embraced. Businesses can use LLMs to gain valuable insights, streamline processes, and deliver enhanced customer experiences. Unlike traditional natural language processing (NLP) approaches, such as classification methods, LLMs offer greater flexibility in adapting to dynamically changing categories and improved accuracy by using pre-trained knowledge embedded within the model.

Amazon Bedrock, a fully managed service designed to facilitate the integration of LLMs into enterprise applications, offers a choice of high-performing LLMs from leading artificial intelligence (AI) companies like Anthropic, Mistral AI, Meta, and Amazon through a single API. It provides a broad set of capabilities like model customization through fine-tuning, knowledge base integration for contextual responses, and agents for running complex multi-step tasks across systems. With Amazon Bedrock, developers can experiment, evaluate, and deploy generative AI applications without worrying about infrastructure management. Its enterprise-grade security, privacy controls, and responsible AI features enable secure and trustworthy generative AI innovation at scale.

To create and share customer feedback analysis without the need to manage underlying infrastructure, Amazon QuickSight provides a straightforward way to build visualizations, perform one-time analysis, and quickly gain business insights from customer feedback, anytime and on any device. In addition, the generative business intelligence (BI) capabilities of QuickSight allow you to ask questions about customer feedback using natural language, without the need to write SQL queries or learn a BI tool. This user-friendly approach to data exploration and visualization empowers users across the organization to analyze customer feedback and share insights quickly and effortlessly.

In this post, we explore how to integrate LLMs into enterprise applications to harness their generative capabilities. We delve into the technical aspects of workflow implementation and provide code samples that you can quickly deploy or modify to suit your specific requirements. Whether you’re a developer seeking to incorporate LLMs into your existing systems or a business owner looking to take advantage of the power of NLP, this post can serve as a quick jumpstart.

Advantages of adopting generative approaches for NLP tasks

For customer feedback analysis, you might wonder if traditional NLP classifiers such as BERT or fastText would suffice. Although these traditional machine learning (ML) approaches might perform decently in terms of accuracy, there are several significant advantages to adopting generative AI approaches. The following table compares the generative approach (generative AI) with the discriminative approach (traditional ML) across multiple aspects.

. Generative AI (LLMs) Traditional ML
Accuracy Achieves competitive accuracy by using knowledge acquired during pre-training and utilizing the semantic similarity between category names and customer feedback. Particularly beneficial if you don’t have much labeled data. Can achieve high accuracy given sufficient labeled data, but performance may degrade if you don’t have much labeled data and rely solely on predefined features, because it lacks the ability to capture semantic similarities effectively.
Acquiring labeled data Uses pre-training on large text corpora, enabling zero-shot or few-shot learning. No labeled data is needed. Requires labeled data for all categories of interest, which can be time-consuming and expensive to obtain.
Model generalization Benefits from exposure to diverse text genres and domains during pre-training, enhancing generalization to new tasks. Relies on a large volume of task-specific labeled data to improve generalization, limiting its ability to adapt to new domains.
Operational efficiency Uses prompt engineering, reducing the need for extensive fine-tuning when new categories are introduced. Requires retraining the model whenever new categories are added, leading to increased computational costs and longer deployment times.
Handling rare categories and imbalanced data Can generate text for rare or unseen categories by using its understanding of context and language semantics. Struggles with rare categories or imbalanced classes due to limited labeled examples, often resulting in poor performance on infrequent classes.
Explainability Provides explanations for its predictions through generated text, offering insights into its decision-making process. Explanations are often limited to feature importance or decision rules, lacking the nuance and context provided by generated text.

Generative AI models offer advantages with pre-trained language understanding, prompt engineering, and reduced need for retraining on label changes, saving time and resources compared to traditional ML approaches. You can further fine-tune a generative AI model to tailor the model’s performance to your specific domain or task. For more information, see Customize models in Amazon Bedrock with your own data using fine-tuning and continued pre-training.

In this post, we primarily focus on the zero-shot and few-shot capabilities of LLMs for customer feedback analysis. Zero-shot learning in LLMs refers to their ability to perform tasks without any task-specific examples, whereas few-shot learning involves providing a small number of examples to improve performance on a new task. These capabilities have gained significant attention due to their ability to strike a balance between accuracy and operational efficiency. By using the pre-trained knowledge of LLMs, zero-shot and few-shot approaches enable models to perform NLP with minimal or no labeled data. This eliminates the need for extensive data annotation efforts and allows for quick adaptation to new tasks.

Solution overview

Our solution presents an end-to-end generative AI application for customer review analysis. When the automated content processing steps are complete, you can use the output for downstream tasks, such as to invoke different components in a customer service backend application, or to insert the generated tags into metadata of each document for product recommendation.

The following diagram illustrates the architecture and workflow of the proposed solution.

The customer review analysis workflow consists of the following steps:

    A user uploads a file to dedicated data repository within your Amazon Simple Storage Service (Amazon S3) data lake, invoking the processing using AWS Step Functions. The Step Functions workflow starts. In the first step, an AWS Lambda function reads and validates the file, and extracts the raw data. The raw data is processed by an LLM using a preconfigured user prompt. The LLM generates output based on the user prompt. The processed output is stored in a database or data warehouse, such as Amazon Relational Database Service (Amazon RDS). The stored data is visualized in a BI dashboard using QuickSight. The user receives a notification when the results are ready and can access the BI dashboard to view and analyze the results.

The project is available on GitHub and provides AWS Cloud Development Kit (AWS CDK) code to deploy. The AWS CDK is an open source software development framework for defining cloud infrastructure in code (IaC) and provisioning it through AWS CloudFormation. This provides an automated deployment experience on your AWS account. We highly suggest you follow the GitHub README and deployment guidance to get started.

In the following sections, we highlight the key components to explain this automated framework for insight discovery: workflow orchestration with Step Functions, prompt engineering for the LLM, and visualization with QuickSight.

Prerequisites

This post is intended for developers with a basic understanding of LLM and prompt engineering. Although no advanced technical knowledge is required, familiarity with Python and AWS Cloud services will be beneficial if you want to explore our sample code on GitHub.

Workflow orchestration with Step Functions

To manage and coordinate multi-step workflows and processes, we take advantage of Step Functions. Step Functions is a visual workflow service that enables developers to build distributed applications, automate processes, orchestrate microservices, and create data and ML pipelines using AWS services. It can automate extract, transform, and load (ETL) processes, so multiple long-running ETL jobs run in order and complete successfully without manual orchestration. By combining multiple Lambda functions, Step Functions allows you to create responsive serverless applications and orchestrate microservices. Moreover, it can orchestrate large-scale parallel workloads, enabling you to iterate over and process large datasets, such as security logs, transaction data, or image and video files. The definition of our end-to-end orchestration is detailed in the GitHub repo.

Step Functions invokes multiple Lambda functions for the end-to-end workflow:

Step Functions uses the Map state processing modes to orchestrate large-scale parallel workloads. You can modify the Step Functions state machine to adapt to your own workflow, or modify the Lambda function for your own processing logic.

Prompt engineering

To invoke Amazon Bedrock, you can follow our code sample that uses the Python SDK. A prompt is natural language text describing the task that an AI should perform. Prompt engineering may involve phrasing a query, specifying a style, providing relevant context, or assigning a role to the AI, such as “You are helpful assistant.” We provide a prompt example for feedback categorization. For more information, refer to Prompt engineering. You can modify the prompt to adapt to your own workflow.

This framework uses a sample prompt to generate tags for user feedback from the predefined tags listed. You can engineer the prompt based on your user feedback style and business requirements.

You are tasked with selecting an appropriate tag from the given lists based on user feedback content and feedback title enclosed within the `<feedback>` and `<title>` XML tag. Here is the list of potential tags: <tags> $tags </tags> <title> $title </title><feedback> $feedback </feedback> Please choose only one from tag list and response to the user’s questions within <tag></tag> tags. If none of the tags above are suitable for the feedback or information is not enough, return "unknown". No explanation is required. No need to echo tag list and feedback. 

Visualization with QuickSight

We have successfully used an LLM to categorize the feedback into predefined categories. After the data is categorized and stored in Amazon RDS, you can use QuickSight to generate an overview and visualize the insights from the dataset. For deployment guidance, refer to GitHub Repository: Result Visualization Guide.

We use an LLM from Amazon Bedrock to generate a category label for each piece of feedback. This generated label is stored in the label_llm field. To analyze the distribution of these labels, select the label_llm field along with other relevant fields and visualize the data using a pie chart. This will provide an overview of the different categories and their proportions within the feedback dataset, as shown in the following screenshot.

In addition to the category overview, you can also generate a trend analysis of the feedback or issues over time. The following screenshot demonstrates a trend where the number of issues peaked in March but then showed immediate improvement, with a reduction in the number of issues in subsequent months.

Sometimes, you may need to create paginated reports to present to a company management team about customer feedback. You can use Amazon QuickSight Paginated Reports to create highly formatted multi-page reports from the insight extracted by LLMs, define report layouts and formatting, and schedule report generation and distribution.

Clean up

If you followed the GitHub deployment guide and want to clean up afterwards, delete the stack customer-service-dev on the CloudFormation console or run the command cdk destroy customer-service-dev. You can also refer to the cleanup section in the GitHub deployment guide.

Applicable real-world applications and scenarios

You can use this automated architecture for content processing for various real-world applications and scenarios:

Conclusion

In this post, we explored how you can seamlessly integrate LLMs into enterprise applications to take advantage of their powerful generative AI capabilities. With AWS services such as Amazon Bedrock, Step Functions, and QuickSight, businesses can create intelligent workflows that automate processes, generate insights, and enhance decision-making.

We have provided a comprehensive overview of the technical aspects involved in implementing such a workflow, along with code samples that you can deploy or customize to meet your organization’s specific needs. By following the step-by-step guide and using the provided resources, you can quickly incorporate this generative AI application into your current workload. We encourage you to check out the GitHub repository, deploy the solution to your AWS environment, and modify it according to your own user feedback and business requirements.

Embracing LLMs and integrating them into your enterprise applications can unlock a new level of efficiency, innovation, and competitiveness. You can learn from AWS Generative AI Customer Stories how others harness the power of generative AI to drive their business forward, and check out our AWS Generative AI blogs for the latest technology updates in today’s rapidly evolving technological landscape.


About the Authors

Jacky Wu, is a Senior Solutions Architect at AWS. Before AWS, he had been implementing front-to-back cross-asset trading system for large financial institutions, developing high frequency trading system of KRX KOSPI Options and long-short strategies of APJ equities. He is very passionate about how technology can solve capital market challenges and provide beneficial outcomes by AWS latest services and best practices. Outside of work, Jacky enjoys 10km run and traveling.

Yanwei Cui, PhD, is a Senior Machine Learning Specialist Solutions Architect at AWS. He started machine learning research at IRISA (Research Institute of Computer Science and Random Systems), and has several years of experience building AI-powered industrial applications in computer vision, natural language processing, and online user behavior prediction. At AWS, he shares his domain expertise and helps customers unlock business potentials and drive actionable outcomes with machine learning at scale. Outside of work, he enjoys reading and traveling.

Michelle Hong, PhD, works as Prototyping Solutions Architect at Amazon Web Services, where she helps customers build innovative applications using a variety of AWS components. She demonstrated her expertise in machine learning, particularly in natural language processing, to develop data-driven solutions that optimize business processes and improve customer experiences.

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

生成式 AI 大型语言模型 客户反馈分析 Amazon Bedrock Amazon QuickSight AWS Step Functions 提示工程
相关文章