The implementation of various recommender system models (Tensorflow).
RS
├─cf # collaborative filtering based recommender system
│ ├─config # store the configurations of models (one model may has many configurations)
│ ├─layers # store the layers source code
│ ├─models # store the models source code
│ ├─preprocess # store the preprocessing of datasets.
│ ├─result # store the result of training models, include configs, model summays, weights and accuracy (1 -> n)
│ ├─run # store the files which run the training process.
│ ├─tune # The multiple config of yaml files which used to fine tune.
│ └─utils # store some common functions
├─data
│ ├─avazu
│ ├─criteo
│ └─movielens
├─gnn # gnn based recommender system
├─shell # some shell scripts
├─notebook # some classical models in the form of notebooks
└─log # store the log file.
-
CTR models
-
Recall models
-
Other:
- criteo
- avazu
- movielens-1m
- User Behavior Data from Taobao
- Ad Display/Click Data
- Fliggy
- Huawei Competition --- data_3.zip
- Without MirroredStrategy in lower tf version, it will come with unknown shape warning, even sometimes it will affect the training speed. You can ignore the warning.
- In the Callback(keras.callbacks.Callback) of lower version of tensorflow (<2.4.0), if
set
self.model.stop_training = True
, the training process will stop in the end of epoch, while higher version of tf will stop in the end of this step. - If you wanna to modify the process of keras function
fit()
, you can inherit the classkeras.model.Model
, then override the functiontrain_step()
(Learnt from cowclip model). - Some imports such as
from keras.callbacks import Callback
may not work in lower version of tensorflow 2.X(<2.4.0), then you should replace it withfrom tensorflow.keras.callbacks import Callback
. - If you want to debug training process gracefully, you should set the flag
run_eagerly=True
in thecompile()
function when construct the model. - Original cowclip source code will crash when gradient because there are mismatch between gradient and trainable
variables(In the
train_step
function). - For cowclip model in lower version of tensorflow 2.X(<2.4.0), you should also implement the function
test_step
otherwise it will cause OOM error because of bad conversion of tensor. - For recommendation system, the numerical feature have large variance and hurt algorithms, so we should normalize them(AutoInt C5.1). If we consider training numerical feature with sparse feature in the attention based model, the performance may not well.
- In EDCN, using
BatchNormalization
is required, other than it will occur gradient vanishing problems because small number matrix hadamard product in bridge module, and use residual shortcut optionally. - For ragged tensor, it occurs
keepdims=True is not supported for RaggedTensors
error in lower version of Tensorflow(<2.4.0), while it is okay in higher version. - In lower version of tf(<2.4.0), the name of variables must conform to regex
"^[A-Za-z0-9.][A-Za-z0-9_.\\/>-]*$"
. - In lower version of tf(<2.4.0), there is no
PReLU
activation function, you need to write it manually(In packagecf.metric.recall.PReLU
).
- Training with 10240, 4096, 1024, 10240 batches in order which can reach better performance for CTR models.