Views
No views yet
distilbert-base-uncased for binary classification of clickbait titles. It predicts whether a given title is clickbait (1) or not clickbait (0).| Metric | Score |
|---|---|
| Accuracy | 99.19% |
| Precision | 99.61% |
| Recall | 98.72% |
| F1 Score | 99.17% |
| Step | Training Loss | Validation Loss | Accuracy | Precision | Recall | F1 |
|---|---|---|---|---|---|---|
| 500 | 0.0623 | 0.0516 | 98.56% | 97.74% | 99.36% | 98.54% |
| 1000 | 0.0114 | 0.0412 | 99.11% | 99.26% | 98.91% | 99.09% |
| 1500 | 0.0133 | 0.0386 | 99.19% | 99.61% | 98.72% | 99.17% |
| 2000 | 0.0025 | 0.0511 | 98.95% | 98.45% | 99.43% | 98.94% |
1import torch
2import numpy as np
3from transformers import AutoTokenizer, AutoModelForSequenceClassification
4
5# Load model and tokenizer
6model = AutoModelForSequenceClassification.from_pretrained("path/to/model")
7tokenizer = AutoTokenizer.from_pretrained("path/to/model")
8
9# Prepare model
10device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
11model.to(device)
12model.eval()
13
14# Inference function
15def predict_clickbait(text):
16 with torch.no_grad():
17 inputs = tokenizer(text, return_tensors='pt', truncation=True,
18 padding=True, max_length=512)
19 inputs = {k: v.to(device) for k, v in inputs.items()}
20 outputs = model(**inputs)
21 probabilities = torch.nn.functional.softmax(outputs.logits, dim=-1).cpu().numpy()
22 predicted_class = np.argmax(probabilities, axis=1).item()
23
24 return {
25 'prediction': 'clickbait' if predicted_class == 1 else 'not clickbait',
26 'confidence': probabilities[0][predicted_class]
27 }
28
29# Example usage
30result = predict_clickbait("You Won't Believe What Happened Next!")
31print(result)1@misc{clickbait-distilbert-classifier,
2 author = {[Your Name]},
3 title = {DistilBERT Clickbait Title Classifier},
4 year = {2025},
5 publisher = {[Platform]},
6 note = {Fine-tuned on marksverdhei/clickbait_title_classification}
7}