ashish-001's picture
Update README.md
e8ebcc6 verified
---
license: apache-2.0
datasets:
- SetFit/amazon_reviews_multi_en
base_model:
- google-bert/bert-base-uncased
metrics:
- accuracy
pipeline_tag: text-classification
# Sentiment Classification with Fine-Tuned BERT on Amazon Reviews
This repository contains a fine-tuned BERT model for sentiment classification of Amazon product reviews The model classifies a given review into two classes: Positive and Negative
---
## **Model Overview**
- **Base Model**: [google-bert/bert-base-uncased](https://huggingface.co/google-bert/bert-base-uncased)
- **Dataset**: [SetFit/amazon_reviews_multi_en](https://huggingface.co/datasets/SetFit/amazon_reviews_multi_en),
- **Classes**: Binary classification (`Positive`, `Negative`)
- **Performance**:
- **Test Accuracy**: 89%
- **Validation Accuracy**: 89%
*Figure 1: Confusion matrix for test data*
![image/png](https://cdn-uploads.huggingface.co/production/uploads/6585ab80ef59559493941225/qBheOoyz8f_XD7BVFaRT9.png)
*Figure 2: Confusion matrix for validation data*
![image/png](https://cdn-uploads.huggingface.co/production/uploads/6585ab80ef59559493941225/Js_Bkuf9JDHuvZvgZJ61c.png)
### How to Use the Model
Below is an example of how to load and use the model for sentiment classification:
```python
from transformers import BertTokenizer, BertForSequenceClassification
import torch
# Load the tokenizer and model
tokenizer = BertTokenizer.from_pretrained(
"ashish-001/Bert-Amazon-review-sentiment-classifier")
model = BertForSequenceClassification.from_pretrained(
"ashish-001/Bert-Amazon-review-sentiment-classifier")
# Example usage
text = "This product is amazing!"
inputs = tokenizer(text, return_tensors="pt")
outputs = model(**inputs)
logits = outputs.logits
sentiment = torch.argmax(logits, dim=1).item()
print(f"Predicted sentiment: {'Positive' if sentiment else 'Negative'}")