CoolFace
Modelpublic

faysal725/product-review-sentiment-classifier

sourceHugging Facemitupdated 3mo agoView on Hugging Face
0likes16downloads
Model Card

Product Review Sentiment Classifier

Binary sentiment classifier for product reviews — positive or negative with calibrated confidence scores.

Performance

MetricScore
Accuracy91.2%
F10.913
Brier0.079

Usage

python
from setfit import SetFitModel
import pickle, numpy as np

model = SetFitModel.from_pretrained("faysal725/product-review-sentiment-classifier")

# For calibrated confidence, download platt_calibrator.pkl from this repo
with open("platt_calibrator.pkl", "rb") as f:
    platt = pickle.load(f)

text = "This product is amazing, best purchase ever!"
raw_probs = np.array(model.predict_proba([text]))
calibrated = platt.predict_proba(raw_probs[:, 1].reshape(-1, 1))[0]
label = "positive" if calibrated[1] >= 0.5 else "negative"
confidence = max(calibrated)

print(f"{label} ({confidence:.1%})")

Training

  • —Method: SetFit (few-shot contrastive learning, 256 examples)
  • —Backbone: paraphrase-mpnet-base-v2
  • —Calibration: Platt scaling (LogisticRegression on raw scores)
  • —Data: Amazon Reviews Binary (Apache-2.0), 10k balanced subset

Full Package

For the complete package with FastAPI server, batch endpoint, Docker deployment, and full documentation, visit Gumroad.

License

MIT