A configurable, tunable, and reproducible library for CTR prediction

Overview

FuxiCTR

This repo is the community dev version of the official release at huawei-noah/benchmark/FuxiCTR.

Click-through rate (CTR) prediction is an critical task for many industrial applications such as online advertising, recommender systems, and sponsored search. FuxiCTR provides an open-source library for CTR prediction, with key features in configurability, tunability, and reproducibility. It also supports the building of the BARS-CTR-Prediction benchmark, which aims for open benchmarking for CTR prediction.

👉 If you find our code or benchmarks helpful in your research, please kindly cite the following paper.

Jieming Zhu, Jinyang Liu, Shuai Yang, Qi Zhang, Xiuqiang He. Open Benchmarking for Click-Through Rate Prediction. The 30th ACM International Conference on Information and Knowledge Management (CIKM), 2021.

Model List

Publication Model Paper Available
WWW'07 LR Predicting Clicks: Estimating the Click-Through Rate for New Ads ✔️
ICDM'10 FM Factorization Machines ✔️
CIKM'15 CCPM A Convolutional Click Prediction Model ✔️
RecSys'16 FFM Field-aware Factorization Machines for CTR Prediction ✔️
RecSys'16 YoutubeDNN Deep Neural Networks for YouTube Recommendations ✔️
DLRS'16 Wide&Deep Wide & Deep Learning for Recommender Systems ✔️
ICDM'16 IPNN Product-based Neural Networks for User Response Prediction ✔️
KDD'16 DeepCross Deep Crossing: Web-Scale Modeling without Manually Crafted Combinatorial Features ✔️
NIPS'16 HOFM Higher-Order Factorization Machines ✔️
IJCAI'17 DeepFM DeepFM: A Factorization-Machine based Neural Network for CTR Prediction ✔️
SIGIR'17 NFM Neural Factorization Machines for Sparse Predictive Analytics ✔️
IJCAI'17 AFM Attentional Factorization Machines: Learning the Weight of Feature Interactions via Attention Networks ✔️
ADKDD'17 DCN Deep & Cross Network for Ad Click Predictions ✔️
WWW'18 FwFM Field-weighted Factorization Machines for Click-Through Rate Prediction in Display Advertising ✔️
KDD'18 xDeepFM xDeepFM: Combining Explicit and Implicit Feature Interactions for Recommender Systems ✔️
KDD'18 DIN Deep Interest Network for Click-Through Rate Prediction ✔️
CIKM'19 FiGNN FiGNN: Modeling Feature Interactions via Graph Neural Networks for CTR Prediction ✔️
CIKM'19 AutoInt/AutoInt+ AutoInt: Automatic Feature Interaction Learning via Self-Attentive Neural Networks ✔️
RecSys'19 FiBiNET FiBiNET: Combining Feature Importance and Bilinear feature Interaction for Click-Through Rate Prediction ✔️
WWW'19 FGCNN Feature Generation by Convolutional Neural Network for Click-Through Rate Prediction ✔️
AAAI'19 HFM/HFM+ Holographic Factorization Machines for Recommendation ✔️
NeuralNetworks'20 ONN Operation-aware Neural Networks for User Response Prediction ✔️
AAAI'20 AFN/AFN+ Adaptive Factorization Network: Learning Adaptive-Order Feature Interactions ✔️
AAAI'20 LorentzFM Learning Feature Interactions with Lorentzian Factorization ✔️
WSDM'20 InterHAt Interpretable Click-through Rate Prediction through Hierarchical Attention ✔️
DLP-KDD'20 FLEN FLEN: Leveraging Field for Scalable CTR Prediction ✔️
CIKM'20 DeepIM Deep Interaction Machine: A Simple but Effective Model for High-order Feature Interactions ✔️
WWW'21 FmFM FM^2: Field-matrixed Factorization Machines for Recommender Systems ✔️
WWW'21 DCN-V2 DCN V2: Improved Deep & Cross Network and Practical Lessons for Web-scale Learning to Rank Systems ✔️

Installation

Please follow the guide for installation. In particular, FuxiCTR has the following dependent requirements.

  • python 3.6
  • pytorch v1.0/v1.1
  • pyyaml >=5.1
  • scikit-learn
  • pandas
  • numpy
  • h5py
  • tqdm

Get Started

  1. Run the demo to understand the overall workflow

  2. Run a model with dataset and model config files

  3. Preprocess raw csv data to h5 data

  4. Run a model with h5 data as input

  5. How to make configurations?

  6. Tune the model hyper-parameters via grid search

  7. Run a model with sequence features

  8. Run a model with pretrained embeddings

Code Structure

Check an overview of code structure for more details on API design.

Open Benchmarking

If you are looking for the benchmarking settings and results on the state-of-the-art CTR prediction models, please refer to the BARS-CTR-Prediction benchmark. By clicking on the "SOTA Results", you will find the benchmarking results along with the corresponding reproducing steps.

Discussion

Welcome to join our WeChat group for any questions and discussions.

Join Us

We have open positions for internships and full-time jobs. If you are interested in research and practice in recommender systems, please send your CV to [email protected].

Comments
  • expid repeat

    expid repeat

    when i run "python run_expid.py --config /..../ --expid 191 --gpu 0" in my code,i get 2 results log .they are ..._tune_191_ahdfy68.log and ..._tune_051_os191usd.log.In second log file name,it also has the string of '191'.

    opened by lsquser 3
  • Implementation of the model DIN

    Implementation of the model DIN

    I am not sure whether the implementation of DIN here is consistent with the original official released code DIN or DIEN. Given query_field (e.g., query Goods ID, query Cate ID) and history_field (e.g., Goods ID, Cate ID), in the original implementation, they first concatenate the embeddings of history_field (i.e., [Goods ID embedding, Cate ID embedding]) and then perform so-called "local activation unit (LAU)" with the concatenated query_field (i.e., [query Goods ID embedding, query Cate ID embedding]). In contrast, the implementation here seems to first perform the LAU then do the concatenation. Specifically, the code in DIN.py:

    # 1. perform the LAU for each history_field
    for idx, (din_query_field, din_history_field) \
                in enumerate(zip(self.din_query_field, self.din_history_field)):
                item_emb = feature_emb_dict[din_query_field]
                history_sequence_emb = feature_emb_dict[din_history_field]
                pooled_history_emb = self.attention_layers[idx](item_emb, history_sequence_emb)
                feature_emb_dict[din_history_field] = pooled_history_emb
    # 2. do the concatenation here
    feature_emb = self.embedding_layer.dict2tensor(feature_emb_dict)
    

    If my understanding is correct, I wonder whether this will affect the final performance compared with the original implementation?

    opened by cjfcsjt 2
  • HFM may not be available due to compatibility issues

    HFM may not be available due to compatibility issues

    HFM adopts HolographicInteractionLayer in fuxictr/pytorch/layers/interaction.py.

    However, HolographicInteractionLayer may be not available in Pytorch 1.10 because torch.rfft/torch.irfft has changed.\

    Here is a solution for reference:

    try:
        from torch import irfft
        from torch import rfft
    except ImportError:
        from torch.fft import irfft2
        from torch.fft import rfft2
        def rfft(x, d):
            t = rfft2(x, dim = (-d))
            return torch.stack((t.real, t.imag), -1)
        def irfft(x, d, signal_sizes):
            return irfft2(torch.complex(x[:,:,0], x[:,:,1]), s = signal_sizes, dim = (-d))
    
    opened by Dansheng 1
  • Modify InterHat Attention : value.view

    Modify InterHat Attention : value.view

    Hi. Thank you for the nice RecSys code.

    I am sending you PR because there was a mistake in the InterHAT code. I think it should be modified in MultiHeadSelfAtt code :

    • before : value = value(batch_size, -1, self.num_heads, self.head_dim).transpose(1, 2)
    • after : value = value.view(batch_size, -1, self.num_heads, self.head_dim).transpose(1, 2)

    Please checking this PR!

    Thanks.

    opened by lsjsj92 1
  • Normalizer and NaN values.

    Normalizer and NaN values.

    For StandardScaler, looks like it supports NaN values, see class Normalizer:

    null_index = np.isnan(X)
    

    However, during preprocess, _fill_na() will fill na_value for non-string. So

    • for dtype=str, the X values will be string
    • for dtype=float/int, the X values will be na_value

    In the first case, np.isnan will throw an error because X elements are of string type. In the second case, there is no point to normalize numbers if we have a na_value there.

    Is this behavior expected or not?

    opened by w32zhong 1
  • Sequence feature in demo

    Sequence feature in demo "DeepFM_with_sequence_feature.py".

    Should field "sequence" share embeddings with the field "adgroup_id"? I found that the method "encoder.fit()" assigns the encoder such as tokenizer for each field. Since the given tiny datasets record the user historical behavior (ad sequence), then in my understanding that the id that appeared in the field "sequence" may also appear in the field "adgroup_id". As a result, it seems that the field "sequence" should share the same encoder (i.e., tokenizer) with the field "adgroup_id", but the demo "DeepFM_with_sequence_feature.py" gives separate encoders for these two fields.

    opened by cjfcsjt 1
  • sequence feature

    sequence feature

    41/5000 When I try to use sequence characteristics, the program has an array out of bounds error. Could you please give an example of sequence features.

    documentation 
    opened by jzm-123 1
  • MultiHeadAttention bug when num_heads is greater than 1

    MultiHeadAttention bug when num_heads is greater than 1

    The code of splitting heads is buggy, without transpose the shape. The buggy code impacts AutoInt, DESTINE, InterHAt

    query = query.view(batch_size * self.num_heads, -1, self.attention_dim)
    key = key.view(batch_size * self.num_heads, -1, self.attention_dim)
    value = value.view(batch_size * self.num_heads, -1, self.attention_dim)
    

    The buggy code is from the reference code https://zhuanlan.zhihu.com/p/47812375

    The correct code should be:

    query = query.view(batch_size, seq_len, self.num_heads, self.attention_dim).transpose(1, 2)
    key = key.view(batch_size, seq_len, self.num_heads, self.attention_dim).transpose(1, 2)
    value = value.view(batch_size, seq_len, self.num_heads, self.attention_dim).transpose(1, 2)
    
    bug 
    opened by zhujiem 0
  • Emb_LayerNorm bug in MaskNet

    Emb_LayerNorm bug in MaskNet

    The paper uses concat(LN(e1), LN(e2),..., LN(ef)), but the code use nn.LayerNorm([feature_map.num_fields, embedding_dim]). This makes normalization happen in the last two dimensions.

    bug 
    opened by xpai 0
  • sample weights

    sample weights

    This PR adds the option to add sample weights to model instances, by specifying weight_col to the dataset config. This creates a sample_weight: 1 in the feature map json. When this is absent, from now on all instances receive a weight 1 by default, since pytorch enforces DataLoader to output tensor so we cannot set the weights to None. We also set the package dependency to torch=1.7 the last version that supports fft as used now by the HolographicInteractionLayer.

    opened by samins 0
Owner
XUEPAI
XUEPAI
FADNet++: Real-Time and Accurate Disparity Estimation with Configurable Networks

FADNet++: Real-Time and Accurate Disparity Estimation with Configurable Networks

HKBU High Performance Machine Learning Lab 6 Nov 18, 2022
Capture all information throughout your model's development in a reproducible way and tie results directly to the model code!

Rubicon Purpose Rubicon is a data science tool that captures and stores model training and execution information, like parameters and outcomes, in a r

Capital One 97 Jan 3, 2023
Open-L2O: A Comprehensive and Reproducible Benchmark for Learning to Optimize Algorithms

Open-L2O This repository establishes the first comprehensive benchmark efforts of existing learning to optimize (L2O) approaches on a number of proble

VITA 161 Jan 2, 2023
MQBench: Towards Reproducible and Deployable Model Quantization Benchmark

MQBench: Towards Reproducible and Deployable Model Quantization Benchmark We propose a benchmark to evaluate different quantization algorithms on vari

null 494 Dec 29, 2022
Fake-user-agent-traffic-geneator - Python CLI Tool to generate fake traffic against URLs with configurable user-agents

Fake traffic generator for Gartner Demo Generate fake traffic to URLs with custo

New Relic Experimental 3 Oct 31, 2022
Price-Prediction-For-a-Dream-Home - A machine learning based linear regression trained model for house price prediction.

Price-Prediction-For-a-Dream-Home ROADMAP TO THIS LINEAR REGRESSION BASED HOUSE PRICE PREDICTION PREDICTION MODEL Import all the dependencies of the p

DIKSHA DESWAL 1 Dec 29, 2021
Doge-Prediction - Coding Club prediction ig

Doge-Prediction Coding Club prediction ig Basically: Create an application that

null 1 Jan 10, 2022
:boar: :bear: Deep Learning based Python Library for Stock Market Prediction and Modelling

bulbea "Deep Learning based Python Library for Stock Market Prediction and Modelling." Table of Contents Installation Usage Documentation Dependencies

Achilles Rasquinha 1.8k Jan 5, 2023
MolRep: A Deep Representation Learning Library for Molecular Property Prediction

MolRep: A Deep Representation Learning Library for Molecular Property Prediction Summary MolRep is a Python package for fairly measuring algorithmic p

AI-Health @NSCC-gz 83 Dec 24, 2022
Code and datasets for the paper "Combining Events and Frames using Recurrent Asynchronous Multimodal Networks for Monocular Depth Prediction" (RA-L, 2021)

Combining Events and Frames using Recurrent Asynchronous Multimodal Networks for Monocular Depth Prediction This is the code for the paper Combining E

Robotics and Perception Group 69 Dec 26, 2022
Fast and scalable uncertainty quantification for neural molecular property prediction, accelerated optimization, and guided virtual screening.

Evidential Deep Learning for Guided Molecular Property Prediction and Discovery Ava Soleimany*, Alexander Amini*, Samuel Goldman*, Daniela Rus, Sangee

Alexander Amini 75 Dec 15, 2022
A modified version of DeepMind's Alphafold2 to divide CPU part (MSA and template searching) and GPU part (prediction model)

ParallelFold Author: Bozitao Zhong This is a modified version of DeepMind's Alphafold2 to divide CPU part (MSA and template searching) and GPU part (p

Bozitao Zhong 77 Dec 22, 2022
In this project I played with mlflow, streamlit and fastapi to create a training and prediction app on digits

Fastapi + MLflow + streamlit Setup env. I hope I covered all. pip install -r requirements.txt Start app Go in the root dir and run these Streamlit str

null 76 Nov 23, 2022
Image Classification - A research on image classification and auto insurance claim prediction, a systematic experiments on modeling techniques and approaches

A research on image classification and auto insurance claim prediction, a systematic experiments on modeling techniques and approaches

null 0 Jan 23, 2022
Age and Gender prediction using Keras

cnn_age_gender Age and Gender prediction using Keras Dataset example : Description : UTKFace dataset is a large-scale face dataset with long age span

XN3UR0N 58 May 3, 2022
git《Joint Entity and Relation Extraction with Set Prediction Networks》(2020) GitHub:

Joint Entity and Relation Extraction with Set Prediction Networks Source code for Joint Entity and Relation Extraction with Set Prediction Networks. W

null 130 Dec 13, 2022
TalkNet 2: Non-Autoregressive Depth-Wise Separable Convolutional Model for Speech Synthesis with Explicit Pitch and Duration Prediction.

TalkNet 2 [WIP] TalkNet 2: Non-Autoregressive Depth-Wise Separable Convolutional Model for Speech Synthesis with Explicit Pitch and Duration Predictio

Rishikesh (ऋषिकेश) 69 Dec 17, 2022
VIMPAC: Video Pre-Training via Masked Token Prediction and Contrastive Learning

This is a release of our VIMPAC paper to illustrate the implementations. The pretrained checkpoints and scripts will be soon open-sourced in HuggingFace transformers.

Hao Tan 74 Dec 3, 2022
A selection of State Of The Art research papers (and code) on human locomotion (pose + trajectory) prediction (forecasting)

A selection of State Of The Art research papers (and code) on human trajectory prediction (forecasting). Papers marked with [W] are workshop papers.

Karttikeya Manglam 40 Nov 18, 2022