# Implementing simple fallback

**URL:** <https://forum.rasa.com/t/implementing-simple-fallback/1639>\
**Category:** Rasa Open Source\
**Created:** [October 4, 2018, 6:34pm UTC](https://forum.rasa.com/t/implementing-simple-fallback/1639 "2018-10-04T18:34:28Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![prcastro](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/prcastro/32/663_2.png) [@prcastro](https://forum.rasa.com/u/prcastro)\
**Post date:** [October 4, 2018, 6:34pm UTC](https://forum.rasa.com/t/implementing-simple-fallback/1639/1 "2018-10-04T18:34:28Z")

</div>

Hi everyone,

I’m having trouble implementing my fallback utter message. As of now, I already defined `utter_default` template on the `domain.yaml` and registered it as an action in that same file. Also, I created two stories:

```auto
## story_fallback
  * out_of_scope
   - action_default_fallback

## fallback
   - utter_fallback

```

The first one is working: when the intent is `out_of_scope` (I have some examples of this on my `nlu_data.md`) it activates the `action_default_fallback` and spits out my `utter_fallback` template.

However, since I’m training my model using:

```auto
python -m rasa_core.train -d domain.yml -s data/stories.md -o models/current/dialogue --nlu_threshold 0.1 --core_threshold 0.1 --fallback_action action_default_fallback 

```

I was expecting the model to fallback to `utter_fallback` when the NLU confidence was bellow 0.1. But on reality this doesn’t happen:

```auto
2018-10-04 15:21:03 DEBUG urllib3.connectionpool - Starting new HTTP connection (1): localhost
2018-10-04 15:21:03 DEBUG rasa_core.tracker_store - Recreating tracker for id 'default'
2018-10-04 15:21:03 DEBUG rasa_core.processor - Received user message '' with intent '{'name': None, 'confidence': 0.0}' and entities '[]'
2018-10-04 15:21:03 DEBUG rasa_core.processor - Logged UserUtterance - tracker now has 19 events
2018-10-04 15:21:03 DEBUG rasa_core.processor - Current slot values: 
	address: None
	delivery_state: None
	name: paulo
2018-10-04 15:21:03 DEBUG rasa_core.policies.memoization - Current tracker state [{'slot_name_0': 1.0, 'intent_name': 1.0, 'prev_action_listen': 1.0}, {'slot_name_0': 1.0, 'intent_name': 1.0, 'prev_utter_greet': 1.0}, {'prev_action_listen': 1.0, 'slot_name_0': 1.0}]
2018-10-04 15:21:03 DEBUG rasa_core.policies.memoization - There is no memorised next action
2018-10-04 15:21:03 DEBUG rasa_core.policies.ensemble - Predicted next action using policy_2_KerasPolicy
2018-10-04 15:21:03 DEBUG rasa_core.processor - Predicted next action 'utter_thanks' with prob 0.66.

```

As you can see, it predicts another action (`utter_thanks`) when I type an empty string (that has an intent confidence of 0.0).

What am I doing wrong? I followed all the directions on the tutorial and I still can’t default when the confidence is low.

---

<div class="post-metadata">

**Author:** ![vinaynagpal9](https://avatars.discourse-cdn.com/v4/letter/v/d07c76/32.png) [@vinaynagpal9](https://forum.rasa.com/u/vinaynagpal9)\
**Post date:** [October 8, 2018, 7:36am UTC](https://forum.rasa.com/t/implementing-simple-fallback/1639/2 "2018-10-08T07:36:36Z")

</div>

i have also same problem

---

<div class="post-metadata">

**Author:** ![vinaynagpal9](https://avatars.discourse-cdn.com/v4/letter/v/d07c76/32.png) [@vinaynagpal9](https://forum.rasa.com/u/vinaynagpal9)\
**Post date:** [October 8, 2018, 7:37am UTC](https://forum.rasa.com/t/implementing-simple-fallback/1639/3 "2018-10-08T07:37:43Z")

</div>

if some one help according to rasa-core==0.9.4

rasa-nlu==0.12.3

---

<div class="post-metadata">

**Author:** ![prcastro](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/prcastro/32/663_2.png) [@prcastro](https://forum.rasa.com/u/prcastro)\
**Post date:** [October 9, 2018, 12:58pm UTC](https://forum.rasa.com/t/implementing-simple-fallback/1639/4 "2018-10-09T12:58:49Z")

</div>

Anyone has any idea of what is happening?

---

<div class="post-metadata">

**Author:** ![akelad](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/akelad/32/69_2.png) [@akelad](https://forum.rasa.com/u/akelad)\
**Post date:** [October 9, 2018, 2:07pm UTC](https://forum.rasa.com/t/implementing-simple-fallback/1639/5 "2018-10-09T14:07:07Z")

</div>

@vinaynagpal9 we only added the fallback policy in version 0.10 as far as i remember, please upgrade to the latest version 0.11

@prcastro that looks strange. which version of core are you using?

---

<div class="post-metadata">

**Author:** ![prcastro](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/prcastro/32/663_2.png) [@prcastro](https://forum.rasa.com/u/prcastro)\
**Post date:** [October 9, 2018, 2:22pm UTC](https://forum.rasa.com/t/implementing-simple-fallback/1639/6 "2018-10-09T14:22:32Z")

</div>

I’m using rasa\_core version `0.11.1`

---

<div class="post-metadata">

**Author:** ![souvikg10](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/souvikg10/32/93_2.png) [@souvikg10](https://forum.rasa.com/u/souvikg10)\
**Post date:** [October 9, 2018, 2:29pm UTC](https://forum.rasa.com/t/implementing-simple-fallback/1639/7 "2018-10-09T14:29:33Z")

</div>

@prcastrogot this from the code

# type: (…) -\> bool

```
    """It should predict fallback action only if
    a. predicted NLU confidence is lower than ``nlu_threshold`` &&
    b. last action is NOT fallback action
    """

```

Was your last action a fallback action by any chance?

---

<div class="post-metadata">

**Author:** ![prcastro](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/prcastro/32/663_2.png) [@prcastro](https://forum.rasa.com/u/prcastro)\
**Post date:** [October 9, 2018, 2:46pm UTC](https://forum.rasa.com/t/implementing-simple-fallback/1639/8 "2018-10-09T14:46:32Z")

</div>

No, this happens even at the very start of the conversation

---

<div class="post-metadata">

**Author:** ![akelad](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/akelad/32/69_2.png) [@akelad](https://forum.rasa.com/u/akelad)\
**Post date:** [October 9, 2018, 3:54pm UTC](https://forum.rasa.com/t/implementing-simple-fallback/1639/9 "2018-10-09T15:54:03Z")

</div>

can you paste the contents of your `metadata.json` from your trained model here please? Also try upgrading to 0.11.11, that’s the latest version

---

<div class="post-metadata">

**Author:** ![prcastro](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/prcastro/32/663_2.png) [@prcastro](https://forum.rasa.com/u/prcastro)\
**Post date:** [October 9, 2018, 4:21pm UTC](https://forum.rasa.com/t/implementing-simple-fallback/1639/10 "2018-10-09T16:21:30Z")

</div>

Do you mean my NLU model? Here it is:

```json
{
    "language": "pt",
    "pipeline": [
        {
            "model": "pt",
            "case_sensitive": false,
            "name": "nlp_spacy",
            "class": "rasa_nlu.utils.spacy_utils.SpacyNLP"
        },
        {
            "name": "tokenizer_spacy",
            "class": "rasa_nlu.tokenizers.spacy_tokenizer.SpacyTokenizer"
        },
        {
            "name": "intent_featurizer_spacy",
            "class": "rasa_nlu.featurizers.spacy_featurizer.SpacyFeaturizer"
        },
        {
            "name": "intent_entity_featurizer_regex",
            "regex_file": "regex_featurizer.json",
            "class": "rasa_nlu.featurizers.regex_featurizer.RegexFeaturizer"
        },
        {
            "BILOU_flag": true,
            "features": [
                [
                    "low",
                    "title",
                    "upper"
                ],
                [
                    "bias",
                    "low",
                    "prefix5",
                    "prefix2",
                    "suffix5",
                    "suffix3",
                    "suffix2",
                    "upper",
                    "title",
                    "digit",
                    "pattern"
                ],
                [
                    "low",
                    "title",
                    "upper"
                ]
            ],
            "max_iterations": 50,
            "L1_c": 0.1,
            "L2_c": 0.1,
            "name": "ner_crf",
            "classifier_file": "crf_model.pkl",
            "class": "rasa_nlu.extractors.crf_entity_extractor.CRFEntityExtractor"
        },
        {
            "name": "ner_synonyms",
            "synonyms_file": "entity_synonyms.json",
            "class": "rasa_nlu.extractors.entity_synonyms.EntitySynonymMapper"
        },
        {
            "C": [
                1,
                2,
                5,
                10,
                20,
                100
            ],
            "kernels": [
                "linear"
            ],
            "max_cross_validation_folds": 5,
            "scoring_function": "f1_weighted",
            "name": "intent_classifier_sklearn",
            "classifier_file": "intent_classifier_sklearn.pkl",
            "class": "rasa_nlu.classifiers.sklearn_intent_classifier.SklearnIntentClassifier"
        }
    ],
    "training_data": "training_data.json",
    "trained_at": "20181009-114048",
    "rasa_nlu_version": "0.13.5"
}

```

I’m retraining with the new version you suggested now. Let’s see.

---

<div class="post-metadata">

**Author:** ![prcastro](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/prcastro/32/663_2.png) [@prcastro](https://forum.rasa.com/u/prcastro)\
**Post date:** [October 9, 2018, 4:28pm UTC](https://forum.rasa.com/t/implementing-simple-fallback/1639/11 "2018-10-09T16:28:27Z")

</div>

Apparently it was a problem with the version, now it is working. Thanks for the tip.
