EasyRec

repository·master·Indexed 25 days ago

https://github.com/alibaba/easyrec

An extendable and efficient framework for building industrial-scale recommendation systems. EasyRec supports candidate generation, ranking, and multi-task learning, featuring a variety of models including DeepFM, Wide & Deep, DCN, AutoInt, DSSM, and MIND. It includes tools for data preprocessing and inference via the EasyRecProcessor client, with provided examples and configurations for datasets such as Amazon Books, Criteo, and MovieLens-1M.

Tokens
141.1K
Snippets
255
Records
462
Agent score
80%

What's inside EasyRec

  1. Overview of EasyRec capabilities

    master
    EasyRec is a recommendation framework designed for candidate generation (matching), scoring (ranking), and multi-task learning. It focuses on improving model generation efficiency through simple configuration and Hyper Parameter Tuning (HPO).
  2. Overview of EasyRec capabilities

    master

    EasyRec is designed for industrial-scale recommendation systems with the following key features:

    Supported Runtimes & Data

    • Runtimes: TF1.12-1.15, TF2.x, and PAI-TF.
    • Input Data: MaxCompute Tables, HDFS files, Hive Tables, OSS files, CSV/Parquet files, and Datahub/Kafka Streams.

    Core Functionality

    • Model Variety: Supports a wide range of models including DSSM, MIND, Wide & Deep, DeepFM, DIN, BST, MMoE, ESMM, and more.
    • Smart Features: Includes EarlyStop, Best Checkpoint Saver, Hyper Parameter Search (via PAI-NNI), AutoFeatureCross, and Knowledge Distillation.
    • Scalability: Supports large-scale embedding, online learning, and multiple parallel strategies (ParameterServer, Mirrored, MultiWorker).
    • Deployment: Easy deployment to EAS with automatic scaling and monitoring, ensuring consistency between training and serving.
    • Vector Retrieval: Supports running kNN algorithms in a distributed environment.
  3. Use EasyRec Python layers for model building

    master

    EasyRec provides a suite of specialized neural network layers via the easy_rec.python.layers module to facilitate the construction of recommendation models. These layers are organized by their functional purpose, such as input handling, embedding, attention mechanisms, and specific model architectures like FM or MMOE.

    Available layer modules include:

    • easy_rec.python.layers.dnn: Deep Neural Network layers.
    • easy_rec.python.layers.embed_input_layer: Embedding input layers for handling categorical features.
    • easy_rec.python.layers.fm: Factorization Machine layers.
    • easy_rec.python.layers.input_layer: Standard input layers.
    • easy_rec.python.layers.layer_norm: Layer Normalization layers.
    • easy_rec.python.layers.seq_input_layer: Sequence input layers for sequential recommendation tasks.
    • easy_rec.python.layers.multihead_attention: Multi-head attention mechanisms.
    • easy_rec.python.layers.mmoe: Multi-gate Mixture-of-Experts (MMOE) layers for multi-task learning.
  4. Key features of EasyRec

    master

    EasyRec provides several advanced features for recommendation workflows:

    • Configuration: Flexible feature and model configuration with efficient feature generation.
    • Intelligence: Includes EarlyStop, Best Checkpoint Saver, Hyper Parameter Search, and AutoFeatureCross. (NAS, Knowledge Distillation, and MultiModal are in development).
    • Scalability: Supports large-scale embedding and incremental saving. It utilizes parallel strategies such as ParameterServer, Mirrored, and MultiWorker.
    • Deployment: Easy deployment to EAS with automatic scaling and monitoring, ensuring consistency between training and serving.
    • Vector Retrieval: Supports running knn algorithm on vectors in a distributed environment.
  5. Use different input data sources in EasyRec Python API

    master

    EasyRec provides a variety of input modules within the easy_rec.python.input namespace to handle different data sources for recommendation tasks. Depending on your data storage and streaming requirements, you can use the following input types:

    • CSV Files: Use csv_input or csv_input_v2 for reading data from local or distributed CSV files.
    • Kafka: Use kafka_input for real-time streaming data from Kafka topics.
    • ODPS (MaxCompute): Use odps_input, odps_input_v2, or odps_rtp_input for data stored in Alibaba Cloud's ODPS/MaxCompute.
    • RTP (Real-Time Processing): Use rtp_input or rtp_input_v2 for real-time data processing pipelines.

    All input modules are designed to integrate with the EasyRec framework to feed data into models for training or inference.

  6. What is AITM (Adaptive Information Transfer Multi-task)?

    master

    AITM is a multi-task learning framework designed for recommendation scenarios where users follow a sequential conversion path (e.g., Impression $\rightarrow$ Click $\rightarrow$ Conversion). It aims to improve the estimation of backend conversion rates by utilizing samples from all nodes in the conversion chain.

    Key features include:

    1. Attention Mechanism: Used to fuse feature representations corresponding to multiple objectives.
    2. Behavior Correction: Introduces an auxiliary loss function (e.g., ORDER_CALIBRATE_LOSS) to correct predictions based on the sequential dependency of behaviors.
  7. What is FiBiNet?

    master

    FiBiNet is a recommendation model designed to improve Click-Through Rate (CTR) prediction by combining two core modules:

    1. SENET (Squeeze-Excitation network): Dynamically learns feature importance by assigning higher weights to important features and reducing the weights of less important ones.
    2. Bilinear Feature Interaction: Unlike simple Inner Product or Hadamard Product methods, this module inserts a weight matrix between two features to dynamically learn their combination relationships.

    It is implemented as a RankModel within EasyRec.

  8. What is the Rocket Launching framework?

    master

    Rocket Launching is a framework designed for online real-time response systems (like CTR prediction) where strict latency requirements prevent the use of deep, complex models during inference.

    How it works:

    • Training Phase: It simultaneously trains two networks with different complexities: a light net (simple) and a booster net (complex). The two networks share some parameters and learn class labels separately. The light net learns to mimic the booster net by learning its soft target, which improves the training effectiveness of the lightweight model.
    • Testing/Inference Phase: Only the light net is used for prediction, ensuring high speed and low latency while maintaining performance close to the complex booster model.
  9. What is RTP FG?

    master

    RTP FG (RealTime Predict Feature Generation) is a framework designed to handle feature engineering requirements for real-time prediction. It efficiently generates complex cross-features, such as match feature and lookup feature, using C++ code to ensure consistency between offline training and online prediction.

    Key capabilities:

    • Generates features that can be integrated into EasyRec for training.
    • Automatically generates EasyRec pipeline.config files from an fg.json configuration.
    • Supports one-click deployment using the EasyRec Processor.
  10. What is the Feature Generator (FG)?

    master

    The Feature Generator (FG) is a data transformation module that converts raw input into the features required by a model. Its primary purpose is to ensure consistency between offline and online sample generation.

    Key characteristics:

    • DAG Execution: FG executes a series of feature transformation operators (FG operators) in parallel according to a Directed Acyclic Graph (DAG) defined in a configuration file.
    • Efficiency: It efficiently generates complex cross-features like expr feature and lookup feature.
    • Integration: Features generated by FG can be used for EasyRec training and are supported during online deployment via the EasyRec Processor.
    • Capabilities: Supports complex types (array, map), custom operators, discretization (binning), and feature dependencies.
  11. Use PAIAssessor for early stopping in HPO

    master

    The PAIAssessor is used to compare current trial results against historical results within the same group. If the results do not meet specific criteria (e.g., falling below a certain threshold), the assessor can stop the execution of that hyperparameter group to save resources. This means the actual number of trials run may be significantly less than the configured maxTrialNumber.

    Configuration Options for PAIAssessor (via classArgs in exp.yml):

    OptionDescriptionValues
    optimize_modeDirection of optimizationmaximize / minimize
    start_stepThe step number at which early stopping decisions beginInteger (e.g., 2)
    moving_avgWhether to use a moving average of all historical results as the benchmarkTrue / False
    proportionThe ratio used to compare the current best value against historical recordsFloat (e.g., 0.5)
    patienceNumber of consecutive decreases in the metric before stoppingInteger (e.g., 10)
    assessor:
      name: PAIAssessor
      classArgs:
        platform: MAXCOMPUTE
        optimize_mode: maximize
        start_step: 1
        moving_avg: true
        proportion: 0.5
  12. How the UNITER model handles multi-modal features

    master

    The UNITER (UNiversal Image-TExt Representation Learning) model is a Transformer-based architecture designed to fuse multi-modal information (such as images and text) for recommendation tasks. In EasyRec, the model is extended to support item attributes and statistical features.

    To use UNITER, you must organize your input features into one of four specific feature_groups. You do not need all four; providing at least one is sufficient for training. If a group is not provided, the corresponding network structure is skipped.

    1. image: Contains image or video features (e.g., a single embedding or a set of embeddings representing multiple frames/regions).
    2. general: Contains regular features (numerical, single-value categorical, or multi-value categorical) that participate in cross-modal attention. Note: All features in this group must have the same embedding_dim.
    3. text: Contains variable-length text sequences (e.g., title, description) that participate in cross-modal attention. Note: All features in this group must have the same embedding_dim.
    4. other: Contains features that do not participate in cross-modal attention (e.g., statistical features). These are concatenated directly with the output of the cross-modal fusion module before the final MLP.

    Critical Requirement: For the cross-modal attention mechanism to work, the embedding_dim of all features in both the text and general groups must be consistent.

    model_config: {
      model_class: 'Uniter'
      feature_groups: {
        group_name: 'image'
        feature_names: 'embedding'
      }
      feature_groups: {
        group_name: 'general'
        feature_names: 'user_id'
        feature_names: 'gender'
      }
      feature_groups: {
        group_name: 'text'
        feature_names: 'title'
      }
      feature_groups: {
        group_name: 'other'
        feature_names: 'score_time'
      }
    }