Skip to content

Master's thesis : Exploiting Latent Interaction Information for Session-Aware Recommendation Using Recurrent Neural Networks ( Recommendation System / Tensorflow / Python )

Notifications You must be signed in to change notification settings

Junwu0615/LCII-Rec-Model

Repository files navigation

GitHub Views GitHub Clones

歷史紀錄

事件 敘述 時間
Master's thesis 推薦系統模型 : LCII-Rec-Model 2023/01/19
LCII v1.0 第一次將程式碼發布於 GitHub 2023/12/09
LCII v1.1 精簡程式碼,以及 LCII 環境安裝說明 2024/02/14

HOW TO USE

STEP.1 CREATE ENVIRONMENT

本論文程式碼是建立於 Tensorflow 1.14.0,但如今 TF 版本和顯卡設備日新月異的現在,若沒有正確地方式啟動本模型,LCII 將無法成功運作,因此我微調了一下程式碼,讓架構不至於需要重構。

  • 當初程式是在 Anaconda 環境下完成,我將可運行之 conda 環境匯出成 yaml 檔。
    • conda env create -f C:\Users\xxx\LCII-Rec-Model\environment.yaml (自行設路徑安裝)。
    # xxx > username
    prefix: C:\Users\xxx\anaconda3\envs\lcii
  • N 卡安裝 TF-GPU 環境網路教學很多,我推薦一篇
  • 我運行環境如下所示 :
    • Tensorflow-GPU 2.4.0
      • Python : 3.8.18
      • 顯示卡 : Nvidia GeForce GTX 4070 | 驅動 : 551.23
      • CUDA : 11.0
      • cuDNN : 8.0
  • 程式碼已改寫成 TF 2.0 以上版本皆可運行的內容。另外想抱怨建置環境這塊,它 ! 非 ! 常 ! 麻 ! 煩 !,我也是額外多買了一塊 N 卡 (GTX 4070),解決原先 A 卡 (RX 6090 XT) 在 win 環境不支援等問題,且又花了快 2 天時間才建置好運行環境...
  • 大概簡述安裝流程 :
    • 顯卡若是 N 卡的話,去 Nvidia 官網安裝對應持有顯卡的驅動程式。
    • 查看持有顯卡驅動版本,cmd 輸入 : nvidia-smi,確認符合需求的 CUDA 版本。
      • 由於 RTX 30 系列之後的 GPU 不支援 CUDA 10.0 以下(含),因此我也只能裝 CUDA 11.0 以上版本 (有實測撞牆過...)。
    • 接著查閱 Tensorflow-GPU 版本,已確定需要的 CUDA / cuDNN 版本。
    • 下載各自對應的 CUDA / cuDNN 版本。
      • CUDA 自定義安裝並勾選"只安裝 CUDA"即可 (安裝過程會將系統環境變數新增上去)。另外把 cuDNN 包解壓縮後,將內容物 (bin / include / lib) 剪下貼至 CUDA 安裝地。

STEP.2 CLONE

git clone https://github.com/Junwu0615/LCII-Rec-Model.git

跳至 LCII-Rec-Model 專案目錄 : cd LCII-Rec-Model


STEP.3 DOWNLOADS DATASETS

跳至 preprocess 目錄 : cd preprocess

資料集來源 :

Dataset Search the Page for Keywords
Amazon Clothing Shoes and Jewelry | 5-core (11,285,464 reviews) | 1.17 GB
MovieLens-1M ml-1m.zip | 6 MB
Steam Version 2: Review Data | 1.3 GB
LCII Dataset Backup Dataset has been backup to the cloud

下載資料集並解壓縮到指定位置 :

Dataset Path
Amazon 需將 Clothing_Shoes_and_Jewelry_5.json.gz 放置於 LCII-Rec-Model/datasets
解壓縮完路徑為: LCII-Rec-Model/datasets/Clothing_Shoes_and_Jewelry_5.json
MovieLens-1M 需將 ml-1m.zip 放置於 LCII-Rec-Model/datasets
解壓縮完路徑為: LCII-Rec-Model/datasets/ml-1m
Steam 需將 steam_reviews.json.gz 放置於 LCII-Rec-Model/datasets
解壓縮完路徑為: LCII-Rec-Model/datasets/steam_new.json

STEP.4 PREPROCESS

資料預處理指令 :

Dataset Program Instructions
Amazon python amazon_preprocess.py
Amazon ver. BERT4Rec python amazon_preprocess_ver_bert4rec.py
MovieLens-1M python ml_steam_preprocess.py -d MovieLens-1M
Steam python ml_steam_preprocess.py -d Steam

preprocess_ml-1m.gif

查閱預處理後之資料 :

Dataset Program Instructions
Amazon python see_pickle_amazon.py
MovieLens-1M python see_pickle_ml_steam.py -d MovieLens-1M
Steam python see_pickle_ml_steam.py -d Steam

see_ml-1m.gif


STEP.5 HELP

回到 LCII-Rec-Model 專案目錄 cd ..

python LCII-Rec-Model.py -h
  • -d Dataset : Amazon / MovieLens-1M / Steam
  • -sp Switch Plot : sum / dot / attention_gate_sum / attention_gate_dot
  • -sis Switch Initial State : True / False
  • -fw Fusion Way : att / lp / fix / none
  • -s Strategy : pre-combine / post-combine / original
  • -w Window : 0-100 / 'no_use'
  • -ls Long Score : 0.0-1.0 / 'no_use'
  • -ss Short Score : 0.0-1.0 / 'no_use'
  • -es Embedding Size : 30 / 50 / 80 / 100 / 200 / 300 / 500 / 800 / 1000
  • -bs Batch Size : 16 / 32 / 64 / 100 / 128 / 256 / 512
  • -lr Learning Rate : 0.001 / 0.01 / ...
  • -dr Dropout : 0.8
  • -me Max Epoch : 100 / 200 / ...
  • -t Threshold : 98
  • -add Whether to finally add FC to input_sum : True / False

STEP.6 RUN MAIN PROGRAM

下列為 LCII 模型在各資料集中的程式運行之指令範例,執行完畢後會在 /testlog/ 產出實驗結果 ( .txt / .png )。

Amazon

python LCII-Rec-Model.py -d Amazon -sp attention_gate_dot -sis True -fw none -s original -w 'no_use' -ls 'no_use' -ss 'no_use' -es 80 -bs 100 -lr 0.001 -dr 0.8 -me 100 -t 98 -add False

amazon.jpg

MovieLens-1M

python LCII-Rec-Model.py -d MovieLens-1M -sp attention_gate_dot -sis True -fw fix -s pre-combine -w 30 -ls 0.8 -ss 0.2 -es 80 -bs 100 -lr 0.01 -dr 0.8 -me 200 -t 98 -add False

ml-1m.jpg

Steam

python LCII-Rec-Model.py -d Steam -sp attention_gate_dot -sis True -fw fix -s post-combine -w 4 -ls 0.2 -ss 0.8 -es 80 -bs 100 -lr 0.001 -dr 0.8 -me 200 -t 98 -add False

steam.jpg


下列為相關 Baseline

About

Master's thesis : Exploiting Latent Interaction Information for Session-Aware Recommendation Using Recurrent Neural Networks ( Recommendation System / Tensorflow / Python )

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages