Skip to content

Commit

Permalink
make NLU fallback intent a hardcoded intent name
Browse files Browse the repository at this point in the history
It has to be hardcoded since the TwoStageFallbackPolicy relies on it's name, similar to the out of scope intent name
  • Loading branch information
wochinge committed Jun 11, 2020
1 parent 05233e0 commit 68cbb5d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
1 change: 0 additions & 1 deletion examples/rules/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ pipeline:
- name: EntitySynonymMapper
- name: FallbackClassifier
threshold: 0.5
fallback_intent_name: nlu_fallback

policies:
- name: RulePolicy
8 changes: 2 additions & 6 deletions rasa/nlu/classifiers/fallback_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from rasa.nlu.constants import INTENT_RANKING_KEY, INTENT, INTENT_CONFIDENCE_KEY

THRESHOLD_KEY = "threshold"
FALLBACK_INTENT_NAME_KEY = "fallback_intent_name"


class FallbackClassifier(Component):
Expand All @@ -18,10 +17,7 @@ class FallbackClassifier(Component):
# ## Architecture of the used neural network
# If all intent confidence scores are beyond this threshold, set the current
# intent to `FALLBACK_INTENT_NAME`
THRESHOLD_KEY: DEFAULT_NLU_FALLBACK_THRESHOLD,
# The intent which is used to signal that the NLU confidence was below the
# threshold.
FALLBACK_INTENT_NAME_KEY: DEFAULT_NLU_FALLBACK_INTENT_NAME,
THRESHOLD_KEY: DEFAULT_NLU_FALLBACK_THRESHOLD
}

@classmethod
Expand Down Expand Up @@ -59,7 +55,7 @@ def _should_fallback(self, message: Message) -> bool:

def _fallback_intent(self) -> Dict[Text, Union[Text, float]]:
return {
"name": self.component_config[FALLBACK_INTENT_NAME_KEY],
"name": DEFAULT_NLU_FALLBACK_INTENT_NAME,
# TODO: Re-consider how we represent the confidence here
INTENT_CONFIDENCE_KEY: 1.0,
}

0 comments on commit 68cbb5d

Please sign in to comment.