ai-agents-for-beginners

多智能體設計

(按上方圖片以觀看本課堂的影片)

多智能體設計模式

As soon as you start working on a project that involves multiple agents, you will need to consider the multi-agent design pattern. However, it might not be immediately clear when to switch to multi-agents and what the advantages are.

介紹

In this lesson, we’re looking to answer the following questions:

學習目標

After this lesson, you should be able to:

What’s the bigger picture?

多智能體是一種設計模式,讓多個智能體一起協作以達成共同目標

This pattern is widely used in various fields, including robotics, autonomous systems, and distributed computing.

適用多智能體的情境

So what scenarios are a good use case for using multi-agents? The answer is that there are many scenarios where employing multiple agents is beneficial especially in the following cases:

使用多智能體相對於單一智能體的優勢

A single agent system could work well for simple tasks, but for more complex tasks, using multiple agents can provide several advantages:

Let’s take an example, let’s book a trip for a user. A single agent system would have to handle all aspects of the trip booking process, from finding flights to booking hotels and rental cars. To achieve this with a single agent, the agent would need to have tools for handling all these tasks. This could lead to a complex and monolithic system that is difficult to maintain and scale. A multi-agent system, on the other hand, could have different agents specialized in finding flights, booking hotels, and rental cars. This would make the system more modular, easier to maintain, and scalable.

Compare this to a travel bureau run as a mom-and-pop store versus a travel bureau run as a franchise. The mom-and-pop store would have a single agent handling all aspects of the trip booking process, while the franchise would have different agents handling different aspects of the trip booking process.

實作多智能體設計模式的構成要素

Before you can implement the multi-agent design pattern, you need to understand the building blocks that make up the pattern.

Let’s make this more concrete by again looking at the example of booking a trip for a user. In this case, the building blocks would include:

對多智能體互動的可視性

It’s important that you have visibility into how the multiple agents are interacting with each other. This visibility is essential for debugging, optimizing, and ensuring the overall system’s effectiveness. To achieve this, you need to have tools and techniques for tracking agent activities and interactions. This could be in the form of logging and monitoring tools, visualization tools, and performance metrics.

For example, in the case of booking a trip for a user, you could have a dashboard that shows the status of each agent, the user’s preferences and constraints, and the interactions between agents. This dashboard could show the user’s travel dates, the flights recommended by the flight agent, the hotels recommended by the hotel agent, and the rental cars recommended by the rental car agent. This would give you a clear view of how the agents are interacting with each other and whether the user’s preferences and constraints are being met.

Let’s look at each of these aspects more in detail.

多智能體模式

Let’s dive into some concrete patterns we can use to create multi-agent apps. Here are some interesting patterns worth considering:

群組聊天

This pattern is useful when you want to create a group chat application where multiple agents can communicate with each other. Typical use cases for this pattern include team collaboration, customer support, and social networking.

In this pattern, each agent represents a user in the group chat, and messages are exchanged between agents using a messaging protocol. The agents can send messages to the group chat, receive messages from the group chat, and respond to messages from other agents.

This pattern can be implemented using a centralized architecture where all messages are routed through a central server, or a decentralized architecture where messages are exchanged directly.

群組聊天

交接

This pattern is useful when you want to create an application where multiple agents can hand off tasks to each other.

Typical use cases for this pattern include customer support, task management, and workflow automation.

In this pattern, each agent represents a task or a step in a workflow, and agents can hand off tasks to other agents based on predefined rules.

交接

協同過濾

This pattern is useful when you want to create an application where multiple agents can collaborate to make recommendations to users.

Why you would want multiple agents to collaborate is because each agent can have different expertise and can contribute to the recommendation process in different ways.

Let’s take an example where a user wants a recommendation on the best stock to buy on the stock market.

推薦

範例情境:退款流程

Consider a scenario where a customer is trying to get a refund for a product, there can be quite a few agents involved in this process but let’s divide it up between agents specific for this process and general agents that can be used in other processes.

針對退款流程的專屬智能體:

Following are some agents that could be involved in the refund process:

通用智能體:

These agents can be used by other parts of your business.

There’s quite a few agents listed previously both for the specific refund process but also for the general agents that can be used in other parts of your business. Hopefully this gives you an idea on how you can decide on which agents to use in your multi-agent system.

作業

Design a multi-agent system for a customer support process. Identify the agents involved in the process, their roles and responsibilities, and how they interact with each other. Consider both agents specific to the customer support process and general agents that can be used in other parts of your business.

在閱讀以下解答之前先想一想,你可能比想像中需要更多的代理。 提示:想一想客戶支援流程的不同階段,並考慮任何系統所需的代理。

Solution

解決方案

Knowledge checks

Question: When should you consider using multi-agents?

解答測驗

Summary

在本課中,我們探討了多代理設計模式,包括適用多代理的情境、使用多代理相較於單一代理的優勢、實作多代理設計模式的組成要素,以及如何掌握多個代理之間互動的可見性。

Got More Questions about the Multi-Agent Design Pattern?

加入 Microsoft Foundry Discord 與其他學習者交流、參加辦公時間,並獲得你關於 AI 代理的問題解答。

Additional resources

Previous Lesson

規劃設計

Next Lesson

AI 代理中的元認知


免責聲明: 本文件已使用 AI 翻譯服務 Co-op Translator 進行翻譯。雖然我們力求準確,但請注意,自動翻譯可能包含錯誤或不準確之處。原文(母語版本)應視為具權威性的版本。如涉及重要資訊,建議委託專業人工翻譯。我們對因使用本翻譯而引致的任何誤解或誤釋概不承擔責任。