Package: fairlib
fairlibfairlibis a Python framework for assessing and improving fairness. Built-in algorithms can be applied to text inputs, structured inputs, and image inputs.Thefairlibpackage includes metrics for fairness evaluation,algorithms for bias mitigation, and functions for analysis.For those who want to start withfairlibnow, you can try ourColab Tutorial, which provides a gentle introduction to the concepts and capabilities.The tutorials and other notebooksoffer a deeper introduction. Thecomplete APIis also available.Installationfairlibcurrently requires Python3.7+ andPytorch1.10 or higher.
Dependencies of the core modules are listed inrequirements.txt.
Westronglyrecommend using avenvorcondaenvironment for installation.Standard InstallationIf you do not need further modifications, you can install it with:# Start a new virtual environment:condacreate-nfairlibpython=3.7
condaactivatefairlib

pipinstallfairlibDevelopment InstallationTo set up a development environment, run the following commands to clone the repository and installfairlib:gitclonehttps://github.com/HanXudong/fairlib.git~/fairlibcd~/fairlib
pythonsetup.pydevelopBenchmark DatasetsPlease refer todata/README.mdfor a list of fairness benchmark datasets.UsageThe full description offairlibusages can be found infairlibcheat sheetand API reference. Here are the most basic examples.fairlibcan be run from the command line:pythonfairlib--exp_idEXP_NAMEfairlibcan be imported as a packagefromfairlib.base_optionsimportoptionsfromsrcimportnetworksconfig_file='opt.yaml'# Get optionsstate=options.get_state(conf_file=config_file)# Init the modelmodel=networks.get_main_model(state)# Training with debiasingmodel.train_self()Model Selection and Fairness EvaluationBesides the classical loss- and performance-based model selection, we provide performance-fairness trade-off based model selection (see the paper below).Please seethis tutorialfor an example of loading training history, performing model selections based on different strategies, and creating basic plots.
Moreover,interactive plotsare also supported, which can be used for analysis.Known issues and limitationsNone are known at this time.Getting helpIf you have any problem with our code or have some suggestions, including the future feature, feel free to contactXudong Han (xudongh1@student.unimelb.edu.au)or describe it in Issues.Paperfairlib: A Unified Framework for Assessing and Improving Classification FairnessCite Us@article{han2022fairlib,
  title={fairlib: A Unified Framework for Assessing and Improving Classification Fairness},
  author={Han, Xudong and Shen, Aili and Li, Yitong and Frermann, Lea and Baldwin, Timothy and Cohn, Trevor},
  journal={arXiv preprint arXiv:2205.01876},
  year={2022}
}ContributingWe appreciate all contributions. If you are planning to contribute back bug-fixes, please do so without any further discussion. If you plan to contribute new features, utility functions or extensions, please first open an issue and discuss the feature with us.LicenseThis project is distributed under the terms of theAPACHE LICENSE, VERSION 2.0.  The license applies to all files in theGitHub repositoryhosting this file.Acknowledgmentshttps://github.com/HanXudong/Decoupling_Adversarial_Training_for_Fair_NLPhttps://github.com/HanXudong/Diverse_Adversaries_for_Mitigating_Bias_in_Traininghttps://github.com/SsnL/dataset-distillationhttps://github.com/huggingface/torchMojihttps://github.com/mhucka/readminehttps://github.com/yanaiela/demog-text-removalhttps://github.com/lrank/Robust_and_Privacy_preserving_Text_Representationshttps://github.com/yuji-roh/fairbatchhttps://github.com/shauli-ravfogel/nullspace_projectionhttps://github.com/AiliAili/contrastive_learning_fair_representationshttps://github.com/AiliAili/Difference_Mean_Fair_Models