Associate a Content Recommendation (CR) model with a query pipeline
Associate a Content Recommendation (CR) model with a query pipeline
When a Coveo Machine Learning (Coveo ML) 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
Test the model efficiency
Once you’ve created a Coveo ML CR model, the leading practice is to test the model performance by doing an A/B test.
This allows you to test the model on a chosen proportion of the traffic passing through a given query pipeline. You can then assess the impact of the model by comparing the query pipeline search performance metrics with and without the model.
Once satisfied with the model efficiency, you can stop the A/B test to make the model effective for all the traffic passing through the query 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 Coveo ML models 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.
Notes
|
Associate a CR Model
Follow the model association leading practices when associating your model with your query pipeline. |
-
On the Query Pipelines (platform-ca | platform-eu | platform-au) page, click the query pipeline for which you want to associate the model, and then click Edit components in the Action bar.
-
On the subpage that opens, select the Machine Learning tab, and then in the upper-right corner, click Associate Model.
-
In the Model dropdown menu, select the desired model.
CR models should not be associated with pipelines that contain other model types.
-
On the right side, under Condition, you can select a query pipeline condition in the dropdown menu or create a new one.
-
Click Associate Model.
Leading practice
Associate all the CR models that serve a single use case to the same pipeline and assign each CR model its own condition. For example, if you have multiple CR 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 (for example, Context[userRole] is supportAgent). |
Note
Now that your CR model is associated with a pipeline, you must include a Coveo JavaScript Search |
Edit a CR Model Association
Follow the model association leading practices when associating your model with your query pipeline. |
-
On the Query Pipelines (platform-ca | platform-eu | platform-au) page, click the query pipeline for which you want to edit a model association, and then click Edit components in the Action bar.
-
On the subpage that opens, select the Machine Learning tab, click the desired model, and then click Edit in the Action bar.
-
On the right side, under Condition, you can select a query pipeline condition in the dropdown menu or create a new one.
-
Click Save.
Leading practice
Associate all the CR models that serve a single use case to the same pipeline and assign each CR model its own condition. For example, if you have multiple CR 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 (for example, Context[userRole] is supportAgent). |
Note
Now that your CR model is associated with a pipeline, you must include a Coveo JavaScript Search |
Associate a CR 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.
-
On the Query Pipelines (platform-ca | platform-eu | platform-au) page, click the query pipeline for which you want to associate a model, and then click Edit components in the Action bar.
-
On the subpage that opens, select the Machine Learning tab, and then in the upper-right corner, click , and select Associate a model in JSON view.
-
On the Associate a Model subpage, in JSON view, replace the
<Model_ID>
placeholder with the actualID
of the model you want to associate with the pipeline (see Review model information).NoteOnce 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 on 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.
-
-
Click Associate Model.
Edit a CR 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.
-
On the Query Pipelines (platform-ca | platform-eu | platform-au) page, click the query pipeline for which you want to edit a model association, and then click Edit components in the Action bar.
-
In the Machine Learning tab, click the desired model, and then click Edit in the Action bar.
-
On the Edit a Model Association subpage, click , and then select Switch to JSON view.
-
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.
-
On the Edit a Model Association subpage, in JSON view, tune the JSON model association configuration as needed (see Model association parameters).
NoteOnce 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 on 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.
-
-
Click Save.
Dissociate a model
-
On the Query Pipelines (platform-ca | platform-eu | platform-au) page, click the query pipeline from which you want to dissociate a model, and then click Edit components in the Action bar.
-
On the subpage that opens, select the Machine Learning tab.
-
In the Machine Learning tab, click the model you want to dissociate from the pipeline, and then click Dissociate in the Action bar.
Reorder model associations
The Coveo ML models of a given type are executed in the order in which they appear on the page until a condition is satisfied.
The first model on the list will be used if no conditions are met. |
-
On the Query Pipelines (platform-ca | platform-eu | platform-au) page, click the query pipeline in which you want to reorder model associations, and then click Edit components in the Action bar.
-
On the subpage that opens, select the Machine Learning tab.
-
In the Machine Learning tab of the desired query pipeline, click the model whose position you want to change, and then use the Move up or Move down arrows in the Action bar to change the position of the model.
Reference
Model association parameters
You can use the following parameters when creating or editing a Coveo ML CR 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 Review 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. This field is automatically filled with the ID of the Coveo ML model.
Example: eventrecommendation
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
locale
(string)
The locale of the current user.
Adding a locale
parameter to a model association allows Coveo ML to provide more relevant recommendations by taking into account the user’s language and regional preferences.
The locale
for a user in the United States would be: en-US
.
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 CR model to recommend the most popular or trending items by using the padding
parameter.
-
You want a CR model to recommend the most viewed items only, regardless of the item the user is currently looking at. Therefore, you configure the
maxActionsHistoryItemsToConsider
mlParameter
to0
andpadding
to thepopular
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, "padding": "popular" }, "useAdvancedConfiguration": false }
Sets the maxActionsHistoryItemsToConsider
parameter to0
, meaning that the model don’t consider any events in theactionsHistory
array of the request.Sets the padding
parameter to thepopular
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 thepopular
value and thenum
parameter to10
.{ "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", "num": 10 }, "useAdvancedConfiguration": false }
Sets the padding
parameter to thepopular
value to fill a potential lack of available candidate items with most popular documents.Sets the num
parameter to10
to ensure that 10 recommendations are returned. Note that thenum
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
Note
The 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 |
Code sample
The following code sample shows a CR 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 CR model available association parameters, see CR model association parameters reference.
Required privileges
By default, members with the required privileges can view and edit elements of the Models (platform-ca | platform-eu | platform-au) 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 |
View |
Edit model associations |
Organization - Organization |
View |
Search - Query pipelines |
Edit |