A newer version of the Gradio SDK is available:
5.27.0
title: Headlne
emoji: π₯
colorFrom: indigo
colorTo: pink
sdk: gradio
sdk_version: 5.23.1
app_file: app.py
pinned: false
Bias Bin: Bias Detection and Mitigation in Language Models
Bias Bin is an interactive Gradio-based web application for detecting and mitigating gender bias in narrative text. It uses a fine-tuned BERT model and counterfactual data augmentation techniques to highlight and analyze bias in NLP outputs.
π§ Project Overview
This tool allows users to: β’ Detect gender bias in input text using a BERT-based classification model. β’ Explore counterfactual predictions by swapping gendered terms. β’ Visualize bias scores to understand model behavior. β’ Demonstrate bias mitigation through gender-swapped text examples.
This project was developed as part of a university coursework in Deep Learning & Generative AI.
π Repository Contents β’ app.py β Main Python file to launch the Gradio web app. β’ Evaluation&Results.ipynb β Notebook with experiments, model evaluations, and visualizations. β’ fine_tuned_model.zip β Zip file containing the fine-tuned BERT model (must be extracted). β’ requirements.txt β List of Python dependencies.
βοΈ Setup Instructions 1. Clone the Repository
git clone https://huggingface.co/spaces/aryn25/bias.bin cd bias.bin
2. Install Dependencies
pip install -r requirements.txt
3. Extract the Model
Unzip the fine_tuned_model.zip file and place the extracted folder in the project root. 4. Run the App
python app.py
5. Open in Browser
Visit the Gradio URL printed in the terminal
π Methodology β’ Model: Fine-tuned BERT classifier trained on gender-labeled narrative datasets. β’ Bias Detection: Uses counterfactual data augmentation by swapping gendered words (e.g., βheβ β βsheβ). β’ Metrics: Bias scores are computed based on prediction discrepancies between original and counterfactual samples.
π References
This project is built using foundational and peer-reviewed research on: β’ BERT and Transformer models β’ Gender bias in NLP β’ Counterfactual data augmentation β’ Bias mitigation techniques
Full citation list available in the project report.
π Authors
Created by Aryan N. Salge and team as part of the Deep Learning & Generative AI coursework at the National College of Ireland.
π License
This project is for educational and research purposes. Please cite appropriately if you use or adapt the work.