Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rules #6088

Merged
merged 68 commits into from
Jul 10, 2020
Merged

Rules #6088

Show file tree
Hide file tree
Changes from 65 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
f5d2122
add RulePolicy
Ghostvv Apr 29, 2020
8b9aafe
add ... helper
Ghostvv May 1, 2020
46f9032
fix rule prediction based on slots
Ghostvv May 4, 2020
1edf80b
fix comment
Ghostvv May 4, 2020
d079923
return padding
Ghostvv May 6, 2020
07da429
fix states
Ghostvv May 7, 2020
210038b
Merge branch 'master' into rules
wochinge May 26, 2020
0200cfd
remove old 'EmbeddingPolicy
wochinge May 26, 2020
474fc54
Merge branch 'master' into rules
wochinge May 27, 2020
f8a7a34
implement Forms with RulePolicy
wochinge May 28, 2020
79601f1
fix rule policy
Ghostvv May 29, 2020
e274da8
add comments that this is a hack
Ghostvv May 29, 2020
83e3c91
initialize slots for temp tracker
wochinge May 29, 2020
1ac061d
return FormAction based on `forms` section in Domain
wochinge May 29, 2020
5c5d859
fix missing slots in forms test domain
wochinge May 29, 2020
da148ae
validate each slot with the different action
Ghostvv May 29, 2020
aa51fb2
Merge branch 'rules' of https://github.com/RasaHQ/rasa into rules
Ghostvv May 29, 2020
33c282b
Rules nlu fallback (#5911)
wochinge May 29, 2020
9247f0d
predict form only if there is no rule
Ghostvv Jun 12, 2020
440ede7
RulePolicy: Abstract loop interface + TwoStageFallbackPolicy (#5933)
wochinge Jun 13, 2020
9301a57
RulePolicy: scope dispatches per form
alwx Jun 16, 2020
ff213fc
New Form featurization (#6029)
wochinge Jun 23, 2020
afad45f
Test added!
alwx Jun 24, 2020
bed6aeb
Merge pull request #6030 from RasaHQ/rules-scope-dispatched-per-form
alwx Jun 24, 2020
2c65b10
remove form unfeaturization, fix rules prediction (#6068)
Ghostvv Jun 25, 2020
5f0f30f
Merge branch 'master' into rules
wochinge Jun 29, 2020
650d49c
Merge branch 'master' into rules
wochinge Jul 2, 2020
351517e
add rules support to YAML training data
ricwo Jul 3, 2020
607e1e4
add Form support to YAML reader
ricwo Jul 3, 2020
51c5ff2
let policies decide on training data type
ricwo Jul 3, 2020
d1f56cd
remove one-line fn
ricwo Jul 3, 2020
08db056
remove debug line
ricwo Jul 3, 2020
97e18b9
fix lint stage
ricwo Jul 3, 2020
1850fd5
update docstring
ricwo Jul 5, 2020
01e855c
Apply suggestions from code review
ricwo Jul 7, 2020
8caddd9
complete docstring
ricwo Jul 7, 2020
6143a05
Merge branch 'rules-yaml' of https://github.com/RasaHQ/rasa into rule…
ricwo Jul 7, 2020
0e74e6a
move tracker splitting to SupportedData
ricwo Jul 7, 2020
3e7f2c2
Merge branch 'master' into rules
wochinge Jul 7, 2020
97fa683
update docstring
ricwo Jul 7, 2020
dc0c258
merge rules
ricwo Jul 7, 2020
c4f95e8
fix test data
ricwo Jul 7, 2020
7db99a6
unused constants and typos
ricwo Jul 7, 2020
0148e28
Merge pull request #6136 from RasaHQ/rules-yaml
ricwo Jul 7, 2020
6f6770a
fix breaking tests in rules branch (#6097)
wochinge Jul 8, 2020
618bbac
Merge branch 'master' into rules
wochinge Jul 9, 2020
6d60ca5
preserve key order when dumping YAML (#6168)
ricwo Jul 9, 2020
151d213
use an enum for the different slot mappings
wochinge Jul 9, 2020
78cf134
expand comment in RulePolicy
Ghostvv Jul 9, 2020
2f6cb17
Merge branch 'rules' of github.com:RasaHQ/rasa into rules
wochinge Jul 9, 2020
b64cece
have one validate function for the whole form (#6171)
wochinge Jul 9, 2020
d60c5b2
Merge branch 'rules' of github.com:RasaHQ/rasa into rules
wochinge Jul 9, 2020
c4936b0
remove unused constant
wochinge Jul 9, 2020
2c993b7
return only to make code more readable
wochinge Jul 9, 2020
a942cf6
Merge branch 'rules' of github.com:RasaHQ/rasa into rules
wochinge Jul 9, 2020
0f827fa
use f-strings
wochinge Jul 9, 2020
9065291
adapt to new Policy interface and add types
wochinge Jul 9, 2020
3a7d6f6
rename 'evts' to '_events'
wochinge Jul 9, 2020
4927007
add missing types
wochinge Jul 9, 2020
3edbfee
remove whitespace
wochinge Jul 9, 2020
4a08f34
make return type explicit
wochinge Jul 9, 2020
6fb55a5
fix some deepsource warnings
wochinge Jul 9, 2020
df9b595
add comments to _rule_is_good
Ghostvv Jul 9, 2020
988e2ea
Merge branch 'master' into rules
wochinge Jul 10, 2020
64ca4a0
Rules feedback (#6177)
wochinge Jul 10, 2020
1de450d
fix typos
wochinge Jul 10, 2020
5ad7aae
improve documentation of forms in domain.yml
wochinge Jul 10, 2020
3cb9b5f
don't mix strip and slicing
wochinge Jul 10, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions changelog/5996.feature.rst
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Introduced a new `YAML` format of the Core training data and implemented a parser for it.
Rasa Open Source can now read stories in both `Markdown` and `YAML` formats.
Introduced a new ``YAML`` format for Core training data and implemented a parser
for it. Rasa Open Source can now read stories in both ``Markdown`` and ``YAML`` format.
1 change: 1 addition & 0 deletions changelog/6065.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add support for rule data and forms in YAML format.
20 changes: 20 additions & 0 deletions changelog/6088.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Added the new dialogue policy ``RulePolicy`` which will replace the old "rule-like"
policies :ref:`mapping-policy`, :ref:`fallback-policy`,
:ref:`two-stage-fallback-policy`, and :ref:`form-policy`. These policies are now
deprecated and will be removed in the future. Please see ``examples/rules``
for a usage example.

Added new NLU component ``FallbackClassifier`` which predicts an intent ``nlu_fallback``
in case the confidence was below a given threshold. The intent ``nlu_fallback`` may
then be used to write stories / rules to handle the fallback in case of low NLU
confidence.

.. code-block::

pipeline:
- ... # Other NLU components
- name: FallbackClassifier
# If the highest ranked intent has a confidence lower than the threshold than
wochinge marked this conversation as resolved.
Show resolved Hide resolved
# the NLU pipeline predicts an intent `nlu_fallback` which you can then use in
wochinge marked this conversation as resolved.
Show resolved Hide resolved
# stories / rules to implement an appropriate fallback.
threshold: 0.5
5 changes: 4 additions & 1 deletion data/test_evaluations/form-end-to-end-stories.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- restaurant_form
- form{"name": "restaurant_form"}
- form{"name": null}
- utter_submit
- utter_slots_values
* thankyou: /thankyou
- utter_noworries
Expand All @@ -18,6 +19,7 @@
* form: /inform{"cuisine": "afghan"} <!-- intent "inform" is ignored inside the form -->
- form: restaurant_form
- form{"name": null}
- utter_submit
- utter_slots_values
* thankyou: /thankyou
- utter_noworries
Expand All @@ -32,6 +34,7 @@
- utter_chitchat
- restaurant_form
- form{"name": null}
- utter_submit
- utter_slots_values
* thankyou: /thankyou
- utter_noworries
- utter_noworries
23 changes: 23 additions & 0 deletions data/test_stories/rules_without_stories.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
>> rule 1
- form{"name": "loop_q_form"} <!-- condition that form is active-->
- slot{"requested_slot": "some_slot"} <!-- some condition -->
- ...
* inform{"some_slot":"bla"} <!-- can be ANY -->
- loop_q_form <!-- can be internal core action, can be anything -->

>> rule 2
- form{"name": "loop_q_form"} <!-- condition that form is active-->
- slot{"requested_slot": "some_slot"} <!-- some condition -->
- ...
* explain <!-- can be anything -->
- utter_explain_some_slot
- loop_q_form
- form{"name": "loop_q_form"} <!-- condition that form is active-->

>> rule 3
- form{"name": "loop_q_form"} <!-- condition that form is active-->
- ...
- loop_q_form <!-- condition that form is active -->
- form{"name": null}
- slot{"requested_slot": null}
- action_stop_q_form
48 changes: 48 additions & 0 deletions data/test_stories/stories_with_rules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
>> rule 1
- form{"name": "loop_q_form"} <!-- condition that form is active-->
- slot{"requested_slot": "some_slot"} <!-- some condition -->
- ...
* inform{"some_slot":"bla"} <!-- can be ANY -->
- loop_q_form <!-- can be internal core action, can be anything -->

>> rule 2
- form{"name": "loop_q_form"} <!-- condition that form is active-->
- slot{"requested_slot": "some_slot"} <!-- some condition -->
- ...
* explain <!-- can be anything -->
- utter_explain_some_slot
- loop_q_form
- form{"name": "loop_q_form"} <!-- condition that form is active-->

## ML story 1
* greet
- utter_greet
* request_restaurant
- restaurant_form
- form{"name": "restaurant_form"}
- form{"name": null}
- utter_slots_values
* thankyou
- utter_noworries

>> rule 3
- form{"name": "loop_q_form"} <!-- condition that form is active-->
- ...
- loop_q_form <!-- condition that form is active -->
- form{"name": null}
- slot{"requested_slot": null}
- action_stop_q_form

## ML story 2
* greet
- utter_greet
* request_restaurant
- restaurant_form
- form{"name": "restaurant_form"}
* chitchat
- utter_chitchat
- restaurant_form
- form{"name": null}
- utter_slots_values
* thankyou
- utter_noworries
2 changes: 1 addition & 1 deletion data/test_wrong_yaml_stories/wrong_yaml.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
!
[dasdassd,
30 changes: 30 additions & 0 deletions data/test_yaml_stories/rules_without_stories.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
rules:
- rule: rule 1
steps:
- form: loop_q_form
- slot: requested_slot
value: some_slot
- ...
- intent: inform
entities:
- some_slot: bla
- action: loop_q_form

- rule: rule 2
steps:
- form: loop_q_form
- slot: requested_slot
value: some_slot
- ...
- intent: explain
- action: utter_explain_some_slot
- action: loop_q_form
- form: loop_q_form

- rule: rule 3
steps:
- form: loop_q_form
- ...
- form: null
- slot: null
- action: stop_q_form
51 changes: 51 additions & 0 deletions data/test_yaml_stories/stories_and_rules.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
rules:
- rule: rule 1
steps:
- form: loop_q_form
- slot: requested_slot
value: some_slot
- ...
- intent: inform
entities:
- some_slot: bla
- action: loop_q_form

- rule: rule 2
steps:
- form: loop_q_form
- slot: requested_slot
value: some_slot
- ...
- intent: explain
- action: utter_explain_some_slot
- action: loop_q_form
- form: loop_q_form

- rule: rule 3
steps:
- form: loop_q_form
- ...
- form: null
- slot: null
- action: stop_q_form

stories:
- story: simple_story_without_checkpoint
steps:
- intent: simple
- action: utter_default
- action: utter_greet

- story: simple_story_with_only_start
steps:
- checkpoint: check_greet # checkpoints at the start define entry points
- intent: simple
- action: utter_default

- story: simple_story_with_only_end
steps:
- intent: hello
- action: utter_greet
- slot: name
value: peter
- checkpoint: check_greet # checkpoint defining the end of this turn
1 change: 1 addition & 0 deletions docs/core/policies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ The ``FallbackPolicy`` invokes a :ref:`fallback action
You can include either the ``FallbackPolicy`` or the
``TwoStageFallbackPolicy`` in your configuration, but not both.

.. _two-stage-fallback-policy:

Two-Stage Fallback Policy
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
5 changes: 1 addition & 4 deletions examples/formbot/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,4 @@ pipeline:
- name: EntitySynonymMapper

policies:
- name: FallbackPolicy
- name: MemoizationPolicy
- name: FormPolicy
- name: MappingPolicy
- name: RulePolicy
Loading