Adversarial Removal of Demographic Attributes from Text Data

Yanai Elazar, Yoav Goldberg

TL;DR

Don't blindly trust adversarial training to sanitize your text data. This paper demonstrates that even when an adversarial component successfully drives demographic attribute prediction down to chance level during training, a post-hoc "attacker" network can still easily extract sensitive traits like race, gender, and age from the learned representations.

What Problem Does This Paper Address?

Text data naturally contains subtle cues that reveal demographic information about its author, such as age, gender, or dialect. When deep learning models process raw text for downstream applications—like credit scoring, insurance risk profiling, or hiring decisions—they risk implicitly conditioning on these protected attributes, perpetuating systemic biases.

Adversarial training has emerged as a popular defense mechanism to strip out this unwanted information. The standard approach trains an encoder to optimize for a main task while simultaneously trying to fool an internal "adversary" classifier trying to guess the protected demographic attribute. The authors investigate a critical flaw in this workflow: does adversarial training genuinely erase demographic attributes, or does it merely hide them from the active training adversary?

Methods

The authors evaluate a standard adversarial setup using a Gradient Reversal Layer (GRL). The network consists of an encoder (a one-layer LSTM) that creates a text representation, a main task classifier, and an adversarial classifier trained to predict the protected attribute.

To rigorously test if the information is truly gone, the authors introduce a post-hoc Attacker Network. After adversarial training is complete, they freeze the encoder, extract the text representations, and train this independent attacker solely to predict the protected demographic attributes.

They also explore several techniques to strengthen the adversary against this leakage:

  • Capacity: Increasing the hidden dimension size of the adversarial network.
  • Weighting: Tuning the loss weight parameter ($\lambda$) to penalize demographic leakage more heavily.
  • Ensembles: Introducing multiple adversaries with different random initializations to focus on different aspects of the text representation.

Datasets

  • DIAL Corpus: A massive dataset of tweets containing predicted race annotations (African-American English vs. Standard American English). It was used for binary sentiment prediction and tweet-mention prediction.
  • PAN16 Dataset: Twitter data manually annotated for age (18–34 vs. 35+) and gender (Male vs. Female), used for tweet-mention prediction.
  • DeepMoji: A popular out-of-the-box encoder trained on 1.2 billion tweets for emotion detection, utilized to demonstrate demographic leakage in real-world pretrained models.

Key Insights and Ideas

  • The Illusion of Guarding: During training, the adversary's accuracy drops to 50% (pure chance), giving a false sense of security that the demographic data has been successfully scrubbed. However, this is a mathematical illusion; the information remains encoded in a non-linear fashion that a fresh, post-hoc attacker can easily exploit.
The training adversary drops to chance level, but the information remains recoverable by an attacker.
  • RNN vs. Embeddings: By fusing "leaky" and "guarded" modules, the authors discovered that the sequential processing of the RNN is primarily responsible for leaking demographic data, rather than the static word embedding matrix.
  • The Rare Word Problem: Rare words strongly associated with a specific demographic group don't receive enough gradient updates during adversarial training, allowing them to retain their predictive demographic signals.

Key Results

  • Baseline Leakage: Without any adversarial defense, standard text classifiers leak significant demographic data (e.g., 83.9% accuracy for direct race prediction on DIAL).
  • The Attacker's Success: Even when adversarial training successfully forces the training adversary down to ~50% accuracy, the post-hoc attacker achieves 56.0% accuracy on the Sentiment/Race task and 63.1% on the Mention/Race task.
  • Mitigation Limits: Strengthening the adversary via ensembles or increased capacity reduces leakage slightly but never completely eliminates it. For instance, an ensemble of 5 adversaries brought the attacker's accuracy down to 54.8% on Sentiment/Race, but at the cost of training stability.

Limitations and Future Work

The primary limitation highlighted by the authors is that none of the attempted mitigations fully succeeded in removing all demographic information. Furthermore, increasing adversarial constraints (like higher $\lambda$ weights or larger ensembles) frequently caused severe training instability, sometimes preventing the main task from learning at all.

The authors conclude with a strong cautionary warning: adversarial removal should not be blindly trusted for fairness or invariant representations. They call for future research into more robust verification methods and alternative sanitization techniques before these systems are deployed in high-stakes real-world scenarios.

Summary updated

Abstract

Recent advances in Representation Learning and Adversarial Training seem to succeed in removing unwanted features from the learned representation. We show that demographic information of authors is encoded in -- and can be recovered from -- the intermediate representations learned by text-based neural classifiers. The implication is that decisions of classifiers trained on textual data are not agnostic to -- and likely condition on -- demographic attributes. When attempting to remove such demographic information using adversarial training, we find that while the adversarial component achieves chance-level development-set accuracy during training, a post-hoc classifier, trained on the encoded sentences from the first part, still manages to reach substantially higher classification accuracies on the same data. This behavior is consistent across several tasks, demographic properties and datasets. We explore several techniques to improve the effectiveness of the adversarial component. Our main conclusion is a cautionary one: do not rely on the adversarial training to achieve invariant representation to sensitive features.
BibTeX
@inproceedings{elazar2018adversarial,
  author = {Yanai Elazar and Yoav Goldberg},
  title = {{Adversarial Removal of Demographic Attributes from Text Data}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2018},
  doi = {10.18653/v1/d18-1002},
}
Figure