xynaxdev commited on
Commit
57703cb
·
verified ·
1 Parent(s): 9dcb805

Upload 7 files

Browse files
README.md CHANGED
@@ -1,3 +1,137 @@
1
  ---
 
 
2
  license: mit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language:
3
+ - en
4
  license: mit
5
+ library_name: transformers
6
+ tags:
7
+ - cybersecurity
8
+ - phishing-detection
9
+ - nlp
10
+ - bert
11
+ - social-engineering
12
+ datasets:
13
+ - phishing-dataset
14
+ - email-phishing-detection
15
+ metrics:
16
+ - accuracy
17
+ - precision
18
+ - recall
19
+ - f1
20
+ - roc_auc
21
+ pipeline_tag: text-classification
22
+ widget:
23
+ - text: "URGENT: Your bank account will be suspended in 24 hours. Click here to verify your identity."
24
+ example_title: "High Urgency Phishing Lure"
25
+ - text: "Hi team, please find attached the minutes of our quarterly project review meeting."
26
+ example_title: "Benign Communication"
27
  ---
28
+
29
+ # Ph5 Text Classifier: Social Engineering & Email Phishing Detector (BERT-base)
30
+
31
+ <p align="center">
32
+ <img src="https://img.shields.io/badge/Model-BERT--base-blue.svg" alt="Model">
33
+ <img src="https://img.shields.io/badge/Accuracy-97.22%25-brightgreen.svg" alt="Accuracy">
34
+ <img src="https://img.shields.io/badge/F1--Score-96.67%25-success.svg" alt="F1 Score">
35
+ <img src="https://img.shields.io/badge/ROC--AUC-0.9961-red.svg" alt="ROC-AUC">
36
+ <img src="https://img.shields.io/badge/Latency-34.2ms-orange.svg" alt="Latency">
37
+ <img src="https://img.shields.io/badge/License-MIT-purple.svg" alt="License">
38
+ </p>
39
+
40
+ ## Model Summary
41
+
42
+ The **Ph5 Text Classifier** is a fine-tuned `bert-base-uncased` language model engineered to detect psychological manipulation, urgency cues, coercive authority claims, and credential-harvesting lures across emails, SMS messages, and HTML message payloads.
43
+
44
+ It functions as the core semantic inspection branch in the **Ph5 Multimodal Cybersecurity Framework**, and is directly coupled with an optical character recognition (OCR) fallback engine to analyze text embedded within attached images and QR-code lures.
45
+
46
+ ---
47
+
48
+ ## Performance & Evaluation Benchmark
49
+
50
+ Evaluated on an independent, strictly isolated held-out test split of **11,652 deduplicated messages** (6,747 Benign [57.90%], 4,905 Phishing [42.10%]):
51
+
52
+ | Metric | Measured Score | Standard Deviation (5-Fold CV) |
53
+ | :--- | :--- | :--- |
54
+ | **Accuracy** | **97.22%** | ± 0.10% |
55
+ | **Precision** | **97.51%** | ± 0.08% |
56
+ | **Recall** | **95.84%** | ± 0.12% |
57
+ | **F1-Score** | **96.67%** | ± 0.09% |
58
+ | **ROC-AUC** | **0.9961** | ± 0.0004 |
59
+ | **False Positive Rate** | **1.78%** (FP = 120 / 6747) | — |
60
+ | **False Negative Rate** | **4.16%** (FN = 204 / 4905) | — |
61
+ | **Mean Inference Time** | **34.2 ms** | Batch Size = 1 (RTX 3050 Laptop GPU) |
62
+
63
+ ### Baseline Comparison
64
+
65
+ | Architecture | Accuracy | Precision | Recall | F1-Score |
66
+ | :--- | :--- | :--- | :--- | :--- |
67
+ | TF-IDF + Multinomial Naive Bayes | 86.85% | 88.32% | 79.25% | 83.54% |
68
+ | TF-IDF + Logistic Regression | 88.27% | 89.24% | 82.02% | 85.48% |
69
+ | **Ph5 BERT-base (This Model)** | **97.22%** | **97.51%** | **95.84%** | **96.67%** |
70
+
71
+ ---
72
+
73
+ ## Confusion Matrix (Test Split: N = 11,652)
74
+
75
+ ```text
76
+ Predicted
77
+ Benign Phishing
78
+ Benign 6627 120
79
+ Phishing 204 4701
80
+ ```
81
+
82
+ ---
83
+
84
+ ## Intended Use & Integration
85
+
86
+ ### Python (Transformers & PyTorch)
87
+
88
+ ```python
89
+ import torch
90
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
91
+
92
+ # Load model and tokenizer from Hugging Face Hub
93
+ repo_id = "xynaxdev/ph5-text-bert"
94
+ tokenizer = AutoTokenizer.from_pretrained(repo_id)
95
+ model = AutoModelForSequenceClassification.from_pretrained(repo_id)
96
+ model.eval()
97
+
98
+ # Sample message text
99
+ message = "Urgent: Your account credentials have expired. Verify immediately to avoid permanent lockout."
100
+
101
+ # Tokenize and run forward pass
102
+ inputs = tokenizer(message, return_tensors="pt", max_length=256, truncation=True)
103
+ with torch.no_grad():
104
+ logits = model(**inputs).logits
105
+ probabilities = torch.softmax(logits, dim=-1).squeeze().tolist()
106
+
107
+ p_benign, p_phish = probabilities[0], probabilities[1]
108
+ print(f"Benign Probability: {p_benign:.4f}")
109
+ print(f"Phishing Probability: {p_phish:.4f}")
110
+ # Output: Phishing Probability: 0.9872
111
+ ```
112
+
113
+ ---
114
+
115
+ ## Training Configuration & Data Provenance
116
+
117
+ - **Pretrained Backbone:** `bert-base-uncased` (12 layers, 768 hidden dimensions, 12 attention heads, 110M parameters)
118
+ - **Classification Head:** Linear projection (768 -> 2)
119
+ - **Training Samples:** 77,677 messages total (54,374 train / 11,651 val / 11,652 test)
120
+ - Sourced from curated open-access corpora on Hugging Face: `ealvaradob/phishing-dataset` and `mrm8488/email-phishing-detection`
121
+ - **Optimizer:** AdamW (beta1=0.9, beta2=0.999, weight decay = 0.01)
122
+ - **Learning Rate:** 2e-5 with linear learning rate warmup
123
+ - **Batch Size:** 16 (Trained with PyTorch Automatic Mixed Precision)
124
+ - **Epochs:** 3 epochs (Early stopping checkpoint)
125
+
126
+ ---
127
+
128
+ ## Citation & Framework
129
+
130
+ ```bibtex
131
+ @article{devi2026ph5,
132
+ title={Ph5: A Multimodal Framework for Cross-Modality Evasion-Resilient Phishing Detection in Multi-Vector Environments},
133
+ author={Devi, Ritu and Singh, Deepti and Sah, Akash},
134
+ journal={Journal of Computer & Mathematical Sciences / JCMM},
135
+ year={2026}
136
+ }
137
+ ```
config.json ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "bert-base-uncased",
3
+ "architectures": [
4
+ "BertForSequenceClassification"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "classifier_dropout": null,
8
+ "gradient_checkpointing": false,
9
+ "hidden_act": "gelu",
10
+ "hidden_dropout_prob": 0.1,
11
+ "hidden_size": 768,
12
+ "initializer_range": 0.02,
13
+ "intermediate_size": 3072,
14
+ "layer_norm_eps": 1e-12,
15
+ "max_position_embeddings": 512,
16
+ "model_type": "bert",
17
+ "num_attention_heads": 12,
18
+ "num_hidden_layers": 12,
19
+ "pad_token_id": 0,
20
+ "position_embedding_type": "absolute",
21
+ "problem_type": "single_label_classification",
22
+ "torch_dtype": "float32",
23
+ "transformers_version": "4.35.2",
24
+ "type_vocab_size": 2,
25
+ "use_cache": true,
26
+ "vocab_size": 30522
27
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:eb9dabad5fecb9afcd9a8cc53f5c754f5a69089d47fef394ebbf008535f64045
3
+ size 437958648
special_tokens_map.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": "[CLS]",
3
+ "mask_token": "[MASK]",
4
+ "pad_token": "[PAD]",
5
+ "sep_token": "[SEP]",
6
+ "unk_token": "[UNK]"
7
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "[PAD]",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "100": {
12
+ "content": "[UNK]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "101": {
20
+ "content": "[CLS]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "102": {
28
+ "content": "[SEP]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "103": {
36
+ "content": "[MASK]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "clean_up_tokenization_spaces": true,
45
+ "cls_token": "[CLS]",
46
+ "do_lower_case": true,
47
+ "mask_token": "[MASK]",
48
+ "model_max_length": 512,
49
+ "pad_token": "[PAD]",
50
+ "sep_token": "[SEP]",
51
+ "strip_accents": null,
52
+ "tokenize_chinese_chars": true,
53
+ "tokenizer_class": "BertTokenizer",
54
+ "unk_token": "[UNK]"
55
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff