UnBIAS Classification BERT Model

Model Description

This model is trained to classify news articles or statements into categories of bias. The main goal is to determine whether a given text is biased or neutral.

Intended Use

The primary use case for this model is for media analysts, news consumers, or researchers who want to understand the bias in a particular article or statement.

Inputs

The model expects raw text (in English) that you want to classify. The text can be a full article, a paragraph, or even a single sentence.

Outputs

The model classifies each input into one of the three categories:

Model Training and Evaluation

The model was trained on a proprietary dataset containing labeled examples of biased and neutral statements/articles.

How to Use

You can use this model with the Hugging Face transformers library. Here's a quick code example:

from transformers import AutoTokenizer, AutoModelForSequenceClassification

# Load tokenizer and model
tokenizer = AutoTokenizer.from_pretrained("newsmediabias/UnBIAS-classification-bert")
model = AutoModelForSequenceClassification.from_pretrained("newsmediabias/UnBIAS-classification-bert")

# Function for batch inference
def classify_news_bias_batch(texts):
    # Tokenize input texts
    inputs = tokenizer(texts, return_tensors="pt", truncation=True, max_length=512, padding='max_length')

    # Get model's predictions
    with torch.no_grad():
        outputs = model(**inputs)
        logits = outputs.logits

    # Find the class with the maximum logit value for each text and map to descriptive label from config
    predicted_class_idxs = torch.argmax(logits, dim=1).tolist()
    descriptive_labels = [model.config.id2label[idx] for idx in predicted_class_idxs]

    return descriptive_labels

# Test with a batch of examples
texts_batch = [
    "The government's policies have led to a stable economy and prosperity.",
    "Unemployment has skyrocketed, leading to widespread discontent among the masses.",
    "The city council announced new regulations to curb pollution.",
    "Corporate greed continues to destroy our environment without any checks.",
    "Economic indicators suggest a mild recession might be on the horizon.",
    "Politicians from both sides are to blame for the current crisis."
]

predicted_biases = classify_news_bias_batch(texts_batch)
for text, bias in zip(texts_batch, predicted_biases):
    print(f"Text: {text}\nBias: {bias}\n{'-'*80}")

Limitations

License

This model is distributed under [MIT License].