zefang-liu/phishing-email-dataset
Viewer • Updated • 18.7k • 1.53k • 33
How to use ElSlay/BERT-Phishing-Email-Model with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-classification", model="ElSlay/BERT-Phishing-Email-Model") # Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("ElSlay/BERT-Phishing-Email-Model")
model = AutoModelForSequenceClassification.from_pretrained("ElSlay/BERT-Phishing-Email-Model")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.
Install Dependencies: You can use the following command to install the necessary libraries:
pip install transformers torch
Load Model:
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()
Use the model for Prediction:
# 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}")
Expected Outputs: 1: Phishing 0: Legitimate
Base model
google-bert/bert-base-uncased