Update README.md
Browse files
README.md
CHANGED
|
@@ -1,10 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
datasets:
|
| 3 |
- zefang-liu/phishing-email-dataset
|
|
|
|
| 4 |
language:
|
| 5 |
- en
|
|
|
|
| 6 |
base_model:
|
| 7 |
- google-bert/bert-base-uncased
|
|
|
|
| 8 |
tags:
|
| 9 |
- phishing
|
| 10 |
- email
|
|
|
|
| 1 |
+
# BERT Model for Phishing Detection
|
| 2 |
+
|
| 3 |
+
This repository contains the fine-tuned **BERT model** for detecting phishing emails. The model has been trained to classify emails as either **phishing** or **legitimate** based on their body text.
|
| 4 |
+
|
| 5 |
+
## Model Details
|
| 6 |
+
|
| 7 |
+
- **Model Type**: BERT (Bidirectional Encoder Representations from Transformers)
|
| 8 |
+
- **Task**: Phishing detection (Binary classification)
|
| 9 |
+
- **Fine-Tuning**: The model was fine-tuned on a dataset of phishing and legitimate emails.
|
| 10 |
+
|
| 11 |
+
## How to Use
|
| 12 |
+
|
| 13 |
+
1. **Install Dependencies**:
|
| 14 |
+
You can use the following command to install the necessary libraries:
|
| 15 |
+
```bash
|
| 16 |
+
pip install transformers torch
|
| 17 |
+
|
| 18 |
+
2. **Load Model**:
|
| 19 |
+
```bash
|
| 20 |
+
from transformers import BertForSequenceClassification, BertTokenizer
|
| 21 |
+
import torch
|
| 22 |
+
|
| 23 |
+
# Replace with your Hugging Face model repo name
|
| 24 |
+
model_name = 'ElSlay/BERT-Phishing-Email-Model'
|
| 25 |
+
|
| 26 |
+
# Load the pre-trained model and tokenizer
|
| 27 |
+
model = BertForSequenceClassification.from_pretrained(model_name)
|
| 28 |
+
tokenizer = BertTokenizer.from_pretrained(model_name)
|
| 29 |
+
|
| 30 |
+
# Ensure the model is in evaluation mode
|
| 31 |
+
model.eval()
|
| 32 |
+
|
| 33 |
+
3. **Use the model for Prediction**:
|
| 34 |
+
```bash
|
| 35 |
+
# Input email text
|
| 36 |
+
email_text = "Your email content here"
|
| 37 |
+
|
| 38 |
+
# Tokenize and preprocess the input text
|
| 39 |
+
inputs = tokenizer(email_text, return_tensors="pt", truncation=True, padding='max_length', max_length=512)
|
| 40 |
+
|
| 41 |
+
# Make the prediction
|
| 42 |
+
with torch.no_grad():
|
| 43 |
+
outputs = model(**inputs)
|
| 44 |
+
logits = outputs.logits
|
| 45 |
+
predictions = torch.argmax(logits, dim=-1)
|
| 46 |
+
|
| 47 |
+
# Interpret the prediction
|
| 48 |
+
result = "Phishing" if predictions.item() == 1 else "Legitimate"
|
| 49 |
+
print(f"Prediction: {result}")
|
| 50 |
+
|
| 51 |
+
4. **Expected Outputs**:
|
| 52 |
+
1: Phishing
|
| 53 |
+
0: Legitimate
|
| 54 |
+
|
| 55 |
---
|
| 56 |
datasets:
|
| 57 |
- zefang-liu/phishing-email-dataset
|
| 58 |
+
---
|
| 59 |
language:
|
| 60 |
- en
|
| 61 |
+
---
|
| 62 |
base_model:
|
| 63 |
- google-bert/bert-base-uncased
|
| 64 |
+
---
|
| 65 |
tags:
|
| 66 |
- phishing
|
| 67 |
- email
|