Views
No views yet
mobilebert-uncased model for fake news detection. The model classifies news articles into two categories: Fake or Real based on their titles and content. This model is trained using the transformers library and leverages pre-trained embeddings from MobileBERT, fine-tuned on a custom fake news dataset.mobilebert-uncased)Fake or Real categories. It's suitable for applications where automated detection of misinformation or fake news is required.transformers, torch, datasetspip install transformers torch datasets nltk evaluatefrom transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
# Load the fine-tuned model
model_name = "iTzMiNOS/mobilebert-uncased-fake-news-detector"
model = AutoModelForSequenceClassification.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)
# Define device
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model.to(device)
# Example input text
text = "Breaking: The government announces new economic measures."
# Tokenize the input text
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True, max_length=512)
inputs = {key: value.to(device) for key, value in inputs.items()}
# Inference
with torch.no_grad():
logits = model(**inputs).logits
# Get predicted class (Fake = 1, Real = 0)
predicted_class = torch.argmax(logits, dim=-1).item()
print("Predicted Class:", "Fake" if predicted_class == 1 else "Real")