SmartReview is a domain-adapted DistilRoBERTa model fine-tuned for sentiment analysis of smartphone and electronics reviews.
The model achieves 88.23% accuracy on 3-class sentiment classification (Positive, Neutral, Negative) and was specifically trained on 67,987 Amazon smartphone reviews.
🎯 Key Features
✅ Domain-Adapted: Pretrained on 61,553 smartphone reviews via Masked Language Modeling
✅ Efficient: Only 82M parameters (34% smaller than RoBERTa-base)
✅ Accurate: 88.23% overall accuracy, 94.88% F1 on positive sentiment
✅ Fast: ~50ms inference time per review
✅ Specialized: Understands product review vocabulary and context
🏗️ Architecture
Base Model: distilroberta-base (82M parameters)
Task: 3-class sequence classification
Classes:
LABEL_0: Positive
LABEL_1: Neutral
LABEL_2: Negative
Max Length: 512 tokens
📊 Training Approach
Two-Phase Training:
Phase 1 - Domain Adaptation (MLM)
Task: Masked Language Modeling
Data: 61,553 smartphone reviews
Duration: 66 minutes
Result: 99.99% accuracy on domain vocabulary
Phase 2 - Sentiment Fine-tuning
Task: 3-class classification
Data: 39,044 training samples
Duration: 67 minutes
Optimizer: AdamW (lr=2e-5, weight_decay=0.01)
Hardware: NVIDIA RTX 3050 (4GB)
📈 Performance
Overall Metrics (Test Set: 8,367 reviews)
Metric
Score
Accuracy
88.23%
Precision (Macro)
72.38%
Recall (Macro)
72.39%
F1 (Macro)
72.35%
F1 (Weighted)
88.13%
Per-Class Performance
Class
Precision
Recall
F1-Score
Support
Positive
95.39%
94.38%
94.88% ✅
5,481
Neutral
37.79%
35.02%
36.35% ⚠️
614
Negative
83.96%
87.76%
85.82% ✅
2,272
Note: Neutral class F1 is lower due to severe class imbalance (only 7.4% of training data). This is expected in product reviews where opinions are rarely truly neutral.
Confusion Matrix
PREDICTED
Pos Neu Neg
ACTUAL
Pos 5,173 175 133 (94.4% correct)
Neu 151 215 248 (35.0% correct)
Neg 99 179 1,994 (87.8% correct)
🚀 Usage
Quick Start
python
1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
34# Load model and tokenizer5model_name ="Abhishek86798/smartreview-distilroberta-sentiment"6tokenizer = AutoTokenizer.from_pretrained(model_name)7model = AutoModelForSequenceClassification.from_pretrained(model_name)89# Example review10text ="Battery life is excellent but camera quality is poor"1112# Tokenize and predict13inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512)1415with torch.no_grad():16 outputs = model(**inputs)17 logits = outputs.logits
18 probabilities = torch.softmax(logits, dim=-1)19 prediction = logits.argmax(-1).item()2021# Map to labels22labels =["Positive","Neutral","Negative"]23sentiment = labels[prediction]24confidence = probabilities[0][prediction].item()2526print(f"Sentiment: {sentiment}")27print(f"Confidence: {confidence:.2%}")
Output:
Sentiment: Positive
Confidence: 85.34%
Using Pipeline
python
1from transformers import pipeline
23# Create sentiment analysis pipeline4classifier = pipeline(5"sentiment-analysis",6 model="Abhishek86798/smartreview-distilroberta-sentiment",7 tokenizer="Abhishek86798/smartreview-distilroberta-sentiment"8)910# Single prediction11result = classifier("Amazing phone! Battery lasts all day.")12print(result)13# [{'label': 'LABEL_0', 'score': 0.9876}] # LABEL_0 = Positive1415# Batch prediction16reviews =[17"Amazing phone! Battery lasts all day.",18"Terrible. Phone broke after one week.",19"It's okay, nothing special."20]2122results = classifier(reviews)23for review, result inzip(reviews, results):24print(f"{review} → {result['label']} ({result['score']:.2%})")
Detailed Prediction Function
python
1defpredict_sentiment_detailed(text, model, tokenizer):2# Get detailed sentiment prediction with all probabilities3# Args: text (str), model, tokenizer4# Returns: dict with sentiment, confidence, and probabilities5# Tokenize6 inputs = tokenizer(7 text,8 return_tensors="pt",9 truncation=True,10 max_length=512,11 padding=True12)1314# Predict15with torch.no_grad():16 outputs = model(**inputs)17 logits = outputs.logits
18 probabilities = torch.softmax(logits, dim=-1)[0]1920# Get results21 labels =["Positive","Neutral","Negative"]22 prediction_idx = logits.argmax(-1).item()2324return{25"text": text,26"sentiment": labels[prediction_idx],27"confidence": probabilities[prediction_idx].item(),28"probabilities":{29"positive": probabilities[0].item(),30"neutral": probabilities[1].item(),31"negative": probabilities[2].item()32}33}3435# Example36result = predict_sentiment_detailed(37"Screen is bright and clear, love the display!",38 model,39 tokenizer
40)4142print(f"Sentiment: {result['sentiment']}")43print(f"Confidence: {result['confidence']:.2%}")44print(f"Probabilities:")45for sentiment, prob in result['probabilities'].items():46print(f" {sentiment.capitalize()}: {prob:.2%}")
Sentiment analysis of smartphone/electronics reviews
Product feedback analysis for e-commerce platforms
Customer satisfaction monitoring
Review summarization preprocessing
Aspect-based sentiment analysis (as part of ABSA pipeline)
❌ Out-of-Scope Use
Non-English reviews (model trained on English only)
Non-product reviews (news articles, social media posts, etc.)
Offensive content detection
Sarcasm detection (known limitation)
Real-time chat/conversation analysis
⚠️ Limitations
Neutral Class Performance: F1-score of 36.35% due to severe class imbalance (only 7.4% of training data). The model tends to classify neutral reviews as positive or negative.
Sarcasm Detection: Model struggles with sarcastic language. Example: "Great, another phone that breaks after a week" may be classified as positive.
Domain Specificity: Trained specifically on smartphone reviews. Performance may degrade on other product categories without domain adaptation.
Context-Free Predictions: Doesn't consider user expectations or product price range. "Battery lasts 4 hours" might be negative for smartphones but positive for smartwatches.
Mixed Sentiments: Reviews with multiple conflicting opinions may be misclassified based on the dominant sentiment.