[英]How to set default action in Rasa
Using vanilla Rasa NLU will cause Rasa core to make use of the outputs of the highest probability of an intent or entity value. 使用香草Rasa NLU将使Rasa核心使用意图或实体值的最高可能性的输出。 In other words, even if the probability of an intent is low, and yet it is the highest of all the options, it is still taken by Rasa core as the intent the user is conveying. 换句话说,即使意图的可能性很小,但是它是所有选项中最高的,但Rasa core仍将其视为用户传达的意图。 How do I make it so that Rasa core performs a default action if the probability of the maximum probability intent provided by the NLU is below a certain threshold, say 5%? 如果NLU提供的最大概率意图的概率低于某个阈值(例如5%),如何使Rasa核心执行默认操作?
We can achieve this by adding FallbackPolicy
in policies file. 我们可以通过在策略文件中添加FallbackPolicy
来实现。 For eg: 例如:
policies:
- name: "FallbackPolicy"
nlu_threshold: 0.1
core_threshold: 0.1
fallback_action_name: "fallback_action"
This feature was added recently and is called Fallback Policy . 此功能是最近添加的,称为“ 回退策略” 。
See documentation here: https://core.rasa.com/patterns.html?highlight=fallback%20policy#fallback-default-actions 请参阅此处的文档: https : //core.rasa.com/patterns.html?highlight=fallback%20policy#fallback-default-actions
Simply you can do it in two steps 只需两步即可完成
Step 1 In domain.yml
file 步骤1在domain.yml
文件中
actions:
- action_default_fallback
Step 2 In action.py
file 步骤2在action.py
文件中
class ActionDefaultFallback(Action):
def name(self):
return "action_default_fallback"
def run(self, dispatcher, tracker, domain):
dispatcher.utter_message("Sorry, I couldn't understand.")
Now, whenever intent classification confidence will be below a certain threshold, this default action will execute. 现在,只要意图分类置信度低于某个阈值,就会执行此默认操作。
Resource: 资源:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.