Views
No views yet
paypa1-secure-login.com/verify)
Output: BENIGN or MALICIOUS with a confidence score.distilbert-base-uncasedhttp://, https://, and www. prefixes from all URLs (training and inference) to prevent the model from learning protocol-presence as a spurious shortcut| Metric | Value |
|---|---|
| Accuracy | 90.1% |
| F1 | 0.902 |
| Precision | 0.897 |
| Recall | 0.907 |
http:// vs bare domain) and label. The model had learned to detect the prefix, not the threat. After normalizing the protocol on both classes, accuracy "dropped" to 90% — but the model now generalizes to actual phishing patterns. The 90% number is the real one.google.com are rare in the benign training set (which mostly contains long path-heavy URLs), so the model can flag them as malicious. Not a model bug — a data coverage issue.1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
3
4repo = "gdsrAbhi/cyber-url-slm"
5tokenizer = AutoTokenizer.from_pretrained(repo)
6model = AutoModelForSequenceClassification.from_pretrained(repo)
7
8def normalize_url(url):
9 url = str(url).lower().strip()
10 for prefix in ['https://', 'http://']:
11 if url.startswith(prefix):
12 url = url[len(prefix):]
13 if url.startswith('www.'):
14 url = url[4:]
15 return url
16
17def predict(url):
18 cleaned = normalize_url(url)
19 inputs = tokenizer(cleaned, return_tensors='pt', padding='max_length', truncation=True, max_length=128)
20 with torch.no_grad():
21 outputs = model(**inputs)
22 probs = torch.softmax(outputs.logits, dim=1)[0]
23 label = 'MALICIOUS' if probs[1] > probs[0] else 'BENIGN'
24 return label, max(probs).item()
25
26print(predict("http://paypa1-secure-login.com/verify"))