ucirvine/sms_spam
Viewer β’ Updated β’ 5.57k β’ 5.03k β’ 56
How to use DhruvSoni/social-engineering-detector with Keras:
# Available backend options are: "jax", "torch", "tensorflow".
import os
os.environ["KERAS_BACKEND"] = "jax"
import keras
model = keras.saving.load_model("hf://DhruvSoni/social-engineering-detector")
An intelligent ML model that detects social engineering attacks in text messages, emails, and SMS.
Multi-kernel CNN: Embedding(64) β Conv1D(3-gram, 64) + Conv1D(5-gram, 64) β Concat β Dense(64) β Dense(32) β Sigmoid
Total Parameters: 1,323,265 (5.05 MB)
| Metric | Value |
|---|---|
| Accuracy | 0.9844 |
| AUC | 0.9986 |
| Precision | 0.9854 |
| Recall | 0.9812 |
| Loss | 0.0456 |
Trained for 6 epochs with early stopping.
50,112 samples from 3 combined datasets:
Class distribution: ~53% legitimate, ~47% malicious
| File | Description |
|---|---|
social_engineering_detector.keras |
Keras native format (recommended) |
social_engineering_detector.h5 |
HDF5 format (legacy compatible) |
vocabulary.json |
Tokenizer vocabulary (20,000 tokens) |
vectorizer_config.json |
Text vectorization settings |
metrics.json |
Full evaluation metrics |
training_history.json |
Training curves data |
import tensorflow as tf
import numpy as np
# Load model
model = tf.keras.models.load_model("social_engineering_detector.h5")
# Predict
messages = [
"URGENT: Your account compromised! Click to verify: http://fake-bank.xyz",
"Hey, are we meeting for lunch tomorrow?",
"You won $10,000! Send SSN to claim.",
"Please review the Q3 report attached.",
]
predictions = model.predict(tf.constant(messages))
for msg, pred in zip(messages, predictions):
label = "π¨ SOCIAL ENGINEERING" if pred[0] > 0.5 else "β
LEGITIMATE"
confidence = pred[0] if pred[0] > 0.5 else 1 - pred[0]
print(f"{label} ({confidence:.1%}): {msg}")
from huggingface_hub import hf_hub_download
import tensorflow as tf
# Download .h5 model
path = hf_hub_download("DhruvSoni/social-engineering-detector", "social_engineering_detector.h5")
model = tf.keras.models.load_model(path)
# Or download .keras model
path = hf_hub_download("DhruvSoni/social-engineering-detector", "social_engineering_detector.keras")
model = tf.keras.models.load_model(path)
| Predicted Legitimate | Predicted Malicious | |
|---|---|---|
| Actual Legitimate | 3,962 (TN) | 51 (FP) |
| Actual Malicious | 66 (FN) | 3,438 (TP) |
MIT β free for personal and commercial use.