Engine configuration case for recommendation scenario

Updated at:

This topic walks through a complete engine configuration for the home_feed recommendation scenario, covering data sources, recall, filtering, feature loading, ranking, and re-ranking.

How it works

An engine configuration is a JSON document that wires together six types of building blocks. Define each building block first, then reference it by name in SceneConfs:

Building blockDefined inReferenced in
Recall strategiesRecallConfsSceneConfs
Filter strategiesFilterConfsFilterNames
Ranking modelsAlgoConfsRankConf
Re-ranking strategiesSortConfsSortNames
Feature loadingFeatureConfs(bound to scenario)
Online data sourcesHologresConfs, FeatureStoreConfsReferenced by name across all confs
Note: FilterNames supports a default key as a fallback. If no entry matches the current scenario name, the engine uses default.

Full configuration example

The following JSON configures the home_feed scenario end-to-end. Each section is explained in detail below.

{
    "HologresConfs": {
        "holo_info": {
            "DSN": "postgres://${AccessKey}:${AccessSecret}@hgpostcn-cn-xxxx-cn-shanghai-vpc-st.hologres.aliyuncs.com:80/test_db?sslmode=disable&connect_timeout=1"
        }
    },
    "FeatureStoreConfs": {
        "fs_info": {
            "RegionId": "cn-shanghai",
            "AccessId": "${AccessKey}",
            "AccessKey": "${AccessSecret}",
            "ProjectName": "projectName"
        }
    },
    "RecallConfs": [
        {
            "Name": "etrec_u2i2i_recall_v1",
            "RecallType": "UserCustomRecall",
            "RecallCount": 300,
            "DaoConf": {
                "AdapterType": "hologres",
                "HologresName": "holo_info",
                "HologresTableName": "home_feed_etrec_u2i2i_score_holo_v1"
            }
        },
        {
            "Name": "user_global_hot_recall_v1",
            "RecallType": "UserGlobalHotRecall",
            "RecallCount": 200,
            "DaoConf": {
                "AdapterType": "hologres",
                "HologresName": "holo_info",
                "HologresTableName": "home_feed_global_hot_holo_v1"
            }
        }
    ],
    "FilterConfs": [
        {
            "Name": "UserExposureFilter",
            "FilterType": "User2ItemExposureFilter",
            "MaxItems": 50,
            "TimeInterval": 604800,
            "WriteLog": true,
            "DaoConf": {
                "AdapterType": "hologres",
                "HologresName": "holo_info",
                "HologresTableName": "exposure_history"
            }
        },
        {
            "Name": "ItemStateFilter",
            "FilterType": "ItemStateFilter",
            "ItemStateDaoConf": {
                "AdapterType": "hologres",
                "HologresName": "holo_info",
                "HologresTableName": "item_status_table_v1",
                "ItemFieldName": "item_id",
                "SelectFields": "is_online"
            },
            "FilterParams": [
                {
                    "Name": "is_online",
                    "Type": "int",
                    "Operator": "equal",
                    "Value": 1
                }
            ]
        }
    ],
    "AlgoConfs": [
        {
            "Name": "home_feed_dbmtl_v1",
            "Type": "EAS",
            "EasConf": {
                "Processor": "EasyRec",
                "ResponseFuncName": "easyrecMutValResponseFunc",
                "Url": "http://xxx.vpc.cn-shanghai.pai-eas.aliyuncs.com/api/predict/home_feed_dbmtl_v1",
                "EndpointType": "DIRECT",
                "Auth": "xxxxx"
            }
        }
    ],
    "SortConfs": [
        {
            "Name": "BoostScoreSortByAuthor",
            "SortType": "BoostScoreSort",
            "Debug": false,
            "BoostScoreConditions": [
                {
                    "Conditions": [
                        {
                            "Name": "author_status",
                            "Domain": "item",
                            "Type": "string",
                            "Value": "teacher",
                            "Operator": "equal"
                        }
                    ],
                    "Expression": "score * 10"
                }
            ]
        }
    ],
    "SortNames": {
        "home_feed": [
            "BoostScoreSortByAuthor"
        ]
    },
    "FilterNames": {
        "default": [
            "UniqueFilter",
            "UserExposureFilter"
        ]
    },
    "RankConf": {
        "home_feed": {
            "RankAlgoList": [
                "home_feed_dbmtl_v1"
            ],
            "RankScore": "${home_feed_dbmtl_v1_probs_is_click}+${home_feed_dbmtl_v1_probs_is_collect_like_comment}",
            "BatchCount": 100,
            "Processor": "EasyRec"
        }
    },
    "FeatureConfs": {
        "home_feed": {
            "AsynLoadFeature": true,
            "FeatureLoadConfs": [
                {
                    "FeatureDaoConf": {
                        "AdapterType": "hologres",
                        "HologresName": "holo_info",
                        "FeatureKey": "user:uid",
                        "UserFeatureKeyName": "user_id",
                        "HologresTableName": "user_table_v1_all_feature_v1_online",
                        "UserSelectFields": "*",
                        "FeatureStore": "user"
                    },
                    "Features": []
                },
                {
                    "FeatureDaoConf": {
                        "AdapterType": "hologres",
                        "HologresName": "holo_info",
                        "ItemFeatureKeyName": "item_id",
                        "FeatureKey": "item:id",
                        "HologresTableName": "item_table_v1_all_feature_v1_online",
                        "ItemSelectFields": "item_id,author",
                        "FeatureStore": "item"
                    },
                    "Features": []
                }
            ]
        }
    },
    "SceneConfs": {
        "home_feed": {
            "default": {
                "RecallNames": [
                    "etrec_u2i2i_recall_v1",
                    "user_global_hot_recall_v1"
                ]
            }
        }
    }
}

Data sources

This example connects two online data sources: Hologres and FeatureStore. Together they store user features, item features, recall candidates (U2I and global hot), and exposure history.

ParameterDescription
DSNHologres connection string in PostgreSQL DSN format
RegionIdAlibaba Cloud region of the FeatureStore project
AccessId / AccessKeyAlibaba Cloud credentials — the engine replaces ${AccessKey} and ${AccessSecret} at runtime; no manual replacement needed
ProjectNameFeatureStore project name
Note: If FeatureStore uses FeatureDB as its online data source, also configure FeatureDBUsername and FeatureDBPassword. These parameters are not required for other data source types.

Recall

RecallConfs defines the candidate retrieval strategies. This example uses two:

  • U2I recall (etrec_u2i2i_recall_v1, RecallType: UserCustomRecall): Retrieves up to 300 candidates based on user-to-item collaborative signals, reading from the home_feed_etrec_u2i2i_score_holo_v1 Hologres table.

  • Global hot recall (user_global_hot_recall_v1, RecallType: UserGlobalHotRecall): Retrieves up to 200 trending items from the home_feed_global_hot_holo_v1 Hologres table.

Both recalls are referenced by name in SceneConfs → home_feed → default → RecallNames.

Key parameters:

ParameterDescription
NameUnique identifier for this recall configuration
RecallTypeBuilt-in recall type (enumeration). See Configure recalls for all supported values
RecallCountMaximum number of candidates to retrieve
AdapterTypeData source type (hologres in this example)
HologresNameName of the Hologres data source defined in HologresConfs
HologresTableNameHologres table that stores the recall data

Filters

FilterConfs defines the filtering strategies. This example uses two, referenced in FilterNames → default.

Exposure filter

Use case: Remove items the user has already seen in the past week to avoid repetitive recommendations.

UserExposureFilter reads the exposure_history Hologres table and drops any item the user was exposed to within the last 604,800 seconds (7 days). After each request, WriteLog: true writes the newly recommended items back to the exposure table.

ParameterDescription
FilterTypeUser2ItemExposureFilter — filters items based on per-user exposure history. See User2ItemExposureFilter for setup requirements
MaxItemsMaximum rows fetched from the exposure table per request (equivalent to SQL LIMIT)
TimeIntervalLookback window in seconds (604800 = 7 days)
WriteLogWhen true, writes this request's recommended items to the exposure table
HologresTableNameExposure history table in Hologres — must be created in advance

Item status filter

Use case: Keep only items that are currently online; discard anything that has been taken offline.

ItemStateFilter queries the is_online field from item_status_table_v1 and retains only items where is_online = 1. Items with any other value are removed from the candidate set.

ParameterDescription
FilterTypeItemStateFilter — filters items based on a field value in a state table. See Configure filters for all supported types
HologresTableNameState table in Hologres
ItemFieldNamePrimary key field of the state table (item_id)
SelectFieldsFields to query from the state table
FilterParamsConditions to evaluate. Items that match all conditions are retained; others are removed

Feature loading

FeatureConfs loads user and item features into the engine before scoring. User features feed the ranking model; item features are primarily used in re-ranking.

AsynLoadFeature: true loads features asynchronously to reduce latency.

User features:

ParameterDescription
FeatureKeyuser:uid (default) — queries the database using the user's uid attribute
UserFeatureKeyNamePrimary key field in the user feature table (user_id)
HologresTableNameUser feature table (user_table_v1_all_feature_v1_online)
UserSelectFieldsFields to retrieve (* = all fields)
FeatureStoreSet to user to indicate user-side features

Item features:

ParameterDescription
FeatureKeyitem:id — queries the database using the item's id attribute
ItemFeatureKeyNamePrimary key field in the item feature table (item_id)
HologresTableNameItem feature table (item_table_v1_all_feature_v1_online)
ItemSelectFieldsFields to retrieve (comma-separated; item_id,author in this example)
FeatureStoreSet to item to indicate item-side features

Ranking

Ranking is configured in two parts: AlgoConfs defines the model services, and RankConf binds them to a scenario and specifies the scoring formula.

AlgoConfs — define the ranking model

AlgoConfs registers the EasyRec model deployed on PAI-EAS.

ParameterDescription
NameUnique identifier for this model configuration
TypeEAS — static value; most models are deployed on PAI-EAS
ProcessorEasyRec — static value
ResponseFuncNameeasyrecMutValResponseFunc — static value
UrlPAI-EAS endpoint URL for the model service
EndpointTypeDIRECT — uses a direct connection with less network loss
AuthAuthentication token for the model service

RankConf — configure scoring for the scenario

RankConf references the model defined above and computes a final score by combining multiple prediction targets.

ParameterDescription
RankAlgoListModel(s) to use for scoring
RankScoreScoring formula. Variable format: ${<model_name>_<target_name>}. This example adds click probability and engagement probability: ${home_feed_dbmtl_v1_probs_is_click}+${home_feed_dbmtl_v1_probs_is_collect_like_comment}
BatchCountNumber of items scored per batch (100 in this example)
ProcessorEasyRec — static value

Re-ranking

SortConfs adjusts the ranked list after scoring — boosting certain items up or enforcing diversity. The strategies in SortConfs are referenced by name in SortNames.

Boost strategy

Use case: Surface content from verified educators — items where author_status = "teacher" get their score multiplied by 10.

BoostScoreSortByAuthor evaluates each item's author_status attribute. Items matching the condition have their score multiplied by the Expression value; items that don't match are left unchanged.

ParameterDescription
SortTypeBoostScoreSort — multiplies the model score by a factor based on item attributes. See Configure re-ranking for all supported types
DebugWhen true, prints detailed logs to the console for troubleshooting
ConditionsItem attribute conditions to match (author_status == "teacher")
ExpressionScore multiplier applied to matching items (score * 10)

Diversity strategy

Use case: Avoid flooding the feed with content from the same author.

Configure a diversity strategy using SortType: DiversitySort with DiversityRules. Set WindowSize to the number of consecutive items to evaluate, and FrequencySize to the maximum occurrences of the same dimension value within that window. For example, WindowSize: 20 and FrequencySize: 1 means each author's items appear at most once in every 20 consecutive recommendations.

For the full list of DiversityRules parameters, see Configure re-ranking.

What's next