File size: 1,954 Bytes
708d260
 
 
 
 
 
 
 
 
 
 
 
 
 
2317567
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
708d260
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
---
datasets:
- zefang-liu/phishing-email-dataset
language:
- en
base_model:
- google-bert/bert-base-uncased
library_name: transformers
tags:
- phishing
- email
- detection
- scam
---
# BERT Model for Phishing Detection

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.

## Model Details

- **Model Type**: BERT (Bidirectional Encoder Representations from Transformers)
- **Task**: Phishing detection (Binary classification)
- **Fine-Tuning**: The model was fine-tuned on a dataset of phishing and legitimate emails.

## How to Use

1. **Install Dependencies**:
   You can use the following command to install the necessary libraries:
   ```bash
   pip install transformers torch

2. **Load Model**:
   ```bash
   from transformers import BertForSequenceClassification, BertTokenizer
    import torch
    
    # Replace with your Hugging Face model repo name
    model_name = 'ElSlay/BERT-Phishing-Email-Model'
    
    # Load the pre-trained model and tokenizer
    model = BertForSequenceClassification.from_pretrained(model_name)
    tokenizer = BertTokenizer.from_pretrained(model_name)
    
    # Ensure the model is in evaluation mode
    model.eval()

3. **Use the model for Prediction**:
   ```bash
   # Input email text
    email_text = "Your email content here"
    
    # Tokenize and preprocess the input text
    inputs = tokenizer(email_text, return_tensors="pt", truncation=True, padding='max_length', max_length=512)
    
    # Make the prediction
    with torch.no_grad():
        outputs = model(**inputs)
        logits = outputs.logits
        predictions = torch.argmax(logits, dim=-1)
    
    # Interpret the prediction
    result = "Phishing" if predictions.item() == 1 else "Legitimate"
    print(f"Prediction: {result}")

4. **Expected Outputs**:
   1: Phishing
   0: Legitimate