-
Couldn't load subscription status.
- Fork 57
feat: add configurable param logical_operator (OR/AND) to factual knowledge #307
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
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.
overall looks good, just some minor fixes needed
| :param output_key: The key corresponding to the factual knowledge score that | ||
| will be added to the input record. | ||
| :param target_output_delimiter: See the docstring in `FactualKnowledgeConfig`. | ||
| :param logical_operator: See the docstring in `FactualKnowledgeConfig`. |
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.
Please do not refer to other config param.
| raise EvalAlgorithmClientError( | ||
| "Empty target_output_delimiter is provided. Please either provide a non-empty string, or set it to None." | ||
| ) | ||
| if self.logical_operator != "OR" and self.logical_operator != "AND": |
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:
if self.logical_operator not in ["OR", "AND"]:
| os.environ["PARALLELIZATION_FACTOR"] = "2" | ||
|
|
||
| config = FactualKnowledgeConfig("<OR>") | ||
| config = FactualKnowledgeConfig("<OR>", "OR") |
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.
If you do not change this config, the exist tests should also pass, right?
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.
yup! I just wanted to add "OR" becuase "<OR>" was also there
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.
Looks good, one comment:
As discussed before, in my opinion the user experience would be better if target_output_delimiter and logical_operator where linked:
logical_operator = "OR"impliestarget_output_delimiter=<OR>andlogical_operator = "AND"impliestarget_output_delimiter=<AND>.
Is it possible to set the default target_output_delimiter dynamically based on the logical_operator? Alternatively we could raise a warning when the user modifies the logical_operator to "AND" but keeps the target_output_delimiter as <OR>.
| model_input="Who is Andrew R. Jassy?", | ||
| model_output="Chief Executive Officer of Amazon.com Inc.", | ||
| target_output="Chief Executive Officer of Amazon.com, Inc.", | ||
| delimiter="<OR", |
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.
Delimiter is different here (doesn't matter functionally but could be confusing?)
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.
@polaschwoebel We will work towards to change target_output (ground_truth) a list as the Ray issue is solved, then the delimiter should go away and there won't be conflict.
Similar to context(s): #305
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.
Makes sense. Here, I simply meant "" vs "<OR" (small typo in the code above).
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.
Overall looks good, just couple changes needed to improve the unit test
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.
Thanks for addressing all the comments! LGTM
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.
All comments addressed!
Description of changes: I created a new configurable parameter called
logical_operatorthat accepts "OR" (as default) and "AND" in FactualKnowledgeConfig. I added checks so that when thelogical_operatoris "AND", all possible target outputs must be included in model generation in order for the answer to be correct. I also updated all of the current configurations, and created new unit tests to check for behavior given invalid configurations and scores for valid inputs.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.