Views
No views yet
sentence-transformers/all-mpnet-base-v2 base model, which is well-suited for text classification tasks.en)transformers library to classify text into clickbait or not clickbait.1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2
3# Load tokenizer and model
4model_name = "Milan97/ClickbaitDetectionModel"
5tokenizer = AutoTokenizer.from_pretrained(model_name)
6model = AutoModelForSequenceClassification.from_pretrained(model_name)
7
8# Input text
9text = "You won’t believe what happened next!"
10
11# Tokenize and perform inference
12inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
13outputs = model(**inputs)
14
15# Get predicted label and confidence
16logits = outputs.logits
17predicted_class = logits.argmax(dim=1).item()
18confidence = logits.softmax(dim=1).max().item()
19
20# Label mapping
21labels = {0: "Not Clickbait", 1: "Clickbait"}
22
23print(f"Text: {text}")
24print(f"Prediction: {labels[predicted_class]} (Confidence: {confidence:.2f})")