EasyRec
repository·master·Indexed 25 days ago
https://github.com/alibaba/easyrecAn 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.
What's inside EasyRec
- 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).
Overview of EasyRec capabilities
masterEasyRec 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.
Use EasyRec Python layers for model building
masterEasyRec provides a suite of specialized neural network layers via the
easy_rec.python.layersmodule 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.
Key features of EasyRec
masterEasyRec 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, andMultiWorker. - Deployment: Easy deployment to EAS with automatic scaling and monitoring, ensuring consistency between training and serving.
- Vector Retrieval: Supports running
knn algorithmon vectors in a distributed environment.
Use different input data sources in EasyRec Python API
masterEasyRec provides a variety of input modules within the
easy_rec.python.inputnamespace 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_inputorcsv_input_v2for reading data from local or distributed CSV files. - Kafka: Use
kafka_inputfor real-time streaming data from Kafka topics. - ODPS (MaxCompute): Use
odps_input,odps_input_v2, orodps_rtp_inputfor data stored in Alibaba Cloud's ODPS/MaxCompute. - RTP (Real-Time Processing): Use
rtp_inputorrtp_input_v2for 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.
- CSV Files: Use
What is AITM (Adaptive Information Transfer Multi-task)?
masterAITM 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:
- Attention Mechanism: Used to fuse feature representations corresponding to multiple objectives.
- Behavior Correction: Introduces an auxiliary loss function (e.g.,
ORDER_CALIBRATE_LOSS) to correct predictions based on the sequential dependency of behaviors.
What is FiBiNet?
masterFiBiNet is a recommendation model designed to improve Click-Through Rate (CTR) prediction by combining two core modules:
- SENET (Squeeze-Excitation network): Dynamically learns feature importance by assigning higher weights to important features and reducing the weights of less important ones.
- 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
RankModelwithin EasyRec.What is the Rocket Launching framework?
masterRocket 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.
- 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
What is RTP FG?
masterRTP 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 featureandlookup 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.configfiles from anfg.jsonconfiguration. - Supports one-click deployment using the EasyRec Processor.
What is the Feature Generator (FG)?
masterThe 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 featureandlookup 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.
Use PAIAssessor for early stopping in HPO
masterThe
PAIAssessoris 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 configuredmaxTrialNumber.Configuration Options for
PAIAssessor(viaclassArgsinexp.yml):Option Description Values optimize_modeDirection of optimization maximize/minimizestart_stepThe step number at which early stopping decisions begin Integer (e.g., 2)moving_avgWhether to use a moving average of all historical results as the benchmark True/FalseproportionThe ratio used to compare the current best value against historical records Float (e.g., 0.5)patienceNumber of consecutive decreases in the metric before stopping Integer (e.g., 10)assessor: name: PAIAssessor classArgs: platform: MAXCOMPUTE optimize_mode: maximize start_step: 1 moving_avg: true proportion: 0.5How the UNITER model handles multi-modal features
masterThe 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.image: Contains image or video features (e.g., a single embedding or a set of embeddings representing multiple frames/regions).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 sameembedding_dim.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 sameembedding_dim.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_dimof all features in both thetextandgeneralgroups 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' } }