DistilBERT Political Bias Detector
This is a fine-tuned DistilBERT model designed to classify English text (such as news articles, opinion pieces, or social media posts) into three categories of political leaning: Left, Center, or Right.
The model was trained with class weights and label smoothing to ensure highly calibrated, reliable probability scores across all three political spectrums.
How to Use
You can easily use this model in your own applications using the Hugging Face pipeline for text classification.
Installation
First, ensure you have the transformers library installed:
pip install transformers torch
from transformers import pipeline
# Initialize the bias classifier
# Note: Replace 'your_username/your_model_name' with your actual repository path
bias_classifier = pipeline(
"text-classification",
model="your_username/your_model_name",
return_all_scores=True
)
# Test it with a sample sentence
text = "The new tax policy heavily favors corporate interests while ignoring the working class."
predictions = bias_classifier(text)
print(predictions)
This model is highly suitable for:
Media Analysis: Automatically auditing news sources or aggregators to analyze the spread of left/right-leaning content.
Content Moderation/Tagging: Tagging articles or forum posts in political discussion boards for balanced reading feeds.
Academic Research: Tracking political polarization trends over time in digital media.
Browser Extensions: Building tools that notify readers of potential bias in the article they are currently reading.
Limitations & Bias:
Subjectivity of "Center": The line between "Center" and slight "Left/Right" is highly subjective. The model may occasionally struggle with nuanced or purely factual reporting, misclassifying it if it contains politically charged keywords.
Context Length: The model uses DistilBERT, which truncates text after 512 tokens (roughly 350-400 words). For very long articles, it only analyzes the text passed to it (we recommend passing the first 200 and last 200 words for long-form articles).
Language: The model is trained exclusively on English text and US-centric political datasets. It may not accurately reflect political spectrums in other countries.
- Downloads last month
- -
Space using detre/bias_detection_model 1
Evaluation results
- Accuracy on Political Bias Datasetself-reported0.850
- AUC (Left) on Political Bias Datasetself-reported0.950
- AUC (Center) on Political Bias Datasetself-reported0.960
- AUC (Right) on Political Bias Datasetself-reported0.970