πŸ€– Gender Bias Detection Model (BERT-based)

This model is a fine-tuned version of bert-base-uncased designed to detect gender bias in text data. It was trained on a combination of WinoBias and Bias in Bios datasets for binary classification:

  • label=0: Stereotypical/Male Bias
  • label=1: Anti-stereotypical/Female Bias

πŸ—‚οΈ Datasets Used


πŸ“Š Model Details

  • Base model: bert-base-uncased
  • Layers: Pretrained BERT + classification head
  • Loss: Weighted Cross-Entropy (to handle class imbalance)
  • Evaluation metrics: Accuracy, F1 Score
  • Optimizations: FP16 (mixed precision), checkpointing, batch size = 32

🏁 How to Use

from transformers import BertForSequenceClassification, BertTokenizer
import torch

model = BertForSequenceClassification.from_pretrained("AymanKhan/final-gender-bias-model")
tokenizer = BertTokenizer.from_pretrained("AymanKhan/final-gender-bias-model")

text = "The nurse asked the doctor if she could leave early."

inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
outputs = model(**inputs)
predicted_label = torch.argmax(outputs.logits, dim=1).item()

print("Prediction:", "Stereotype" if predicted_label == 0 else "Anti-stereotype")
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support