chatbot中的多意图处理
我正在使用RASA开发一个用于银行目的的bot。我有资金转账、交易历史记录、贷款、余额、账单支付等意图。我已经实现了一次处理一个功能的意图。现在,我想一次处理多个意图 例如,如果用户说 显示我最近的交易记录,然后在显示余额后支付账单。 如果用户在一次讲话中要求一个或两个以上的功能,我如何处理这些类型的输入 我知道,我可以用多个实体实现意图,但这似乎对我不起作用,因为我有太多的意图,以至于我无法用2或3个实体的组合来实现意图 甚至可以使用RASA或任何其他技术来构建聊天机器人吗?方法1-多意图 您可以使用多意图(不要与多实体混淆)。您需要做的是:chatbot中的多意图处理,chatbot,rasa,Chatbot,Rasa,我正在使用RASA开发一个用于银行目的的bot。我有资金转账、交易历史记录、贷款、余额、账单支付等意图。我已经实现了一次处理一个功能的意图。现在,我想一次处理多个意图 例如,如果用户说 显示我最近的交易记录,然后在显示余额后支付账单。 如果用户在一次讲话中要求一个或两个以上的功能,我如何处理这些类型的输入 我知道,我可以用多个实体实现意图,但这似乎对我不起作用,因为我有太多的意图,以至于我无法用2或3个实体的组合来实现意图 甚至可以使用RASA或任何其他技术来构建聊天机器人吗?方法1-多意图 您
- 分别为意图编写示例nlu数据(您已经拥有的)
- 为多意图组合写入nlu数据。理论上,Rasa将使用来自单一意图和多意图示例的信息来正确分类。这意味着您不需要在multi-intent中使用那么多的培训示例
- 写一些关于这些多重意图的故事
- 在标记器配置中指定分隔符:
intent\u split\u symbol:“+”
- (请小心,此后配置已更改,您应该遵循文档)
# 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
-
# 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
# 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)
# story 1
* ask_action
- action_execute_instructions
注意,您可以编写一个脚本,从单个意图自动生成几个多意图的示例
stories.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
-
# 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
# 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)
# story 1
* ask_action
- action_execute_instructions
config.yml
language: "en"
pipeline:
- name: "WhitespaceTokenizer"
intent_split_symbol: "+"
- name: "CountVectorsFeaturizer"
- name: "EmbeddingIntentClassifier"
请注意,我使用的拆分符号与文档中的不同
方法2-作为实体的指令
另一种方法是使用单个意图ask_action
和一个或多个实体来识别指令
然后,您可以有一个操作action\u execute\u指令
,处理所有这些指令。它将查看最新消息中的实体,并执行您需要的任何操作
您对指令的理解方式将在很大程度上取决于您选择如何定义实体以及如何将它们映射到所需的指令。有SynonymMapper
,但它一点也不灵活,如果您有一个不完全匹配的新示例,它将失败。在这种情况下,最好编写自己的NLU管道组件
老实说,我认为这不是一个好办法。实体应该是实体(例如:对象、位置等)
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
-
# 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
# 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)
# story 1
* ask_action
- action_execute_instructions
stories.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
-
# 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
# 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)
# story 1
* ask_action
- action_execute_instructions
建议
我强烈建议使用最简单的方法。一旦你的机器人上线,你应该检查你的用户如何使用它,看看是否需要更复杂的意图组合(如果你有多个意图) 方法1-多重意图
您可以使用多意图(不要与多实体混淆)。您需要做的是:
- 分别为意图编写示例nlu数据(您已经拥有的)
- 为多意图组合写入nlu数据。理论上,Rasa将使用来自单一意图和多意图示例的信息来正确分类。这意味着您不需要在multi-intent中使用那么多的培训示例
- 写一些关于这些多重意图的故事
- 在标记器配置中指定分隔符:
intent\u split\u symbol:“+”
- (请小心,此后配置已更改,您应该遵循文档)
# 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
-
# 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
# 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)
# story 1
* ask_action
- action_execute_instructions
注意,您可以编写一个脚本,从单个意图自动生成几个多意图的示例
stories.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
-
# 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
# 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)
# story 1
* ask_action
- action_execute_instructions
config.yml
language: "en"
pipeline:
- name: "WhitespaceTokenizer"
intent_split_symbol: "+"
- name: "CountVectorsFeaturizer"
- name: "EmbeddingIntentClassifier"
请注意,我使用的拆分符号与文档中的不同
方法2-作为实体的指令
另一种方法是使用单个意图ask_action
和一个或多个实体来识别指令
然后,您可以有一个操作action\u execute\u指令
,处理所有这些指令。它将查看最新消息中的实体,并执行您需要的任何操作
您对指令的理解方式将在很大程度上取决于您选择如何定义实体以及如何将它们映射到所需的指令。有SynonymMapper
,但它一点也不灵活,如果您有一个不完全匹配的新示例,它将失败。在这种情况下,最好编写自己的NLU管道组件
老实说,我认为这不是一个好办法。实体应该是实体(例如:对象、位置等)
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
-
# 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
# 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)
# story 1
* ask_action
- action_execute_instructions
stories.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
-
# 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
# 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)
# story 1
* ask_action
- action_execute_instructions
建议
我强烈建议使用最简单的方法。一旦你的机器人上线,你应该检查你的用户如何使用它,看看是否需要更复杂的意图组合(如果你有多个意图) 参考@AkshayN