5. Tutorials¶
This section provides interactive tutorials demonstrating how to use FairLangProc for bias detection and mitigation in NLP models.
Tip
All tutorials are available as Jupyter notebooks. You can run them locally by cloning the repository or access them on Google Colab.
git clone https://github.com/arturo-perez-peralta/FairLangProc
Then navigate to the notebooks/ directory and open the notebooks in Jupyter.
5.1. Datasets¶
Demo Datasets - Open on GitHub
Learn how to load and explore bias benchmark datasets.
Load BBQ, StereoSet, BOLD, and other datasets
Explore dataset structure and attributes
5.2. Metrics¶
Demo Metrics - Open on GitHub
Measure bias using various fairness metrics.
WEAT for embedding-level bias
LPBS, CBS, CPS, AUL for probability-level bias
DR, ST, HONEST for generated text bias
5.3. Bias Mitigation¶
Demo Debiasing - Open on GitHub
Apply debiasing algorithms to reduce model bias.
Pre-processing with CDA, BLIND and projection-based debiasing.
In-procesing with ADELE and regularizers.
Intra-processing with MoDDiffy and EAT scaling.
5.4. End-to-End Workflow¶
Demo Processors - Open on GitHub
Use fairness processor to debiase LLMs in the GLUE tasks.
Use WEAT to measure bias.
Use the different processors to mitigate embedding-level bias.
Measure the impact on the performance metrics of the GLUE datasets.
5.5. Notebook Index¶
Notebook |
Description |
|---|---|
Load and explore bias benchmark datasets |
|
Measure bias with WEAT, LPBS, CBS, HONEST, etc. |
|
Apply debiasing algorithms (CDA, Projection, ADELE) |
|
Use in-processing and intra-processing bias mitigators |
5.6. Requirements¶
To run the notebooks locally, you need to install FairLangProc and download the datasets:
pip install FairLangProc
Note
Some notebooks require significant computational resources (GPU recommended). For GPU acceleration, ensure CUDA is installed and configured.
# Verify CUDA availability
python -c "import torch; print(f'CUDA available: {torch.cuda.is_available()}')"