聊天机器人中的多个意图处理

时间:2020-02-26 06:25:37

标签: chatbot rasa

我正在使用RASA开发用于银行业务的机器人。我有意向进行资金转账,交易历史记录,贷款,余额,票据支付等。我已经实施了意向一次处理这些功能。现在,我想一次处理多个意图。

例如,如果用户说,

显示我的最新交易,然后在显示余额后支付账单。

当用户一次要一个或多个功能时,如何处理这类输入?

我知道,我可以实现多个实体的意图,但是这似乎对我不起作用,因为我有太多意图,因此我无法承受将2个或3个实体组合而成的意图。

是否甚至可以使用RASA或其他任何技术来构建聊天机器人?

1 个答案:

答案 0 :(得分:2)

方法1-多目标

您可以使用多意图(不要与多实体混淆)。您需要做的是:

  • 分别为意图编写示例nlu数据(已有的内容)
  • 为多目标组合写入nlu数据。从理论上讲,Rasa会同时使用来自单意图和多意图示例的信息进行正确分类。这意味着您不需要在多意图中使用太多的训练示例
  • 写一些关于这些多目的故事的故事
  • 在令牌生成器配置中指定分隔符:intent_split_symbol: "+"

请注意,您需要同时拥有要支持的多目标的NLU数据和故事,否则Rasa在NLU中将无法识别它们,并且在Core中将不会做任何事情。

参考:

示例

这可以给你这样的东西:

nlu.md

# intent:show transactions
- please show me my latest transactions
- show me my transactions
- ...

# intent:pay bill
- pay my bill please
- i want to pay my bill
- go ahead and pay the bills
- ...

# intent:show transactions+pay bill
- Show my latest transactions and then pay my bill after showing the balance.
- show me my transactions and go ahead and pay the bills
- 

请注意,您可以编写脚本以从单个意图自动生成一些多意图示例

stories.md

# story 1
* show transactions
- action_show_transactions

# story 2
* pay bill
- action_pay_bill

# story 3 (combined)
* show transactions+pay bill
- action_show_transactions
- action_pay_bill

config.yml

language: "en"

pipeline:
- name: "WhitespaceTokenizer"
  intent_split_symbol: "+"
- name: "CountVectorsFeaturizer"
- name: "EmbeddingIntentClassifier"

请注意,我使用的拆分符号与文档中的符号不​​同。

方法2-作为实体的说明

另一种方法是使用单个意图ask_action和一个或多个标识您的指令的实体。

然后您可以进行处理所有操作的action_execute_instructions。它将根据最新消息查看实体,然后执行所需的任何操作。

您对指令的理解方式在很大程度上取决于您选择如何定义实体以及如何将它们映射到所需的指令。可以使用SynonymMapper,但它一点都不灵活,如果您有一个不完全匹配的新示例,它将失败。在这种情况下,最好编写自己的NLU管道组件。

说实话,我认为这不是一个好方法。实体应该是实体(即:对象,位置等)

nlu.md

# intent:ask_action
- [Show my latest transactions](instruction) and then [pay my bill](instruction) after showing the balance.
- [show me my transactions](instruction) and go ahead and [pay the bills](instruction)
- [pay the bill](instruction)

stories.md

# story 1
* ask_action
- action_execute_instructions

建议

我强烈建议您使用最简单的方法。一旦您的漫游器上线,您应该查看您的用户如何使用它,并查看是否需要更复杂的意图组合(如果您使用多意图)。