Authors: Michele Pulvirenti, Marco Riva
Date: November 2024
This project focuses on building a recommendation system leveraging TripAdvisor reviews. Starting with a BM25 baseline, the analysis explores advanced NLP models to enhance recommendation performance. Key steps include preprocessing, model evaluation, and the implementation of an ensemble strategy to combine predictions from different models.
See full project description (PDF)
- Columns irrelevant to ratings and reviews were removed.
- Reviews with missing values were excluded.
- Over 90% of reviews were in English. Non-English reviews were detected using
fast-langdetect
for efficient and accurate language detection.
Text preprocessing steps (using NLTK):
- Lowercasing: Standardizing text.
- Tokenization: Splitting text into words.
- Removing Punctuation and Stopwords: Filtering unnecessary tokens.
- Lemmatization: Reducing words to base forms.
- A fixed set of 50 randomly selected reviews was used as queries.
- Models predicted the most similar hotels based on review text, evaluated using Mean Squared Error (MSE).
- Implemented with
rank-bm25
. - Scores based on term frequency (TF), inverse document frequency (IDF), and document length.
- Pre-trained
bert-base-uncased
. - Cosine similarity between averaged embeddings used for recommendation.
Several variants tested:
- MiniLM: Lightweight and fast.
- BertNLI: Fine-tuned for natural language inference.
- MPNET: Contextually advanced.
- Roberta: Best performer for semantic similarity.
- Roberta: Achieved the lowest average MSE (0.86), outperforming BERT and BM25.
- Sentence transformers demonstrated significant gains over the baseline.
- Combined predictions from all models.
- Best-performing model per query selected based on MSE.
Example Results:
Query ID | Best Model | Best MSE |
---|---|---|
111507 | MPNET | 0.05 |
93517 | MiniLM | 0.11 |
93340 | Roberta | 0.16 |
- Transformer models (e.g., Roberta) excel in capturing semantic nuances.
- Preprocessing and embedding efficiency are critical to scalability.
- Ensemble methods further enhance recommendation accuracy.
- Intermediate results (e.g., datasets, embeddings) stored to facilitate reproducibility.
- Code structured to automate retrieval of precomputed artifacts, minimizing computational overhead.