Chatbot + Knowledge Base聊天机器人 + 知识库

AI GUIDES9个月前更新 Prompt engineer
5,361 0

GPT-3和ChatGPT等大型语言模型 (LLM) 的最新进展在科技行业引起了广泛关注。这些模型对于内容生成来说非常强大,但它们也有一些缺点,例如偏见和幻觉。这些 LLM 特别有用的一个领域是聊天机器人开发。

基于意图的聊天机器人

传统的聊天机器人通常是基于意图的,这意味着它们旨在响应特定的用户意图。每个意图都由一组示例问题和相关联的响应组成。例如,意图“天气”可能包含诸如“今天天气如何?”之类的示例问题。或者“今天会下雨吗?” 以及“今天会是晴天”之类的回应。当用户提出问题时,聊天机器人会将其与具有最相似示例问题的意图进行匹配,并返回相关的响应。

Chatbot + Knowledge Base聊天机器人 + 知识库

传统的基于意图的聊天机器人是如何工作的。图片由作者提供。

然而,基于意图的聊天机器人有其自身的一系列问题。一个问题是它们需要大量特定的意图才能给出特定的答案。例如,像“我无法登录”、“我忘记了密码”或“登录错误”这样的用户话语可能需要三个不同的答案,因此需要三个不同的意图,尽管它们都非常相似。

GPT-3 如何提供帮助

这是 GPT-3 特别有用的地方。不是有许多非常具体的意图,每个意图都可以更广泛并利用来自您的知识库的文档。知识库 (KB) 是存储为结构化和非结构化数据的信息,可随时用于分析或推理。您的知识库可能由一系列说明如何使用您的产品的文档组成。

这样,每个意图都与一个文档相关联,而不是与问题列表和特定答案相关联,例如,一个意图是“登录问题”,一个意图是“如何订阅”等。当用户询问有关登录的问题时,我们可以将“登录问题”文档作为上下文信息传递给 GPT-3,并对用户的问题生成特定的响应。

Chatbot + Knowledge Base聊天机器人 + 知识库

利用 GPT-3 的聊天机器人如何工作。图片由作者提供。

这种方法减少了需要管理的意图数量,并允许更好地适应每个问题的答案。此外,如果与意图相关的文档描述了不同的过程(例如“登录网站”的过程和“登录移动应用程序”的过程),GPT-3 可以在给出最终答案之前自动要求用户澄清.

为什么我们不能将整个 KB 传递给 GPT-3 ?

今天,像 GPT-3 这样的 LLM 的最大提示大小约为 4k 令牌(对于模型text-davinci-003),这很多但不足以将整个知识库输入到单个提示中。出于计算原因,LLM 具有最大提示大小,因为使用它们生成文本涉及大量计算,这些计算会随着提示大小的增加而迅速增加。

未来的 LLM 在保留文本生成功能的同时可能没有此限制。但是,就目前而言,我们需要围绕它设计一个解决方案。

使用 GPT-3 的聊天机器人如何工作

因此,聊天机器人管道可以由两个步骤组成:

  1. 首先,我们需要为用户问题选择合适的意图,即我们需要从我们的知识库中检索正确的文档。
  2. 然后,一旦我们有了正确的文档,我们就可以利用 GPT-3 为用户生成合适的答案。为此,我们需要设计一个好的提示。

第一步本质上是通过语义搜索来解决的。我们可以使用库中的预训练模型sentence-transformers,轻松地为每个文档分配分数。得分最高的文档将用于生成聊天机器人答案。

Chatbot + Knowledge Base聊天机器人 + 知识库

利用 GPT-3 的聊天机器人如何工作。GPT-3 可用于利用知识库文档中的信息生成适当的答案。图片由作者提供。

使用 GPT- 3

一旦我们有了正确的文档,我们就需要创建一个好的提示,以便与 GPT-3 一起使用来生成答案。在接下来的实验中,我们将始终使用text-davinci-003温度为 的模型0.7

为了制作提示,我们将尝试使用:

  • 角色提示:一种启发式技术,可为 AI 分配特定角色。
  • 相关知识库信息,即在语义搜索步骤中检索到的文档。
  • 用户和聊天机器人之间交换的最后消息。这些对于未指定整个上下文的用户发送的消息很有用。我们稍后会看到它的一个例子。查看此示例,了解如何管理与 GPT-3 的对话。
  • 最后,用户问题

Chatbot + Knowledge Base聊天机器人 + 知识库

用于制作我们的 GPT-3 提示的信息。图片由作者提供。

让我们使用角色提示技术开始我们的提示。

As an advanced chatbot named Skippy, your primary goal is to assist users to the best of your ability.

然后,假设语义搜索步骤从我们的知识库中提取了以下文档。所有文档都描述了 VideoGram 产品的工作原理,这是一个类似于 Instagram 的虚构产品,但仅限于视频。

Chatbot + Knowledge Base聊天机器人 + 知识库

解释如何登录 VideoGram 的文档。图片由作者提供。

我们可以通过这种方式在提示中添加它的内容。

As an advanced chatbot named Skippy, your primary goal is to assist users to the best of your ability.

START CONTEXT
Login to VideoGram from Website
1. Open your web browser and go to the VideoGram website.
2. Click on the “Login” button located in the top right corner of the page.
3. On the login page, enter your VideoGram username and password.
4. Once you have entered your credentials, click on the “Login” button.
5. You should now be logged in to your VideoGram account.

Login to VideoGram from Mobile App
1. Open the VideoGram app on your mobile device.
2. On the main page, tap the “Login” button located in the bottom right corner.
3. On the login page, enter your VideoGram username and password.
4. Once you have entered your credentials, tap the “Login” button.
5. You should now be logged in to your VideoGram account.
END CONTEXT

最后,我们需要将对话和用户问题添加到提示的末尾,如以下示例所示。

As an advanced chatbot named Skippy, your primary goal is to assist users to the best of your ability.

START CONTEXT
Login to VideoGram from Website
1. Open your web browser and go to the VideoGram website.
2. Click on the “Login” button located in the top right corner of the page.
3. On the login page, enter your VideoGram username and password.
4. Once you have entered your credentials, click on the “Login” button.
5. You should now be logged in to your VideoGram account.

Login to VideoGram from Mobile App
1. Open the VideoGram app on your mobile device.
2. On the main page, tap the “Login” button located in the bottom right corner.
3. On the login page, enter your VideoGram username and password.
4. Once you have entered your credentials, tap the “Login” button.
5. You should now be logged in to your VideoGram account.
END CONTEXT

SKIPPY: Hello, I’m Skippy! How can I help you?
USER: I can’t find the login button.
SKIPPY:

将此提示传递给 GPT-3,我得到了以下生成的答案。

No problem! On the website, the login button is located in the top right corner of the page. On the mobile app, the login button is located in the bottom right corner. Let me know if you need any further assistance!

请注意生成的答案中的信息是如何来自知识库文档的。

使用 GPT- 3

让我们尝试使用更模糊的用户话语,例如“无法登录”。这是完整的提示。

As an advanced chatbot named Skippy, your primary goal is to assist users to the best of your ability.

START CONTEXT
Login to VideoGram from Website
1. Open your web browser and go to the VideoGram website.
2. Click on the “Login” button located in the top right corner of the page.
3. On the login page, enter your VideoGram username and password.
4. Once you have entered your credentials, click on the “Login” button.
5. You should now be logged in to your VideoGram account.

Login to VideoGram from Mobile App
1. Open the VideoGram app on your mobile device.
2. On the main page, tap the “Login” button located in the bottom right corner.
3. On the login page, enter your VideoGram username and password.
4. Once you have entered your credentials, tap the “Login” button.
5. You should now be logged in to your VideoGram account.
END CONTEXT

SKIPPY: Hello, I’m Skippy! How can I help you?
USER: Can’t login
SKIPPY:

GPT-3 试图更好地理解用户的问题。

I’m sorry to hear that. Can you tell me if you are trying to login via the VideoGram website or mobile app?

接下来,完整的对话是这样进行的。隐藏整个提示以获得更好的可见性。

USER: Can’t login
SKIPPY: I’m sorry to hear that. Can you tell me if you are trying to login via the VideoGram website or mobile app?
USER: Mobile app
SKIPPY: OK, no problem. To login via the mobile app, open the VideoGram app on your mobile device. On the main page, tap the “Login” button located in the bottom right corner. On the login page, enter your VideoGram username and password. Once you have entered your credentials, tap the “Login” button. You should now be logged in to your VideoGram account. Please let me know if you need any further assistance.

GPT-3 可以管理消歧,前提是它具有正确的上下文信息。

使用 GPT- 3

前面的示例运行良好。但是,此聊天机器人可能会通过多种方式失败。

如果我们问“移动应用程序免费吗?” 对于 GPT-3 将登录文档作为上下文传递,你通常会得到类似“是的,VideoGram 移动应用程序可以免费下载和使用”的答案,即使上下文信息中没有包含此类信息。生成虚假信息对客服聊天机器人来说非常不利!

当可以在上下文中找到用户问题的答案时,GPT-3 很少生成虚假信息。由于用户问题通常是简短且含糊不清的文本,我们不能依赖语义搜索步骤来始终检索到正确的文档,因此我们总是容易受到错误信息生成的影响。

结论

GPT-3 对于创建会话式聊天机器人非常有用,它能够根据提示中插入的上下文信息回答一系列特定问题。然而,很难让模型仅利用上下文中的信息来产生答案,因为模型往往会产生幻觉(即生成新信息,可能是错误的)。生成虚假信息是一个严重程度不同的问题,具体取决于用例。

© 版权声明

相关文章

暂无评论

您必须登录才能参与评论!
立即登录
暂无评论...