1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
3
4# Load model and tokenizer
5model_name = "Arko007/fact-check1-v1"
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7model = AutoModelForSequenceClassification.from_pretrained(model_name)
8
9# Example prediction function
10def predict_fake_news(text):
11 inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512)
12 with torch.no_grad():
13 outputs = model(**inputs)
14 probabilities = torch.nn.functional.softmax(outputs.logits, dim=-1)
15 prediction = torch.argmax(probabilities, dim=-1).item()
16
17 labels = {0: "REAL", 1: "FAKE"}
18 confidence = probabilities[0][prediction].item()
19
20 return {
21 "prediction": labels[prediction],
22 "confidence": confidence,
23 "probabilities": {
24 "REAL": probabilities[0][0].item(),
25 "FAKE": probabilities[0][1].item()
26 }
27 }
28
29# Test the model
30text = "Breaking: Scientists discover new planet in our solar system!"
31result = predict_fake_news(text)
32print(f"Prediction: {result['prediction']} ({result['confidence']:.2%} confidence)")
1@misc{fake-news-deberta-2025,
2author = {Arko007},
3title = {Elite Fake News Detection with DeBERTa-v3-Large},
4year = {2025},
5publisher = {Hugging Face},
6url = {[https://huggingface.co/](https://huggingface.co/)Arko007/fact-check1-v1}
7}