Customize pipelines

Updated at:

PAI-Rec supports custom pipelines that allow you to define separate recommendation processes for scenarios such as cold starts or multi-format feeds, with dynamic adjustment through A/B testing.

Background information

The PAI-Rec engine provides a pipeline that integrates recommendation phases such as recall, filtering, coarse ranking, feature loading, and fine ranking. In some cases, a single pipeline cannot meet all business requirements. For example, the cold start process requires a separate pipeline because its coarse ranking and fine ranking phases differ from those of the main process. Similarly, recommendation feeds on the home page may contain images, text, and videos that require different processing pipelines before results are merged for display.

PAI-Rec lets you customize pipelines to define recommendation processes that differ from the main process. You can use configuration files to define pipelines and dynamically adjust them based on A/B testing results.

Overall architecture

The primary pipeline flow is as follows:

image-20220107150220242.png

You can configure multiple pipelines for a scenario and merge their output with the data from the main process.

image-20220107151325761.png

Custom pipeline configurations

Configuration details:

 {
   "PipelineConfs": {
    "video_feed": [ // Scenario name. You can configure multiple pipelines for a scenario.
      {
        "Name": "coldstart", // Custom pipeline name. The name must be globally unique across all scenarios.
        "RecallNames": [], // Recall list. Defined in RecallConfs.
        "FilterNames": [], // Filter list. Defined in FilterConfs.
        "GeneralRankConf": { // Coarse ranking definition. For more information, see the coarse ranking configuration.
          "FeatureLoadConfs":[],
          "RankConf":{},
          "ActionConfs": [
            {
              "ActionType": "filter",
              "ActionName": ""
            }
          ]
        },
        "FeatureLoadConfs":[],
        "RankConf":{
          "RankAlgoList":[],
          "RankScore":"",
          "Processor":"",
          "BatchCount": 100
        },
        "ColdStartRankConf": {
          "AlgoName":"",
          "OnlyEmbeddingFeature": true
        },
        "SortNames":[] // Sorting process. Defined in SortConfs.
      }
    ]
  }
 }

The pipeline configuration follows the same structure as the main process. The sample above shows all available fields, but not all are required. The following list describes each parameter:

  • PipelineConfs: the configurations of all pipelines. You can configure pipelines for multiple scenarios.

  • Name: the custom name of the pipeline, which must be globally unique in the configurations.

  • RecallNames: the names of the recalls. You can use the names specified by the RecallConfs parameter, or specify custom names.

  • FilterNames: the names of the filters. You can use the names specified by the FilterConfs parameter, or specify custom names.

  • GeneralRankConf: The coarse ranking configuration. This field is optional.

  • FeatureLoadConfs: The feature loading configuration. For more information, see Configure features.

  • RankConf and ColdStartRankConf are mutually exclusive. If you want to use the cold start algorithm, configure the ColdStartRankConf parameter. If you want to use the fine ranking model, configure the RankConf parameter.

  • SortNames is an optional parameter that specifies custom sorting to further process data in the pipeline. The sort names can be retrieved from SortConfs or be custom-defined.

Experiment parameters

You can configure experiment parameters for all phases of a pipeline to support A/B testing. Parameter names follow the format: "pipelines." + {pipeline name} + ".{phase name}". The following table describes the parameters.

Parameter name

Parameter type

Description

Example

pipelines.{pipeline_name}.RecallNames

json array

The list must contain all retrievals.

{"pipelines.coldstart.RecallNames":[ "ColdStartRecall"]}

pipelines.{pipeline_name}.FilterNames

json array

The filter list contains all filter flows.

{"pipelines.coldstart.FilterNames":["UniqueFilter", "UserExposureFilter"]}

pipelines.{pipeline_name}.GeneralRankConf

recconf.GeneralRankConfig

The configurations of the coarse ranking.

{"pipelines.coldstart.GeneralRankConf":{"Actions":[]}}

pipelines.{pipeline name}.FeatureLoadConfs

[]recconf.FeatureLoadConfig

The configurations of feature loading.

{"pipelines.coldstart.FeatureLoadConfs":[{"FeatureDaoConf":{}}]}

"pipelines." + {pipeline_name} + ".RankConf"

recconf.RankConfig

The configurations of the ranking algorithm.

{

"pipelines.coldstart.RankConf"

:{

"RankAlgoList"

:[

"pai_homepage_fm"

],

"RankScore":"${pai_homepage_fm}"

}

}

pipelines.{pipeline name}.ColdStartRankConf

recconf.ColdStartRankConfig

The configurations of the cold start algorithm.

{

"pipelines.coldstart.ColdStartRankConf"

:{

"AlgoName":""

,

"OnlyEmbeddingFeature":true

}

}

pipelines.{pipeline name}.SortNames

json array

Sorting lists

{ "pipelines.coldstart.SortNames":[]}