AWS Machine Learning Blog 07月02日
Use Amazon SageMaker Unified Studio to build complex AI workflows using Amazon Bedrock Flows
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

本文介绍了如何使用Amazon SageMaker Unified Studio构建基于生成式AI的投诉处理系统。该系统整合了数据处理、模型开发和AI应用部署,简化了工作流程,提高了协作效率。通过SageMaker Unified Studio,用户可以利用Amazon Bedrock、Amazon Bedrock Flows、知识库和Agent,构建智能化的投诉处理应用,实现快速访问历史数据、智能化知识库、简化流程管理和灵活的查询功能。文章详细介绍了解决方案架构、关键组件,以及创建项目、提示、聊天Agent和流程的步骤,帮助用户快速构建和部署生成式AI应用。

💡Amazon SageMaker Unified Studio是一个统一的开发环境,整合了数据、分析和AI功能,简化了数据处理、模型开发和AI应用部署的流程。

🔑该方案的核心是利用Amazon Bedrock Flows构建AI驱动的投诉参考系统,该系统集成了知识库、提示分类、条件路由和Agent响应生成。

⚙️构建流程涉及创建项目、设计提示、构建聊天Agent以及创建流程,每一步都在SageMaker Unified Studio中完成,并使用AWS的AI/ML服务和Bedrock功能。

📊该系统提供快速访问历史投诉数据、智能知识库、简化的工作流程管理和灵活的查询能力,从而提升客户服务效率和内部审计能力。

📝用户需要准备特定数据,如投诉数据,并配置必要的权限和访问权限,才能在SageMaker Unified Studio中运行该流程。

Organizations face the challenge to manage data, multiple artificial intelligence and machine learning (AI/ML) tools, and workflows across different environments, impacting productivity and governance. A unified development environment consolidates data processing, model development, and AI application deployment into a single system. This integration streamlines workflows, enhances collaboration, and accelerates AI solution development from concept to production.

The next generation of Amazon SageMaker is the center for your data, analytics, and AI. SageMaker brings together AWS AI/ML and analytics capabilities and delivers an integrated experience for analytics and AI with unified access to data. Amazon SageMaker Unified Studio is a single data and AI development environment where you can find and access your data and act on it using AWS analytics and AI/ML services, for SQL analytics, data processing, model development, and generative AI application development.

With SageMaker Unified Studio, you can efficiently build generative AI applications in a trusted and secure environment using Amazon Bedrock. You can choose from a selection of high-performing foundation models (FMs) and advanced customization and tooling such as Amazon Bedrock Knowledge Bases, Amazon Bedrock Guardrails, Amazon Bedrock Agents, and Amazon Bedrock Flows. You can rapidly tailor and deploy generative AI applications, and share with the built-in catalog for discovery.

In this post, we demonstrate how you can use SageMaker Unified Studio to create complex AI workflows using Amazon Bedrock Flows.

Solution overview

Consider FinAssist Corp, a leading financial institution developing a generative AI-powered agent support application. The solution offers the following key features:

Let’s explore how SageMaker Unified Studio and Amazon Bedrock Flows, integrated with Amazon Bedrock Knowledge Bases and Amazon Bedrock Agents, address these challenges by creating an AI-powered complaint reference system. The following diagram illustrates the solution architecture.

The solution uses the following key components:

The workflow processes user queries through the following steps:

    A user submits a complaint-related question. The knowledge base provides relevant complaint information. The prompt classifies if the query is about resolution timing. Based on the classification using the condition, the application takes the following action:
      Routes the query to an AI agent for specific resolution responses. Returns general complaint information.
    The application generates an appropriate response for the user.

Prerequisites

For this example, you need the following:

Prepare your data

We have created a sample dataset to use for Amazon Bedrock Knowledge Bases. This dataset has information of complaints received by customer service representatives and resolution information.The following is an example from the sample dataset:

complaint_id,product,sub_product,issue,sub_issue,complaint_summary,action_taken,next_steps,financial_institution,state,submitted_via,resolution_type,timely_responseFIN-2024-001,04/26/24,"Mortgage","Conventional mortgage","Payment issue","Escrow dispute","Customer disputes mortgage payment increase after recent escrow analysis","Reviewed escrow analysis, explained property tax increase impact, provided detailed payment breakdown","1. Send written explanation of escrow analysis 2. Schedule annual escrow review 3. Provide payment assistance options","Financial Institution-1","TX","Web","Closed with explanation","Yes"FIN-2024-002,04/26/24,"Money transfer","Wire transfer","Processing delay","International transfer","Wire transfer of $10,000 delayed, customer concerned about international payment deadline","Located wire transfer in system, expedited processing, waived wire fee","1. Confirm receipt with receiving bank 2. Update customer on delivery 3. Document process improvement needs","Financial Institution-2","FL","Phone","Closed with monetary relief","No"

Create a project

In SageMaker Unified Studio, users can use projects to collaborate on various business use cases. Within projects, you can manage data assets in the SageMaker Unified Studio catalog, perform data analysis, organize workflows, develop ML models, build generative AI applications, and more.

To create a project, complete the following steps:

    Open the SageMaker Unified Studio landing page using the URL from your admin. Choose Create project. Enter a project name and optional description. For Project profile, choose Generative AI application development. Choose Continue.

    Complete your project configuration, then choose Create project.

Create a prompt

Let’s create a reusable prompt to capture the instructions for FMs, which we will use later while creating the flow application. For more information, see Reuse and share Amazon Bedrock prompts.

    In SageMaker Unified Studio, on the Build menu, choose Prompt under Machine Learning & Generative AI.

    Provide a name for the prompt. Choose the appropriate FM (for this example, we choose Claude 3 Haiku). For Prompt message, we enter the following:
You are a complaint analysis classifier. You will receive complaint data from a knowledge base. Analyze the {{input}} and respond with a single letter:T: If the input contains information about complaint resolution timing, response time, or processing timeline (whether timely or delayed)F: For all other types of complaint informationReturn only 'T' or 'F' based on whether the knowledge base response is about resolution timing. Do not add any additional text or explanation - respond with just the single letter 'T' or 'F'.
    Choose Save.

    Choose Create version.

Create a chat agent

Let’s create a chat agent to handle specific resolution responses. Complete the following steps:

    In SageMaker Unified Studio, on the Build menu, choose Chat agent under Machine Learning & Generative AI. Provide a name for the prompt. Choose the appropriate FM (for this example, we choose Claude 3 Haiku). For Enter a system prompt, we enter the following:
You are a Financial Complaints Assistant AI. You will receive complaint information from a knowledge base and questions about resolution timing.When responding to resolution timing queries:1. Use the provided complaint information to confirm if it was resolved within timeline2. For timely resolutions, provide:   - Confirmation of timely completion   - Specific actions taken (from the provided complaint data)   - Next steps that were completed2. For delayed resolutions, provide:   - Acknowledgment of delay   - Standard compensation package:     • $75 service credit     • Priority Status upgrade for 6 months     • Service fees waived for current billing cycle   - Actions taken (from the provided complaint data)   - Contact information for follow-up: Priority Line: ************** Always reference the specific complaint details provided in your input when discussing actions taken and resolution process.
    Choose Save.

    After the agent is saved, choose Deploy. For Alias name, enter demoAlias. Choose Deploy.

Create a flow

Now that we have our prompt and agent ready, let’s create a flow that will orchestrate the complaint handling process:

    In SageMaker Unified Studio, on the Build menu, choose Flow under Machine Learning & Generative AI.

    Create a new flow called demo-flow.

Add a knowledge base to your flow application

Complete the following steps to add a knowledge base node to the flow:

    In the navigation pane, on the Nodes tab, choose Knowledge Base. On the Configure tab, provide the following information:
      For Node name, enter a name (for example, complaints_kb). Choose Create new Knowledge Base.
    In the Create Knowledge Base pane, enter the following information:
      For Name, enter a name (for example, complaints). For Description, enter a description (for example, user complaints information). For Add data sources, select Local file and upload the complaints.txt file. For Embeddings model, choose Titan Text Embeddings V2. For Vector store, choose OpenSearch Serverless. Choose Create.

    After you create the knowledge base, choose it in the flow. In the details name, provide the following information: For Response generation model, choose Claude 3 Haiku. Connect the output of the flow input node with the input of the knowledge base node. Connect the output of the knowledge base node with the input of the flow output node.

    Choose Save.

Add a prompt to your flow application

Now let’s add the prompt you created earlier to the flow:

    On the Nodes tab in the Flow app builder pane, add a prompt node. On the Configure tab for the prompt node, provide the following information: For Node name, enter a name (for example, demo_prompt). For Prompt, choose financeAssistantPrompt. For Version, choose 1. Connect the output of the knowledge base node with the input of the prompt node.
    Choose Save.

Add a condition to your flow application

The condition node determines how the flow handles different types of queries. It evaluates whether a query is about resolution timing or general complaint information, enabling the flow to route the query appropriately. When a query is about resolution timing, it will be directed to the chat agent for specialized handling; otherwise, it will receive a direct response from the knowledge base. Complete the following steps to add a condition:

    On the Nodes tab in the Flow app builder pane, add a condition node. On the Configure tab for the condition node, provide the following information:
      For Node name, enter a name (for example, demo_condition). Under Conditions, for Condition, enter conditionInput == "T". Connect the output of the prompt node with the input of the condition node.
    Choose Save.

Add a chat agent to your flow application

Now let’s add the chat agent you created earlier to the flow:

    On the Nodes tab in the Flow app builder pane, add the agent node. On the Configure tab for the agent node, provide the following information:
      For Node name, enter a name (for example, demo_agent). For Chat agent, choose DemoAgent. For Alias, choose demoAlias.
    Create the following node connections:
      Connect the input of the condition node (demo_condition) to the output of the prompt node (demo_prompt). Connect the output of the condition node:
        Set If condition is true to the agent node (demo_agent). Set If condition is false to the existing flow output node (FlowOutputNode).
      Connect the output of the knowledge base node (complaints_kb) to the input of the following:
        The agent node (demo_agent). The flow output node (FlowOutputNode).
      Connect the output of the agent node (demo_agent) to a new flow output node named FlowOutputNode_2.
    Choose Save.

Test the flow application

Now that the flow application is ready, let’s test it. On the right side of the page, choose the expand icon to open the Test pane.

In the Enter prompt text box, we can ask a few questions related to the dataset created earlier. The following screenshots show some examples.

Clean up

To clean up your resources, delete the flow, agent, prompt, knowledge base, and associated OpenSearch Serverless resources.

Conclusion

In this post, we demonstrated how to build an AI-powered complaint reference system using a flow application in SageMaker Unified Studio. By using the integrated capabilities of SageMaker Unified Studio with Amazon Bedrock features like Amazon Bedrock Knowledge Bases, Amazon Bedrock Agents, and Amazon Bedrock Flows, you can rapidly develop and deploy sophisticated AI applications without extensive coding.

As you build AI workflows using SageMaker Unified Studio, remember to adhere to the AWS Shared Responsibility Model for security. Implement SageMaker Unified Studio security best practices, including proper IAM configurations and data encryption. You can also refer to Secure a generative AI assistant with OWASP Top 10 mitigation for details on how to assess the security posture of a generative AI assistant using OWASP TOP 10 mitigations for common threats. Following these guidelines helps establish robust AI applications that maintain data integrity and system protection.

To learn more, refer to Amazon Bedrock in SageMaker Unified Studio and join discussions and share your experiences in AWS Generative AI Community.

We look forward to seeing the innovative solutions you will create with these powerful new features.


About the authors

Sumeet Tripathi is an Enterprise Support Lead (TAM) at AWS in North Carolina. He has over 17 years of experience in technology across various roles. He is passionate about helping customers to reduce operational challenges and friction. His focus area is AI/ML and Energy & Utilities Segment. Outside work, He enjoys traveling with family, watching cricket and movies.

Vishal Naik is a Sr. Solutions Architect at Amazon Web Services (AWS). He is a builder who enjoys helping customers accomplish their business needs and solve complex challenges with AWS solutions and best practices. His core area of focus includes Generative AI and Machine Learning. In his spare time, Vishal loves making short films on time travel and alternate universe themes.

Fish AI Reader

Fish AI Reader

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

FishAI

FishAI

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

联系邮箱 441953276@qq.com

相关标签

SageMaker Unified Studio 生成式AI Amazon Bedrock AI应用开发
相关文章