SENTRA is a fine-tuned
DistilBERT multilingual model for
SMS fraud detection (smishing). It classifies SMS messages as either
LEGITIMATE or
FRAUD with high accuracy.
1from transformers import pipeline
2
3classifier = pipeline(
4 "text-classification",
5 model="VynoDePal/sentra-sms-fraud-detector",
6 top_k=None,
7)
8
9# Fraudulent SMS
10result = classifier("URGENT: Your account has been suspended. Call +229-12345678 NOW")
11print(result)
12# [[{'label': 'FRAUD', 'score': 0.92}, {'label': 'LEGITIMATE', 'score': 0.08}]]
13
14# Legitimate SMS
15result = classifier("Hey! Are we still on for lunch tomorrow at 2pm?")
16print(result)
17# [[{'label': 'LEGITIMATE', 'score': 0.97}, {'label': 'FRAUD', 'score': 0.03}]]
1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
3
4model_name = "VynoDePal/sentra-sms-fraud-detector"
5tokenizer = AutoTokenizer.from_pretrained(model_name)
6model = AutoModelForSequenceClassification.from_pretrained(model_name)
7
8text = "Congratulations! You won 1,000,000 FCFA. Send your PIN to claim."
9inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=128)
10
11with torch.no_grad():
12 outputs = model(**inputs)
13 probabilities = torch.softmax(outputs.logits, dim=-1)
14 fraud_prob = probabilities[0][1].item()
15
16print(f"Fraud probability: {fraud_prob:.1%}")
17# Fraud probability: 87.3%
1import re
2
3SMS_ABBREVIATIONS = {
4 "u": "you", "ur": "your", "pls": "please", "plz": "please",
5 "acc": "account", "acct": "account", "asap": "as soon as possible",
6 "msg": "message", "txt": "text", "amt": "amount",
7 "slt": "salut", "bjr": "bonjour", "stp": "s il te plait",
8 "svp": "s il vous plait", "mrc": "merci", "cpte": "compte",
9}
10
11CURRENCY_PATTERN = re.compile(
12 r'[£$€]\s?\d+[,.]?\d*|\d+[,.]?\d*\s?(?:usd|eur|gbp|fcfa|cfa|xof)',
13 re.IGNORECASE,
14)
15REPEATED_CHARS = re.compile(r'(.)\1{2,}')
16
17def preprocess_sms(text: str) -> str:
18 text = text.lower()
19 text = CURRENCY_PATTERN.sub("money amount", text)
20 text = re.sub(r'http\S+|www\.\S+', '', text)
21 words = text.split()
22 words = [SMS_ABBREVIATIONS.get(w, w) for w in words]
23 text = ' '.join(words)
24 text = REPEATED_CHARS.sub(r'\1\1', text)
25 return text.strip()
26
27# Usage
28raw_sms = "URGENT!!! Ur acc has been SUSPENDED. Call NOW to claim $5000"
29clean_sms = preprocess_sms(raw_sms)
30result = classifier(clean_sms)
The Random Forest model and the full API are available in the
SENTRA ML repository.
1@misc{sentra2026,
2 title={SENTRA: SMS Fraud Detection with Ensemble DistilBERT and Random Forest},
3 author={SENTRA Team},
4 year={2026},
5 url={https://github.com/VynoDePal/sentra_ml}
6}