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

Policy Predictions for End-to-End #7136

Merged
merged 31 commits into from
Nov 10, 2020
Merged

Conversation

wochinge
Copy link
Contributor

@wochinge wochinge commented Oct 29, 2020

Proposed changes:

  • fix Next steps End-to-end: Implementation Proposal + Implementation #7039
  • Policys now return a PolicyPrediction object instead of the plain probabilities. This allows us to return multiple pieces after a prediction. This is not only useful for this PR but also for this PR
  • PolicyEnsemble now returns a PolicyPrediction object instead of Tuple[probabilities, policy_name]. The reason is the same for the change in the Policy interface: This allows us to encapsulate more information and pass this up to the MessageProcessor
  • type the whole test_policies module
  • add method predict_next_with_tracker to avoid having to reimplement some predict logic within server
  • introduce a constant for followup_action

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)

@wochinge wochinge force-pushed the end-to-end-policy-predictions branch 2 times, most recently from 955ad22 to 36e73a7 Compare November 2, 2020 13:42
from unittest.mock import Mock, patch

import numpy as np
import pytest
from _pytest.monkeypatch import MonkeyPatch
Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry, typing got a bit out of hand here 🙈

@wochinge wochinge force-pushed the end-to-end-policy-predictions branch from 36e73a7 to 4f5c697 Compare November 2, 2020 14:00
@wochinge wochinge marked this pull request as ready for review November 2, 2020 14:08
@wochinge wochinge force-pushed the end-to-end-policy-predictions branch from db327b1 to 47dacd6 Compare November 2, 2020 14:08
@wochinge wochinge requested a review from Ghostvv November 2, 2020 14:08
@wochinge
Copy link
Contributor Author

wochinge commented Nov 2, 2020

I'll have an engineer review this as soon as you're ok with the changes in general @Ghostvv

rasa/core/policies/ensemble.py Outdated Show resolved Hide resolved
rasa/core/policies/ensemble.py Outdated Show resolved Hide resolved
rasa/core/policies/policy.py Show resolved Hide resolved
rasa/core/policies/policy.py Outdated Show resolved Hide resolved
rasa/core/policies/rule_policy.py Outdated Show resolved Hide resolved
rasa/core/policies/rule_policy.py Outdated Show resolved Hide resolved
rasa/core/policies/rule_policy.py Outdated Show resolved Hide resolved
rasa/core/policies/rule_policy.py Outdated Show resolved Hide resolved
@Ghostvv Ghostvv added this to the e2e milestone Nov 3, 2020
@Ghostvv
Copy link
Contributor

Ghostvv commented Nov 3, 2020

part of #6670

@wochinge wochinge marked this pull request as draft November 4, 2020 16:32
@wochinge wochinge force-pushed the end-to-end-policy-predictions branch 4 times, most recently from 20e64bd to da6c99d Compare November 5, 2020 09:49
@wochinge wochinge marked this pull request as ready for review November 5, 2020 17:06
@wochinge wochinge requested review from a team, kalkbrennerei, degiz and Ghostvv and removed request for a team and kalkbrennerei November 5, 2020 17:06
@wochinge
Copy link
Contributor Author

wochinge commented Nov 5, 2020

@degiz Do you have time? It looks bigger than it is. Mostly typing and renames.

@degiz
Copy link
Contributor

degiz commented Nov 5, 2020

@wochinge can review that tomorrow in the morning, would it be fine?

@wochinge
Copy link
Contributor Author

wochinge commented Nov 5, 2020

Sure, absolutely no rush!

Copy link
Contributor

@degiz degiz left a comment

Choose a reason for hiding this comment

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

Great job adding all the docstrings, comments, types and tests 🚀 🚀

changelog/7136.removal.md Outdated Show resolved Hide resolved
rasa/core/agent.py Outdated Show resolved Hide resolved
@staticmethod
def is_not_memo_policy(
policy_name: Text, max_confidence: Optional[float] = None
policy_name: Optional[Text], max_confidence: Optional[float] = None
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the default value of max_confidence be 0.0?

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 as this would otherwise evaluate to True for the call here

) -> bool:
"""Checks if the policy is the `MemoizationPolicy` or one of its subclasses.
Copy link
Contributor

Choose a reason for hiding this comment

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

That's not exactly what it's doing right? There's also a check of max_confidence argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

re-named the function and changed the docstring. Better?

rasa/core/policies/ensemble.py Show resolved Hide resolved
rasa/core/policies/rule_policy.py Show resolved Hide resolved
rasa/core/processor.py Outdated Show resolved Hide resolved
rasa/core/processor.py Outdated Show resolved Hide resolved
rasa/shared/core/trackers.py Outdated Show resolved Hide resolved
tests/core/test_processor.py Show resolved Hide resolved
Copy link
Contributor

@Ghostvv Ghostvv left a comment

Choose a reason for hiding this comment

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

🚀

rasa/core/agent.py Outdated Show resolved Hide resolved
rasa/core/policies/policy.py Show resolved Hide resolved
rasa/core/policies/rule_policy.py Outdated Show resolved Hide resolved
@wochinge wochinge mentioned this pull request Nov 10, 2020
5 tasks
@rasabot rasabot merged commit a5dcad8 into master Nov 10, 2020
@rasabot rasabot deleted the end-to-end-policy-predictions branch November 10, 2020 14:26
@wochinge wochinge mentioned this pull request Nov 17, 2020
4 tasks
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.

Next steps End-to-end: Implementation Proposal + Implementation
5 participants