# Unable to properly use Rule Policy

**URL:** <https://forum.rasa.com/t/unable-to-properly-use-rule-policy/49969>\
**Category:** Rasa Open Source\
**Created:** [December 13, 2021, 1:21pm UTC](https://forum.rasa.com/t/unable-to-properly-use-rule-policy/49969 "2021-12-13T13:21:04Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sajjadmanal](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/sajjadmanal/32/18330_2.png) [@Sajjadmanal](https://forum.rasa.com/u/Sajjadmanal)\
**Post date:** [December 13, 2021, 1:21pm UTC](https://forum.rasa.com/t/unable-to-properly-use-rule-policy/49969/1 "2021-12-13T13:21:04Z")

</div>

Hi, I am using rasa 2.x and using Rule Policy to handle queries which my model is not trained on.

Here is the rue policy:

```auto
> - name: RulePolicy
> core_fallback_threshold: 0.7
> core_fallback_action_name: "action_default_fallback"
> enable_fallback_prediction: True

```

I have given the text:

> can you help me?

My model is not trained for this query and the prediction score is 0.50 (as seen below). So, as per Rule policy, It should predict ‘utter\_default’ but it has perdicted ‘greet’ Here is the output: `rasa.core.processor - Received user message 'can you help me?' with intent '{'id': -3112698601225084444, 'name': 'greet', 'confidence': 0.5097352862358093}' and entities '[]'`

Please help.

---

<div class="post-metadata">

**Author:** ![nik202](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/nik202/32/16098_2.png) [@nik202](https://forum.rasa.com/u/nik202)\
**Post date:** [December 13, 2021, 1:50pm UTC](https://forum.rasa.com/t/unable-to-properly-use-rule-policy/49969/2 "2021-12-13T13:50:54Z")

</div>

@Sajjadmanal can you try this configuration and do confirm the output, please also delete the older trained model and try run it again :

**Note:** This is for demo purpose only, please change the values as per your use case.

```auto

policies:
  - name: MemoizationPolicy
  - name: TEDPolicy
    max_history: 5
    epochs: 100
  - name: RulePolicy
    nlu_threshold: 0.4
    core_threshold: 0.4
    fallback_action_name: "action_default_fallback"

```

I hope you had mentioned the` utter_default:` in the `domain.yml`

---

<div class="post-metadata">

**Author:** ![Sajjadmanal](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/sajjadmanal/32/18330_2.png) [@Sajjadmanal](https://forum.rasa.com/u/Sajjadmanal)\
**Post date:** [December 13, 2021, 1:55pm UTC](https://forum.rasa.com/t/unable-to-properly-use-rule-policy/49969/3 "2021-12-13T13:55:44Z")

</div>

@nik202 Yes, I have utter\_default in domain.yml why the threshold is 0.4 and not 0.7? greet was being predicted with 0.50 accuracy. (with my configuration)

---

<div class="post-metadata">

**Author:** ![nik202](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/nik202/32/16098_2.png) [@nik202](https://forum.rasa.com/u/nik202)\
**Post date:** [December 13, 2021, 1:59pm UTC](https://forum.rasa.com/t/unable-to-properly-use-rule-policy/49969/4 "2021-12-13T13:59:26Z")

</div>

@Sajjadmanal you can set any threshold value, for my use case it’s giving me the default message on these values, so I just shared with you, please do try with different values and check the response.

@Sajjadmanal do even check this input text “can you help me?” have some example mentioned in the greet intent?

---

<div class="post-metadata">

**Author:** ![Sajjadmanal](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/sajjadmanal/32/18330_2.png) [@Sajjadmanal](https://forum.rasa.com/u/Sajjadmanal)\
**Post date:** [December 13, 2021, 2:09pm UTC](https://forum.rasa.com/t/unable-to-properly-use-rule-policy/49969/5 "2021-12-13T14:09:29Z")

</div>

@nik202 Thanks. It worked. Can you let me know taking threshold as 0.4 means what? The accuracy of prediction should be at least 0.4?

---

<div class="post-metadata">

**Author:** ![nik202](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/nik202/32/16098_2.png) [@nik202](https://forum.rasa.com/u/nik202)\
**Post date:** [December 13, 2021, 2:13pm UTC](https://forum.rasa.com/t/unable-to-properly-use-rule-policy/49969/6 "2021-12-13T14:13:25Z")

</div>

@Sajjadmanal its basically the confidence score values, we tried to mention the values between .4-.6 for the best case scenarios, but it can vary as per the use case. In one of my project I set the value to 5 or 6 even.

---

<div class="post-metadata">

**Author:** ![Sajjadmanal](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/sajjadmanal/32/18330_2.png) [@Sajjadmanal](https://forum.rasa.com/u/Sajjadmanal)\
**Post date:** [December 13, 2021, 2:16pm UTC](https://forum.rasa.com/t/unable-to-properly-use-rule-policy/49969/7 "2021-12-13T14:16:15Z")

</div>

@nik202 Then what does this mean? When i take threshold= 0.7 `2021-12-13 19:43:30 DEBUG rasa.core.processor - Received user message 'can you help me?' with intent '{'id': -1385349519514546219, 'name': 'out_of_scope', 'confidence': 0.47837963700294495}' and entities '[]'`

---

<div class="post-metadata">

**Author:** ![nik202](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/nik202/32/16098_2.png) [@nik202](https://forum.rasa.com/u/nik202)\
**Post date:** [December 13, 2021, 2:20pm UTC](https://forum.rasa.com/t/unable-to-properly-use-rule-policy/49969/8 "2021-12-13T14:20:16Z")

</div>

@Sajjadmanal ok, as you see first screenshot you have shared the intent name is greet and now its out of scope. It means your model is confused and for that you need to provide a good amount of training examples. How many training examples you are mentioned in per intents for your project?

---

<div class="post-metadata">

**Author:** ![Sajjadmanal](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/sajjadmanal/32/18330_2.png) [@Sajjadmanal](https://forum.rasa.com/u/Sajjadmanal)\
**Post date:** [December 13, 2021, 2:23pm UTC](https://forum.rasa.com/t/unable-to-properly-use-rule-policy/49969/9 "2021-12-13T14:23:15Z")

</div>

@nik202 I have used from 6 to 12. some are 6, some are 8 some are 10-11.
