SetFit/amazon_reviews_multi_en
Viewer • Updated • 210k • 1.23k • 7
How to use ashish-001/DistilBert-Amazon-review-sentiment-classifier with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-classification", model="ashish-001/DistilBert-Amazon-review-sentiment-classifier") # Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("ashish-001/DistilBert-Amazon-review-sentiment-classifier")
model = AutoModelForSequenceClassification.from_pretrained("ashish-001/DistilBert-Amazon-review-sentiment-classifier")This repository contains a fine-tuned DistilBERT model for sentiment classification of Amazon product reviews The model classifies a given review into two classes: Positive and Negative
Positive, Negative)Figure 1: Confusion matrix for test data

Figure 2: Confusion matrix for validation data
Below is an example of how to load and use the model for sentiment classification:
from transformers import DistilBertTokenizer,DistilBertForSequenceClassification
import torch
# Load the tokenizer and model
model = DistilBertForSequenceClassification.from_pretrained(
"ashish-001/DistilBert-Amazon-review-sentiment-classifier")
tokenizer = DistilBertTokenizer.from_pretrained(
"ashish-001/DistilBert-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'}")
Base model
distilbert/distilbert-base-uncased