Why is my Fallback Intent and FallbackClassifier not working in Rasa?

2.4k views Asked by At

I have mentioned it in my pipeline in the config.yml file, that I will be using the FallbackClassifier.

So my code looks like:

language: en
pipeline:
  - name: FallbackClassifier
    threshold: 0.7
    ambiguity_threshold: 0.1

However, I receive this error, when I try to run it:

InvalidConfigException: The pipeline configuration contains errors. The component 'FallbackClassifier' requires 'IntentClassifier' to be placed before it in the pipeline. Please add the required components to the pipeline.
2

There are 2 answers

0
user16844758 On BEST ANSWER

the FallbackClassifier steps in when the IntentClassifier is not confident about the intent. so you cant use the Fallback classifier without using an Intentclassifier.

you can choose an IntentClassifier from this https://rasa.com/docs/rasa/components/#intent-classifiers

the most simple Intentclassifier is the "KeywordIntentClassifier" but it wont be a great choice if the bot is expected to make complicated Conversations.

this as an Example of a working Pipeline using the Fallbackclassifier:

language: "en"

pipeline:
 - name: "WhitespaceTokenizer"
 - name: "CountVectorsFeaturizer"
 - name: "DIETClassifier"
 - name: FallbackClassifier
    threshold: 0.7
    ambiguity_threshold: 0.1
0
Brookie_C On

Your FallbackClassifier needs a IntentClassifier, which further needs a Featurizer, and a Featurizer requires a Tokenizer.

So the easiest way of making your FallbackClassifier to work is to take the config.yml file from when you run rasa init on your CLI. Copy paste the config.yml code and remove all the "#" comment lines from the properties of "pipeline".

So your code for pipeline should look like this:

language: en

pipeline:
# # No configuration for the NLU pipeline was provided. The following default pipeline was used to train your model.
# # If you'd like to customize it, uncomment and adjust the pipeline.
# # See https://rasa.com/docs/rasa/tuning-your-model for more information.
  - name: WhitespaceTokenizer
  - name: RegexFeaturizer
  - name: LexicalSyntacticFeaturizer
  - name: CountVectorsFeaturizer
  - name: CountVectorsFeaturizer
    analyzer: char_wb
    min_ngram: 1
    max_ngram: 4
  - name: DIETClassifier
    epochs: 100
    constrain_similarities: true
  - name: EntitySynonymMapper
  - name: ResponseSelector
    epochs: 100
    constrain_similarities: true
  - name: FallbackClassifier
    threshold: 0.7
    ambiguity_threshold: 0.1

Now your FallbackClassifier should work like a charm!