Associate an Event Recommendations (ER) Model With a Query Pipeline

When a Coveo Machine Learning (Coveo ML) Event Recommendations (ER) model has been created, it must be associated with a query pipeline to be effective in a search interface.

Organization members with the required privileges can access the Machine Learning tab of a query pipeline configuration page to manage Coveo ML model associations for that query pipeline.

Leading Practices

Duplicate the Production Query Pipeline

Once you have created a Coveo ML ER model, the leading practice is to duplicate the query pipeline with which you plan to associate the model, and then associate the model with the pipeline copy.

Once satisfied with the model efficiency on the pipeline copy, dissociate the model from the test pipeline and associate it with the production pipeline. You can test your Coveo ML model’s efficiency by performing A/B tests or testing the model.

Once you’re done testing the model in the test pipeline, you can delete the test pipeline.

Validate That the Model Is Effective

To validate that your Coveo ML models work as expected, you can inspect your models.

Plan the Usage of Custom Contexts

While the various Coveo ML features can perform well without custom context information, using custom contexts can take Coveo ML relevance one step further.

You can define custom contexts and then pass appropriate ones along with usage analytics events and queries to allow Coveo ML to take them into account.

If you’re just getting started with Coveo ML, you can skip this step to take advantage of Coveo ML features more quickly and easily, and consider using custom contexts in a second phase.

Associate an ER Model

Follow the model association leading practices when associating your model with your query pipeline.

  1. On the Query Pipelines page, click the query pipeline for which you want to associate a ER model, and then in the Action bar, click Edit Components.

  2. On the subpage that opens, select the Machine Learning tab, and then in the upper-right corner, click Associate Model.

  3. In the Model drop-down menu, select the desired model.

    ER models cannot be associated with pipelines that contain other model types.

  4. On the right side, under Condition, you can optionally select a query pipeline condition in the drop-down menu or create a new one.

  5. Click Associate Model.

Associate all the ER models that serve a single use case to the same pipeline and assign each ER model its own condition.

For example, if you have multiple ER models that serve the same search hub, you could group them in the same query pipeline and assign each model a condition that triggers the model when appropriate (e.g., Context[userRole] is supportAgent).

Now that your ER model is associated with a pipeline, you must include a Coveo JavaScript Search Recommendation component in your website pages where you want to show recommendations from this model (see Coveo Machine Learning Event Recommendations Deployment Overview).

Edit an ER Model Association

Follow the model association leading practices when associating your model with your query pipeline.

  1. On the Query Pipelines page, click the query pipeline for which you want to edit a model association, and then in the Action bar, click Edit Components.

  2. On the subpage that opens, click the desired model, and then in the Action Bar, click Edit.

  3. On the right side, under Condition, you can optionally select a query pipeline condition in the drop-down menu or create a new one.

  4. Click Save.

Associate all the ER models that serve a single use case to the same pipeline and assign each ER model its own condition.

For example, if you have multiple ER models that serve the same search hub, you could group them in the same query pipeline and assign each model a condition that triggers the model when appropriate (e.g., Context[userRole] is supportAgent).

Now that your ER model is associated with a pipeline, you must include a Coveo JavaScript Search Recommendation component in your website pages where you want to show recommendations from this model (see Coveo Machine Learning Event Recommendations Deployment Overview).

Associate an ER Model via a JSON Configuration

Advanced users may want to manage a model association via a JSON configuration to specify association parameters that don’t fit with the parameters available in the Administration Console.

  1. On the Query Pipelines page, click the query pipeline for which you want to associate a model, and then in the Action bar, click Edit Components.

  2. On the subpage that opens, select the Machine Learning tab, and then in the upper-right corner, click menu-button, and select Associate a model in JSON view.

  3. On the Associate a Model subpage, in JSON view, replace the <Model_ID> placeholder with the actual ID of the model you want to associate with the pipeline (see Review Coveo Machine Learning Information).

    Once you have accessed the Associate a Model subpage in JSON view:

    • You can always go back to the Associate a Model subpage in the UI view and use the available options. However, all unsaved changes made in the Associate a Model subpage in JSON view will be lost.

    • The Associate a Model subpage in JSON view becomes the default model association view for that model. In other words, the Associate a Model subpage in JSON view is now automatically displayed when you access this model association.

  4. Click Associate Model.

Edit an ER Model Association via a JSON Configuration

Advanced users may want to manage a model association via a JSON configuration to specify association parameters that don’t fit with the parameters available in the Administration Console.

  1. On the Query Pipelines page, click the query pipeline for which you want to edit a model association, and then in the Action bar, click Edit Components.

  2. In the Machine Learning tab, click the desired model, and then in the Action bar, click Edit.

  3. On the Edit a Model Association subpage, click menu-button, and then select Switch to JSON view.

  4. On the Switch to JSON view? panel that appears, click Switch to JSON view.

    Switching to the JSON view of the Edit a Model Association subpage cancels unsaved configuration changes made on the Model Association page.

  5. On the Edit a Model Association subpage, in JSON view, tune the JSON model association configuration as needed (see Model Association Parameters).

    Once you have accessed the Associate a Model subpage in JSON view:

    • You can always go back to the Edit a Model Association subpage in the UI view and use the available options. However, all unsaved changes made in the Associate a Model subpage in JSON view will be lost.

    • If you specified non-default parameters in JSON view of the Edit a Model Association subpage, the complete configuration will be reset to the default one when switching back to the UI view of the Edit a Model Association subpage.

    • The Edit a Model Association subpage in JSON view becomes the default model association view for that model. In other words, the Edit a Model Association subpage in JSON view is now automatically displayed when you access this model association.

  6. Click Save.

Dissociate a Model

  1. On the Query Pipelines page, click the query pipeline from which you want to dissociate a model, and then in the Action bar, click Edit Components.

  2. On the subpage that opens, select the Machine Learning tab.

  3. In the Machine Learning tab, click the model you want to dissociate from the pipeline, and then in the Action Bar, click Dissociate.

The model is now dissociated from the pipeline.

Reorder Model Associations

The Coveo ML models of a given type are executed in the order in which they appear in the page until a condition is satisfied.

The first model on the list will be used if no conditions are met.

  1. On the Query Pipelines page, click the query pipeline in which you want to reorder model associations, and then in the Action bar, click Edit Components.

  2. On the subpage that opens, select the Machine Learning tab.

  3. In the Machine Learning tab of the desired query pipeline, click the model whose position you want to change.

  4. In the Action bar, use the Move up or Move down arrows to change the position of the model.

Reference

Model Association Parameters

You can use the following parameters when creating or editing a Coveo ML ER model association.

id (string)

The unique identifier of the model association (automatically generated by the Coveo Search API).

Example: 62579f33-a505-4d07-b77d-545aefb2eea1

position (integer [int32])

The position of the model in the order of execution (see Reorder Model Associations).

Example: 8

modelId (string)

The unique identifier of the model (see Reviewing Coveo Machine Learning Model Information).

Example: c7ab60e2-e6b8-41e8-be6a-ad5c8edc662e

modelDisplayName (string)

The name of the model as selected when creating the model. This field is automatically filled with the name of the Coveo ML model.

Example: MyModelName

modelEngine (string)

The ID of the Coveo ML model (see Creating a Model With JSON). This field is automatically filled with the ID of the Coveo ML model.

Example: topclicks

modelStatus (string)

The status of the model. This field is automatically generated according to the current ML model status.

Example: ONLINE

condition (string)

The unique identifier of the condition that must be satisfied for a request to be processed by the ML model.

Example: c7ab60e2-e6b8-41e8-be6a-ad5c8edc662e

conditionDefinition (string)

The QPL expression that indicates the condition defined for the model association (see Query Pipeline Language (QPL)). This field is automatically filled when a condition is specified.

Example: when $searchHub is \"internalSearch\"

cacheMaximumAge (string)

The maximum age of cached query results the ML model should accept, in the ISO-8601 format only including the seconds and milliseconds part.

For each incoming query to be processed by the ML model, if a result set for an identical previously made query is available in the cache and this result set isn’t older than the specified value, the ML model makes recommendations based on that cached query result set. Otherwise, the query is executed against the index.

Default: PT105

useAdvancedConfiguration (boolean)

Whether the model association specifies an advanced configuration.

Default: false

rankingModifier (integer [int32])

The ranking score modifier the ML model should apply to each item it recommends.

Default: 0

exclusive (boolean)

Whether the Search API should only return items which were recommended by the ML model, even if other items matching the query were found in the index.

Default: true

customQueryParameters (JValue (object))

A JSON object representing the additional parameters to send to Coveo ML on all queries.

You can use this object, for instance, to configure your ER model to recommend the most popular or trending items by using the padding parameter.

EXAMPLES
  • You want an ER model to recommend the most viewed items only, regardless of the item the user is currently looking at. Therefore, you configure the maxActionsHistoryItemsToConsider mlParameter to 0 and padding to the popular value as follows:

    {
      "position": 1,
      "modelId": "XXXXXX_eventrecommendation_XXXXXXXX_XXXX_XXXX_XXXX_XXXXXXXXXXXX",
      "condition": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
      "modelEngine": "eventrecommendation",
      "rankingModifier": 1000,
      "cacheMaximumAge": "PT10S",
      "exclusive": true,
      "customQueryParameters": {
        "maxActionsHistoryItemsToConsider": 0, (1)
        "padding": "popular" (2)
      },
      "useAdvancedConfiguration": false
    }
    1 Sets the maxActionsHistoryItemsToConsider parameter to 0, meaning that the model don’t consider any events in the actionsHistory array of the request.
    2 Sets the padding parameter to the popular value so that the model uses the most popular items as recommendations.
  • You want your recommendation interface to always display 10 recommended items, even if the model cannot provide the requested number of recommendations. Therefore, you configure the padding mlParameter to the popular value and the num parameter to 10.

    {
      "position": 1,
      "modelId": "XXXXXX_eventrecommendation_XXXXXXXX_XXXX_XXXX_XXXX_XXXXXXXXXXXX",
      "condition": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
      "modelEngine": "eventrecommendation",
      "rankingModifier": 1000,
      "cacheMaximumAge": "PT10S",
      "exclusive": true,
      "customQueryParameters": {
        "padding": "popular", (1)
        "num": 10 (2)
      },
      "useAdvancedConfiguration": false
    }
    1 Sets the padding parameter to the popular value to fill a potential lack of available candidate items with most popular documents.
    2 Sets the num parameter to 10 to ensure that 10 recommendations are returned. Note that the num mlParameter indicates the maximum number of recommendations that the model returns before the Coveo Search API and the index apply subsequent filters, such as query pipeline rules or item permissions.

maxRecommendations (integer [int32])

The maximum number of recommendations the ML model should return.

Default: 10

The maxRecommendations parameter value indicates the maximum number of recommendations that the model returns before the Coveo Search API and the index apply subsequent filters (e.g., query pipeline rules or item permission).

For example, a query pipeline containing a recommendation model can be configured to return five recommendations. Since some of the items that the model can recommend are not accessible to the user or have been filtered out by a query pipeline rule, the user sees only three recommended items.

Setting maxRecommendations to a higher value lets the model query for more items, ensuring that the user obtains the expected number of recommendations.

Code Sample

The following code sample shows a ER model association in JSON:

{
  "position": 1,
  "modelId": "XXXXXX_eventrecommendation_XXXXXXXX_XXXX_XXXX_XXXX_XXXXXXXXXXXX",
  "condition": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
  "useAdvancedConfiguration": false
}

For complete information on ER model available association parameters, see ER Model Association Parameters Reference.

Required Privileges

By default, members of the Administrators and Relevance Managers built-in groups can view and edit elements of the Models page.

The following table indicates the privileges required to use elements of the Models page and associated panels (see Manage Privileges and Privilege Reference).

Action Service - Domain Required access level

View model associations

Machine Learning - Models

Search - Query pipelines

View

Edit model associations

Machine Learning - Models

Search - Query pipelines

Edit

Recommended Articles