Text Classification
Transformers
PyTorch
roberta
Inference Endpoints
Edit model card

You need to agree to share your contact information to access this model

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Log in or Sign Up to review the conditions and access this model content.

from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline

# Load model and tokenizer
tokenizer = AutoTokenizer.from_pretrained("newsmediabias/fake-news-classifier-elections")
model = AutoModelForSequenceClassification.from_pretrained("newsmediabias/fake-news-classifier-elections")

# Initialize the pipeline for sequence classification with the model and tokenizer
fake_news_classifier = pipeline(
    "text-classification",
    model=model,
    tokenizer=tokenizer
)

# Define label mapping based on the model's training
label_mapping = {
    "LABEL_0": "REAL",
    "LABEL_1": "FAKE"
}

# Example text to classify
example_text = "The election was rigged and full of fraud."

# Perform inference
predictions = fake_news_classifier(example_text)
predicted_class = label_mapping[predictions[0]['label']]
confidence_score = predictions[0]['score'] * 100

# Output the results
print(f"Predicted Class: {predicted_class}")
print(f"Confidence Score: {confidence_score:.2f}%")
Downloads last month
0

Datasets used to train newsmediabias/FakeWatch