Contrastive Learning for Aspect Representation towards Explainable Recommendation
CLARER is a model that utilizes contrastive learning to generate aspect-based representations from user reviews. These representations are then used for explainable recommendation tasks across different domains such as hotels, TVs, and restaurants.
Download the dataset from the following Google Drive link:
🔗 Dataset Link
Place the review.pickle file inside each of the following folders:
tripamzMTyelp
Please note that the only tripadvisor dataset has both the explanation and original review data. However, for amazMT and yelp dataset has only explanation. Corresponding original review datasets can be found in https://business.yelp.com/data/resources/open-dataset/ and https://cseweb.ucsd.edu/~jmcauley/datasets/amazon_v2/ for yelp and amazon review respectively. Your directory should look like this:
.
├── rawdata/
│ ├── trip/
│ │ ├── OriginalReviews.json
│ │ └── review.pickle
│ ├── amzMT/
│ │ ├── Movies_and_TV.json
│ │ └── review.pickle
│ └── yelp/
│ ├── yelp_academic_dataset_review.json
│ └── review.pickle
├── prepdata/
│ ├── trip/
│ │ ├── trip.csv
| | └── trip_emb.npy
│ ├── amzMT/
│ │ ├── amzMT.csv
| | └── amz_emb.npy
│ └── yelp/
│ ├── yelp.csv
| └── yelp_emb.npy
├──codes/
| ├── trip_preprocessing.py
| ├── amzMT_preprocessing.py
| ├── yelp_preprocessing.py
| ├── aspect_embedder.py
| ├── CLARER_ratingPred.py
| └── CLARER_exp.py
|--results/
│ ├── trip/
│ │ └── trip_model.pth
| | └── trip.logs
│ ├── amzMT/
│ │ └── amzMT_model.pth
| | └── amzMT.logs
│ └── yelp/
│ |── yelp_model.pth
| └── yelp.logs
|
└── README.md
Run the following scripts to preprocess the datasets. These scripts generate intermediate data required for model training:
python trip_preprocessing.py
python amzMT_preprocessing.py
python yelp_preprocessing.py
python aspect_embedder.py
After preprocessing, use the following command to run the model:
python CLARER_ratingPred.py --dataset yelp.csv
python CLARER_exp.py --dataset yelp.csvReplace
yelp.csvwithtripdata.csvoramz_tv.csvbased on the dataset you're using.
Install the required dependencies using:
pip install -r requirements.txtCLARER/
├── rawdata/
├── prepdata/
├── codes/
├── results/
├── README.md
└── requirements.txt # Dependencies
If you have any questions, suggestions, or want to contribute, feel free to open an issue or submit a pull request.