This model is a sentiment classification model for Yelp reviews, trained to predict whether a review is star ratings (1 to 5 stars). The model was fine-tuned using the distilbert-base-uncased model architecture, based on the DistilBERT model from Hugging Face, and trained on a Yelp reviews dataset.
Model Details
Model Type: DistilBERT-based model for sequence classification
Model Architecture: distilbert-base-uncased
Number of Parameters: Approximately 66M parameters
Training Dataset: The model was trained on a curated Yelp reviews dataset, labeled for star ratings (1 to 5 stars).
Fine-Tuning Task: Multi-class classification for Yelp reviews, predicting the star rating (from 1 to 5 stars) based on the content of the review.
Training Data
Dataset: Custom Yelp reviews dataset
Data Description: The dataset consists of Yelp reviews, labeled for star ratings (1 to 5 stars).
Preprocessing: The dataset was preprocessed by cleaning the reviews to remove unwanted characters and URLs.
Training Details
Training Framework: Hugging Face Transformers and PyTorch
Learning Rate: 2e-5
Epochs: 6
Batch Size: 16
Optimizer: AdamW
Training Time: Approximately 2 hours on a GPU
Usage
To use the model for inference, you can use the following code:
python
1from transformers import AutoModelForSequenceClassification, AutoTokenizer
2import torch
34# Load the fine-tuned model and tokenizer from Hugging Face5model_name ="kmack/YELP-Review_Classifier"# Replace with your model name if different6model = AutoModelForSequenceClassification.from_pretrained(model_name)7tokenizer = AutoTokenizer.from_pretrained(model_name)89# List of reviews for prediction10reviews =[11"The food was absolutely delicious, and the atmosphere was perfect for a family gathering. The staff was friendly, and we had a great time. Definitely coming back!",12"It was decent, but nothing special. The food was okay, but the service was a bit slow. I think there are better places around.",13"I had a terrible experience. The waiter was rude, and the food was cold when it arrived. I won't be returning anytime soon."14]1516# Map prediction to star ratings17label_map ={180:"1 Star",191:"2 Stars",202:"3 Stars",213:"4 Stars",224:"5 Stars"23}2425# Iterate over each review and get the prediction26for review in reviews:27# Tokenize the input text28 inputs = tokenizer(review, return_tensors="pt", padding=True, truncation=True)2930# Get predictions31with torch.no_grad():32 outputs = model(**inputs)3334# Get the predicted label (0 to 4 for star ratings)35 prediction = torch.argmax(outputs.logits, dim=-1).item()3637# Map prediction to star rating38 predicted_rating = label_map[prediction]3940print(f"Rating: {predicted_rating}\n")
Citation
If you use this model in your research, please cite the following:
@misc{YELP-Review_Classifier,
1 author = {Kmack},
2 title = {YELP-Review_Classifier},
3 year = {2024},
4 url = {https://huggingface.co/kmack/YELP-Review_Classifier}
5}