sms-spam-detector / README.md
didulantha's picture
Update README.md
1a4d99f verified
metadata
language: en
license: apache-2.0
tags:
  - text-classification
  - spam-detection
  - distilbert
  - sms
datasets:
  - sms_spam
metrics:
  - accuracy
  - f1
  - precision
  - recall
widget:
  - text: Congratulations! You've won a FREE prize. Call now!
  - text: Hey, are we still meeting for lunch tomorrow?
  - text: 'URGENT: Your account has been compromised!'
  - text: Can you pick up milk on the way home?

SMS Spam Detector

Model Description

Fine-tuned DistilBERT model for detecting spam SMS messages.

Performance:

  • Accuracy: 0.9916 (99.16%)
  • Precision: 0.9730
  • Recall: 0.9643
  • F1-Score: 0.9686
  • ROC-AUC: 0.9990

Quick Start

from transformers import pipeline

classifier = pipeline("text-classification", model="didulantha/sms-spam-detector")
result = classifier("Win a free prize now!")
print(result)

Detailed Usage

from transformers import DistilBertTokenizer, DistilBertForSequenceClassification
import torch

tokenizer = DistilBertTokenizer.from_pretrained("didulantha/sms-spam-detector")
model = DistilBertForSequenceClassification.from_pretrained("didulantha/sms-spam-detector")

def predict(text):
    inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=128)
    outputs = model(**inputs)
    probs = torch.softmax(outputs.logits, dim=1)
    return "SPAM" if probs[0][1] > 0.5 else "HAM"

print(predict("Free prize!"))

Training Data

  • Dataset: SMS Spam Collection (5,574 messages)
  • Train/Val/Test split: 70/15/15
  • Ham: 86.6%, Spam: 13.4%

Training Details

  • Base model: distilbert-base-uncased
  • Epochs: 3
  • Batch size: 16
  • Learning rate: 2e-05
  • Optimizer: AdamW

Limitations

  • Trained on English SMS messages only
  • May not generalize well to other languages
  • Performance may degrade on heavily obfuscated spam

Citation

@misc{sms-spam-detector,
  author = {Isuru Didulantha},
  title = {SMS Spam Detector},
  year = {2025},
  publisher = {HuggingFace},
  url = {https://huggingface.co/didulantha/sms-spam-detector}
}