π€ 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 Biaslabel=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")
Inference Providers
NEW
This model isn't deployed by any Inference Provider.
π
Ask for provider support