Instructions to use Project-Bastion/url-phishing-classifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Project-Bastion/url-phishing-classifier with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="Project-Bastion/url-phishing-classifier")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("Project-Bastion/url-phishing-classifier") model = AutoModelForSequenceClassification.from_pretrained("Project-Bastion/url-phishing-classifier", device_map="auto") - Notebooks
- Google Colab
- Kaggle
# pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("Project-Bastion/url-phishing-classifier")
model = AutoModelForSequenceClassification.from_pretrained("Project-Bastion/url-phishing-classifier", device_map="auto")url-phishing-classifier
Scores whether a URL is a phishing URL, from the URL string alone (no page fetch). An 82M-parameter DistilRoBERTa classifier. On the 1.1M-URL fed-phishing-urls corpus it clearly beats the open URL classifiers I compared (AUROC 0.994 vs 0.977 for kmack/malicious-url-detection), and on pirocheto/phishing-url it is level with the best of them (0.9915 vs 0.9903 and 0.9921), with a much lower false-positive rate at the default threshold than kmack (3.8% vs 8.8%).
Try it in your browser: a static page that runs the model locally (transformers.js, ONNX int8, about 86 MB, downloaded once). The URL you paste never leaves your device.
Results
AUROC, with recall at 1% false-positive rate in brackets. All models scored with identical code on identical URLs.
| Benchmark (URLs) | url-phishing-classifier | kmack/malicious-url-detection | CrabInHoney/urlbert-tiny-v4-phishing-classifier | ealvaradob/bert-finetuned-phishing | cybersectony/phishing-email-detection-distilbert_v2.4.1 (URL classes) |
|---|---|---|---|---|---|
| pirocheto/phishing-url test (3,772) | 0.9915 (0.885) | 0.9903 (0.838) | 0.9921 (0.897) | 0.9555 (0.235) | 0.573 (0.004) |
| flwrlabs/fed-phishing-urls, test sample (6,000) | 0.994 (0.881) | 0.9774 (0.745) | 0.8944 (0.046) | 0.9624 (0.525) | 0.599 (0.038) |
False-positive rate on legitimate URLs at the default threshold (margin 0): 3.8% (pirocheto) and 3.5% (fed-phishing-urls), against 8.8% and 10.6% for kmack.
Usage
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
repo = "Project-Bastion/url-phishing-classifier"
tok = AutoTokenizer.from_pretrained(repo); model = AutoModelForSequenceClassification.from_pretrained(repo).eval()
def phishing_margin(url):
enc = tok(url, truncation=True, max_length=128, return_tensors="pt")
with torch.no_grad(): logits = model(**enc).logits[0]
return float(logits[1] - logits[0]) # label 0 = legitimate, 1 = phishing
for u in ["http://secure-login.paypa1-verify.example.top/account/update", "https://en.wikipedia.org/wiki/Phishing"]:
m = phishing_margin(u); print(round(m, 2), "PHISHING" if m > 0 else "ok", u)
The score is a logit margin (phishing minus legitimate); 0 corresponds to p = 0.5. Raise the threshold for fewer false alarms.
Files
onnx/model_quantized.onnx (weight-only int8, 86 MB, the demo default) and onnx/model.onnx (fp32, 329 MB). On 300 checked URLs fp32 gives the same decision as PyTorch for all, int8 for 99.3% (largest margin difference 0.8).
Notes on the numbers
The model was trained on the training split of flwrlabs/fed-phishing-urls (Apache-2.0) and on the training split of pirocheto/phishing-url (CC-BY-4.0); the scores are on test data (pirocheto's test split, and a random 6,000-URL test sample of the fed corpus that is disjoint from the training URLs). The fed test sample comes from the same corpus as the training data, so it is the easier of the two benchmarks. The other models were trained on other data. Public URL corpora carry label noise.
Limits
- Looks at the URL string only: it cannot see page content, redirects or reputation, so use it as one signal.
- About 3-4% of legitimate URLs are flagged at the default threshold: raise the threshold, or tune it on your own URLs.
License and credits
Apache-2.0. Base model: distilroberta-base (Apache-2.0). Data: flwrlabs/fed-phishing-urls (Apache-2.0); pirocheto/phishing-url (CC-BY-4.0, Pirocheto). Other models were used only as baselines.
- Downloads last month
- -
Model tree for Project-Bastion/url-phishing-classifier
Base model
distilbert/distilroberta-base
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="Project-Bastion/url-phishing-classifier")