This project implements a multi-task recommender system using TensorFlow Recommenders (TFRS). It's based on the TensorFlow Recommenders example for building a multi-objective recommender for Movielens, using both implicit (movie watches) and explicit signals (ratings).
multitask_recommender/
├── config.yaml # Configuration file for hyperparameters
├── data.py # Script for loading and preprocessing the Movielens dataset
├── model.py # Script defining the multi-task recommender model
├── train.py # Script for training and evaluating the model
├── requirements.txt # List of project dependencies
└── README.md # This file
The config.yaml
file contains the following hyperparameters:
embedding_dimension
: Dimension of the embedding vectors for users and movies.rating_weight
: Weight for the rating prediction loss.retrieval_weight
: Weight for the retrieval task loss.learning_rate
: Learning rate for the optimizer.epochs
: Number of training epochs.batch_size
: Batch size for training.
The project dependencies are listed in requirements.txt
. To install them, run:
pip install -r requirements.txt
To train and evaluate the model, run the train.py
script:
python train.py
This script will:
- Load the Movielens dataset.
- Build the multi-task recommender model.
- Train the model using the training data.
- Evaluate the model on the test data, reporting the retrieval top-100 accuracy and the ranking Root Mean Squared Error (RMSE).
The model is a multi-task model that jointly optimizes for two tasks:
- Rating Prediction: Predicts the explicit ratings given by users to movies.
- Retrieval: Predicts which movies a user will interact with (implicit feedback).
The model consists of:
- User and movie embedding layers.
- A rating prediction network that takes user and movie embeddings as input.
- Two task-specific loss functions: Mean Squared Error for rating prediction and a retrieval loss.
- Weighted combination of the two losses to train the model jointly.
- Clone the repository.
- Navigate to the
multitask_recommender
directory. - Install the dependencies:
pip install -r requirements.txt
. - Run the training script:
python train.py
.
- Experiment with different loss weights to balance the importance of the two tasks.
- Explore different model architectures for the rating prediction network.
- Incorporate additional user and movie features.
- Evaluate the model with different metrics.