我正在使用 RASA 开发一个用于银行业务的机器人。我有资金转账、交易历史、贷款、余额、账单支付等意图。我已经实现了一次处理一项功能的意图。现在,我想一次处理多个意图。
例如,如果用户说,
显示我的最新交易,然后在显示余额后支付我的账单。
当用户在一次话语中要求超过一两个功能时,我该如何处理这些类型的输入?
我知道,我可以使用多个实体来实现意图,但这似乎对我不起作用,因为我有太多的意图,以至于我无法承担使用 2 或 3 个实体的组合来实现意图。
是否有可能使用 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
-
Run Code Online (Sandbox Code Playgroud)
请注意,您可以编写一个脚本来从单个意图自动生成一些多意图示例
故事.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
Run Code Online (Sandbox Code Playgroud)
配置.yml
language: "en"
pipeline:
- name: "WhitespaceTokenizer"
intent_split_symbol: "+"
- name: "CountVectorsFeaturizer"
- name: "EmbeddingIntentClassifier"
Run Code Online (Sandbox Code Playgroud)
请注意,我使用的分割符号与文档中的分割符号不同。
另一种方法是使用单一意图ask_action和一个或多个实体来识别您的指令。
然后您可以采取一项行动action_execute_instructions来处理所有这些问题。它将查看最新消息中的实体,并执行您需要的任何内容。
您如何理解这些指令在很大程度上取决于您选择如何定义实体以及如何将它们映射到您想要的指令。有一个SynonymMapperfor ,但它根本不灵活,如果您有一个不完全匹配的新示例,它就会失败。在这种情况下,您最好编写自己的 NLU 管道组件。
说实话,我不认为这是一个好的做法。实体应该是实体(即:对象、位置等)
nlu.md
language: "en"
pipeline:
- name: "WhitespaceTokenizer"
intent_split_symbol: "+"
- name: "CountVectorsFeaturizer"
- name: "EmbeddingIntentClassifier"
Run Code Online (Sandbox Code Playgroud)
故事.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)
Run Code Online (Sandbox Code Playgroud)
我强烈建议使用最简单的方法。一旦你的机器人上线,你应该检查你的用户如何使用它,并看看是否需要更复杂的意图组合(如果你有多个意图)。