amrohendawi / recommender_BERT4Rec

This is a demonstration of the BERT4Rec model as a movies recommender

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BERT4Rec implementation and demonstration

This is a demonstration of the BERT4Rec model from the BERT4Rec paper.

graph TD
    A[User] -->|list: input watch history| B[Black Panther 2017, The Avengers 2012, ...  Spider-Man 3]
    A[User] -->|int: top n recommendations| B1[3]
    B --> |convert movie strings to indices| B2[113, 22, .. 598]
    B2 --> C{BERT4Rec Movies Recommender}
    B1 --> C{BERT4Rec Movies Recommender}
    C -->|list: integer| D1[13, 976, 49]
    D1 --> |convert indices to movie strings| D[Thor: Ragnarok 2017, Deadpool 2 2018, Incredibles 2]

How it works

Setup (GPU)

Tested on NVIDIA RTX 3070 with CUDA 11.6 and Python 3.9.13

1. Create a virtual environment:

python -m venv venv

2. Activate the virtual environment:

For Linux
source venv/bin/activate
For Powershell
.\venv\Scripts\activate

3. Install the dependencies:

pip install -r requirements.txt

Training

  1. Download the movies dataset from here.
  2. Store the unzipped data in data folder.
  3. Run the following command to train the model:
python3  recommender/training.py --data_csv_path <path-to-the-data>

Docker (CPU)

docker build . -t recommender
docker run recommender sh -c "python3.8 -m pytest"

References

About

This is a demonstration of the BERT4Rec model as a movies recommender

License:GNU General Public License v2.0


Languages

Language:Python 63.7%Language:Jupyter Notebook 33.2%Language:Dockerfile 3.2%