Engine configuration case for recommendation scenario
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 block | Defined in | Referenced in |
|---|---|---|
| Recall strategies | RecallConfs | SceneConfs |
| Filter strategies | FilterConfs | FilterNames |
| Ranking models | AlgoConfs | RankConf |
| Re-ranking strategies | SortConfs | SortNames |
| Feature loading | FeatureConfs | (bound to scenario) |
| Online data sources | HologresConfs, FeatureStoreConfs | Referenced by name across all confs |
Note:FilterNamessupports adefaultkey as a fallback. If no entry matches the current scenario name, the engine usesdefault.
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.
| Parameter | Description |
|---|---|
DSN | Hologres connection string in PostgreSQL DSN format |
RegionId | Alibaba Cloud region of the FeatureStore project |
AccessId / AccessKey | Alibaba Cloud credentials — the engine replaces ${AccessKey} and ${AccessSecret} at runtime; no manual replacement needed |
ProjectName | FeatureStore project name |
Note: If FeatureStore uses FeatureDB as its online data source, also configureFeatureDBUsernameandFeatureDBPassword. 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 thehome_feed_etrec_u2i2i_score_holo_v1Hologres table.Global hot recall (
user_global_hot_recall_v1,RecallType: UserGlobalHotRecall): Retrieves up to 200 trending items from thehome_feed_global_hot_holo_v1Hologres table.
Both recalls are referenced by name in SceneConfs → home_feed → default → RecallNames.
Key parameters:
| Parameter | Description |
|---|---|
Name | Unique identifier for this recall configuration |
RecallType | Built-in recall type (enumeration). See Configure recalls for all supported values |
RecallCount | Maximum number of candidates to retrieve |
AdapterType | Data source type (hologres in this example) |
HologresName | Name of the Hologres data source defined in HologresConfs |
HologresTableName | Hologres 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.
| Parameter | Description |
|---|---|
FilterType | User2ItemExposureFilter — filters items based on per-user exposure history. See User2ItemExposureFilter for setup requirements |
MaxItems | Maximum rows fetched from the exposure table per request (equivalent to SQL LIMIT) |
TimeInterval | Lookback window in seconds (604800 = 7 days) |
WriteLog | When true, writes this request's recommended items to the exposure table |
HologresTableName | Exposure 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.
| Parameter | Description |
|---|---|
FilterType | ItemStateFilter — filters items based on a field value in a state table. See Configure filters for all supported types |
HologresTableName | State table in Hologres |
ItemFieldName | Primary key field of the state table (item_id) |
SelectFields | Fields to query from the state table |
FilterParams | Conditions 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:
| Parameter | Description |
|---|---|
FeatureKey | user:uid (default) — queries the database using the user's uid attribute |
UserFeatureKeyName | Primary key field in the user feature table (user_id) |
HologresTableName | User feature table (user_table_v1_all_feature_v1_online) |
UserSelectFields | Fields to retrieve (* = all fields) |
FeatureStore | Set to user to indicate user-side features |
Item features:
| Parameter | Description |
|---|---|
FeatureKey | item:id — queries the database using the item's id attribute |
ItemFeatureKeyName | Primary key field in the item feature table (item_id) |
HologresTableName | Item feature table (item_table_v1_all_feature_v1_online) |
ItemSelectFields | Fields to retrieve (comma-separated; item_id,author in this example) |
FeatureStore | Set 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.
| Parameter | Description |
|---|---|
Name | Unique identifier for this model configuration |
Type | EAS — static value; most models are deployed on PAI-EAS |
Processor | EasyRec — static value |
ResponseFuncName | easyrecMutValResponseFunc — static value |
Url | PAI-EAS endpoint URL for the model service |
EndpointType | DIRECT — uses a direct connection with less network loss |
Auth | Authentication 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.
| Parameter | Description |
|---|---|
RankAlgoList | Model(s) to use for scoring |
RankScore | Scoring 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} |
BatchCount | Number of items scored per batch (100 in this example) |
Processor | EasyRec — 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.
| Parameter | Description |
|---|---|
SortType | BoostScoreSort — multiplies the model score by a factor based on item attributes. See Configure re-ranking for all supported types |
Debug | When true, prints detailed logs to the console for troubleshooting |
Conditions | Item attribute conditions to match (author_status == "teacher") |
Expression | Score 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
Configure recalls — all supported
RecallTypevaluesConfigure filters — all supported
FilterTypevalues and exposure table setupConfigure re-ranking — all supported
SortTypevalues andDiversityRulesparameters