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

UnexpecTEDIntentPolicy predictions fix #9079

Merged
merged 20 commits into from
Jul 12, 2021

Conversation

alwx
Copy link
Contributor

@alwx alwx commented Jul 8, 2021

Proposed changes:

Status (please check what you already did):

  • added some tests for the functionality
  • updated the documentation
  • updated the changelog (please check changelog for instructions)
  • reformat files using black (please check Readme for instructions)

@alwx alwx changed the base branch from main to intent-ted July 8, 2021 15:18
rasa/core/test.py Outdated Show resolved Hide resolved
@dakshvar22 dakshvar22 requested review from joejuzl and wochinge and removed request for joejuzl July 9, 2021 11:38
@wochinge wochinge requested review from joejuzl and removed request for wochinge July 9, 2021 12:07
@alwx alwx marked this pull request as ready for review July 9, 2021 12:14
@alwx alwx requested a review from a team as a code owner July 9, 2021 12:14
@dakshvar22 dakshvar22 removed the request for review from a team July 9, 2021 12:17
rasa/core/test.py Outdated Show resolved Hide resolved
rasa/core/test.py Outdated Show resolved Hide resolved
rasa/shared/core/events.py Outdated Show resolved Hide resolved
@@ -235,6 +236,11 @@ def is_action_unlikely_intent(event: Event) -> bool:
return (
type(event) == ActionExecuted
and event.action_name == ACTION_UNLIKELY_INTENT_NAME
) or (
type(event) == WronglyPredictedAction
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need this now we have WarningPredictedAction?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also do we need any check for these test events here? They are not actually predicted ever right?

if has_prediction_target_mismatch or (
predicted_warning and predicted_action != expected_action
if action_executed_eval_store.has_prediction_target_mismatch() or (
predicted_action_unlikely_intent and predicted_action != expected_action
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this part now the equivalent of previously_predicted_action_unlikely_intent?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because we make another prediction => predicted_action gets overwritten

if has_prediction_target_mismatch or (
predicted_warning and predicted_action != expected_action
if action_executed_eval_store.has_prediction_target_mismatch() or (
predicted_action_unlikely_intent and predicted_action != expected_action
):
partial_tracker.update(
WronglyPredictedAction(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have an predict action_unlikely_intent but it's not in the story, and the following action is correct, won't be now end up with two WronglyPredictedAction in the tracker?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we predict action_unlikely_intent then we ask for another prediction, and only add this WronglyPredictedAction if there is a mismatch in expected/predicted. This is the only case when two WronglyPredictedActions will be added but that's perfectly fine because we filter out action_unlikely_intents from logs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok but if predicted_action_unlikely_intent and predicted_action != expected_action on line 584 is False, then predicted_action is not changed because we don't re-run so we no predicted_action_unlikely_intent and predicted_action != expected_action on line 609 will also always be False. And if line 584 is True then we know the next action can't be another action_unlikely_intents right? So can we change 609 to just if action_executed_eval_store.has_prediction_target_mismatch()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's correct. Changed that.

if (
fail_on_prediction_errors
and predicted_action != ACTION_UNLIKELY_INTENT_NAME
and expected_action != ACTION_UNLIKELY_INTENT_NAME
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this break the requirement we fail if the test story contains ACTION_UNLIKELY_INTENT_NAME but we don't predict it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the condition and added a test for it (test_action_unlikely_intent_fail_on_prediction_errors)

@@ -667,6 +638,16 @@ def _collect_action_executed_predictions(
"training stories and retrain."
)
raise WrongPredictionException(error_msg)
elif previously_predicted_action_unlikely_intent:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this possible given that we already have predicted_action_unlikely_intent and predicted_action != expected_action in the or of the associated if?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is possible. prev_action_unlikely_intent is different from predicted_action_unlikely_intent and predicted_action != expected_action (see comment above)

tests/core/test_test.py Show resolved Hide resolved
@alwx alwx requested review from joejuzl and dakshvar22 July 12, 2021 08:18
tests/core/test_test.py Outdated Show resolved Hide resolved
tests/core/test_test.py Outdated Show resolved Hide resolved
@alwx alwx requested a review from dakshvar22 July 12, 2021 08:58
Copy link
Contributor

@dakshvar22 dakshvar22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mainly reviewed rasa/core/test.py as the shared codeowner for those files.

rasa/core/test.py Outdated Show resolved Hide resolved
rasa/core/test.py Show resolved Hide resolved
rasa/core/test.py Outdated Show resolved Hide resolved
rasa/shared/core/events.py Outdated Show resolved Hide resolved
tests/core/test_test.py Outdated Show resolved Hide resolved
tests/core/test_test.py Outdated Show resolved Hide resolved
@alwx alwx requested review from wochinge and dakshvar22 and removed request for wochinge July 12, 2021 10:52
Copy link
Contributor

@dakshvar22 dakshvar22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing all my comments 🚀

Copy link
Contributor

@joejuzl joejuzl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@dakshvar22 dakshvar22 merged commit 60d5b32 into intent-ted Jul 12, 2021
@dakshvar22 dakshvar22 deleted the intent-ted-wrong-prediction branch July 12, 2021 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants