Instructions to use anmolshrivastav/indicbert-scam-classifier-v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use anmolshrivastav/indicbert-scam-classifier-v2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="anmolshrivastav/indicbert-scam-classifier-v2")# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("anmolshrivastav/indicbert-scam-classifier-v2") model = AutoModelForSequenceClassification.from_pretrained("anmolshrivastav/indicbert-scam-classifier-v2", device_map="auto") - Notebooks
- Google Colab
- Kaggle
IndicBERT Multilingual Scam & Fraud Classifier (v2)
A sequence classification model fine-tuned on top of ai4bharat/IndicBERTv2-MLM-only to detect fraudulent, phishing, and scam messages across 14 Indian languages and language varieties[cite: 4].
This v2 model represents a significant upgrade over the baseline v1 iteration, leveraging advanced entity masking and continuous feedback loop training on a T4 GPU to heavily reduce False Negatives (scam $ightarrow$ ham misclassifications).
Supported Languages
| Language | Code |
|---|---|
| Assamese | as |
| Bengali | bn |
| English | en |
| Gujarati | gu |
| Hindi | hi |
| Hinglish (Hindi in Latin script) | hi-Latn |
| Kannada | kn |
| Kashmiri | ks |
| Malayalam | ml |
| Marathi | mr |
| Odia | or |
| Punjabi | pa |
| Tamil | ta |
| Telugu | te |
Training Methodology: v2 Upgrades
The original v1 baseline achieved a highly respectable 98.29% accuracy but exhibited vulnerabilities to specific scam evasion tactics (e.g., protocol obfuscation like hxxp://, naked domains, and specific tele-fraud requests)[cite: 4]. To resolve this, v2 was engineered on Nvidia T4 hardware using the following pipeline:
- Aggressive Entity Masking: Texts are preprocessed using complex regular expressions to capture evasive links and contact numbers.
- URLs, naked domains, and obfuscated protocols are masked with a
[URL]token. - 10-digit formats and international phone codes are masked with a
[PHONE]token.
- URLs, naked domains, and obfuscated protocols are masked with a
- Imbalanced Class Weighting: The loss function was modified to heavily penalize missed scams (False Negatives) exponentially more than False Positives.
- Continuous Feedback Loop (Hard Negative Mining): Errors generated by the v1 baseline were logged as "Hard Mistakes", oversampled, mixed with a fractional batch of original data to prevent catastrophic forgetting, and retrained at a remarkably low learning rate (1e-5) for targeted semantic updates.
Intended Use & Capabilities
This model is intended to detect common fraud and scam patterns prevalent across Indian communications, including:
- Electricity and utility disconnection threats[cite: 4].
- Impersonation of major institutions such as banks, India Post, and courier services[cite: 4].
- Fake lottery, subsidy, and government-scheme claims[cite: 4].
- Suspicious payment requests and fee demands[cite: 4].
- Phishing and malicious links[cite: 4].
- Requests for OTPs, passwords, PINs, or banking information[cite: 4].
- Fake delivery, refund, account-verification, and KYC messages[cite: 4].
- Suspicious promotional and reward messages[cite: 4].
The model is also trained to distinguish potentially legitimate transactional messages, such as:
- OTP notifications[cite: 4].
- Bank debit/transaction alerts[cite: 4].
- Utility bill reminders[cite: 4].
- Official-style service notifications[cite: 4].
Note: Classification depends on the text provided to the model. A legitimate message can resemble a scam, and a sophisticated scam can resemble a legitimate notification. The model should therefore be treated as a classification aid rather than a definitive fraud-verification system[cite: 4].
Evaluation (v2 Results)
The model was evaluated using a manually curated multilingual evaluation set containing 100 samples per language across all 14 supported languages[cite: 4]. Each language contains 50 SCAM samples and 50 HAM (legitimate) samples, for a total of 1,400 evaluation samples[cite: 4].
Overall Results (Highest Score on Unseen Dataset)
| Metric | v1 Baseline Result | v2 Optimized Result |
|---|---|---|
| Evaluation Samples | 1,400[cite: 4] | 1,400 |
| Correct Predictions | 1,376[cite: 4] | 1,395 |
| Incorrect Predictions | 24[cite: 4] | 5 |
| Overall Accuracy | 98.29%[cite: 4] | 99.64% |
Per-Language Evaluation (v2 Breakdown)
| Language | Samples | Correct | Accuracy |
|---|---|---|---|
Assamese (as) |
100 | 99 | 99.00% |
Bengali (bn) |
100 | 100 | 100.00% |
English (en) |
100 | 100 | 100.00% |
Gujarati (gu) |
100 | 100 | 100.00% |
Hindi (hi) |
100 | 100 | 100.00% |
Hinglish (hi-Latn) |
100 | 100 | 100.00% |
Kannada (kn) |
100 | 100 | 100.00% |
Kashmiri (ks) |
100 | 99 | 99.00% |
Malayalam (ml) |
100 | 100 | 100.00% |
Marathi (mr) |
100 | 99 | 99.00% |
Odia (or) |
100 | 100 | 100.00% |
Punjabi (pa) |
100 | 99 | 99.00% |
Tamil (ta) |
100 | 100 | 100.00% |
Telugu (te) |
100 | 99 | 99.00% |
| Total | 1,400 | 1,395 | 99.64% |
Observations
The feedback loop iterations completely eliminated the systemic errors found in v1's Hinglish and Kannada evaluations. Nine out of fourteen languages now demonstrate a perfect 100.00% accuracy rate on the test suite. The remaining five languages missed a maximum of 1 sample out of 100, bringing the overall performance tightly to an exceptionally stable production-ready threshold.
Quick Usage
Preprocessing Requirements
Because v2 was trained using explicit structural anchors, you must apply regex masking to URLs and Phone Numbers before passing text to the model.
Using Hugging Face Pipelines
from transformers import pipeline
# Load pipeline (Ensure you are pointing to the v2 model repo)
classifier = pipeline(
"text-classification",
model="anmolshrivastav/indicbert-scam-classifier-v2",
device_map="auto"
)
sample = "Aapka Bijli bill baki hai, connection aaj raat cut ho jayega. Turant call karein 9876543210"
# Note: Mask URLs and Phones using regex matching BEFORE inference for optimal results
# processed_sample = apply_regex_masks(sample)
result = classifier(sample)
print(result)
Programmatic Usage
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
class IndicScamClassifier:
def __init__(self, model_path: str = repo_id, device: str = None):
if device is None:
self.device = "cuda" if torch.cuda.is_available() else "cpu"
else:
self.device = device
self.tokenizer = AutoTokenizer.from_pretrained(model_path)
self.model = AutoModelForSequenceClassification.from_pretrained(model_path).to(self.device)
self.model.eval()
def predict(self, texts, threshold: float = 0.5):
is_single = isinstance(texts, str)
if is_single:
texts = [texts]
inputs = self.tokenizer(
texts,
padding=True,
truncation=True,
max_length=128,
return_tensors="pt"
).to(self.device)
with torch.no_grad():
outputs = self.model(**inputs)
probs = torch.softmax(outputs.logits, dim=-1)
results = []
for prob in probs:
scam_score = prob[1].item()
label = "scam" if scam_score >= threshold else "ham"
results.append({
"label": label,
"confidence": scam_score if label == "scam" else prob[0].item(),
"scam_probability": scam_score
})
return results[0] if is_single else results
# Quick test
detector = IndicScamClassifier()
sample = "Congratulations, you won lottery. Call 9876543210 immediately."
print(detector.predict(sample))
- Downloads last month
- 34
Model tree for anmolshrivastav/indicbert-scam-classifier-v2
Base model
ai4bharat/IndicBERTv2-MLM-only