-
Notifications
You must be signed in to change notification settings - Fork 9
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
Merge extended_conditions into main repository #35
base: dev
Are you sure you want to change the base?
Conversation
- Replace df_engine with dff.core.engine - Replace df_runner with dff.core.pipeline - Replace df_extended_conditions with dff.script.logic.extended_conditions
Fix references to files inside examples/extended_conditions since those were moved from examples. Also rename example_utils.py to _extended_conditions_utils.py.
Also add a step that generates a gdf_account.json file from secret.
Rename the second `testing_model` function to `hf_matcher`
* adjust line length; * adapt to new directory structure; * move tests and examples to script/extras/conditions; * reformat with black; * rework imports;
chatsky/conditions/ml.py
Outdated
|
||
|
||
@singledispatch | ||
def has_cls_label(model: ExtrasBaseModel, label, threshold: float = 0.9): |
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.
Add validator for label (present in the model config).
chatsky/conditions/ml.py
Outdated
def __init__(self, *args): | ||
super().__init__(*args) | ||
|
||
async def call(self): |
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.
Incorrect call signature (should accept context and return bool).
chatsky/conditions/ml.py
Outdated
super().__init__(*args) | ||
|
||
async def call(self): | ||
async def has_cls_label_innner(ctx: Context, _) -> bool: |
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.
Remove inner functions.
chatsky/conditions/ml.py
Outdated
if negative_examples is None: | ||
negative_examples = [] |
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.
Use Pydantic's Field default factory instead.
TRANSITIONS: { | ||
# We get to one of the dialog branches depending on the annotation | ||
("service", "buy", 1.2): i_cnd.has_cls_label( | ||
api_model, "LABEL_1", threshold=0.95 |
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.
These models should be passed to pipeline (same as #376) to allow has cls label to accept model name (instead of model instance).
async def save(self, path: str, **kwargs) -> None: | ||
""" | ||
Save the model to a specified location. | ||
|
||
:param path: string-formatted path. If tokenizer state | ||
needs to be saved, the path is used as the base. | ||
""" | ||
raise NotImplementedError | ||
|
||
@classmethod | ||
async def load(cls, path: str, namespace_key: str): | ||
""" | ||
Load a model from the specified location and instantiate the model. | ||
|
||
:param str: Path to saving directory. | ||
:param namespace_key: Name of the namespace in that the model will be using. | ||
Will be forwarded to the model on construction. | ||
""" | ||
raise NotImplementedError |
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.
Remove unnecessary methods.
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.
Move these files from models/remote_api
to models
-- there are no other models.
Checklist
Add README.md
Sync dependencies with df_stats (stats requires
httpx<=0.23.0
andrequests>=2.28.1
while extended_conditions requireshttpx>=0.23.0
andrequests<=2.28.1
)Skip tests if required dependencies are not installed, env vars are not set or docker is not running
Add
try: except ImportError
when importing extended_conditions dependenciesFix huggingface tests:
testing_model
, I renamed the second one tohf_matcher
Replace _extended_conditions_utils.py imports when All example utils moved to
dff
#34 is mergedAt the moment rasa docker image building includes model training. This doesn't seem like good practice.