{"id":24976760,"url":"https://github.com/libr-ai/fairlib","last_synced_at":"2025-12-14T00:03:32.239Z","repository":{"id":39793412,"uuid":"458974236","full_name":"Libr-AI/fairlib","owner":"Libr-AI","description":"A framework for assessing and improving classification fairness.","archived":false,"fork":false,"pushed_at":"2023-06-12T21:32:57.000Z","size":28213,"stargazers_count":33,"open_issues_count":3,"forks_count":8,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-04T20:17:46.621Z","etag":null,"topics":["deep-learning","fairness","machine-learning","pytorch"],"latest_commit_sha":null,"homepage":"https://hanxudong.github.io/fairlib/","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Libr-AI.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":"docs/supported_bias_mitigation_algorithms.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-14T01:05:25.000Z","updated_at":"2025-03-16T11:50:13.000Z","dependencies_parsed_at":"2024-11-02T04:19:41.792Z","dependency_job_id":"82cb9f26-8d2f-4742-bfed-ea787413fe59","html_url":"https://github.com/Libr-AI/fairlib","commit_stats":null,"previous_names":["hanxudong/fairlib"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Libr-AI%2Ffairlib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Libr-AI%2Ffairlib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Libr-AI%2Ffairlib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Libr-AI%2Ffairlib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Libr-AI","download_url":"https://codeload.github.com/Libr-AI/fairlib/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248414990,"owners_count":21099585,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deep-learning","fairness","machine-learning","pytorch"],"created_at":"2025-02-03T22:54:19.816Z","updated_at":"2025-12-14T00:03:32.210Z","avatar_url":"https://github.com/Libr-AI.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# *fairlib*\n\n\n[*fairlib*](https://github.com/HanXudong/fairlib) is a Python framework for assessing and improving fairness. Built-in algorithms can be applied to text inputs, structured inputs, and image inputs.  \n\nThe *fairlib* package includes metrics for fairness evaluation, [algorithms for bias mitigation](https://hanxudong.github.io/fairlib/supported_bias_mitigation_algorithms.html), and functions for analysis.\n\nFor those who want to start with *fairlib* now, you can try our [Colab Tutorial](https://colab.research.google.com/github/HanXudong/fairlib/blob/main/tutorial/fairlib_demo.ipynb), which provides a gentle introduction to the concepts and capabilities. \n[The tutorials and other notebooks](https://hanxudong.github.io/fairlib/tutorial_interactive_demos.html) offer a deeper introduction. The [complete API](https://hanxudong.github.io/fairlib) is also available.\n\n## Installation\n\n*fairlib* currently requires Python3.8+ and [Pytorch](https://pytorch.org) 1.10 or higher.\nDependencies of the core modules are listed in [`requirements.txt`](https://github.com/HanXudong/fairlib/blob/main/requirements.txt). \nWe *strongly* recommend using a [venv](https://docs.python.org/3/library/venv.html) or [conda](https://www.anaconda.com/) environment for installation.\n\n**Standard Installation**\n\nIf you do not need further modifications, you can install it with:\n\n```bash\n# Start a new virtual environment:\nconda create -n fairlib python=3.8\nconda activate fairlib\n\npip install fairlib\n```\n\n**Development Installation**\n\nTo set up a development environment, run the following commands to clone the repository and install\n*fairlib*:\n\n```bash\ngit clone https://github.com/HanXudong/fairlib.git ~/fairlib\ncd ~/fairlib\npython setup.py develop\n```\n\n**Benchmark Datasets**  \n\nPlease refer to [data/README.md](https://github.com/HanXudong/fairlib/blob/main/data/README.md) for a list of fairness benchmark datasets.\n\n## Usage\n\nThe full description of *fairlib* usages can be found in [*fairlib* cheat sheet](https://hanxudong.github.io/fairlib/tutorial_usage.html) and API reference. Here are the most basic examples.\n\n- *fairlib* can be run from the command line:\n  ```bash\n  python fairlib --exp_id EXP_NAME\n  ```\n\n- *fairlib* can be imported as a package\n  ```python\n  from fairlib.base_options import options\n  from src import networks\n\n  config_file = 'opt.yaml'\n  # Get options\n  state = options.get_state(conf_file=config_file)\n\n  # Init the model\n  model = networks.get_main_model(state)\n\n  # Training with debiasing\n  model.train_self()\n  ```\n\n## Model Selection and Fairness Evaluation\n\nBesides the classical loss- and performance-based model selection, we provide performance-fairness trade-off based model selection (see the paper below). \n\nPlease see [this tutorial](https://hanxudong.github.io/fairlib/tutorial_notebooks/tutorial_Moji_demo.html) for an example of loading training history, performing model selections based on different strategies, and creating basic plots.\nMoreover, [interactive plots](https://hanxudong.github.io/fairlib/tutorial_notebooks/tutorial_interactive_plots.html) are also supported, which can be used for analysis.\n\n## Known issues and limitations\n\nNone are known at this time.\n\n\n## Getting help\n\nIf you have any problem with our code or have some suggestions, including the future feature, feel free to contact \n\n- Xudong Han (xudongh1@student.unimelb.edu.au)\n\nor describe it in Issues.\n\n## Paper\n\n[fairlib: A Unified Framework for Assessing and Improving Classification Fairness](https://arxiv.org/abs/2205.01876)\n\nCite Us\n```\n@inproceedings{han-etal-2022-fairlib,\n    title = \"{F}air{L}ib: A Unified Framework for Assessing and Improving Fairness\",\n    author = \"Han, Xudong  and\n      Shen, Aili  and\n      Li, Yitong  and\n      Frermann, Lea  and\n      Baldwin, Timothy  and\n      Cohn, Trevor\",\n    booktitle = \"Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing: System Demonstrations\",\n    month = dec,\n    year = \"2022\",\n    address = \"Abu Dhabi, UAE\",\n    publisher = \"Association for Computational Linguistics\",\n    url = \"https://aclanthology.org/2022.emnlp-demos.7\",\n    pages = \"60--71\",\n    abstract = \"This paper presents FairLib, an open-source python library for assessing and improving model fairness. It provides a systematic framework for quickly accessing benchmark datasets, reproducing existing debiasing baseline models, developing new methods, evaluating models with different metrics, and visualizing their results.Its modularity and extensibility enable the framework to be used for diverse types of inputs, including natural language, images, and audio.We implement 14 debiasing methods, including pre-processing,at-training-time, and post-processing approaches. The built-in metrics cover the most commonly acknowledged fairness criteria and can be further generalized and customized for fairness evaluation.\",\n}\n\n```\n\n\n## Contributing\n\nWe 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.\n\n\n## License\n\nThis project is distributed under the terms of the [APACHE LICENSE, VERSION 2.0](https://www.apache.org/licenses/LICENSE-2.0).  The license applies to all files in the [GitHub repository](http://github.com/HanXudong/fairlib) hosting this file.\n\n## Acknowledgments\n\n* https://github.com/HanXudong/Decoupling_Adversarial_Training_for_Fair_NLP\n* https://github.com/HanXudong/Diverse_Adversaries_for_Mitigating_Bias_in_Training\n* https://github.com/SsnL/dataset-distillation\n* https://github.com/huggingface/torchMoji\n* https://github.com/mhucka/readmine\n* https://github.com/yanaiela/demog-text-removal\n* https://github.com/lrank/Robust_and_Privacy_preserving_Text_Representations\n* https://github.com/yuji-roh/fairbatch\n* https://github.com/shauli-ravfogel/nullspace_projection\n* https://github.com/AiliAili/contrastive_learning_fair_representations\n* https://github.com/AiliAili/Difference_Mean_Fair_Models\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibr-ai%2Ffairlib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flibr-ai%2Ffairlib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibr-ai%2Ffairlib/lists"}