models.install

Prev Next

Description

Initiates an asynchronous installation of a specified machine learning (ML) model from your app's locker.

When installation completes, the model is stored inside the runtime's cache object using a provided key.

The Ux.ResourceReady event is triggered so you can take action when your model becomes available.


Input Parameters

Name Type Required Description
token Text Yes Model's locker token
key Text Yes Unique cache key where model will be stored

Returns

No return value.


Examples

// inside the Ux.Initialize script...
// install model from app's locker using its token
ai.models.install("TOKEN", "riskModel");
JavaScript

Model Formats

The following model formats are supported:

Name Description
javascript Javascript model format
bayesialab Bayesialab model format
tf * Tensor Flow model format
onnx * Open ONNX AI CNN format

Formats with an asterisk coming soon


Remarks

Use this function to install a previously trained machine learning (ML) model that you would like to use while your app is running.

One common scenario is to install a model during intialization. Next, as a user interacts with your app in realtime, gather their inputs (using the Ux.Change event) and run them through your model. Finally, display model results inside the attached insights panel or adjust your app's language output.

Two-Step Process

Installing models can be slow based on connection speeds and the size of the models being downloaded.

As a result, downloading models requires a two-step process. First, you must initiate the installation from one script (typically Ux.Initialize). Second, you run the model (using ai.models.run) after the installation completes from another script (typically Ux.ResourceReady or Ux.Change).

By separating these steps, the user's experience remains fluid. Otherwise, the user interface would freeze until the installation completes, resulting in a poor user experience.