-
Notifications
You must be signed in to change notification settings - Fork 10
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
Create explainable user model classes #223
Conversation
Simple Explainable user model based on tags. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly nits and suggestions. As for PR #184, we may need few iterations.
def generate_explanation( | ||
self, user_preferences: UserPreferences | ||
) -> AnnotatedUtterance: | ||
"""Generate an explanation based on the provided input data. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"""Generate an explanation based on the provided input data. | |
"""Generates an explanation based on the provided input data. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
generated. | ||
|
||
Returns: | ||
The generated explanation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Maybe this could be more precise, like utterance containing explanation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 I was wondering why the return type was AnnotatedUtterance, so it would be worth mentioning here that the explanation is to be returned as a system utterance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
UserPreferences, | ||
) | ||
|
||
_DEFAULT_TEMPLATE_FILE = "moviebot/explainability/explanation_templates.yaml" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would argue to put this file in the folder data
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
class ExplainableUserModelTagBased(ExplainableUserModel): | ||
def __init__(self, template_file: str = _DEFAULT_TEMPLATE_FILE): | ||
"""Initialize the ExplainableUserModelTagBased class. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: conjugate verb in docstring.
"""Initialize the ExplainableUserModelTagBased class. | |
"""Initializes the ExplainableUserModelTagBased class. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Args: | ||
template_file: Path to the YAML file containing explanation | ||
templates. Defaults to _DEFAULT_TEMPLATE_FILE. | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: check if file exists raise exception otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
def generate_explanation( | ||
self, user_preferences: UserPreferences | ||
) -> AnnotatedUtterance: | ||
"""Generate an explanation based on the provided user preferences. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: conjugate verb in docstring.
"""Generate an explanation based on the provided user preferences. | |
"""Generates an explanation based on the provided user preferences. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
"""Generate an explanation based on the provided user preferences. | ||
|
||
Args: | ||
user_preferences: Nested dictionary of user preferences. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: simply user preferences?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
Args: | ||
template: Template containing negative keyword. | ||
remove: If True, remove the negative keyword. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: add defaults value.
remove: If True, remove the negative keyword. | |
remove: If True, remove the negative keyword. Defaults to True. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
|
||
@pytest.fixture | ||
def explainable_model(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: missing return type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@pytest.fixture | ||
def explainable_model(): | ||
return ExplainableUserModelTagBased( | ||
"moviebot/explainability/explanation_templates.yaml" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering if it you be best to make _DEFAULT_TEMPLATE_FILE
public and reuse it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We dont even need to make it public. It defaults to the default path :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming that UserPreferences contains item-based preferences, there is a missing step of inferring preferences for tags. That should take place in this class (by talking to the movie DB).
generated. | ||
|
||
Returns: | ||
The generated explanation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 I was wondering why the return type was AnnotatedUtterance, so it would be worth mentioning here that the explanation is to be returned as a system utterance.
@@ -0,0 +1,81 @@ | |||
"""This module contains the ExplainableUserModelTagBased class. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most modules contain a single class, so this docstring is not that informative. Suggestion instead: "Tag-based user model explanation."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
Args: | ||
template_file: Path to the YAML file containing explanation | ||
templates. Defaults to _DEFAULT_TEMPLATE_FILE. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: second line should be indented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
accidentally approved it, ignore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see comments
Since we have attribute preferances readily available, we can start with those. Later, we can expand to item-based preferances. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (see one nit)
The class generates explanations for user preferences in the movie domain based | ||
on templates loaded from a YAML file. | ||
The class generates explanations for user preferences in the movie domain. | ||
Currently, the explanations are based on the explicit movie tags/attributes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: "... are based on movie tags/attributes that were explicitly mentioned by the user in the conversation."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
No description provided.