Downloads Β· 30 days
23
13% of all-time downloads
IberaSoft/customer-sentiment-analyzer
customer-sentiment-analyzer is a text classification model from IberaSoft. Use it when you need a label for a piece of text. It is set up for transformers. The card lists the license as mit.
Fine-tuned DistilBERT model for analyzing customer review sentiment in e-commerce and SaaS domains.
Downloads Β· 30 days
23
13% of all-time downloads
All-time downloads
178
Public
Parameters
67M
268 MB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors268 MB Β· 100%
From the Hugging Face model README
Fine-tuned DistilBERT model for analyzing customer review sentiment in e-commerce and SaaS domains.
This model is a fine-tuned version of distilbert-base-uncased on a custom dataset of 20,000 customer reviews from e-commerce and SaaS platforms. It classifies text into three sentiment categories: positive, negative, and neutral.
from transformers import pipeline
# Load the model
classifier = pipeline(
"sentiment-analysis",
model="IberaSoft/customer-sentiment-analyzer"
)
# Analyze sentiment
result = classifier("This product is amazing! Highly recommend.")
print(result)
# [{'label': 'positive', 'score': 0.9823}]
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
# Load model and tokenizer
model_name = "IberaSoft/customer-sentiment-analyzer"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
# Prepare text
text = "Great quality but shipping took forever"
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512)
# Get prediction
with torch.no_grad():
outputs = model(**inputs)
predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
# Map to labels
labels = ['negative', 'neutral', 'positive']
predicted_class = predictions.argmax().item()
confidence = predictions[0][predicted_class].item()
print(f"Sentiment: {labels[predicted_class]}")
print(f"Confidence: {confidence:.2%}")
from transformers import pipeline
classifier = pipeline(
"sentiment-analysis",
model="IberaSoft/customer-sentiment-analyzer",
device=0 # Use GPU if available
)
reviews = [
"Excellent product, will buy again!",
"Disappointed with the quality.",
"It's okay, nothing special."
]
results = classifier(reviews)
for review, result in zip(reviews, results):
print(f"{review[:30]}... β {result['label']} ({result['score']:.2f})")
| Metric | Score |
|---|---|
| Accuracy | 90.2% |
| F1 Score (Macro) | 0.89 |
| Precision | 0.90 |
| Recall | 0.89 |
| Class | Precision | Recall | F1-Score | Support |
|---|---|---|---|---|
| Positive | 0.92 | 0.91 | 0.91 | 800 |
| Negative | 0.89 | 0.90 | 0.89 | 700 |
| Neutral | 0.88 | 0.86 | 0.87 | 500 |
Predicted
Pos Neu Neg
Actual Pos [ 728 45 27 ]
Neu [ 38 430 32 ]
Neg [ 22 48 630 ]
| Batch Size | CPU (ms) | GPU (ms) |
|---|---|---|
| 1 | 35 | 8 |
| 8 | 180 | 25 |
| 32 | 650 | 75 |
Tested on Intel i7-11700K (CPU) and NVIDIA RTX 3080 (GPU)
β Medical or health-related sentiment analysis
β Financial advice or stock sentiment (not trained on financial data)
β Political sentiment analysis (potential bias)
β Languages other than English
β Detecting sarcasm or irony (limited capability)
The model was fine-tuned on 20,000 labeled customer reviews consisting of:
Dataset Distribution:
Class Balance:
π¦ View Dataset on HuggingFace
Base Model: distilbert-base-uncased (66M parameters)
Hyperparameters:
learning_rate: 2e-5
batch_size: 16
epochs: 3
warmup_steps: 500
weight_decay: 0.01
max_length: 512
optimizer: AdamW
scheduler: linear with warmup
Training Environment:
Training Code: GitHub Repository
Text preprocessing steps:
Standard Model: 268 MB
Quantized (INT8): 67 MB (4x smaller, <2% accuracy drop)
from optimum.onnxruntime import ORTModelForSequenceClassification
# Convert to ONNX with quantization
model = ORTModelForSequenceClassification.from_pretrained(
"IberaSoft/customer-sentiment-analyzer",
export=True,
provider="CPUExecutionProvider"
)
# Save quantized model
model.save_pretrained("./optimized_model")
import torch
# Use GPU if available
device = "cuda" if torch.cuda.is_available() else "cpu"
model = model.to(device)
# Enable inference mode
model.eval()
torch.set_grad_enabled(False)
# Batch processing for better throughput
classifier = pipeline(
"sentiment-analysis",
model=model,
tokenizer=tokenizer,
batch_size=32,
device=0 if device == "cuda" else -1
)
from fastapi import FastAPI
from transformers import pipeline
from pydantic import BaseModel
app = FastAPI()
# Load model once at startup
classifier = pipeline(
"sentiment-analysis",
model="IberaSoft/customer-sentiment-analyzer"
)
class ReviewRequest(BaseModel):
text: str
@app.post("/predict")
def predict_sentiment(request: ReviewRequest):
result = classifier(request.text)[0]
return {
"sentiment": result["label"],
"confidence": round(result["score"], 4)
}
FROM python:3.11-slim
RUN pip install transformers torch fastapi uvicorn
# Download model during build
RUN python -c "from transformers import pipeline; \
pipeline('sentiment-analysis', \
model='IberaSoft/customer-sentiment-analyzer')"
COPY app.py .
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
Full API: GitHub Repository
If you use this model in your research or application, please cite:
@misc{customer-sentiment-analyzer,
author = {Your Name},
title = {Customer Sentiment Analyzer: Fine-tuned DistilBERT for E-commerce Reviews},
year = {2026},
publisher = {HuggingFace},
howpublished = {\url{https://huggingface.co/IberaSoft/customer-sentiment-analyzer}},
}
This model is licensed under the MIT License. See LICENSE for details.
The base model distilbert-base-uncased is licensed under Apache 2.0.
Found an issue or want to improve the model?
Try the live demo: HuggingFace Spaces
</div>