The retrieval configuration maps to RecallConfs on the configuration overview.
Configuration
The PAI-Rec engine supports built-in recall templates, including collaborative filtering (UserCollaborativeFilterRecall), vector recall (HologresVectorRecall), and U2I recall (UserCustomRecall), as well as data sources such as Hologres, PAI-FeatureStore, and Tablestore.
Common recall configurations
Each recall configuration uses a subset of the common configuration. This section explains these common settings to avoid repeating them in the documentation for each specific recall configuration.
Configuration example:
{
"RecallConfs": [
{
"Name": "collaborative_filter",
"RecallType": "UserCollaborativeFilterRecall",
"RecallCount": 1000,
"RecallAlgo": "",
"ItemType": "",
"CacheAdapter": "",
"CacheConfig": "",
"CachePrefix": "",
"CacheTime": 0
}
]
}Parameter | Type | Required | Description |
Name | string | Yes | A custom name for the recall configuration, referenced in |
RecallType | string | Yes | The built-in recall type. Supported values include:
|
RecallCount | string | Yes | The number of items to recall. |
RecallAlgo | string | No | For real-time vector recall only. Specifies the name of the vector model to use, which must be pre-configured in |
ItemType | string | No | The type of item to recommend. |
CacheAdapter | string | No | Specifies the adapter for caching recall results. Supported values:
|
CacheConfig | string | No | The configuration settings for the cache. Example for Redis: Example for |
CachePrefix | string | No | A prefix prepended to the cache key for recall results. This parameter is required when caching is enabled to prevent key collisions between different recall configurations. For example,
|
CacheTime | string | No | The cache duration in seconds. The default value is 1800. |
Collaborative filtering (UserCollaborativeFilterRecall)
Hologres
Collaborative filtering requires two tables with fixed schemas: a u2i table to retrieve an item list based on a user_id, and an i2i table to retrieve similar items.
In addition to retrieving similar items directly from an i2i table (the u2i2i method), you can also retrieve them indirectly by using an i2x table and an x2i table (the u2i2x2i method). In this approach, 'x' represents an item attribute, such as a category, brand, or city. The process first retrieves the 'x' attribute of an item (for example, the category field) and then uses the x2i table to fetch popular items that share this attribute value for recommendation.
u2i table
Parameter | Type | Description |
user_id | string | The user ID. This value must be unique. |
item_ids | string | A list of item IDs that the user has browsed. Supported formats: or |
i2i table (required only for u2i2i)
Parameter | Type | Description |
item_id | string | The item ID. This value must be unique. |
similar_item_ids | string | A list of items similar to |
i2x table (required only for u2i2x2i)
Parameter | Type | Description |
item_id | string | The item ID. This value must be unique. |
x | string | An item attribute. The column name is customizable and must be specified in the engine configuration. |
x2i table (required only for u2i2x2i)
Parameter | Type | Description |
x | string | An item attribute. The column name is customizable and must be specified in the engine configuration. |
item_id | string | The item ID. Use a comma (,) to separate multiple values. |
u2i2i configuration example:
{
"RecallConfs": [
{
"Name": "collaborative_filter",
"RecallType": "UserCollaborativeFilterRecall",
"RecallCount": 1000,
"UserCollaborativeDaoConf": {
"AdapterType": "hologres",
"HologresName": "holo_info",
"User2ItemTable": "u2i_table",
"Item2ItemTable": "i2i_table",
"Normalization": "on"
}
}
]
}u2i2x2i configuration example:
{
"RecallConfs": [
{
"Name": "collaborative_filter",
"RecallType": "UserCollaborativeFilterRecall",
"RecallCount": 1000,
"UserCollaborativeDaoConf": {
"AdapterType": "hologres",
"HologresName": "holo_info",
"User2ItemTable": "u2i_table",
"Item2XTable": "i2x_table",
"X2ItemTable": "x2i_table",
"XKey": "category",
"XDelimiter": ",",
"Normalization": "on"
}
}
]
}UserCollaborativeDaoConfig
Parameter | Type | Required | Description |
AdapterType | string | Yes | Fixed value: |
HologresName | string | Yes | The name of the Hologres instance, as defined in the data source configuration ( |
User2ItemTable | string | Yes | The name of the u2i table. |
Item2ItemTable | string | No | The name of the i2i table. This parameter is required for the |
Item2XTable | string | No | The name of the i2x table. This parameter is required for the |
X2ItemTable | string | No | The name of the x2i table. This parameter is required for the |
XKey | string | No | The name of the attribute column ( |
XDelimiter | string | No | The delimiter for 'x' values. By default, 'x' values are not split. |
Normalization | string | No | Specifies whether to normalize recalled items. Valid values: |
PAI-FeatureStore
Collaborative filtering requires two tables with fixed schemas: a u2i table to retrieve an item list based on a user_id, and an i2i table to retrieve similar items.
The data for both tables is generated in MaxCompute and must be registered with PAI-FeatureStore as offline views. The required MaxCompute table schema is described below.
u2i table
Parameter | Type | Description |
user_id | string | The user ID. This value must be unique. |
item_ids | string | A list of item IDs that the user has browsed. Supported formats: or |
ds | string | The MaxCompute table partition field. |
The following example shows how to register data with PAI-FeatureStore:
i2i table
Parameter | Type | Description |
item_id | string | The item ID. This value must be unique. |
similar_item_ids | string | A list of items similar to |
dt | string | The MaxCompute table partition field. |
Configuration example:
{
"RecallConfs": [
{
"Name": "collaborative_filter",
"RecallType": "UserCollaborativeFilterRecall",
"RecallCount": 1000,
"UserCollaborativeDaoConf": {
"AdapterType": "featurestore",
"FeatureStoreName": "fs_pairec",
"User2ItemFeatureViewName": "u2i_recall",
"Item2ItemFeatureViewName": "i2i_collaborative",
"Normalization": "on"
}
}
]
}UserCollaborativeDaoConfig
Parameter | Type | Required | Description |
AdapterType | string | Yes | Fixed value: |
FeatureStoreName | string | Yes | The name of the PAI-FeatureStore instance, as defined in the data source configuration ( |
User2ItemFeatureViewName | string | Yes | The name of the view that corresponds to the u2i table. |
Item2ItemFeatureViewName | string | Yes | The name of the view that corresponds to the i2i table. |
Normalization | string | No | Specifies whether to normalize recalled items. Valid values: |
Tablestore
Collaborative filtering requires two tables with fixed schemas: a u2i table to retrieve an item list based on a user_id, and an i2i table to retrieve similar items.
u2i table
Parameter | Type | Description |
user_id | string | The user ID. This value must be unique. |
item_ids | string | A list of item IDs that the user has browsed. Supported formats: or |
i2i table
Parameter | Type | Description |
item_id | string | The item ID. This value must be unique. |
similar_item_ids | string | A list of items similar to |
{
"RecallConfs": [
{
"Name": "collaborative_filter",
"RecallType": "UserCollaborativeFilterRecall",
"RecallCount": 1000,
"UserCollaborativeDaoConf": {
"AdapterType": "tablestore",
"TableStoreName": "tablestore_info",
"User2ItemTable": "u2i_table",
"Item2ItemTable": "i2i_table",
"Normalization": "on"
}
}
]
}Parameter | Type | Required | Description |
AdapterType | string | Yes | Fixed value: |
TableStoreName | string | Yes | The name of the Tablestore instance, as defined in the data source configuration ( |
User2ItemTable | string | Yes | The name of the u2i table. |
Item2ItemTable | string | Yes | The name of the i2i table. |
Normalization | string | No | Specifies whether to normalize recalled items. Valid values: |
Redis
The collaborative filtering process for Redis is unique, involving two steps:
Construct a key by concatenating the
RedisPrefixvalue with the user ID (uid) to query the u2i list. The result is a string in one of the following formats:item_id1,item_id2,item_id3...oritem_id1:score1,item_id2:score2,item_id3:score3....Query the i2i list. Use the
MGETcommand with the item IDs obtained in the previous step. The i2i data is also a string, with the following format:item_id1:score1,item_id2:score2,item_id3:score3....
Configuration example:
{
"RecallConfs": [
{
"Name": "collaborative_filter",
"RecallType": "UserCollaborativeFilterRecall",
"RecallCount": 1000,
"UserCollaborativeDaoConf": {
"AdapterType": "redis",
"RedisName": "redis_info",
"RedisPrefix": "cr_",
"Normalization": "on"
}
}
]
}Parameter | Type | Required | Description |
AdapterType | string | Yes | Fixed value: |
RedisName | string | Yes | The name of the Redis instance, as defined in the data source configuration ( |
RedisPrefix | string | No | The prefix for the u2i data key. This prefix is prepended to the user ID ( |
Redis is the only supported data cache.
Real-time U2I2I (RealTimeU2IRecall)
Hologres
This approach retrieves data using the same logic as collaborative filtering, but computes U2I data in real time from a user historical behavior table.
The system updates the user historical behavior table in real time based on logs, enabling real-time recall.
Like collaborative filtering, this method also supports u2i2x2i. First, it retrieves an item's x attribute, and then recalls other items that have the same attribute.
User historical behavior table
Field | Type | Description |
user_id | string | The user ID. |
item_id | string | The ID of the item that the user browsed. |
event | string | The event name. |
play_time | float | The duration of the event, such as the watch time of a video. Set to 0 if not applicable. |
timestamp | int | The timestamp of the event, in seconds. |
i2i table (required only for u2i2i)
Field | Type | Description |
item_id | string | The item ID. This value must be unique. |
similar_item_ids | string | A list of items similar to item_id. The supported format is: item_id1:score1,item_id2:score2,item_id3:score3... |
i2x table (required only for u2i2x2i)
item_id | string | The item ID. This value must be unique. |
x | string | An attribute of the item. The column name is customizable and must be specified in the engine configuration. |
x2i table (required only for u2i2x2i)
x | string | An attribute of the item. The column name is customizable and must be specified in the engine configuration. |
item_id | string | The item ID. Use commas (,) to separate multiple values. |
Statement for creating the behavior table:
BEGIN;
CREATE TABLE "sv_rec"."user_behavior_seq" (
"user_id" text NOT NULL,
"item_id" text NOT NULL,
"event" text NOT NULL,
"play_time" float8 NULL,
"timestamp" int8 NOT NULL
);
CALL SET_TABLE_PROPERTY('"sv_rec"."user_behavior_seq"', 'orientation', 'column');
call set_table_property('table_name', 'distribution_key', '"user_id"');
CALL SET_TABLE_PROPERTY('"sv_rec"."user_behavior_seq"', 'clustering_key', '"user_id:asc","timestamp:desc"');
CALL SET_TABLE_PROPERTY('"sv_rec"."user_behavior_seq"', 'bitmap_columns', '"user_id","event"');
CALL SET_TABLE_PROPERTY('"sv_rec"."user_behavior_seq"', 'dictionary_encoding_columns', '"user_id:auto","item_id:auto","event"');
CALL SET_TABLE_PROPERTY('"sv_rec"."user_behavior_seq"', 'time_to_live_in_seconds', '2592000');
comment on table "sv_rec"."user_behavior_seq" is 'User real-time behavior sequence';
comment on column "sv_rec"."user_behavior_seq"."user_id" is 'User ID';
comment on column "sv_rec"."user_behavior_seq"."item_id" is 'Item ID';
comment on column "sv_rec"."user_behavior_seq"."event" is 'Event type';
comment on column "sv_rec"."user_behavior_seq"."play_time" is 'Reading or playback duration';
comment on column "sv_rec"."user_behavior_seq"."timestamp" is 'Timestamp, in seconds';
COMMIT;Configuration example:
{
"RecallConfs": [
{
"Name": "RealTimeEtrecRecall",
"RecallType": "RealTimeU2IRecall",
"RecallCount": 200,
"RealTimeUser2ItemDaoConf": {
"UserTriggerDaoConf": {
"AdapterType": "hologres",
"HologresName": "holo_info",
"HologresTableName": "user_behavior_table",
"WhereClause": "event='xxx'",
"Limit": 200,
"EventPlayTime": "playback:5000;playvslide:5000",
"EventWeight": "playback:1;playvslide:2",
"WeightExpression": "exp((-0.2)*((currentTime-eventTime)/3600/24))",
"WeightMode": "sum",
"NoUsePlayTimeField": false
},
"Item2ItemTable": "i2i_table",
"SimilarItemIdField": "similar_item_ids"
}
}
]
}u2i2x2i configuration example:
{
"RecallConfs": [
{
"Name": "RealTimeU2I2X2IRecall",
"RecallType": "RealTimeU2IRecall",
"RecallCount": 200,
"RealTimeUser2ItemDaoConf": {
"UserTriggerDaoConf": {
"AdapterType": "hologres",
"HologresName": "holo_info",
"HologresTableName": "user_behavior_table",
"WhereClause": "event='xxx'",
"Limit": 200,
"EventPlayTime": "playback:5000;playvslide:5000",
"EventWeight": "playback:1;playvslide:2",
"WeightExpression": "exp((-0.2)*((currentTime-eventTime)/3600/24))",
"WeightMode": "sum",
"NoUsePlayTimeField": false
},
"Item2XTable": "i2x_table",
"X2ItemTable": "x2i_table",
"XKey": "category",
"XDelimiter": ","
}
}
]
}RealTimeUser2ItemDaoConf:
Field | Type | Required | Description |
AdapterType | string | Yes | Fixed value: hologres. |
HologresName | string | Yes | The custom name of the Hologres instance, configured in the HologresConfs data source configuration. For example, holo_info. |
HologresTableName | string | Yes | The name of the user historical behavior table in Hologres. |
WhereClause | string | No | The filter condition, equivalent to an SQL WHERE clause. |
Limit | int | No | The query limit, equivalent to an SQL LIMIT clause. |
EventPlayTime | string | No | Filters events by play duration. For example, e_sv_func_svplayback:5000 means that for this event type, the play_time value must be greater than 5000. Events that do not meet this condition are filtered out. Use semicolons (;) to separate multiple event filters. |
EventWeight | string | No | You can define a weight for each event. The default is 1. |
WeightExpression | string | No | An expression for calculating an event's weight based on time decay. currentTime represents the current timestamp, and eventTime represents the timestamp from the behavior table. |
WeightMode | string | No | The method for calculating the trigger weight. Valid values are sum and max. The default is sum. |
NoUsePlayTimeField | bool | No | Set to true if you do not use the play_time field. |
Item2ItemTable | string | No | The name of the i2i table in Hologres. This parameter is required for the u2i2i method. |
SimilarItemIdField | string | No | The name of the field in the i2i table in Hologres. Default value: similar_item_ids. |
Item2XTable | string | No | The name of the i2x table. This parameter is required for the u2i2x2i method. |
X2ItemTable | string | No | The name of the x2i table. This parameter is required for the u2i2x2i method. |
XKey | string | No | The x key. Its value is the name of the x column in the i2x and x2i tables. This parameter is required for the u2i2x2i method. |
XDelimiter | string | No | The delimiter for x values. By default, x values are not split. |
PAI-FeatureStore
This approach retrieves data using the same logic as collaborative filtering, but computes U2I data in real time from a user historical behavior table.
The system updates the user historical behavior table in real time based on logs, enabling real-time recall.
On the PAI-FeatureStore platform, you can use a behavior sequence feature view to store user historical behavior data.
User historical behavior table
Field | Type | Description |
user_id | string | The user ID. |
item_id | string | The ID of the item that the user browsed. |
event | string | The event name. |
playtime | float | The duration of the event, such as the watch time of a video. Set to 0 if not applicable. |
event_unix_time | int | The timestamp of the event, in seconds. |
i2i table
Field | Type | Description |
item_id | string | The item ID. This value must be unique. |
similar_item_ids | string | A list of items similar to item_id. The supported format is: item_id1:score1,item_id2:score2,item_id3:score3... |
Configuration example:
{
"RecallConfs": [
{
"Name": "realtimeu2i",
"RecallType": "RealTimeU2IRecall",
"RecallCount": 200,
"RealTimeUser2ItemDaoConf": {
"UserTriggerDaoConf": {
"AdapterType": "featurestore",
"FeatureStoreName": "fs_pairec",
"FeatureStoreViewName": "user_behavior_table",
"TriggerCount": 100,
"EventWeight": "click:1;order:1",
"WeightExpression": "exp((-0.2)*((currentTime-eventTime)/3600/24))",
"WeightMode": "sum",
"NoUsePlayTimeField": false,
"ItemIdFieldName": "item_id",
"EventFieldName": "event",
"PlayTimeFieldName": "playtime",
"TimestampFieldName": "event_unix_time"
},
"Item2ItemFeatureViewName": "i2i_collaborative",
"SimilarItemIdField": "similar_item_ids"
}
}
]
}RealTimeUser2ItemDaoConf:
Field | Type | Required | Description |
UserTriggerDaoConf | |||
| string | Yes | Fixed value: featurestore. |
| string | Yes | The custom name of the PAI-FeatureStore project, configured in the FeatureStoreConfs data source configuration. For example, fs_pairec. |
| string | Yes | The name of the user historical behavior sequence feature view in PAI-FeatureStore. |
| int | Yes | The number of user behavior triggers. |
| string | No | Filters events by play duration. For example, e_sv_func_svplayback:5000 means that for this event type, the play_time value must be greater than 5000. Events that do not meet this condition are filtered out. You can specify multiple event filters, separated by semicolons (;). |
| string | Yes | You can define a weight for each event. The default weight is 1. Use a semicolon ( |
| string | Yes | An expression for calculating an event's weight based on time decay. currentTime represents the current timestamp, and eventTime represents the timestamp from the behavior table. |
| string | No | The method for calculating the trigger weight. Valid values are sum and max. The default is sum. |
| bool | No | Set to true if you do not use the play_time field. |
| string | No | The name of the item_id field in the user behavior sequence. Default value: item_id. |
| string | No | The name of the event field in the user behavior sequence. Default value: event. |
| string | No | The name of the play time field in the user behavior sequence. Default value: play_time. |
| string | No | The name of the timestamp field in the user behavior sequence. Default value: timestamp. |
Item2ItemFeatureViewName | string | No | The name of the i2i table's feature view in PAI-FeatureStore. This parameter is required for the u2i2i method. |
SimilarItemIdField | string | No | The name of the i2i table's field in PAI-FeatureStore. Default value: similar_item_ids. |
MergeMode | string | No | Controls how to merge items recalled by triggerId. By default, recalled items are combined, sorted, and deduplicated. The 'snake' value merges the recalled item lists by interleaving them. |
I2ICacheSize | int | No | If this value is greater than 0, caching is enabled. The triggerId is used as the cache key, and the list of items recalled from the i2i table is the cached value. |
I2ICacheTime | int | No | If caching is enabled, this parameter sets the cache duration in seconds. |
Hologres vector recall
Vector recall supports only Hologres as a data source. All vector data must be stored in Hologres tables.
Example configuration:
{
"RecallConfs": [
{
"Name": "vector_recall",
"RecallType": "HologresVectorRecall",
"RecallCount": 100,
"VectorDaoConf": {
"AdapterType": "hologres",
"HologresName": "holo_info",
"HologresTableName": "user_embedding_table",
"KeyField": "user_id",
"EmbeddingField": "emb"
},
"HologresVectorConf": {
"VectorTable": "item_embedding_table",
"VectorEmbeddingField": "emb",
"VectorKeyField": "item_id"
}
}
]
}VectorDaoConf:
Parameter | Type | Required | Description |
AdapterType | string | Yes | The data source type. Must be |
HologresName | string | Yes | The custom name for the Hologres data source, as defined in the |
HologresTableName | string | Yes | The name of the vector table in Hologres. |
KeyField | string | Yes | The primary key field in the vector table. |
EmbeddingField | string | Yes | The field that stores vector embeddings. |
HologresVectorConf:
Parameter | Type | Required | Description |
VectorTable | string | Yes | The item vector table in Hologres. |
VectorEmbeddingField | string | Yes | The field in the item vector table that stores vectors. |
VectorKeyField | string | Yes | The primary key field in the item vector table. |
The VectorDaoConf object defines the user vector table. The table is defined as follows:
BEGIN;
CREATE TABLE "public"."graphsage_user_embedding" (
"user_id" text NOT NULL,
"emb" float4[] NOT NULL,
"dt" text,
PRIMARY KEY ("user_id")
);
CALL SET_TABLE_PROPERTY('"public"."graphsage_user_embedding"', 'orientation', 'row');
CALL SET_TABLE_PROPERTY('"public"."graphsage_user_embedding"', 'clustering_key', '"user_id:asc"');
CALL SET_TABLE_PROPERTY('"public"."graphsage_user_embedding"', 'time_to_live_in_seconds', '3153600000');
comment on column "public"."graphsage_user_embedding"."user_id" is 'User ID';
comment on column "public"."graphsage_user_embedding"."emb" is 'User feature vector';
comment on column "public"."graphsage_user_embedding"."dt" is 'Date in yyyyMMdd format';
COMMIT;The HologresVectorConf table stores item vectors:
BEGIN;
CREATE TABLE "public"."graphsage_item_embedding" (
"item_id" text NOT NULL,
"emb" float4[] NOT NULL,
PRIMARY KEY ("item_id")
);
CALL SET_TABLE_PROPERTY('"public"."graphsage_item_embedding"', 'orientation', 'column');
CALL SET_TABLE_PROPERTY('"public"."graphsage_item_embedding"', 'bitmap_columns', '"item_id"');
CALL SET_TABLE_PROPERTY('"public"."graphsage_item_embedding"', 'time_to_live_in_seconds', '3153600000');
comment on column "public"."graphsage_item_embedding"."item_id" is 'item ID';
comment on column "public"."graphsage_item_embedding"."emb" is 'item feature vector';
COMMIT;Real-time Hologres vector recall (OnlineHologresVectorRecall)
Real-time vector recall is similar to standard vector recall, as both use data from a Hologres table. The key difference is that the user vector is generated in real time by a model, not retrieved from a table. This vector then queries the item vector table. The process has three main steps:
Retrieve user features by querying a data table.
Generate the user vector by calling the vector model deployed on Elastic Algorithm Service (EAS).
Similarly, query the item vector table to retrieve item vectors.
Example configuration:
{
"RecallConfs": [
{
"Name": "online_vector_recall",
"RecallType": "OnlineHologresVectorRecall",
"RecallCount": 500,
"UserFeatureConfs": [
{
"FeatureDaoConf": {
"AdapterType": "hologres",
"HologresName": "holo_info",
"FeatureKey": "user:uid",
"UserFeatureKeyName": "userid",
"HologresTableName": "user_all_feature_table",
"UserSelectFields": "*",
"FeatureStore": "user"
},
"Features": []
}
],
"RecallAlgo": "sv_v2_mind",
"HologresVectorConf": {
"HologresName": "holo_info",
"VectorTable": "item_embedding_table",
"VectorEmbeddingField": "item_emb",
"VectorKeyField": "item_id"
}
}
]
}Parameter | Type | Required | Description |
Name | string | Yes | Specifies the custom recall name. |
RecallType | string | Yes | Specifies the recall type. The value must be |
RecallCount | int | Yes | Specifies the recall count. |
RecallAlgo | string | Yes | Specifies the name of the vector model to use, which must be configured in |
UserFeatureConfs:
Parameter | Type | Required | Description |
AdapterType | string | Yes | The type of the data source. Must be |
HologresName | string | Yes | The name of the Hologres data source, as defined in |
FeatureKey | string | Yes | Specifies the source of the |
UserFeatureKeyName | string | Yes | The primary key field in the user feature table. |
HologresTableName | string | Yes | The name of the user feature table. |
UserSelectFields | string | Yes | Specifies the features to select. Use |
FeatureStore | string | Yes | Specifies where to store the features in the engine. Valid values: |
HologresVectorConf:
Parameter | Type | Required | Description |
HologresName | string | Yes | The name of the Hologres data source, defined in |
VectorTable | string | Yes | The name of the item vector table in Hologres. |
VectorEmbeddingField | string | Yes | The field in the item vector table that stores vector embeddings. |
VectorKeyField | string | Yes | The primary key field in the item vector table. |
The sv_v2_mind model is defined in AlgoConfs as follows:
{
"AlgoConfs": [
{
"Name": "sv_v2_mind",
"Type": "EAS",
"EasConf": {
"Processor": "EasyRec",
"Timeout": 100,
"ResponseFuncName": "easyrecUserEmbResponseFunc",
"Url": "http://xxx.vpc.cn-beijing.pai-eas.aliyuncs.com/api/predict/sv_v2_mind",
"Auth": "xxx"
}
}
]
}The configuration is the same as a ranking model's, except that the ResponseFuncName parameter must be set to easyrecUserEmbResponseFunc.
FAISS online vector recall
The OnlineVectorRecall component connects to an online vector recall service implemented with the TorchEasyRec Processor. Unlike OnlineHologresVectorRecall, OnlineVectorRecall does not rely on a Hologres item vector table for online retrieval. Instead, it performs feature encoding, User Tower inference, and FAISS TopK retrieval within the PAI-EAS service and directly returns a list of recalled items.
The online request process:
The PAI-Rec engine sends a request with the raw user features.
The TorchEasyRec Processor internally performs feature encoding for the FG module, which is consistent with the offline process.
The User Tower generates the user embedding via online inference.
The user embedding is used to retrieve the top-K similar items from the FAISS index.
A list of item IDs and their corresponding distance scores is returned for fine-ranking.
Example configuration file for a recommendation engine:
{
"RecallConfs": [{
"Name": "{model_name}",
"RecallType": "OnlineVectorRecall",
"RecallCount": 200,
"RecallAlgo": "{model_name}",
"VectorAlgoType": "torchrec_vector"
}],
"AlgoConfs": [{
"Name": "{model_name}",
"Type": "EAS",
"EasConf": {
"Processor": "EasyRec",
"ResponseFuncName": "torchrecEmbeddingItemsResponseFunc",
"Url": "http://{aliyun_id}.vpc.{region}.pai-eas.aliyuncs.com/api/predict/{model_name}",
"EndpointType": "DIRECT",
"Auth": "{eas_token}"
}
}]
}Parameter | Type | Required | Description |
Name | string | Yes | A custom name for the recall, which can be referenced in |
RecallType | string | Yes | The type of recall. The value must be |
RecallCount | int | Yes | The number of items to recall. |
RecallAlgo | string | Yes | The name of the online model to invoke. This model must be configured in |
VectorAlgoType | string | Yes | The algorithm for online vector recall. The value must be |
EasConf Configuration Parameters
Parameter | Type | Required | Description |
Processor | string | Yes | Set to |
ResponseFuncName | string | Yes | Set to |
Url | string | Yes | The service endpoint of EAS. |
EndpointType | string | No | The access mode. Example: |
Auth | string | Yes | The credentials that are used to access the EAS service. |
Note
RecallAlgomust matchAlgoConfs.Name.OnlineVectorRecalluses the EasyRec Processor online service for recall and requires no separate Hologres item vector table.In the current reference configuration,
VectorAlgoTypeistorchrec_vector.ResponseFuncNamemust betorchrecEmbeddingItemsResponseFunc.The online service internally performs FG encoding, User Tower inference, and FAISS search, then directly returns the recall results.
Differences from OnlineHologresVectorRecall
OnlineVectorRecall: Computes the user embedding, performs internal FAISS retrieval, and returns a list of items.OnlineHologresVectorRecall: Returns only the user embedding, allowing PAI-Rec to perform recall using the Hologres item vector table.
U2I recall (UserCustomRecall)
Hologres
Retrieves a list of items based on a user ID. The table uses a predefined schema.
U2I table
Parameter | Type | Description |
user_id | string | The user ID. |
item_ids | string | A list of item IDs. Supported formats: |
Configuration example:
{
"RecallConfs": [
{
"Name": "user2item_recall",
"RecallType": "UserCustomRecall",
"RecallCount": 500,
"DaoConf": {
"AdapterType": "hologres",
"HologresName": "holo_info",
"HologresTableName": "user_item_table"
}
}
]
}Parameter | Type | Required | Description |
Name | string | Yes | The custom name for the recall. |
RecallType | string | Yes | The recall type. Set this to |
RecallCount | int | Yes | The number of items to recall. |
DaoConf | json object | Yes | The DAO configuration. |
AdapterType | string | Yes | The data source type. Set this to |
HologresName | string | The custom name of the Hologres data source, as configured in | |
HologresTableName | string | Yes | The name of the U2I table in Hologres. |
PAI-FeatureStore
Retrieves a list of items based on a user ID. The table uses a predefined schema.
The data for this table is generated in MaxCompute and must be registered as an offline feature view in PAI-FeatureStore. The MaxCompute table must use the following schema.
U2I table
Parameter | Type | Description |
user_id | string | The user ID. |
item_ids | string | A list of item IDs. Supported formats: |
ds | string | The partition field of the MaxCompute table. This field name is customizable. |
Configuration example:
{
"RecallConfs": [
{
"Name": "user2item_recall",
"RecallType": "UserCustomRecall",
"RecallCount": 500,
"DaoConf": {
"AdapterType": "featurestore",
"FeatureStoreName": "fs_pairec",
"FeatureStoreViewName": "u2i_recall"
}
}
]
}Parameter | Type | Required | Description |
Name | string | Yes | The custom name for the recall. |
RecallType | string | Yes | The recall type. Set this to |
RecallCount | int | Yes | The number of items to recall. |
DaoConf | json object | Yes | The DAO configuration. |
AdapterType | string | Yes | The data source type. Set this to |
FeatureStoreName | string | The custom name of the PAI-FeatureStore data source, as configured in | |
FeatureStoreViewName | string | Yes | The name of the feature view for the U2I table. |
Tablestore
Retrieves a list of items based on a user ID. The table uses a predefined schema.
U2I table
Parameter | Type | Description |
user_id | string | The user ID. |
item_ids | string | A list of item IDs. Supported formats: |
Configuration example:
{
"RecallConfs": [
{
"Name": "user2item_recall",
"RecallType": "UserCustomRecall",
"RecallCount": 500,
"DaoConf": {
"AdapterType": "tablestore",
"TableStoreName": "ots_info",
"TableStoreTableName": "user_item_table"
}
}
]
}Parameter | Type | Required | Description |
Name | string | Yes | The custom name for the recall. |
RecallType | string | Yes | The recall type. Set this to |
RecallCount | int | Yes | The number of items to recall. |
DaoConf | json object | Yes | The DAO configuration. |
AdapterType | string | Yes | The data source type. Set this to |
TableStoreName | string | The custom name of the Tablestore data source, as configured in | |
TableStoreTableName | string | Yes | The name of the U2I table in Tablestore. |
Redis
Configuration example:
{
"RecallConfs": [
{
"Name": "user2item_recall",
"RecallType": "UserCustomRecall",
"RecallCount": 500,
"DaoConf": {
"AdapterType": "redis",
"RedisName": "redis_info",
"RedisPrefix": ""
}
}
]
}Parameter | Type | Required | Description |
Name | string | Yes | The custom name for the recall. |
RecallType | string | Yes | The recall type. Set this to |
RecallCount | int | Yes | The number of items to recall. |
DaoConf | json object | Yes | The DAO configuration. |
AdapterType | string | Yes | The data source type. Set this to |
RedisName | string | The custom name of the Redis data source, as configured in | |
RedisPrefix | string | Yes | The prefix for the U2I data key. The full key is constructed by concatenating this prefix with the user ID. The value can be a string in one of the following formats: |
GraphRecall
Graph retrieval, a type of U2I retrieval, uses the GraphCompute graph database.
Configuration example:
{
"RecallConfs": [
{
"Name": "graph_recall",
"RecallType": "GraphRecall",
"RecallCount": 500,
"GraphConf": {
"GraphName": "graph_test",
"ItemId": "item_id",
"QueryString": "g(\"test\").V(\"$1\").hasLabel(\"user\").outE().inV()",
"Params": [
"user.uid"
]
}
}
]
}GraphConf:
Parameter | Type | Required | Description |
Name | string | Yes | A custom name for the recall. |
RecallType | string | Yes | The recall type. The value must be |
RecallCount | int | Yes | The number of items to recall. |
GraphName | string | Yes | The name of the graph defined in the |
ItemId | string | Yes | The primary key of an item in the graph query results. |
QueryString | string | Yes | The Gremlin query string for graph recall. It supports placeholders, such as |
Params | string | Yes | The source of the values used to populate placeholders in the
|
User group hot recall (UserGroupHotRecall)
Hologres
The user group hot recall table has a predefined schema.
group_hot_table
Field | Type | Description |
trigger_id | string | An ID constructed from the values of multiple features. |
item_ids | string | A list of item IDs. Supported formats: |
The trigger_id combines user features and contextual information, such as region and OS.
Concatenate the feature values in order with an underscore (
_) to form thetrigger_id.If a feature value is empty, use the string "NULL".
Features that include a
Boundariesparameter must be discretized into left-open, right-closed intervals. For example, for age boundaries of[20, 30, 40, 50], the resulting trigger values are<=20,20-30,30-40,40-50, and>50.
A user age of 23 corresponds to "20-30".
An empty user age corresponds to "NULL".
A user age of 60 corresponds to ">50".
A user age of 19 corresponds to "<=20".
Hologres table example:
This example uses three features: gender, age, and OS.
trigger_id | item_ids |
Male_<=20_IOS | item_id1::score1,item_id2::score2... |
Female_20-30_Android | item_id4::score4,item_id5::score5... |
... | ... |
Configuration example:
{
"RecallConfs": [
{
"Name": "user_group_hot_recall",
"RecallType": "UserGroupHotRecall",
"RecallCount": 500,
"Triggers": [
{
"TriggerKey": "gender"
},
{
"TriggerKey": "age",
"Boundaries": [20,30,40,50]
},
{
"TriggerKey": "os"
}
],
"DaoConf": {
"AdapterType": "hologres",
"HologresName": "holo_info",
"HologresTableName": "group_hotness_table"
}
}
]
}Parameter | Type | Required | Description |
Name | string | Yes | A custom name for the recall configuration. |
RecallType | string | Yes | The recall type. Set this to |
RecallCount | int | Yes | The number of items to recall. |
Triggers | json array | Yes | Defines the features used to construct the |
| string | Yes | The key that retrieves the trigger value from user features. |
| json int array | No | An array of boundary values for discretizing a numerical feature. |
DaoConf | json object | Yes | The data access object (DAO) definition. |
| string | Yes | The data source type. Set this to |
| string | Yes | The custom name of the Hologres data source, as configured in |
| string | Yes | The name of the Hologres data table. |
PAI-FeatureStore
The user group hot recall table has a predefined schema.
You prepare the data for this table in MaxCompute. You must register the table with PAI-FeatureStore as an offline feature view. The MaxCompute table requires the following schema.
group_hot_table
Field | Type | Description |
trigger_id | string | An ID constructed from the values of multiple features. |
item_ids | string | A list of item IDs. Supported formats: |
ds | string | The partition field for the MaxCompute table. The field name is customizable. |
The trigger_id combines user features and contextual information, such as region and OS.
Concatenate the feature values in order with an underscore (
_) to form thetrigger_id.If a feature value is empty, use the string "NULL".
Features that include a
Boundariesparameter must be discretized into left-open, right-closed intervals. For example, for age boundaries of[20, 30, 40, 50], the resulting trigger values are<=20,20-30,30-40,40-50, and>50.
A user age of 23 corresponds to "20-30".
An empty user age corresponds to "NULL".
A user age of 60 corresponds to ">50".
A user age of 19 corresponds to "<=20".
MaxCompute table example:
This example uses three features: gender, age, and OS.
trigger_id | item_ids |
Male_<=20_IOS | item_id1::score1,item_id2::score2... |
Female_20-30_Android | item_id4::score4,item_id5::score5... |
... | ... |
This configuration uses a trigger feature entity.
Configuration example:
{
"RecallConfs": [
{
"Name": "user_group_hot_recall",
"RecallType": "UserGroupHotRecall",
"RecallCount": 500,
"Triggers": [
{
"TriggerKey": "gender"
},
{
"TriggerKey": "age",
"Boundaries": [20,30,40,50]
},
{
"TriggerKey": "os"
}
],
"DaoConf": {
"AdapterType": "featurestore",
"FeatureStoreName": "fs_pairec",
"FeatureStoreViewName": "group_hot_recall"
}
}
]
}Parameter | Type | Required | Description |
Name | string | Yes | A custom name for the recall configuration. |
RecallType | string | Yes | The recall type. Set this to |
RecallCount | int | Yes | The number of items to recall. |
Triggers | json array | Yes | Defines the features used to construct the |
| string | Yes | The key that retrieves the trigger value from user features. |
| json int array | No | An array of boundary values for discretizing a numerical feature. |
DaoConf | json object | Yes | The data access object (DAO) definition. |
| string | Yes | The data source type. Set this to |
| string | Yes | The custom name of the PAI-FeatureStore data source, as configured in |
| string | Yes | The name of the feature view for the hot recall table. |
If the hot recall count for a grouping is consistently 0, ensure the concatenation order of Triggers in the engine configuration matches the order in the recall table.
Global hot recall (UserGlobalHotRecall)
Hologres
The table schema for global hot recall is the same as that for group recall, except that the global hot recall table contains only one record, and its trigger_id is -1.
Configuration example:
{
"RecallConfs": [
{
"Name": "UserGlobalHotRecall",
"RecallType": "UserGlobalHotRecall",
"RecallCount": 500,
"DaoConf": {
"AdapterType": "hologres",
"HologresName": "holo_info",
"HologresTableName": "global_hotness_table"
}
}
]
}PAI-FeatureStore
The table schema for global hot recall is the same as that for group recall, except that the global hot recall table contains only one record, and its trigger_id is -1.
The table data is generated in MaxCompute. You must register the table in Feature Store by using an offline FeatureView. The schema for the MaxCompute table is as follows.
Field | Type | Description |
trigger_id | string | The table contains only one row, and the value of this field is |
item_ids | string | A list of item IDs. Supported formats: |
ds | string | The partition field for the MaxCompute table. The field name is customizable. |
Configuration example:
{
"RecallConfs": [
{
"Name": "UserGlobalHotRecall",
"RecallType": "UserGlobalHotRecall",
"RecallCount": 500,
"DaoConf": {
"AdapterType": "featurestore",
"FeatureStoreName": "fs_pairec",
"FeatureStoreViewName": "global_hot_recall"
}
}
]
}Tablestore
The table schema for global hot recall is the same as that for group recall, except that the global hot recall table contains only one record, and its trigger_id is -1.
Configuration example:
{
"RecallConfs": [
{
"Name": "UserGlobalHotRecall",
"RecallType": "UserGlobalHotRecall",
"RecallCount": 500,
"DaoConf": {
"AdapterType": "tablestore",
"TableStoreName": "ots_info",
"TableStoreTableName": "global_hotness_recall"
}
}
]
}Parameter | Type | Required | Description |
Name | string | Yes | A custom name for the recall configuration. |
RecallType | string | Yes | The recall type. Must be |
RecallCount | int | Yes | The number of items to recall. |
DaoConf | json object | Yes | Specifies the Data Access Object (DAO) configuration. |
AdapterType | string | Yes | The data source type. Must be |
TableStoreName | string | The name of the Tablestore instance, as defined in | |
TableStoreTableName | string | Yes | The name of the data table in the Tablestore instance. |
Cold start recall
An item table is provided and filtered based on conditions or time to query for a candidate set that meets specified rules.
Hologres
{
"RecallConfs": [
{
"Name": "AllLiveItemRecall",
"RecallType": "ColdStartRecall",
"RecallCount": 3000,
"ColdStartDaoConf": {
"AdapterType": "hologres",
"HologresName": "holo_info",
"HologresTableName": "item_status_table",
"WhereClause": "islist_status=1",
"PrimaryKey": "\"item_id\"",
"TimeInterval": 0
}
}
]
}ColdStartDaoConf:
Parameter | Type | Required | Description |
Name | string | Yes | Custom recall name |
RecallType | string | Yes | The recall type. The value must be ColdStartRecall. |
RecallCount | int | Yes | The number of items to recall. |
ColdStartDaoConf | json object | Yes | The configuration for cold start data. |
AdapterType | string | Yes | The type of the data source, such as Hologres. |
HologresName | string | Yes | The custom name of the Hologres instance, as configured in HologresConfs. For example, holo_info. |
HologresTableName | string | Yes | The name of the cold start recall table in Hologres. |
WhereClause | string | No | A filter condition. To filter by time, use the ${time} placeholder. For example, to filter based on creation time, you can use |
PrimaryKey | string | Yes | The primary key of the table. |
TimeInterval | int | No | The time offset for calculating the ${time} variable. The ${time} variable is calculated as: |
You can use WhereClause to filter the candidate set based on features from the API request or user features. For example, to filter the candidate set by language and the user's city, you can set WhereClause to:
"language=${context.features.language} AND city=${user.city}"In this example, language comes from the features field of the API request, and city is a user feature.
Parameter sources follow these formats:
user.xxx: Retrieves the value of the user feature named xxx.
context.features.xxx: Retrieves the value of the feature named xxx from the features field of the API request.
PAI-FeatureStore
This feature supports only FeatureViews that use FeatureDB as the online data source.
This feature randomly recalls a batch of item IDs from a FeatureView that uses the item ID as its primary key.
{
"RecallConfs": [
{
"Name": "item_cold_start_recall",
"RecallType": "ColdStartRecall",
"RecallCount": 200,
"ColdStartDaoConf": {
"AdapterType": "featurestore",
"FeatureStoreName": "fs_pairec",
"FeatureStoreViewName": "rec_sln_demo_item_table_preprocess_all_feature_v1"
},
"FilterParams": [
]
}
]
}Parameter | Type | Required | Description |
Name | string | Yes | A custom name for the recall. |
RecallType | string | Yes | The recall type. The value must be ColdStartRecall. |
RecallCount | int | Yes | The number of items to recall. |
ColdStartDaoConf | json object | Yes | The configuration for cold start data. |
AdapterType | string | Yes | The type of the data source. The value must be featurestore. |
FeatureStoreName | string | Yes | The custom name of the PAI-FeatureStore instance, as configured in FeatureStoreConfs. |
FeatureStoreViewName | string | Yes | The name of the FeatureView for cold start recall. |
FilterParams | string | No | The filter conditions for cold start recall. |
The FeatureView specified by FeatureStoreViewName can be an offline or a real-time FeatureView. If you use a real-time FeatureView, this configuration also enables real-time recall of newly added item IDs.
If FilterParams is empty, no filter conditions are applied, and item IDs are recalled randomly. Use FilterParams to filter for specific item IDs.
{
"Name": "item_cold_start_recall",
"RecallType": "ColdStartRecall",
"RecallCount": 200,
"ColdStartDaoConf": {
"AdapterType": "featurestore",
"FeatureStoreName": "fs_pairec",
"FeatureStoreViewName": "rec_sln_demo_item_table_preprocess_all_feature_v1"
},
"FilterParams": [
{
"Name": "click_count",
"Type": "int",
"Operator": "greater",
"Value": "15"
},
{
"Name": "category",
"Type": "string",
"Operator": "in",
"Value": "user.category"
}
]
}In the preceding example, the user. prefix in the Value field specifies that the value is retrieved from a user feature. For instance, user.category retrieves the value from the user's category feature.
For more information about how to use the Operator parameter, see the appendix.
Contextual item recall
You can also use the item_list parameter to pass custom recalled items to the engine API. For details on the engine API, see API testing.
Use ContextItemRecall, the engine's built-in recall name, directly in RecallNames as follows:
{
"SceneConfs": {
"${scene_name}": {
"default": {
"RecallNames": [
"ContextItemRecall"
]
}
}
}
}I2I recall (ItemCollaborativeFilterRecall)
Hologres
I2I recall is used for similarity recommendation. To retrieve similar items, you must pass the item_id of a source item. For the API definition, see API testing.
Configuration example:
{
"RecallConfs": [
{
"Name": "I2IRecall",
"RecallType": "ItemCollaborativeFilterRecall",
"RecallCount": 500,
"ItemCollaborativeDaoConf": {
"AdapterType": "hologres",
"HologresName": "holo_info",
"Item2ItemTable": "item_collaborative_list"
}
}
]
}The following table describes the configuration parameters.
Parameter | Type | Required | Description |
Name | string | Yes | A custom name for the recall. |
RecallType | string | Yes | The recall type. This value must be |
RecallCount | int | Yes | The number of similar items to retrieve. |
ItemCollaborativeDaoConf | json object | Yes | The configuration for the I2I data table. |
| string | Yes | The type of the data source. Must be set to |
| string | Yes | The custom name of the Hologres instance, as configured in |
| string | Yes | The name of the I2I data table. |
The Item2ItemTable table is defined as follows:
Parameter | Type | Description |
item_id | string | The source item ID. |
item_ids | string | A string that contains a list of similar item IDs. Supported formats: |
PAI-FeatureStore
I2I recall is used for similarity recommendation. To retrieve similar items, you must pass the item_id of a source item. For the API definition, see API testing.
The Item2ItemTable table is defined as follows:
Parameter | Type | Description |
item_id | string | The source item ID. |
item_ids | string | A string that contains a list of similar item IDs. Supported formats: |
Configuration example:
{
"RecallConfs": [
{
"Name": "I2IRecall",
"RecallType": "ItemCollaborativeFilterRecall",
"RecallCount": 200,
"ItemCollaborativeDaoConf": {
"AdapterType": "featurestore",
"FeatureStoreName": "fs_pairec",
"FeatureStoreViewName": "i2i_recall"
}
}
]
}The following table describes the configuration parameters.
Parameter | Type | Required | Description |
Name | string | Yes | A custom name for the recall. |
RecallType | string | Yes | The recall type. This value must be |
RecallCount | int | Yes | The number of similar items to retrieve. |
ItemCollaborativeDaoConf | json object | Yes | The configuration for the I2I data table. |
| string | Yes | The type of the data source. Must be set to |
| string | Yes | The custom name of the PAI-FeatureStore instance, as configured in |
| string | Yes | The name of the data table view for I2I. |
EnableMultipleItemId | bool | No | Specifies whether the |
MultipleItemIdDelimiter | string | No | The delimiter for multiple item IDs when |
If the item_id passed to the API is in a multi-value format and is delimited by ,, you can refer to the following configuration:
{
"RecallConfs": [
{
"Name": "I2IRecall",
"RecallType": "ItemCollaborativeFilterRecall",
"RecallCount": 200,
"ItemCollaborativeDaoConf": {
"AdapterType": "featurestore",
"FeatureStoreName": "fs_pairec",
"FeatureStoreViewName": "i2i_recall"
},
"EnableMultipleItemId": true,
"MultipleItemIdDelimiter": ","
}
]
}For Redis or a local cache, the cache key is item_id.
For I2I recall, set the item_id field in your API request.
OpenSearch recall
Call the OpenSearch service to retrieve a recall list. For details, refer to the documentation for the Industry Algorithm Edition.
Configuration example:
{
"RecallConfs": [
{
"Name": "OpenSearchRecall",
"RecallType": "OpenSearchRecall",
"OpenSearchConf": {
"OpenSearchName": "OpenSearch",
"AppName": "test_search",
"ItemId": "log_id",
"RequestParams": {
"query": "query=result:'$1'&&config=start:0,hit:10,format:fulljson&&sort=-log_id&&filter=request_time>1703952000000",
"format": "fulljson",
"second_rank_type": "expression",
"fetch_fields": "log_id;result_data"
},
"Params": [
"context.features.topic"
]
}
}
]
}The example above shows a query on the result index, where the query term is obtained from the topic field of features in the API request's context.
OpenSearchConf configuration fields:
Parameter | Type | Required | Description |
Name | string | Yes | A custom name for the recall. |
RecallType | string | Yes | The recall type. The value must be |
RecallCount | int | Yes | The number of items to recall. |
OpenSearchName | string | Yes | The custom name for the OpenSearch instance, as specified in |
AppName | string | Yes | The name of the OpenSearch application. |
ItemId | string | Yes | The primary key field for items in the OpenSearch results. |
RequestParams | map[string]interface{} | Yes | The OpenSearch query statement. Placeholders, such as |
Params | string | Yes | The source of values for query placeholders. The following formats are supported:
|
Usage
You can configure recall settings under SceneConfs in the Configuration Overview. SceneConfs is a Map[string]object that allows you to apply different recall configurations for each scene. The configuration is as follows:
"SceneConfs": {
"${scene_name}": {
"default": {
"RecallNames": [
"collaborative_filter"
]
}
}
}Replace
${scene_name}with your scene name.defaultis a directory. You can keep the default.RecallNamesis a[]stringspecifying custom recall names from your recall configuration.