Create README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,109 @@
|
|
| 1 |
---
|
| 2 |
license: mit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: mit
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
pipeline_tag: text-classification
|
| 6 |
+
tags:
|
| 7 |
+
- scam-detection
|
| 8 |
+
- phishing-detection
|
| 9 |
+
- fraud-detection
|
| 10 |
+
- distilbert
|
| 11 |
+
- on-device-ai
|
| 12 |
+
- chrome-extension
|
| 13 |
+
datasets:
|
| 14 |
+
- custom
|
| 15 |
+
metrics:
|
| 16 |
+
- f1
|
| 17 |
+
- accuracy
|
| 18 |
+
- precision
|
| 19 |
+
- recall
|
| 20 |
+
base_model: distilbert-base-uncased
|
| 21 |
---
|
| 22 |
+
|
| 23 |
+
# ScamShield β Scam & Phishing Detection Model
|
| 24 |
+
|
| 25 |
+
A fine-tuned DistilBERT model that classifies text as **scam** or **safe** β built to run fully on-device (browser/edge), as the detection engine behind the [ScamShield Chrome extension](https://github.com/rehan-ml/ScamShield).
|
| 26 |
+
|
| 27 |
+
## Model Description
|
| 28 |
+
|
| 29 |
+
This model detects scam, phishing, and fraudulent job/internship messages from plain text β SMS messages, emails, job offer letters, and similar written content. It was fine-tuned from `distilbert-base-uncased` for binary sequence classification (`0 = safe`, `1 = scam`).
|
| 30 |
+
|
| 31 |
+
It's designed to be small and fast enough to run **entirely client-side** (in a browser via ONNX + Transformers.js, or on edge devices), so no user text needs to be sent to a server for scam detection.
|
| 32 |
+
|
| 33 |
+
- **Base model:** `distilbert-base-uncased`
|
| 34 |
+
- **Task:** Binary text classification (safe vs. scam)
|
| 35 |
+
- **Language:** English
|
| 36 |
+
- **License:** MIT
|
| 37 |
+
|
| 38 |
+
## Intended Use
|
| 39 |
+
|
| 40 |
+
- Detecting phishing/scam SMS and emails
|
| 41 |
+
- Detecting fraudulent job/internship offers (fake recruiters, upfront-fee scams)
|
| 42 |
+
- Powering privacy-preserving, on-device scam-detection tools (browser extensions, edge apps)
|
| 43 |
+
|
| 44 |
+
**Not intended for:** legal/compliance decisions, moderating content at scale without human review, or as a sole determinant of fraud β see Limitations below.
|
| 45 |
+
|
| 46 |
+
## Training Data
|
| 47 |
+
|
| 48 |
+
Combined from three sources:
|
| 49 |
+
1. [SMS Spam Collection Dataset](https://www.kaggle.com/datasets/uciml/sms-spam-collection-dataset) β real SMS messages, ham/spam labeled
|
| 50 |
+
2. [EMSCAD β Employment Scam Aegean Dataset](https://www.kaggle.com/datasets/shivamb/real-or-fake-fake-jobposting-prediction) β real vs. fraudulent job postings
|
| 51 |
+
3. **Custom synthetic contrastive dataset** (~255 examples, generated via LLM) β pairs of professionally-worded job offers that are identical in structure and language, differing *only* in whether an upfront payment is requested. This was added after testing revealed the model initially missed softly-worded scams that avoided obvious keywords (see "Model Iteration History" below).
|
| 52 |
+
|
| 53 |
+
## Training Procedure
|
| 54 |
+
|
| 55 |
+
- Fine-tuned for 2 epochs, learning rate 2e-5, batch size 16, weighted cross-entropy loss (to address class imbalance β scam examples are a minority class)
|
| 56 |
+
- Trained on a single RTX 4050 (6GB VRAM) with fp16 mixed precision
|
| 57 |
+
- Max sequence length: 512 tokens
|
| 58 |
+
|
| 59 |
+
## Evaluation Results (held-out test set)
|
| 60 |
+
|
| 61 |
+
| Metric | Score |
|
| 62 |
+
|---|---|
|
| 63 |
+
| Accuracy | 98.5% |
|
| 64 |
+
| Precision | 0.944 |
|
| 65 |
+
| Recall | 0.833 |
|
| 66 |
+
| F1 | 0.885 |
|
| 67 |
+
|
| 68 |
+
## Model Iteration History
|
| 69 |
+
|
| 70 |
+
This model went through 4 iterations, which is worth documenting honestly since it shapes how the model should be used:
|
| 71 |
+
|
| 72 |
+
- **v1:** Baseline on the two public datasets. Confidently correct on obvious scams, but **confidently wrong (near 0%)** on professionally-worded scams avoiding obvious red-flag keywords.
|
| 73 |
+
- **v2:** Added broad synthetic augmentation to fix this β overcorrected, started flagging legitimate offer letters as scams due to generic HR language ("verification," "documentation").
|
| 74 |
+
- **v3:** Rebalanced with more safe examples β overcorrected the *other* way, lost recall on real scams.
|
| 75 |
+
- **v4 (this model):** Used a **contrastive dataset** β scam/safe pairs with identical structure and language, differing only in whether payment was requested. This isolated the actual decisive signal and fixed both prior failure modes.
|
| 76 |
+
|
| 77 |
+
## Limitations
|
| 78 |
+
|
| 79 |
+
- Trained and evaluated primarily on **job/internship offers and SMS-style messages** β may not generalize well to other scam formats (e.g. crypto scams, romance scams) without further fine-tuning.
|
| 80 |
+
- English only.
|
| 81 |
+
- Can still be uncertain on genuinely ambiguous, real-world borderline messages β in the [ScamShield extension](https://github.com/rehan-ml/ScamShield), this model's output is combined with a rule-based red-flag layer as a safety net, rather than used alone. Using this model standalone without such a safety net is not recommended for high-stakes use.
|
| 82 |
+
- Like any small classifier, it can be sensitive to phrasing changes near its decision boundary.
|
| 83 |
+
|
| 84 |
+
## How to Use
|
| 85 |
+
|
| 86 |
+
```python
|
| 87 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 88 |
+
import torch
|
| 89 |
+
|
| 90 |
+
tokenizer = AutoTokenizer.from_pretrained("rehan-ml/scamshield-scam-detector")
|
| 91 |
+
model = AutoModelForSequenceClassification.from_pretrained("rehan-ml/scamshield-scam-detector")
|
| 92 |
+
|
| 93 |
+
text = "Congratulations! You've been selected. Pay a refundable registration fee of $50 to confirm your position."
|
| 94 |
+
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512)
|
| 95 |
+
|
| 96 |
+
with torch.no_grad():
|
| 97 |
+
outputs = model(**inputs)
|
| 98 |
+
|
| 99 |
+
scam_probability = torch.softmax(outputs.logits, dim=1)[0][1].item()
|
| 100 |
+
print(f"Scam probability: {scam_probability:.4f}")
|
| 101 |
+
```
|
| 102 |
+
|
| 103 |
+
## Related
|
| 104 |
+
|
| 105 |
+
- π [ScamShield Chrome Extension (GitHub)](https://github.com/rehan-ml/ScamShield) β the full project this model powers, including the browser extension, rule-based safety net, and training notebook.
|
| 106 |
+
|
| 107 |
+
## Author
|
| 108 |
+
|
| 109 |
+
Built by [Rehan Raza](https://github.com/rehan-ml) for OSDHack 2026.
|