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