All Products
Search
Document Center

:Feature configuration

Last Updated:Apr 01, 2026

FeatureConfs controls which user and item features the fine-ranking stage loads, and how those features are transformed before scoring. It maps scenario names to feature loading configurations, so different scenarios can use different feature sets.

{
  "FeatureConfs": {
    "<scene_name>": { ... }
  }
}

Key concepts

TermDescription
FeatureConfsTop-level map. The key is the scenario name; the value is a feature loading configuration object.
FeatureLoadConfsA list of feature loading jobs within a scenario. Each job pulls features from one data source.
FeatureDaoConfData access configuration for a single loading job — specifies the data source type, connection, and field selection.
FeatureKeyThe lookup key. Format: <side>:<field>. For example, user:uid looks up the uid field on the user side; item:id looks up the id field on the item side.
FeatureStoreWhere to store the retrieved features. Valid values: user or item.
AsynLoadFeatureWhen true, all jobs in FeatureLoadConfs run concurrently, reducing total loading time.

Choose a data source

Features can be loaded from Hologres, PAI-FeatureStore, Tablestore (OTS), and Redis. The table below summarizes the key differences.

CapabilityHologresPAI-FeatureStoreTablestore (OTS)Redis
AdapterType valuehologresfeaturestoretablestoreredis
Field selection (UserSelectFields / ItemSelectFields)YesYes (with feature view)YesYes (HASH format only)
Local cache (CacheSize / CacheTime)YesYesYesYes
Feature view selectionNoYesNoNo
Data format optionsstring (CSV / JSON) or hash

Hologres

Each entry in FeatureLoadConfs loads from one Hologres table. Configure separate entries for user and item features.

{
  "FeatureConfs": {
    "scene_name": {
      "AsynLoadFeature": true,
      "FeatureLoadConfs": [
        {
          "FeatureDaoConf": {
            "AdapterType": "hologres",
            "HologresName": "holo-pai",
            "FeatureKey": "user:uid",
            "UserFeatureKeyName": "user_id",
            "HologresTableName": "recom_user_features_processed_holo_online",
            "UserSelectFields": "rids_count,sex,alladdfriendnum,allpayrosenum",
            "FeatureStore": "user"
          },
          "Features": []
        },
        {
          "FeatureDaoConf": {
            "AdapterType": "hologres",
            "HologresName": "holo-pai",
            "ItemFeatureKeyName": "item_id",
            "FeatureKey": "item:id",
            "HologresTableName": "recom_user_features_processed_holo_online",
            "ItemSelectFields": "rids_count as rids2_count,sex as guestsex,alladdfriendnum as alladdfriendnum2",
            "FeatureStore": "item"
          },
          "Features": []
        }
      ]
    }
  }
}

`FeatureLoadConfs/FeatureDaoConf` parameters

ParameterTypeRequiredDescription
AdapterTypestringYesSet to hologres.
HologresNamestringYesThe name of the Hologres instance as defined in HologresConfs. For example, holo_info.
FeatureKeystringYesThe lookup key. For example, user:uid looks up the uid field on the user side; item:id looks up the id field on the item side.
UserFeatureKeyNamestringYesThe primary key field of the user feature table.
ItemFeatureKeyNamestringYesThe primary key field of the item feature table.
HologresTableNamestringYesThe name of the feature table in Hologres.
UserSelectFieldsstringNoUser features to retrieve. Use * for all, or a comma-separated list such as feature1,feature2.
ItemSelectFieldsstringNoItem features to retrieve. Use * for all, or a comma-separated list such as feature1,feature2.
FeatureStorestringYesWhere to store the retrieved features. Valid values: user or item.
CacheSizeintegerNoNumber of feature entries to cache locally. Default: 0 (no caching).
CacheTimeintegerNoExpiration time for cached entries, in seconds. Takes effect only when CacheSize is greater than 0. Default: 3600.

PAI-FeatureStore

For setup instructions, see FeatureStore overview.

Load all features from an entity

The following configuration retrieves all features of the user entity from the rank_v1 model:

{
  "FeatureConfs": {
    "scene_name": {
      "AsynLoadFeature": true,
      "FeatureLoadConfs": [
        {
          "FeatureDaoConf": {
            "AdapterType": "featurestore",
            "FeatureStoreName": "pairec-fs",
            "FeatureKey": "user:uid",
            "FeatureStoreModelName": "rank_v1",
            "FeatureStoreEntityName": "user",
            "FeatureStore": "user"
          }
        }
      ]
    }
  }
}

To load item features instead, set FeatureKey to item:id, FeatureStoreEntityName to item, and FeatureStore to item.

`FeatureLoadConfs/FeatureDaoConf` parameters

ParameterTypeRequiredDescription
AdapterTypestringYesSet to featurestore.
FeatureStoreNamestringYesThe name of the FeatureStore instance as defined in FeatureStoreConfs. For example, pairec-fs.
FeatureKeystringYesThe lookup key. For example, user:uid or item:id.
FeatureStoreModelNamestringYesThe model feature name in PAI-FeatureStore.
FeatureStoreEntityNamestringYesThe entity name in PAI-FeatureStore.
FeatureStorestringYesWhere to store the retrieved features. Valid values: user or item.
CacheSizeintegerNoNumber of feature entries to cache locally. Default: 0 (no caching).
CacheTimeintegerNoExpiration time for cached entries, in seconds. Takes effect only when CacheSize is greater than 0. Default: 3600.

Load features from a specific feature view

To retrieve features from a named feature view rather than an entire entity, use FeatureStoreViewName. The following example retrieves all user features from the user_table_preprocess_all_feature_v1 view and a subset of item features from the item_table_preprocess_all_feature_v1 view:

{
  "FeatureConfs": {
    "scene_name": {
      "AsynLoadFeature": true,
      "FeatureLoadConfs": [
        {
          "FeatureDaoConf": {
            "AdapterType": "featurestore",
            "FeatureStoreName": "pairec-fs",
            "FeatureKey": "user:uid",
            "FeatureStoreViewName": "user_table_preprocess_all_feature_v1",
            "UserSelectFields": "*",
            "FeatureStore": "user"
          }
        },
        {
          "FeatureDaoConf": {
            "AdapterType": "featurestore",
            "FeatureStoreName": "pairec-fs",
            "FeatureKey": "item:id",
            "FeatureStoreViewName": "item_table_preprocess_all_feature_v1",
            "ItemSelectFields": "author,duration,category",
            "FeatureStore": "item"
          }
        }
      ]
    }
  }
}
ParameterTypeRequiredDescription
FeatureStoreViewNamestringYesThe name of the feature view.
UserSelectFieldsstringNoUser features to retrieve. Use * for all, or a comma-separated list such as feature1,feature2.
ItemSelectFieldsstringNoItem features to retrieve. Use * for all, or a comma-separated list such as feature1,feature2.

Tablestore (OTS)

{
  "FeatureConfs": {
    "scene_name": {
      "AsynLoadFeature": true,
      "FeatureLoadConfs": [
        {
          "FeatureDaoConf": {
            "AdapterType": "tablestore",
            "TableStoreName": "tablestore_info",
            "FeatureKey": "user:uid",
            "UserFeatureKeyName": "uid",
            "TableStoreTableName": "",
            "UserSelectFields": "*",
            "FeatureStore": "user"
          },
          "Features": []
        },
        {
          "FeatureDaoConf": {
            "AdapterType": "tablestore",
            "TableStoreName": "tablestore_info",
            "FeatureKey": "item:id",
            "ItemFeatureKeyName": "item_id",
            "TableStoreTableName": "",
            "ItemSelectFields": "*",
            "FeatureStore": "item"
          },
          "Features": []
        }
      ]
    }
  }
}

`FeatureLoadConfs/FeatureDaoConf` parameters

ParameterTypeRequiredDescription
AdapterTypestringYesSet to tablestore.
TableStoreNamestringYesThe name of the Tablestore instance as defined in TableStoreConfs. For example, tablestore_info.
FeatureKeystringYesThe lookup key. For example, user:uid or item:pair_id.
UserFeatureKeyNamestringNoThe primary key field of the user feature table.
ItemFeatureKeyNamestringNoThe primary key field of the item feature table.
TableStoreTableNamestringYesThe name of the feature table in Tablestore.
UserSelectFieldsstringNoUser features to retrieve. Use * for all, or a comma-separated list such as feature1,feature2.
ItemSelectFieldsstringNoItem features to retrieve. Use * for all, or a comma-separated list such as feature1,feature2.
FeatureStorestringYesWhere to store the retrieved features. Valid values: user or item.
CacheSizeintegerNoNumber of feature entries to cache locally. Default: 0 (no caching).
CacheTimeintegerNoExpiration time for cached entries, in seconds. Takes effect only when CacheSize is greater than 0. Default: 3600.

Redis

Redis supports two storage formats: key-value (KV) and HASH.

  • KV format: The value can be CSV (with a configurable delimiter) or JSON.

  • HASH format: Retrieves all or selected fields by name using UserSelectFields or ItemSelectFields.

KV format

In this example, user features are stored as CSV and item features as JSON. RedisValueDelimeter specifies the CSV separator.

{
  "FeatureConfs": {
    "scene_name": {
      "AsynLoadFeature": true,
      "FeatureLoadConfs": [
        {
          "FeatureDaoConf": {
            "AdapterType": "redis",
            "RedisName": "user_redis",
            "RedisPrefix": "UF_V2_",
            "FeatureKey": "user:uid",
            "FeatureStore": "user",
            "RedisDataType": "string",
            "RedisFieldType": "csv",
            "RedisValueDelimeter": ","
          },
          "Features": []
        },
        {
          "FeatureDaoConf": {
            "AdapterType": "redis",
            "RedisName": "item_redis",
            "RedisPrefix": "IF_V2_FM_",
            "FeatureKey": "item:id",
            "FeatureStore": "item",
            "RedisDataType": "string",
            "RedisFieldType": "json"
          },
          "Features": []
        }
      ]
    }
  }
}

HASH format

{
  "FeatureConfs": {
    "scene_name": {
      "AsynLoadFeature": true,
      "FeatureLoadConfs": [
        {
          "FeatureDaoConf": {
            "AdapterType": "redis",
            "RedisName": "user_redis",
            "RedisPrefix": "UF_V2_",
            "FeatureKey": "user:uid",
            "FeatureStore": "user",
            "RedisDataType": "hash",
            "UserSelectFields": "*"
          },
          "Features": []
        },
        {
          "FeatureDaoConf": {
            "AdapterType": "redis",
            "RedisName": "item_redis",
            "RedisPrefix": "IF_V2_FM_",
            "FeatureKey": "item:id",
            "FeatureStore": "item",
            "RedisDataType": "hash",
            "ItemSelectFields": "city,author,duration"
          },
          "Features": []
        }
      ]
    }
  }
}

`FeatureLoadConfs/FeatureDaoConf` parameters

ParameterTypeRequiredDescription
AdapterTypestringYesSet to redis.
RedisNamestringYesThe name of the Redis instance as defined in RedisConfs. For example, redis_info.
RedisPrefixstringYesThe key prefix.
FeatureKeystringYesThe lookup key. For example, user:uid or item:pair_id.
FeatureStorestringYesWhere to store the retrieved features. Valid values: user or item.
RedisDataTypestringYesThe data storage format. Valid values: string or hash.
RedisFieldTypestringNoThe field format when RedisDataType is string. Valid values: csv or json.
RedisValueDelimeterstringNoThe CSV separator. Takes effect only when RedisFieldType is csv.
UserSelectFieldsstringNoUser features to retrieve. Use * for all, or a comma-separated list such as feature1,feature2. Takes effect only when RedisDataType is hash.
ItemSelectFieldsstringNoItem features to retrieve. Use * for all, or a comma-separated list such as feature1,feature2. Takes effect only when RedisDataType is hash.
CacheSizeintegerNoNumber of feature entries to cache locally. Default: 0 (no caching).
CacheTimeintegerNoExpiration time for cached entries, in seconds. Takes effect only when CacheSize is greater than 0. Default: 3600.

Feature transformation

After features are loaded, you can derive new features or recombine existing ones using three transformation types:

FeatureTypeDescription
new_featureGenerates a new feature from scratch or from an expression.
raw_featureCreates a renamed copy of an existing feature.
compose_featureCombines multiple existing features into a single composite feature.

Feature transformation configurations are defined inline within each FeatureLoadConf entry, alongside FeatureDaoConf.

new_feature

Use new_feature to generate features that don't exist in the data source — time-based values, random numbers, constants, or expression results.

Time and random values

{ "FeatureType": "new_feature", "FeatureName": "day_h", "Normalizer": "hour_in_day", "FeatureStore": "user" }
{ "FeatureType": "new_feature", "FeatureName": "week_day", "Normalizer": "weekday", "FeatureStore": "user" }
{ "FeatureType": "new_feature", "FeatureName": "rand_int_v", "Normalizer": "random", "FeatureStore": "user" }

hour_in_day and weekday generate real-time values based on the current system time. random generates an integer in the range [0, 100).

Constant value

The following generates a feature named alg with the static value ALRC:

{
  "FeatureType": "new_feature",
  "FeatureStore": "user",
  "Normalizer": "const_value",
  "FeatureValue": "ALRC",
  "FeatureName": "alg"
}

Expression (recommended)

Use Normalizer: "expr" for expression-based features. This method uses the expr library and offers more flexible syntax and better performance than the older expression method.

Reference item-side features with the item. prefix and user-side features with the user. prefix. Use currentTime for the current Unix timestamp in seconds.

The following generates a Boolean feature is_retarget (represented as 1 or 0):

{
  "FeatureType": "new_feature",
  "FeatureStore": "item",
  "Normalizer": "expr",
  "Expression": "item.recall_name in ['retarget_u2i','realtime_retarget_click']",
  "FeatureName": "is_retarget"
}

To combine user-side and item-side features in the same expression:

{
  "FeatureType": "new_feature",
  "FeatureStore": "item",
  "Normalizer": "expr",
  "Expression": "user.user_index - item.index",
  "FeatureName": "index_delta"
}

For expression syntax, see the expr language definition.

Expression (legacy)

Normalizer: "expression" uses the govaluate library. Use FeatureSource to specify which feature value to pass to the expression. If the expression references multiple item properties, omit FeatureSource — all item properties are passed automatically.

{
  "FeatureType": "new_feature",
  "FeatureStore": "item",
  "FeatureSource": "item:recall_name",
  "Normalizer": "expression",
  "Expression": "recall_name in ('retarget_u2i','realtime_retarget_click')",
  "FeatureName": "is_retarget"
}

For expression syntax, see the govaluate manual.

raw_feature

raw_feature copies an existing feature under a new name. Set RemoveFeatureSource to true to delete the original after copying.

The following renames the user's age feature to age_v2:

{
  "FeatureType": "raw_feature",
  "FeatureStore": "user",
  "FeatureSource": "user:age",
  "RemoveFeatureSource": true,
  "FeatureName": "age_v2"
}

Use the user: prefix for user-side features and the item: prefix for item-side features in FeatureSource.

compose_feature

compose_feature joins multiple feature values with an underscore (_) to create a composite feature.

The following creates item_author by joining user:category and item:author. If user:category is category1 and item:author is author1, the result is category1_author1:

{
  "FeatureType": "compose_feature",
  "FeatureStore": "item",
  "FeatureSource": "user:category,item:author",
  "FeatureName": "item_author"
}
The expr method for new_feature provides a more flexible alternative for building composite features.

Built-in expression functions

The following functions are available in both expression and expr expressions.

String functions

FunctionSignatureDescriptionExample
getStringgetString(a, b)Returns a if non-empty; otherwise returns b.getString(user.city, "unknown")
trimtrim(str, cutset)Removes all leading and trailing characters in cutset from str.trim(" hello ", " ") returns "hello"
trimPrefixtrimPrefix(str, cutset)Removes leading characters in cutset from str.trimPrefix("UF_uid", "UF_") returns "uid"
replacereplace(str, old, new)Replaces all occurrences of old with new in str.replace("a-b-c", "-", "_") returns "a_b_c"

Math functions

FunctionSignatureDescriptionExample
roundround(number)Rounds to the nearest integer.round(123.5) returns 124.0
roundround(number, places)Truncates to the specified number of decimal places.round(123.456, 2) returns 123.45
hash32hash32(str)Computes a 32-bit hash using murmur3.Sum32.hash32(item.id)
loglog(number)Natural logarithm (base e).log(2.718)
log10log10(number)Common logarithm (base 10).log10(100) returns 2.0
log2log2(number)Binary logarithm (base 2).log2(8) returns 3.0
powpow(base, exponent)Raises base to the power of exponent.pow(2, 10) returns 1024.0

Geospatial functions

FunctionSignatureDescription
s2CellIDs2CellID(lat, lng) s2CellID(lat, lng, level)Returns the S2 Cell ID (int) for the given coordinates. level controls precision (higher = smaller cell). Default level: 15.
s2CellNeighborss2CellNeighbors(lat, lng) s2CellNeighbors(lat, lng, level)Returns a list of S2 Cell IDs ([]int) for the given coordinates and all 8 adjacent cells — 9 IDs total.
geoHashgeoHash(lat, lng) geoHash(lat, lng, precision)Encodes coordinates as a Geohash string. Default precision: 6.
geoHashWithNeighborsgeoHashWithNeighbors(lat, lng) geoHashWithNeighbors(lat, lng, precision)Returns Geohash strings for the given coordinates and all 8 adjacent areas — 9 strings total.
haversinehaversine(lng1, lat1, lng2, lat2)Calculates the spherical distance between two points using the Haversine formula. Returns float64 in kilometers.
sphereDistancesphereDistance(lng1, lat1, lng2, lat2)Calculates the spherical distance between two points using the spherical law of cosines. Returns float64 in kilometers.