Skip to content

normandy17/ReviewSense

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

20 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ReviewSense πŸ”

From raw reviews to real intelligence

An NLP-powered product review intelligence system that classifies sentiment, discovers product categories, and generates AI-written buying guides β€” deployed as an Amazon-style Streamlit web app.

GitHub: https://github.com/normandy17/ReviewSense
Live App: https://reviewsense-amz-beauty.streamlit.app/


Overview

ReviewSense is a full end-to-end NLP project built on the McAuley Amazon Beauty dataset. It tackles three tasks:

Task Description Model
1 β€” Sentiment Analysis Classify reviews as Positive, Neutral, or Negative DistilBERT fine-tuned
2 β€” Category Clustering Group sparse product categories into meaningful meta-categories BERTopic + K-Means + GPT-4o-mini
3 β€” Review Summarization Generate "Top 10 Best" buying guide articles per category GPT-4o-mini (3-step pipeline)

All three models are integrated into a Streamlit web app with an Amazon-style product browsing experience.


Project Structure

ReviewSense/
β”‚
β”œβ”€β”€ notebooks/
β”‚   β”œβ”€β”€ 01_EDA.ipynb                    ← Exploratory data analysis
β”‚   β”œβ”€β”€ 02_Sentiment_Classifier.ipynb   ← DistilBERT training & evaluation
β”‚   β”œβ”€β”€ 03_Product_Clustering.ipynb     ← BERTopic clustering pipeline
β”‚   └── 04_Summarizer.ipynb             ← GPT-4o-mini article generation
β”‚
β”œβ”€β”€ Sentiment Analyzer 3.0/             ← Saved HuggingFace sentiment model
β”‚   β”œβ”€β”€ config.json
β”‚   β”œβ”€β”€ pytorch_model.bin
β”‚   └── tokenizer files...
β”‚
β”œβ”€β”€ summaries/                          ← AI-generated article .txt files
β”‚   β”œβ”€β”€ Article_CategoryName.txt
β”‚   └── Summary_CategoryName.txt
β”‚
β”œβ”€β”€ data/
β”‚   └── reviews_final.csv               ← Final joined dataset
β”‚
β”œβ”€β”€ app.py                              ← Streamlit web app
β”œβ”€β”€ requirements.txt
└── README.md

Setup & Installation

Prerequisites

  • Python 3.10+
  • An OpenAI API key (for the summarizer and Streamlit live summaries)

Install dependencies

pip install -r requirements.txt

Set your OpenAI API key

export OPENAI_API_KEY="sk-..."

On Windows:

set OPENAI_API_KEY=sk-...

Dataset

The project uses the McAuley Amazon Beauty Reviews dataset.

  1. Download from: https://cseweb.ucsd.edu/~jmcauley/datasets.html#amazon_reviews
  2. Select the Beauty category
  3. Place the downloaded file(s) in the data/ folder
  4. Run 01_EDA.ipynb to clean and export reviews_final.csv

Running the Notebooks

Run the notebooks in order β€” each one produces outputs consumed by the next.

01 β€” EDA

jupyter notebook notebooks/01_EDA.ipynb
  • Loads and inspects the raw dataset
  • Plots category distribution, rating balance, text length analysis, word clouds
  • Exports data/reviews_final.csv

02 β€” Sentiment Classifier

jupyter notebook notebooks/02_Sentiment_Classifier.ipynb
  • Maps star ratings β†’ Positive (4–5β˜…) / Neutral (3β˜…) / Negative (1–2β˜…)
  • Trains DistilBERT (distilbert-base-uncased) on balanced, downsampled data
  • Input: review title + review text combined
  • Saves the model to ./Sentiment Analyzer 3.0/
  • Final accuracy: 83% β€” balanced F1 across all 3 classes

03 β€” Product Clustering

jupyter notebook notebooks/03_Product_Clustering.ipynb
  • Embeds product names using distilbert-base-nli-stsb-mean-tokens
  • Runs BERTopic with K-Means to discover natural product groupings
  • Uses GPT-4o-mini to assign meaningful category names to each cluster
  • Adds bertopic_category_name column to the dataset

04 β€” Summarizer

jupyter notebook notebooks/04_Summarizer.ipynb
  • For each meta-category, selects the top 10 products by rating and volume
  • Step 1 β€” Curate: picks 8 reviews per star rating (1–5), prioritising verified purchases and helpful votes
  • Step 2 β€” Summarize: one GPT-4o-mini call per product β†’ Overall Sentiment, Top 3 Pros, Top 3 Cons, Best For
  • Step 3 β€” Write Article: feeds all 10 summaries to GPT β†’ generates full "Top 10 Best {category}" article with a Category Winner and Buying Guide
  • Saves outputs to summaries/Article_{category}.txt and summaries/Summary_{category}.txt

Running the Streamlit App

streamlit run app.py

The app will open at http://localhost:8501

App pages

Page Description
🏠 Home Project overview, pipeline diagram, dataset statistics
πŸ” Sentiment Analyzer Paste any review text β†’ live DistilBERT prediction with confidence score
πŸ—‚οΈ Categories Grid of all BERTopic meta-categories with product and review counts
πŸ“¦ Category Page Top 10 products + full searchable product list with images
πŸ›οΈ Product Page Amazon-style view: images, star breakdown, paginated reviews (10 at a time) with sentiment badges, live GPT-4o-mini summary on demand
πŸ“° Buying Guide AI-generated buying articles rendered per category with download option

Notes

  • Product AI summaries are cached in session state β€” GPT is only called once per product per session
  • Sentiment is run live on every review card using the saved DistilBERT model
  • Product images load from Amazon CDN URLs with automatic placeholder fallback

Model Training Details

Task 1 β€” Sentiment Classifier

Parameter Value
Base model distilbert-base-uncased
Labels 3 (Positive / Neutral / Negative)
Input Review title + review text (concatenated)
Dataset size ~170,000 reviews
Balancing strategy Downsampled to match smallest class
Training epochs 3
Overall accuracy 83%
Negative F1 0.82
Neutral F1 0.75
Positive F1 0.92

Key decision: The first model reached 95% accuracy but had poor F1 on Negative and Neutral classes due to severe class imbalance. Switching to a larger balanced dataset and downsampling to the smallest class resolved this.

Task 2 β€” Category Clustering

Parameter Value
Embedding model distilbert-base-nli-stsb-mean-tokens
Clustering BERTopic with K-Means
Category naming GPT-4o-mini
Input Product name
Output 4–6 meta-categories

Key decision: Standalone K-Means forced equal cluster sizes regardless of natural data distribution. BERTopic with K-Means respects semantic groupings β€” one category legitimately holding 70% of products was confirmed correct on inspection.

Task 3 β€” Review Summarizer

Parameter Value
LLM GPT-4o-mini
Reviews per product 8 per star rating (1–5) = up to 40 reviews
Review priority verified_purchase + helpful_vote
GPT calls per category 10 (one per product) + 1 (final article)
Output Per-product summary + full category article

Deployment

The app is deployed on Streamlit Community Cloud.

Live URL: <!-- ADD YOUR HOSTED APP URL HERE -->

To deploy your own instance:

  1. Push this repository to GitHub
  2. Go to share.streamlit.io
  3. Connect your repo and select app.py
  4. Add OPENAI_API_KEY under the Secrets panel
  5. Deploy β€” a public URL is generated automatically

Tech Stack

  • NLP models: HuggingFace Transformers, BERTopic, sentence-transformers
  • LLM: OpenAI GPT-4o-mini
  • Data: pandas, numpy
  • Visualisation: matplotlib, seaborn
  • App: Streamlit
  • Training: PyTorch

Acknowledgements

Dataset: McAuley Lab β€” Amazon Reviews
Base model: DistilBERT β€” Hugging Face
Topic modelling: BERTopic

About

Intelligence applied to reviews

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors