Skip to content

Documentation

What is GRADIEND?

GRADIEND is a method for learning features within neural networks by training an encoder-decoder architecture on model gradients. With this library you can find where a language model encodes a feature (e.g. gender, race, religion) and rewrite the model to strengthen or weaken it—for example debias it—while keeping other behaviour.

GRADIEND overview

GRADIEND works by: 1. Training an encoder-decoder network on gradients computed from masked text predictions 2. Learning a single latent feature neuron that encodes the desired interpretation (e.g., gender bias) 3. Using the decoder to modify the base model's weights, enabling targeted feature manipulation

The method is described in detail in the paper: GRADIEND: Feature Learning within Neural Networks Exemplified through Biases (ICLR 2026, Drechsel & Herbold, 2025).

While GRADIEND is methodologically defined to work with any gradient-learned and weight-based model, this library currently documents and supports text prediction as the primary workflow. Preliminary TextClassification code exists, but it is experimental in this release and not recommended as the starting point for new users.

Example use cases (gradiend/examples on GitHub): - English pronouns — notebook; script - German gender–case - Sentiment - Multi-seed stability

Links: GitHub · PyPI · arXiv (main paper) · arXiv (German articles)


Get started


Tutorials

Step-by-step workflows, following the 5 steps of above's overview:

  1. Workflow Overview — Tutorial Overview.
  2. Feature Selection and Data Generation — Build training and neutral data from raw text (syncretism, spaCy, one filter per grammatical cell). Part 1 of the detailed workflow.
  3. GRADIEND Training — Experiment layout, pruning (pre/post), multi-seed, convergence plot, and training options in detail.
  4. Intra-Model Evaluation — Encoder analysis (are target classes seperated?) and decoder evaluation (determine parameters to update model's feature behavior under a language modeling constraint).
  5. Model Rewrite — Using decoder-selected settings to rewrite base-model weights in memory or on disk.
  6. Inter-Model Evaluation — Comparing multiple runs: top-k overlap and heatmap.

Guides

When you need to understand a topic or look up options:


Reference

  • Examples — All example scripts with short descriptions.
  • API referenceAuto-generated from docstrings; main classes and entry points.
  • FAQ — Troubleshooting and common pitfalls.
  • Citation — How to cite the paper and library.