Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
This section offers an overview of setting up retrain triggers for your models. These triggers enable the automatic initiation of your retraining pipeline from the ML cube Platform.
# Retrain Trigger

A retrain trigger can be utilized within a Detection Event Rule. When specific criteria are met, it automatically generates the retrain report and activates the trigger. Alternatively, you can manually activate the trigger for the model on the retraining tool page.
This section offers an overview of how you can set up a retrain trigger for your model.
Retrain triggers enable the automatic initiation of your retraining pipeline from the ML cube Platform. They are designed as
integrations with external services and thus require credentials with the appropriate privileges to be executed.

A retrain trigger is designed as an integration with an external service and necessitates credentials with the appropriate privileges to execute the action.
A Retrain Trigger can be utilized within a [Detection Event Rule](../monitoring/detection_event_rules.md). Alternatively,
it can be manually activated from the WebApp, in the Retraining section.

## Supported Triggers

Expand Down Expand Up @@ -94,11 +97,15 @@ The following retrain triggers are supported:

**Retrain Trigger Setup**

To integrate Amazon Event Bridge, you will need to create a set of AWS credentials, and add a policy that allows to put events in your event bus. Please refer to [this page](index.md) to know more.
To integrate Amazon Event Bridge, you need to create a set of AWS credentials, and add a policy that allows to put events in
your event bus. Please refer to [this page](index.md) for more information.

Once the credentials and the policy have been created, you can set up the retrain trigger for your model through the SDK or the web application.
Once the credentials and the policy have been created, you can set up the retrain trigger for your model through the SDK
or the web application.

!!! example
??? code-block "SDK Example"

Here is an example of how to set up an AWS Event Bridge Retrain Trigger using the SDK:

```py
client.set_retrain_trigger(
Expand Down Expand Up @@ -147,11 +154,15 @@ The following retrain triggers are supported:

**Retrain Trigger Setup**

To integrate GCP Pub/Sub, you will need to create a set of GCP credentials, and add a policy that allows to put events in your Pub/Sub topic. Please refer to [this page](index.md) to know more.
To integrate GCP Pub/Sub, you need to create a set of GCP credentials, and add a policy that allows to put events
in your Pub/Sub topic. Please refer to [this page](index.md) for more information.

Once the credentials and the policy have been created, you can set up the retrain trigger for your model through the SDK or the web application.
Once the credentials and the policy have been created, you can set up the retrain trigger for your model through the SDK or
the web application.

!!! example
??? code-block "SDK Example"

Here is an example of how to set up a GCP Pub/Sub Retrain Trigger using the SDK:

```py
client.set_retrain_trigger(
Expand Down Expand Up @@ -198,11 +209,14 @@ The following retrain triggers are supported:

**Retrain Trigger Setup**

To integrate Azure Event Grid, you will need to create a set of Azure credentials, and add a role that allows to publish events in your Event Grid topic. Please refer to [this page](index.md) to know more.
To integrate Azure Event Grid, you need to create a set of Azure credentials, and add a role that allows to publish events in your Event Grid topic.
Please refer to [this page](index.md) for more information.

Once the credentials and the policy have been created, you can set up the retrain trigger for your model through the SDK or the web application.

!!! example
??? code-block "SDK Example"

Here is an example of how to set up an Azure Event Grid Retrain Trigger using the SDK:

```py
client.set_retrain_trigger(
Expand Down
95 changes: 84 additions & 11 deletions md-docs/user_guide/model.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,93 @@
# Model

In the ML Cube Platform, a Model is a representation of the actual artificial intelligence model used for making predictions. The data used
for its training usually represent the reference data distribution, while production data comprises the data on which the model
performs inference.
For more information about reference and production data see the [Data] page.

A Model is uniquely associated with a [Task] and it can be created both through the WebApp and the Python SDK.
Currently, we support only one model per Task.

A Model is defined by a name and a version. The version is updated whenever the model is retrained, allowing to
track the latest version of the model and the data used for its training. When predictions are uploaded to the platform,
the model version needs to be appropriately specified, following the guidelines in the [Data Schema] page, to ensure that the
predictions are associated to the correct model version.

[//]: # ()
[//]: # ()
[//]: # (What is additional probabilistic output?)
!!! note
You don't need to upload the **real** model on the Platform. We only require its training data and predictions.
The entity you create on the Platform serves more as a placeholder for the actual model. For this reason,
the ML cube Platform is considered *model agnostic*.

[//]: # ()
[//]: # (What is metric?)

[//]: # ()
[//]: # (What is suggestion type?)
### RAG Model

[//]: # ()
[//]: # (What is retraining cost?)
RAG Tasks represent an exception to the model framework presented before. In this type of Tasks, the model
is a Large Language Model (LLM), that is used to generate responses to user queries. The model is not trained on a specific dataset
but is rather a pre-trained model, sometimes finetuned on custom domain data, which means that the classic process of training and
retraining does not apply.

[//]: # ()
[//]: # (What is retraining trigger?)
To maintain a coherent Model definition across task types, the RAG model is also represented as a Model,
but an update of its version represents an update of the reference data distribution and not necessarily
a retraining of the model itself. Moreover, most of the attributes which will be described in the following sections
are not applicable, as they are related to the retraining module, which is not available for RAG tasks.

### Probabilistic output

When creating a model, you can specify if you want to provide also the probabilistic output of the model along with the predictions.
The probabilistic output represents the probability or confidence score associated with the model's predictions. If provided,
the ML cube Platform will use this information to compute additional metrics and insights.

It is optional and currently supported only for Classification and RAG tasks. If specified, the probabilistic output must be provided
as a new column in the predictions file, following the guidelines in the [Data Schema] page.

!!! example
For example, Logistic Regression classification model provides both the probability of belonging to the positive class and the predicted class using a threshold.
In this case, you can upload to ML cube Platform the predicted class as principal prediction and the probability as probabilistic output.

### Model Metric

A Model Metric represents the evaluation metric used to assess the performance of the model.
It can both represent a performance or an error. The chosen metric will be used in the various views of the WebApp to
provide insights on the model's performance and in the [Performance View](modules/retraining.md#performance-view) section
of the Retraining Module.

!!! note
Note that model metrics can only be computed when target data are available.

The available options are:

| Metric | Task Type |
|-------------------|----------------------------|
| Accuracy | Classification tasks |
| RMSE | Regression tasks |
| R2 | Regression tasks |
| Average Precision | For Object Detection tasks |

RAG tasks have no metric, as in that case the model is an LLM for which classic definitions of metrics are not applicable.

!!! warning
Model Metrics should not be confused with [Monitoring Metrics](monitoring/index.md#monitoring-metrics), which are
entities being monitoring by the ML cube Platform and not necessarily related to a Model.

### Suggestion Type

The Suggestion Type represents the type of suggestion that the ML cube Platform should provide when computing the
[Retraining Dataset](modules/retraining.md#retraining-dataset). The available options are provided in the related section.


### Retraining Cost

The Retraining Cost represents the cost associated with retraining the model. This information is used by the Retraining Module
to provide gain-cost analysis and insights on the retraining process. The cost is expressed in the same currency as the one used
in the Task cost information. The default value is 0.0, which means that the cost is negligible.

### Retrain Trigger

You can associate a [Retrain Trigger] to your Model in order to enable the automatic initiation of your retraining pipeline
from the ML cube Platform. More information on how to set up a retrain trigger can be found in the related section.


[Task]: task.md
[Data Schema]: data_schema.md#subrole
[Retrain Trigger]: integrations/retrain_trigger.md
[Data]: data.md
2 changes: 1 addition & 1 deletion md-docs/user_guide/monitoring/detection_event_rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ data preceding the event, while the second one includes data following the event

Retrain Action enables the automatic retraining of your model. Therefore, it is only available when the target of the rule is related to a model.
The retrain action does not need any parameter because it is automatically inferred from the `model name` attribute of the rule.
Of course, the model must already have a retrain trigger associated before setting up this action.
Of course, the model must already have a [Retrain Trigger](../integrations/retrain_trigger.md) associated before setting up this action.

??? code-block "SDK Example"
The following code demonstrates how to create a rule that matches high severity drift events on the error of a model.
Expand Down