Downloads · 30 days
19
11% of all-time downloads
Amirmerfan/tinybert-uncased-fake-news-detector
tinybert-uncased-fake-news-detector is a text classification model from Amirmerfan. Use it when you need a label for a piece of text. It is set up for transformers. The card lists the license as mit.
This model is a fine-tuned version of the TinyBERT 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…
Downloads · 30 days
19
11% of all-time downloads
All-time downloads
178
Public
Parameters
14.4M
57.4 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors57.4 MB · 98%
From the Hugging Face model README
This model is a fine-tuned version of the TinyBERT 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 TinyBERT, fine-tuned on a custom fake news dataset.
tinybert_general_4l_312d)This model can be used to classify news articles into Fake or Real categories. It's suitable for applications where automated detection of misinformation or fake news is required.
transformers, torch, datasetsTo use this model, you'll need to install the following dependencies:
pip install transformers torch datasets nltk evaluate
To use the model for inference, you can load it directly from the Hugging Face Model Hub:
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
# Load the fine-tuned model
model_name = "iTzMiNOS/tinybert-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")
This model provides a solid base for detecting fake news articles based on their titles and content. It can be further fine-tuned or retrained for domain-specific tasks if needed.