--- 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.