Model Card
Sentiment Analysis of Restaurant Reviews from Yelp Dataset
Overview
- Task: Sentiment classification of restaurant reviews from the Yelp dataset.
- Model: Fine-tuned BERT (Bidirectional Encoder Representations from Transformers) for sequence classification.
- Training Dataset: Yelp dataset containing restaurant reviews.
- Training Framework: PyTorch and Transformers library.
Model Details
- Pre-trained Model: BERT-base-uncased.
- Input: Cleaned and preprocessed restaurant reviews.
- Output: Binary classification (positive or negative sentiment).
- Tokenization: BERT tokenizer with a maximum sequence length of 240 tokens.
- Optimizer: AdamW with a learning rate of 3e-5.
- Learning Rate Scheduler: Linear scheduler with no warmup steps.
- Loss Function: CrossEntropyLoss.
- Batch Size: 16.
- Number of Epochs: 2.
Data Preprocessing
- Loaded Yelp reviews dataset and business dataset.
- Merged datasets on the "business_id" column.
- Removed unnecessary columns and duplicates.
- Translated star ratings into binary sentiment labels (positive or negative).
- Upsampled the minority class (negative sentiment) to address imbalanced data.
- Cleaned text data by removing non-letters, converting to lowercase, and tokenizing.
Model Training
- Split the dataset into training (70%), validation (15%), and test (15%) sets.
- Tokenized, padded, and truncated input sequences.
- Created attention masks to differentiate real tokens from padding.
- Fine-tuned BERT using the specified hyperparameters.
- Tracked training and validation accuracy and loss for each epoch.
Model Evaluation
- Achieved high accuracy and F1 scores on both the validation and test sets.
- Generalization observed, as the accuracy on the test set was similar to the validation set.
- The model showed improvement in validation loss, indicating no overfitting.
Model Deployment
- Saved the trained model and tokenizer.
- Published the model and tokenizer to the Hugging Face Model Hub.
- Demonstrated how to load and use the model for making predictions.
Model Performance
- Validation Accuracy: ≈ 97.5% - 97.8%
- Test Accuracy: ≈ 97.8%
- F1 Score: ≈ 97.8% - 97.9%
Limitations
- Excluding stopwords may impact contextual understanding, but it was necessary to handle token length limitations.
- Performance may vary on reviews in languages other than English.
Conclusion
The fine-tuned BERT model demonstrates robust sentiment analysis on Yelp restaurant reviews. Its high accuracy and F1 scores indicate effectiveness in capturing sentiment from user-generated content. The model is suitable for deployment in applications requiring sentiment classification for restaurant reviews.
- Downloads last month
- 483
This model does not have enough activity to be deployed to Inference API (serverless) yet. Increase its social
visibility and check back later, or deploy to Inference Endpoints (dedicated)
instead.