CoolFace
Modelpublic

faizhuda/priormail-phishing

sourceHugging Faceotherupdated 3mo agoView on Hugging Face
0likes
Model Card

Model Card — PriorMail Phishing Detector v1.0

Model ID: phishing/v1.0 Owner: Faiz (PJK-GM095) Date: 2026-06-13 Status: Eval gates passed — pending export approval from Insan + Syafiq


What This Model Does

Binary email classifier: legit (0) vs phishing (1).

Used by prior-mail-backend to flag potentially malicious emails before they reach the user's inbox. Runs at inference time on every incoming email.


Base Model

bert-base-multilingual-cased (Google, 178M params)

Chosen over IndoBERT because the primary training data is English-dominant (~98% EN). mBERT handles English well and retains multilingual capability for future Indonesian phishing data.


Training Data

SourceRoleRows (after dedup)
ealvaradob/phishing-dataset subset textsPhishing + some legit~20,137
Enron corpus (emails.csv)Legit negative class~20,000 sampled

Total after deduplication: ~38,000 rows Train / Val / Test split: 75 / 12.5 / 12.5 (stratified by label)

Deduplication applied on the first 200 chars of body before splitting to prevent leakage.

Note: Dataset is almost entirely English. Indonesian phishing emails are not well-represented. Performance on Indonesian-language phishing may be lower — to be addressed in v1.1 with internal labeled data.


Training Config

See `configs/phishing_v1.yaml` for the full reproducible config.

Key hyperparameters:

ParameterValue
Learning rate2e-5
Batch size16 per device
Max sequence length512
Epochs4 (early stopped at 3)
Warmup ratio0.10
LossWeighted cross-entropy (phishingclassmultiplier=3.0)
Early stopping metricrecall_phishing (patience=2)
Mixed precisionbf16
Seed42

Evaluation Results

Threshold Selection (Validation Set)

Threshold selected on val set to maximize precision while keeping recall ≥ 0.95.

Threshold: 0.95

MetricVal Set
Recall0.981
Precision0.933

Final Results (Test Set, n=5,722)

MetricResultGateStatus
Recall0.970≥ 0.95PASS ✅
Precision0.928≥ 0.80PASS ✅
Latency p95 (CPU)435 ms< 500 msPASS ✅
F10.948——

Confusion Matrix (Test Set)

Predicted LegitPredicted Phishing
Actual Legit4,593 (TN)79 (FP)
Actual Phishing32 (FN)1,018 (TP)

False negatives (missed phishing): 32 out of 1,050 — 3.0% miss rate. False positives (false alarms): 79 out of 4,672 — 1.7% false alarm rate.


Input / Output Format

Input (assembled by src/data/preprocess.build_phishing_input()):

FROM: {sender_email} [SEP] SUBJECT: {subject} [SEP] BODY: {body}

If sender or subject are unavailable (e.g. plain-body-only sources), those fields are empty strings. The model still performs well on body-only input — the HF training data was ~98% body-only.

Output:

  • —Raw: softmax probability for class 1 (phishing), range [0, 1]
  • —Final label: phishing if probability ≥ 0.95, else legit
  • —Threshold stored in threshold.json alongside the checkpoint

Known Limitations

  • —Language: Trained primarily on English data. Lower recall expected on Indonesian-language phishing. Mitigated by mBERT's multilingual pretraining, but not validated.
  • —Sender signal weak: ~98% of HF phishing training samples had no RFC 2822 headers — sender email is not a reliable feature for this version. Enron legit samples do have sender headers, which may introduce a small asymmetry.
  • —Adversarial robustness: Not evaluated against adversarial phishing (obfuscated URLs, lookalike domains, Unicode tricks). Planned for v1.1.
  • —Domain shift: Trained on public phishing corpora. Real-world phishing targeting Indonesian corporate users may have different patterns.

Artifacts

FileDescription
model.safetensorsFine-tuned weights (best checkpoint, step 835 / epoch 1)
config.jsonHuggingFace model config
tokenizer.json, tokenizer_config.jsonTokenizer (bert-base-multilingual-cased)
threshold.json{"threshold": 0.95}
training_config.yamlFull training config + git SHA
val_metrics.jsonVal set metrics at end of training

Eval artifacts (in eval/results/phishing/): | File | Description | |---|---| | eval_report.json | Full test set metrics + confusion matrix + latency |


Changelog

VersionDateNotes
v1.02026-06-13Initial release. All eval gates passed. English-only training data.