Skip to main content

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.

EMNLP 2026 Demos arXiv:2502.01406 Python 3.9+ License: Apache 2.0 Tests Documentation

Paper:


Try it in Google Colab: Quickstart · Sentiment · Compare features · Learn your own feature


Install

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

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

Citation

The Python package paper:

@inproceedings{drechsel2026gradiendpythonpackage,
    title = "The {GRADIEND} Python Package: An End-to-End System for Gradient-Based Feature Learning",
    author = "Drechsel, Jonathan  and
      Herbold, Steffen",
    editor = "Agrawal, Sweta  and
      Abad, Alberto",
    booktitle = "Proceedings of the 2026 Conference on Empirical Methods in Natural Language Processing: System Demonstrations",
    month = oct,
    year = "2026",
    address = "Budapest, Hungary",
    publisher = "Association for Computational Linguistics",
    url = "https://aclanthology.org/2026.emnlp-demos.18/",
    doi = "10.18653/2026.emnlp-demos.18",
    pages = "189--198",
    ISBN = "979-8-89176-461-3",
    abstract = "We present `gradiend{`}, an open-source Python package that operationalizes the GRADIEND method for learning feature directions from factual-counterfactual MLM and CLM gradients in language models. The package provides a unified workflow for feature-related data creation, training, evaluation, visualization, persistent model rewriting via controlled weight updates, and multi-feature comparison. We demonstrate `gradiend{`} through an English pronoun running example, a semantic sentiment use case that evaluates lexical generalization to held-out target words, and a large-scale feature comparison."
}

The original GRADIEND method paper:

@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 on GitHub.

Metadata

Release files for gradiend 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gradiend 0.3.0
File Size Uploaded Provenance Actions
gradiend-0.3.0.tar.gz 820.6 kB With provenance Details for gradiend-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gradiend 0.3.0
File Interpreter ABI Platform Actions
gradiend-0.3.0-py3-none-any.whl Python 3 none any Details for gradiend-0.3.0-py3-none-any.whl

Total release size: 1.4 MB

Release files / gradiend-0.3.0.tar.gz

Download URL gradiend-0.3.0.tar.gz
Size 820.6 kB
Tags Source
SHA-256 checksum
How to use checksums
0e97707cf7dc8872281dbd40a08a3c0f5f92465640877f09ef1c6403fe3ae541
BLAKE2b-256 checksum
How to use checksums
aff5b379e27954f06ed910d8d0c9c982b754e4f9db320cec0f9f891554fa7690
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Release files / gradiend-0.3.0-py3-none-any.whl

Download URL gradiend-0.3.0-py3-none-any.whl
Size 608.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f1a9b5b71ddc523e4f1116481b049dd764bbba916084be9152c6fe0581ecc632
BLAKE2b-256 checksum
How to use checksums
ae3ae605a117a05382031d33bd67338f07866cc784347cc0895156c0219125df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Security for gradiend 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for gradiend-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page