Downloads · 30 days
5
10% of all-time downloads
Arjun24420/FakeNews-BERT-base-cased
FakeNews-BERT-base-cased is a text classification model from Arjun24420. Use it when you need a label for a piece of text. It is set up for transformers.
This model is a Binary classification model fine-tuned on the Fake and Real News Dataset using the BERT (bert-base-cased) architecture. The primary task is to classify news articles into different categories, making i…
Downloads · 30 days
5
10% of all-time downloads
All-time downloads
49
Public
Parameters
108M
433 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors433 MB · 100%
From the Hugging Face model README
This model is a Binary classification model fine-tuned on the Fake and Real News Dataset using the BERT (bert-base-cased) architecture. The primary task is to classify news articles into different categories, making it suitable for fake news detection. BERT (Bidirectional Encoder Representations from Transformers) is a transformer-based model known for its effectiveness in natural language processing tasks.
It takes the title of the news article as well as the entire article itself. The model then classifies it into Reliable or Unreliable news.
text_input = "<title>" + headline + "<content>" + article + "<end>"
Bias: The model may inherit biases present in the training data, and it's important to be aware of potential biases in the predictions.
from transformers import AutoTokenizer, AutoModelForSequenceClassification
# Load model directly
tokenizer = AutoTokenizer.from_pretrained(
"Arjun24420/FakeNews-BERT-base-cased")
model = AutoModelForSequenceClassification.from_pretrained(
"Arjun24420/FakeNews-BERT-base-cased")
def predict(text):
# Tokenize the input text and move tensors to the GPU if available
inputs = tokenizer(text, padding=True, truncation=True,
max_length=512, return_tensors="pt")
# Get model output (logits)
outputs = model(**inputs)
probs = outputs.logits.softmax(1)
# Get the probabilities for each class
class_probabilities = {class_mapping[i]: probs[0, i].item()
for i in range(probs.shape[1])}
return class_probabilities
text = "<title>" + headline + "<content>" + article + "<end>"
predict(text)
# Define class labels mapping
class_mapping = {
1: 'Reliable',
0: 'Unreliable',
}