Text Classification
Safetensors
PyTorch
English
phishbyte
phishing-detection
email-security
cybersecurity
security
from-scratch
no-pretrained-weights
cascading-inference
lightweight
explainable-ai
nlp
phishing
spam-detection
malware-detection
threat-detection
email-classification
feature-engineering
interpretable-ml
tfidf
residual-network
Eval Results (legacy)
Update model card — v7: 85 features, 254K params, F1 0.950, 6-dataset
Browse files
README.md
CHANGED
|
@@ -1,19 +1,38 @@
|
|
| 1 |
---
|
| 2 |
-
language:
|
|
|
|
| 3 |
license: mit
|
| 4 |
library_name: phishbyte
|
| 5 |
pipeline_tag: text-classification
|
| 6 |
tags:
|
| 7 |
- phishing-detection
|
| 8 |
- email-security
|
|
|
|
|
|
|
| 9 |
- pytorch
|
| 10 |
- from-scratch
|
| 11 |
- no-pretrained-weights
|
| 12 |
- cascading-inference
|
| 13 |
- lightweight
|
| 14 |
- explainable-ai
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
datasets:
|
| 16 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
metrics:
|
| 18 |
- f1
|
| 19 |
- precision
|
|
@@ -26,102 +45,146 @@ model-index:
|
|
| 26 |
type: text-classification
|
| 27 |
name: Phishing Email Detection
|
| 28 |
dataset:
|
| 29 |
-
name: CEAS-
|
| 30 |
type: ceas-2008
|
| 31 |
metrics:
|
| 32 |
- type: f1
|
| 33 |
-
value: 0.
|
|
|
|
| 34 |
- type: accuracy
|
| 35 |
-
value: 0.
|
|
|
|
| 36 |
- type: precision
|
| 37 |
-
value: 0.
|
|
|
|
| 38 |
- type: recall
|
| 39 |
-
value: 0.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
---
|
| 41 |
|
| 42 |
-
# Phish_Byte
|
| 43 |
|
| 44 |
A from-scratch PyTorch model for **email phishing detection**.
|
| 45 |
-
**F1 0.948** on CEAS-2008. **12,545 parameters** (≈9,000× smaller than DistilBERT).
|
| 46 |
-
**1,500+ emails/sec** on a laptop GPU. Every verdict explains itself.
|
| 47 |
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
-
|
| 51 |
-
transformer (DistilBERT, BERT, RoBERTa) — 65 to 110 million parameters,
|
| 52 |
-
~250 MB on disk, ~50 ms per email on GPU. Phish_Byte takes a different
|
| 53 |
-
bet: a small custom MLP trained from scratch, fed by 29 carefully chosen
|
| 54 |
-
features, routed through a cascading inference pipeline. The model is
|
| 55 |
-
**9,000× smaller** than DistilBERT, performs competitively, deploys
|
| 56 |
-
without a GPU, and explains every decision.
|
| 57 |
|
| 58 |
-
##
|
| 59 |
|
| 60 |
```python
|
| 61 |
from phishbyte import PhishByteEngine
|
| 62 |
|
| 63 |
-
engine = PhishByteEngine.from_pretrained("
|
| 64 |
verdict = engine.analyze(raw_email_string)
|
| 65 |
|
| 66 |
-
print(verdict.label) #
|
| 67 |
print(verdict.probability) # 0.9735
|
| 68 |
-
print(verdict.confidence) #
|
| 69 |
-
print(verdict.layer_used) # 2
|
| 70 |
-
print(verdict.feature_weights) #
|
| 71 |
```
|
| 72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
## Architecture
|
| 74 |
|
| 75 |
```
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
Layer 2 — MLP (~3 ms): 29 → 96 → 48 → 1 (sigmoid)
|
| 83 |
-
│
|
| 84 |
-
▼
|
| 85 |
-
PhishVerdict {label, probability, confidence, layer_used, feature_weights}
|
| 86 |
```
|
| 87 |
|
| 88 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
-
|
|
| 91 |
-
|------------
|
| 92 |
-
|
|
| 93 |
-
|
|
| 94 |
-
|
|
| 95 |
-
|
|
| 96 |
-
|
|
| 97 |
-
|
|
| 98 |
-
|
|
| 99 |
-
| Throughput (CPU) | ~800 /s |
|
| 100 |
|
| 101 |
-
##
|
| 102 |
|
| 103 |
-
-
|
| 104 |
-
|
| 105 |
-
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
|
|
|
|
|
|
|
|
|
| 109 |
|
| 110 |
## Limitations
|
| 111 |
|
| 112 |
-
- ~5%
|
| 113 |
-
- Trained on
|
| 114 |
-
- SPF validation
|
| 115 |
-
-
|
| 116 |
|
| 117 |
## Citation
|
| 118 |
|
| 119 |
```bibtex
|
| 120 |
@software{phishbyte2026,
|
| 121 |
-
author
|
| 122 |
-
title
|
| 123 |
-
year
|
| 124 |
-
url
|
| 125 |
}
|
| 126 |
```
|
| 127 |
|
|
|
|
| 1 |
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
license: mit
|
| 5 |
library_name: phishbyte
|
| 6 |
pipeline_tag: text-classification
|
| 7 |
tags:
|
| 8 |
- phishing-detection
|
| 9 |
- email-security
|
| 10 |
+
- cybersecurity
|
| 11 |
+
- security
|
| 12 |
- pytorch
|
| 13 |
- from-scratch
|
| 14 |
- no-pretrained-weights
|
| 15 |
- cascading-inference
|
| 16 |
- lightweight
|
| 17 |
- explainable-ai
|
| 18 |
+
- nlp
|
| 19 |
+
- phishing
|
| 20 |
+
- spam-detection
|
| 21 |
+
- malware-detection
|
| 22 |
+
- threat-detection
|
| 23 |
+
- email-classification
|
| 24 |
+
- text-classification
|
| 25 |
+
- feature-engineering
|
| 26 |
+
- interpretable-ml
|
| 27 |
+
- tfidf
|
| 28 |
+
- residual-network
|
| 29 |
datasets:
|
| 30 |
+
- ceas-2008
|
| 31 |
+
- enron-email
|
| 32 |
+
- spamassassin
|
| 33 |
+
- ling-spam
|
| 34 |
+
- nazario-phishing
|
| 35 |
+
- nigerian-fraud
|
| 36 |
metrics:
|
| 37 |
- f1
|
| 38 |
- precision
|
|
|
|
| 45 |
type: text-classification
|
| 46 |
name: Phishing Email Detection
|
| 47 |
dataset:
|
| 48 |
+
name: 6-corpus benchmark (CEAS, Enron, SpamAssassin, Ling-Spam, Nazario, Nigerian)
|
| 49 |
type: ceas-2008
|
| 50 |
metrics:
|
| 51 |
- type: f1
|
| 52 |
+
value: 0.9503
|
| 53 |
+
name: F1 Score
|
| 54 |
- type: accuracy
|
| 55 |
+
value: 0.9494
|
| 56 |
+
name: Accuracy
|
| 57 |
- type: precision
|
| 58 |
+
value: 0.9490
|
| 59 |
+
name: Precision
|
| 60 |
- type: recall
|
| 61 |
+
value: 0.9516
|
| 62 |
+
name: Recall
|
| 63 |
+
widget:
|
| 64 |
+
- text: "From: PayPal Security <security@paypa1-alert.tk>\nReply-To: attacker@evil-domain.ru\nSubject: URGENT: Your account will be suspended\n\nDear Customer, your PayPal account has been suspended. Verify now at http://paypal-login.tk/verify"
|
| 65 |
+
example_title: "Phishing email"
|
| 66 |
+
- text: "From: alice@company.com\nReply-To: alice@company.com\nSubject: Team lunch tomorrow\n\nHi everyone, lunch is at noon tomorrow. See you there!"
|
| 67 |
+
example_title: "Legitimate email"
|
| 68 |
---
|
| 69 |
|
| 70 |
+
# Phish_Byte v7
|
| 71 |
|
| 72 |
A from-scratch PyTorch model for **email phishing detection**.
|
|
|
|
|
|
|
| 73 |
|
| 74 |
+
**F1 0.950** on 5,000 held-out samples from a 6-corpus benchmark.
|
| 75 |
+
**254K parameters** (≈260× smaller than DistilBERT).
|
| 76 |
+
**995 emails/sec** on a laptop GPU.
|
| 77 |
+
**85 engineered features** (35 rule-based + 50 TF-IDF learned from corpus).
|
| 78 |
+
Every verdict explains itself with full per-feature attribution.
|
| 79 |
|
| 80 |
+
> **The only non-transformer phishing detection model on HuggingFace.**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
+
## Quick start
|
| 83 |
|
| 84 |
```python
|
| 85 |
from phishbyte import PhishByteEngine
|
| 86 |
|
| 87 |
+
engine = PhishByteEngine.from_pretrained("SamSec007/phishbyte")
|
| 88 |
verdict = engine.analyze(raw_email_string)
|
| 89 |
|
| 90 |
+
print(verdict.label) # "phishing"
|
| 91 |
print(verdict.probability) # 0.9735
|
| 92 |
+
print(verdict.confidence) # "high"
|
| 93 |
+
print(verdict.layer_used) # 2
|
| 94 |
+
print(verdict.feature_weights) # 85-feature attribution
|
| 95 |
```
|
| 96 |
|
| 97 |
+
## Analyse a real email from Gmail
|
| 98 |
+
|
| 99 |
+
1. Open the email in Gmail
|
| 100 |
+
2. Click ⋮ → **Show original**
|
| 101 |
+
3. Copy all (Ctrl+A, Ctrl+C)
|
| 102 |
+
|
| 103 |
+
```python
|
| 104 |
+
engine = PhishByteEngine.from_pretrained("SamSec007/phishbyte")
|
| 105 |
+
verdict = engine.analyze(pasted_raw_email)
|
| 106 |
+
print(verdict)
|
| 107 |
+
```
|
| 108 |
+
|
| 109 |
+
Or save as `.eml` and run:
|
| 110 |
+
|
| 111 |
+
```bash
|
| 112 |
+
python cli.py --file suspicious.eml
|
| 113 |
+
```
|
| 114 |
+
|
| 115 |
+
## What changed in v7
|
| 116 |
+
|
| 117 |
+
- **85 features** (was 29) — added 50 TF-IDF unigrams + 3 BDI features + 2 domain features + 1 composite
|
| 118 |
+
- **254K parameters** (was 12K) — deeper residual MLP with two ResBlocks and input skip connection
|
| 119 |
+
- **6-dataset training** (was CEAS-2008 only) — Enron, SpamAssassin, Ling-Spam, Nazario, Nigerian Fraud
|
| 120 |
+
- **TF-IDF vocabulary** — 50 most discriminative unigrams learned from training corpus. No pretrained LM.
|
| 121 |
+
- **Body Domain Identification** — most common link domain mismatch, form action mismatch, external link ratio
|
| 122 |
+
- **Display name spoofing** — catches "PayPal Security" \<attacker@evil.com\>
|
| 123 |
+
- **Calibrated training metrics** — F1 at Youden-optimal threshold, not naive 0.5 cutoff
|
| 124 |
+
|
| 125 |
## Architecture
|
| 126 |
|
| 127 |
```
|
| 128 |
+
raw email
|
| 129 |
+
→ Layer 1 (6 rule scorers, ~1ms) → veto gate (obvious phishing only)
|
| 130 |
+
→ Layer 2 (residual MLP, ~3ms)
|
| 131 |
+
85 → 360 → 180 (×2 ResBlock) → 90 → 48 → 1 (sigmoid)
|
| 132 |
+
+ input-to-output skip connection
|
| 133 |
+
→ PhishVerdict {label, probability, confidence, layer_used, feature_weights}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
```
|
| 135 |
|
| 136 |
+
## Benchmarks (5,000 held-out, 6-corpus)
|
| 137 |
+
|
| 138 |
+
| Metric | Phish_Byte v7 | DistilBERT fine-tuned |
|
| 139 |
+
|--------|:------------:|:---------------------:|
|
| 140 |
+
| F1 score | **0.950** | ~0.967 |
|
| 141 |
+
| Accuracy | **94.94%** | ~97% |
|
| 142 |
+
| Parameters | **254K** | 66,000,000 |
|
| 143 |
+
| Model size | **~1 MB** | ~263 MB |
|
| 144 |
+
| Throughput (GPU) | **995/sec** | ~50/sec |
|
| 145 |
+
| GPU required | **No** | Practically yes |
|
| 146 |
+
| Header + SPF analysis | **Yes** | No |
|
| 147 |
+
| Per-feature attribution | **85 features** | Token-level SHAP |
|
| 148 |
+
|
| 149 |
+
## Feature groups (85 total)
|
| 150 |
|
| 151 |
+
| Group | Count | Examples |
|
| 152 |
+
|-------|:-----:|---------|
|
| 153 |
+
| Domain | 7 | mismatch, Reply-To diff, brand impersonation, display name spoof, suspicious pattern |
|
| 154 |
+
| URL + Body | 10 | HTTPS ratio, anchor mismatch, urgency (normalized), caps ratio, digit ratio |
|
| 155 |
+
| SPF | 3 | fail, no record, no IP |
|
| 156 |
+
| Subject | 7 | urgency, security theme, brand, currency, all caps, fake RE, fake txn ID |
|
| 157 |
+
| BDI | 3 | most common link domain mismatch, form action mismatch, external link ratio |
|
| 158 |
+
| TF-IDF | 50 | top-50 discriminative unigrams from training corpus |
|
| 159 |
+
| Composite | 5 | per-module layer scores |
|
|
|
|
| 160 |
|
| 161 |
+
## Training data
|
| 162 |
|
| 163 |
+
CEAS-2008 + Enron + SpamAssassin + Ling-Spam + Nazario + Nigerian Fraud = **~83K emails** (balanced 50/50).
|
| 164 |
+
|
| 165 |
+
Same 6-corpus benchmark used by the top DistilBERT model on HuggingFace.
|
| 166 |
+
|
| 167 |
+
## Install
|
| 168 |
+
|
| 169 |
+
```bash
|
| 170 |
+
pip install huggingface_hub safetensors dnspython
|
| 171 |
+
```
|
| 172 |
|
| 173 |
## Limitations
|
| 174 |
|
| 175 |
+
- ~5% error rate. Use as one signal in defence-in-depth.
|
| 176 |
+
- Trained on English-language phishing (2003–2008 era). Modern attacks and non-English emails will degrade recall.
|
| 177 |
+
- SPF validation skipped for training (historical domains). Re-enables at inference on live emails.
|
| 178 |
+
- TF-IDF vocabulary is corpus-specific. Retrain on your own data for best domain fit.
|
| 179 |
|
| 180 |
## Citation
|
| 181 |
|
| 182 |
```bibtex
|
| 183 |
@software{phishbyte2026,
|
| 184 |
+
author = {Singh, Samratth},
|
| 185 |
+
title = {Phish_Byte: Cascading from-scratch PyTorch phishing detection},
|
| 186 |
+
year = {2026},
|
| 187 |
+
url = {https://github.com/AnonymousSingh-007/Phish_Byte}
|
| 188 |
}
|
| 189 |
```
|
| 190 |
|