Metadata-Version: 2.4
Name: gradiend
Version: 0.2.1
Summary: GRADIEND: Gradient-based Targeted Feature Learning within Neural Networks
Author-email: Jonathan Drechsel <jonathan.drechsel@uni-passau.de>
License: Apache-2.0
Project-URL: Homepage, https://github.com/aieng-lab/gradiend
Project-URL: Documentation, https://aieng-lab.github.io/gradiend/
Project-URL: Repository, https://github.com/aieng-lab/gradiend
Project-URL: Bug Tracker, https://github.com/aieng-lab/gradiend/issues
Keywords: machine learning,neural networks,feature learning,interpretability
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: torch>=2.0.0
Requires-Dist: transformers<6.0.0,>=4.30.0
Requires-Dist: numpy>=1.20.0
Requires-Dist: pandas>=1.3.0
Requires-Dist: tqdm>=4.60.0
Provides-Extra: recommended
Requires-Dist: accelerate>=0.26.0; extra == "recommended"
Requires-Dist: safetensors>=0.3.0; extra == "recommended"
Requires-Dist: sentencepiece>=0.1.99; extra == "recommended"
Requires-Dist: datasets>=3.0.2; extra == "recommended"
Requires-Dist: spacy<3.8.0,>=3.5.0; python_version < "3.10" and extra == "recommended"
Requires-Dist: spacy>=3.5.0; python_version >= "3.10" and extra == "recommended"
Requires-Dist: pyarrow>=14.0.0; extra == "recommended"
Requires-Dist: pyahocorasick>=2.0.0; extra == "recommended"
Requires-Dist: matplotlib>=3.5.0; extra == "recommended"
Requires-Dist: seaborn>=0.12.0; extra == "recommended"
Requires-Dist: plotly>=5.0.0; extra == "recommended"
Requires-Dist: venn>=0.1.0; extra == "recommended"
Requires-Dist: matplotlib_venn>=0.11.7; extra == "recommended"
Requires-Dist: adjustText>=0.7.3; extra == "recommended"
Provides-Extra: data
Requires-Dist: datasets>=3.0.2; extra == "data"
Requires-Dist: spacy<3.8.0,>=3.5.0; python_version < "3.10" and extra == "data"
Requires-Dist: spacy>=3.5.0; python_version >= "3.10" and extra == "data"
Requires-Dist: pyarrow>=14.0.0; extra == "data"
Requires-Dist: pyahocorasick>=2.0.0; extra == "data"
Provides-Extra: plot
Requires-Dist: matplotlib>=3.5.0; extra == "plot"
Requires-Dist: seaborn>=0.12.0; extra == "plot"
Requires-Dist: plotly>=5.0.0; extra == "plot"
Requires-Dist: venn>=0.1.0; extra == "plot"
Requires-Dist: matplotlib_venn>=0.11.7; extra == "plot"
Requires-Dist: adjustText>=0.7.3; extra == "plot"
Provides-Extra: dev
Requires-Dist: mkdocs-material>=9.0.0; extra == "dev"
Requires-Dist: mkdocstrings[python]>=0.24.0; extra == "dev"
Requires-Dist: pre-commit>=3.0.0; extra == "dev"
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
Dynamic: license-file

# GRADIEND

**Gradient-based targeted feature learning within neural networks.** Learn where a language model encodes a feature (e.g. gender, race) and rewrite the model to strengthen or weaken it—for example debias it—while keeping other behaviour unchanged.

[![arXiv:2602.23993](https://img.shields.io/badge/arXiv-2602.23993-blue.svg)](https://arxiv.org/abs/2602.23993)
[![arXiv:2502.01406](https://img.shields.io/badge/arXiv-2502.01406-blue.svg)](https://arxiv.org/abs/2502.01406)
[![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
[![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Tests](https://github.com/aieng-lab/gradiend/actions/workflows/tests.yml/badge.svg)](https://github.com/aieng-lab/gradiend/actions/workflows/tests.yml)
[![Documentation](https://img.shields.io/badge/docs-github.io-blue.svg)](https://aieng-lab.github.io/gradiend/)

Paper: 

- [GRADIEND: Feature Learning within Neural Networks Exemplified through Biases](https://arxiv.org/abs/2502.01406) 
- [The GRADIEND Python Package: An End-to-End System for Gradient-Based Feature Learning](https://arxiv.org/abs/2602.23993)

---

## Install

```bash
pip install gradiend
```

Optional extras (install one or combine with e.g. `gradiend[data,plot]`):

| Tag | Command | Includes                                     |
|-----|---------|----------------------------------------------|
| **recommended** | `pip install gradiend[recommended]` | full data generation, training, and plotting |
| **data** | `pip install gradiend[data]` | for advanced data generation and import |
| **plot** | `pip install gradiend[plot]` | for plotting support |                                                                                   |
| **dev** | `pip install gradiend[dev]` | for building docs and running tests |

---

## Links

| | |
|---|---|
| **Documentation** | [aieng-lab.github.io/gradiend](https://aieng-lab.github.io/gradiend/) |
| **Source & issues** | [github.com/aieng-lab/gradiend](https://github.com/aieng-lab/gradiend) |
| **Example scripts & notebooks** | [gradiend/examples](https://github.com/aieng-lab/gradiend/tree/main/gradiend/examples) — start_workflow, train_english_pronouns, gender_de, gender_en, train_race_religion, etc. |
| **Datasets (Hugging Face)** | [de-gender-case-articles](https://huggingface.co/datasets/aieng-lab/de-gender-case-articles), [gradiend_race_data](https://huggingface.co/datasets/aieng-lab/gradiend_race_data), [gradiend_religion_data](https://huggingface.co/datasets/aieng-lab/gradiend_religion_data), [biasneutral](https://huggingface.co/datasets/aieng-lab/biasneutral), [geneutral](https://huggingface.co/datasets/aieng-lab/geneutral) |
| **Pre-trained GRADIEND models** | [bert-base-cased-gradiend-gender-debiased](https://huggingface.co/aieng-lab/bert-base-cased-gradiend-gender-debiased), [gpt2-gradiend-gender-debiased](https://huggingface.co/aieng-lab/gpt2-gradiend-gender-debiased), [Llama-3.2-3B-gradiend-gender-debiased](https://huggingface.co/aieng-lab/Llama-3.2-3B-gradiend-gender-debiased) |

---

## Citation

The Python package paper:
```bibtex
@misc{drechsel2026gradiendpythonpackage,
      title={The {GRADIEND} Python Package: An End-to-End System for Gradient-Based Feature Learning}, 
      author={Jonathan Drechsel and Steffen Herbold},
      year={2026},
      eprint={2602.23993},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/2602.23993}, 
}
```

The original GRADIEND method paper:
```bibtex
@misc{drechsel2025gradiend,
  title={{GRADIEND}: Feature Learning within Neural Networks Exemplified through Biases},
  author={Jonathan Drechsel and Steffen Herbold},
  year={2025},
  eprint={2502.01406},
  archivePrefix={arXiv},
  primaryClass={cs.LG},
  url={https://arxiv.org/abs/2502.01406},
}
```

---

## License

Apache 2.0. See [LICENSE](https://github.com/aieng-lab/gradiend/blob/main/LICENSE) on GitHub.
