微信扫码
与创始人交个朋友
我要投稿
探索AI代理如何结合领域知识提供精准解答,深入了解企业AI代理的运作机制。核心内容:1. AI代理如何利用领域知识库定制回答2. 企业AI代理与传统大型语言模型的区别3. 领域知识库在AI代理中的关键作用
你是否曾想过,今天最先进平台上的尖端 AI 代理是如何运作的?例如,在上面的截图中,我向 wealthsimple.com 的 AI 代理询问利率问题,它提供了特定于 Wealthsimple 产品的答案,并将其限制在 Wealthsimple 产品范围内。它没有告诉我美国银行的现金账户利率。
它是如何工作的?你可能会说,这很简单,LLM(大型语言模型)!没错,但不仅仅是 LLM。强大的 AI 代理,至少是好的那些,都是由大型语言模型驱动的,因此它们能够理解语言,并能够以对话格式进行支持会话,就像 ChatGPT 一样。但是,有一点很重要,它们还具备两个超出一般 ChatGPT 的特殊功能:
2. AI 代理仅限于领域知识库提供答案。 这意味着它们只会回答与其服务或产品相关的问题,而不会基于通用知识库提供回应。例如,当我询问 Wealthsimple AI 代理特斯拉 Model 3 在加拿大的价格时,这是一条公开可用的信息,并且应该也是通用知识库的一部分,但 AI 代理表示该信息超出了 Wealthsimple 产品和服务的范围。这是完美的,因为出于商业原因,显然也出于法律原因,Wealthsimple 不应该回答此类问题。
在本文中,我们将讨论如何实现上述功能。目标是从技术的高层次理解这些 AI 代理是如何工作的。
免责声明:请注意,来自 Wealthsimple AI 代理的屏幕截图仅用于演示目的。本文并不一定涵盖 Wealthsimple AI 代理的具体工作方式,且不应视为 Wealthsimple 的工程博客。
为了支持 AI 代理,我们需要至少三个主要组件:
让我们从一个对话轮次的高层工作流开始,只是为了理解数据的端到端流动。
在上面的图中,对话始于用户提问。让我们看一下每个单独的步骤。
private const string questionToQueryPrompt = "
Below is a chat history and a new question asked by the user.
The new user question needs to be answered by searching in a knowledge base.
Generate a search query based on the conversation and the new question.
#Requirements#
- If the question is not in English, translate the question to English before generating the search query.
#Chat history#
{{$chat_history}}
#Question#
{{$question}}
";
```python
private const string questionToQueryPrompt = "
Below is a chat history and a new question asked by the user.
The new user question needs to be answered by searching in a knowledge base.
Generate a search query based on the conversation and the new question.
#Requirements#
- If the question is not in English, translate the question to English before generating the search query.
#Chat history#
{{$chat_history}}
#Question#
{{$question}}
";
通过这个提示,用户问题“现金账户的利率是多少”可能被转换为搜索查询,如“现金账户的利率”。
private const string answerPrompt = "
You are a professional chat assistant.
Your role is to help users with their questions about our products.
You will be given the chat history and facts.
Your task is to generate an answer.
- Answer ONLY with the facts listed in the sources provided below.
- Do not generate answers that don't use the sources below.
- If there isn't enough information in the sources, say you don't know.
#Sources#
{{$sources}}
#Chat history#
{{$chat_history}}
";
```python
private const string answerPrompt = "
You are a professional chat assistant.
Your role is to help users with their questions about our products.
You will be given the chat history and facts.
Your task is to generate an answer.
- Answer ONLY with the facts listed in the sources provided below.
- Do not generate answers that don't use the sources below.
- If there isn't enough information in the sources, say you don't know.
#Sources#
{{$sources}}
#Chat history#
{{$chat_history}}
";
上面第 5 步的原始文本搜索结果和这个提示提供给 LLM,然后生成的答案可能如下所示:
The interest rate for a Wealthsimple Cash account
varies depending on your client status and qualifying deposits.
As of December 18, 2024, the standard rate is2.25% forall clients.
Premium clients or Core clients with eligible direct deposits
can earn 2.75%. Generation clients or Premium clients with eligible
direct deposits can earn up to 3.25%.
These rates are annualized, calculated daily,
and paid monthly. Keep in mind that rates are subject to change.
```python
The interest rate for a Wealthsimple Cash account
varies depending on your client status and qualifying deposits.
As of December 18, 2024, the standard rate is2.25% forall clients.
Premium clients or Core clients with eligible direct deposits
can earn 2.75%. Generation clients or Premium clients with eligible
direct deposits can earn up to 3.25%.
These rates are annualized, calculated daily,
and paid monthly. Keep in mind that rates are subject to change.
8. 用户体验接收来自后端的响应。用户体验可能会进一步美化,使其在设备上看起来更好。
9. 用户收到响应。好极了!!
上述模式实际上被称为检索增强生成(RAG),这是一种利用信息检索系统(如搜索服务)提供基础数据,并增强大型语言模型(LLM)如 ChatGPT 能力的架构。有关 RAG 的更多信息,请参见 [*Microsoft 文档 检索增强生成(RAG)在 Azure AI Search 中*](https://learn.microsoft.com/en-us/azure/search/retrieval-augmented-generation-overview),或 [*AWS 文档 什么是检索增强生成*](https://aws.amazon.com/what-is/retrieval-augmented-generation/)。
彩蛋 — 你怎么知道自己是在与真人聊天还是机器人聊天?
![](https://wsrv.nl/?url=https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*Eoz6tKsgwnsy7uXhO4u2xg.png)
感谢你与我一起阅读!希望你喜欢这篇文章!!如果你喜欢这篇文章,以下一些相关的文章可能会引起你的兴趣:
* Towards Data Science: [搜索数据的三大策略](https://towardsdatascience.com/top-3-strategies-to-search-your-data-8b118dfd1350)
53AI,企业落地大模型首选服务商
产品:场景落地咨询+大模型应用平台+行业解决方案
承诺:免费场景POC验证,效果验证后签署服务协议。零风险落地应用大模型,已交付160+中大型企业
2025-01-26
看了Kimi的知识库接口文档,你还敢用吗
2025-01-24
每一家企业都是智能体,每一个CEO都是“数据人”
2025-01-24
TOP 100Summit 主题分享 | AI助力爱奇艺项目管理实践
2025-01-23
用国产AI Deepseek做合同审查,强的一批!
2025-01-23
拥抱AI,实现知识管理的个性化与智能化飞跃
2025-01-22
打造高效私有化知识库:MaxKB、Ollama与Llama3的完美结合
2025-01-15
瓴羊Dataphin:AI驱动的数据治理——千里之行,始于标准
2025-01-15
阿里数据治理进化论:基于瓴羊Dataphin的多引擎兼容与统一资产消费实践
2024-07-10
2024-09-14
2024-04-24
2024-11-07
2024-05-15
2024-08-04
2024-06-23
2024-07-10
2024-06-19
2024-07-10