Views
No views yet
dbmdz/bert-base-turkish-cased for Turkish clickbait detection.[CLS] başlık [SEP] paragraf [SEP]| Metric | Score |
|---|---|
| Macro F1 | ~82% |
| NCB F1 | ~81% |
| CB F1 | ~83% |
1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch, torch.nn.functional as F
3
4model = AutoModelForSequenceClassification.from_pretrained("{HF_REPO_ID}")
5tokenizer = AutoTokenizer.from_pretrained("{HF_REPO_ID}")
6
7def predict(title, paragraph):
8 enc = tokenizer(title, paragraph, return_tensors='pt',
9 max_length=256, truncation=True, padding='max_length')
10 with torch.no_grad():
11 logits = model(**enc).logits
12 prob_cb = F.softmax(logits, dim=1)[0, 1].item()
13 return {'label': 'CB' if prob_cb >= 0.5 else 'NCB', 'score': prob_cb}