Update README.md
Browse files---
license: apache-2.0
language: en
tags:
- sentiment-analysis
- large-language-model
datasets:
- yelp
pipeline_tag: text-classification
model_details:
labels:
LABEL_0: "Negative"
LABEL_1: "Neutral"
LABEL_2: "Positive"
metrics:
accuracy: 0.7850
precision: 0.7837
recall: 0.7850
f1_score: 0.7840
dataset:
name: "Yelp Open Dataset Subset"
url: "https://www.kaggle.com/datasets/capple7/yelp-open-data-philly-restaurants"
features:
- "Review Text"
- "Star Ratings (1-5)"
preprocessing:
sentiment_mapping:
Negative: "0-1 stars"
Neutral: "1-2 stars"
Positive: "3-4 stars"
training:
pretrained_model: "distilbert-base-uncased"
hyperparameter_search:
framework: "Optuna"
config:
learning_rate: 7.91e-5
batch_size: 32
epochs: 2
seed: 5
evaluation:
strategy: "End-of-epoch"
metrics:
- "Accuracy"
- "Precision"
- "Recall"
- "F1-score"
future_work:
- "Explore alternative pretrained models"
- "Develop real-time deployment"
- "Incorporate more diverse datasets"
metrics_calculation:
tools:
- "precision_recall_fscore_support (scikit-learn)"
- "accuracy_score (scikit-learn)"
---
# LLM Sentiment Analysis
Welcome to the **LLM Sentiment Analysis** project! This model has been fine-tuned for sentiment analysis of Yelp restaurant reviews, leveraging the power of **DistilBERT**, a lightweight transformer model.
## Model Details
This model is fine-tuned to classify Yelp restaurant reviews into three sentiment categories:
1. **Positive** (LABEL_2)
2. **Neutral** (LABEL_1)
3. **Negative** (LABEL_0)
### Key Features
- **🚀 Lightweight & Efficient**: Based on DistilBERT for fast inference
- **🔍 Hyperparameter Optimization**: Fine-tuned using Optuna (10 trials)
- **📊 Strong Metrics**:
- Accuracy: 78.5%
- F1-score: 78.4%
- **🧠 Transfer Learning**: Builds on distilbert-base-uncased
## Intended Usage
### Ideal Use Cases
- **📈 Customer Feedback Analysis**: Understand sentiment trends in reviews
- **💼 Business Intelligence**: Identify service/product improvement areas
- **⭐ Review Filtering**: Automatically categorize user feedback
### Limitations
- Best performance on English restaurant reviews
- Accuracy may decrease on very short texts (<10 words)
- Star rating mapping based on Yelp's scale
## How to Use
```python
from transformers import pipeline
# Load model from Hugging Face Hub
sentiment_pipeline = pipeline(
"sentiment-analysis",
model="fitsblb/YelpReviewsAnalyzer" # Replace with your Hugging Face repo name
)
# Define a custom function to map predicted labels to sentiments
def map_sentiment_label(label):
if label == "LABEL_0":
return "Negative"
elif label == "LABEL_1":
return "Neutral"
elif label == "LABEL_2":
return "Positive"
else:
return "Unknown"
# Test the model with a sample input
sample_text = "The food was absolutely amazing and the service was top-notch!"
output = sentiment_pipeline(sample_text)
# Extract the label and map it to your custom sentiment
predicted_label = output[0]['label'] # Use the label returned from the pipeline
sentiment = map_sentiment_label(predicted_label)
print(f"Review: {sample_text}\nPredicted sentiment: {sentiment} (Label: {predicted_label})")
# Output: Predicted sentiment: Positive (Label: LABEL_2)