Skip to main content
QUICK REVIEW

[Paper Review] Polyjuice: Generating Counterfactuals for Explaining, Evaluating, and Improving Models

Tongshuang Wu, Marco Túlio Ribeiro|arXiv (Cornell University)|Jan 1, 2021
Topic ModelingComputer Science76 references22 citations
TL;DR

Polyjuice is a fine-tuned GPT-2 model that generates diverse, controllable counterfactuals for NLP models by learning from paired sentence datasets. It enables application-agnostic counterfactual generation with control codes for perturbation type and location, reducing annotation effort by ~70% in data augmentation and improving model evaluation, explanation, and error analysis across three tasks.

ABSTRACT

While counterfactual examples are useful for analysis and training of NLP models, current generation methods either rely on manual labor to create very few counterfactuals, or only instantiate limited types of perturbations such as paraphrases or word substitutions. We present Polyjuice, a general-purpose counterfactual generator that allows for control over perturbation types and locations, trained by finetuning GPT-2 on multiple datasets of paired sentences. We show that Polyjuice produces diverse sets of realistic counterfactuals, which in turn are useful in various distinct applications: improving training and evaluation on three different tasks (with around 70% less annotation effort than manual generation), augmenting state-of-the-art explanation techniques, and supporting systematic counterfactual error analysis by revealing behaviors easily missed by human experts.

Motivation & Objective

  • Address the high cost and inconsistency of manual counterfactual generation in NLP by automating the process with a general-purpose generator.
  • Overcome limitations of task-specific counterfactual generators that focus only on prediction-changing or label-altering perturbations.
  • Enable broad applicability of counterfactuals across multiple NLP tasks by decoupling generation from downstream application selection.
  • Support human-in-the-loop workflows by generating high-quality, diverse counterfactuals that reduce manual labeling burden.
  • Facilitate systematic model error analysis by exposing behaviors missed by human experts and standard explanation methods.

Proposed method

  • Fine-tune GPT-2 on multiple paired datasets of original and counterfactual sentences to learn conditional generation of diverse counterfactuals.
  • Introduce control codes (e.g., negation, deletion) and fill-in-the-blank templates to specify perturbation type and location in the input.
  • Frame counterfactual generation as conditional text generation, conditioning on both the input sentence and control codes.
  • Use simple, task-specific selection heuristics to extract relevant counterfactuals from the generated pool for downstream applications.
  • Leverage the model’s ability to generate fluent, diverse, and semantically close counterfactuals without relying on off-the-shelf language models.
  • Apply the generator in semi-automatic workflows where humans label or select counterfactuals rather than creating them from scratch.

Experimental results

Research questions

  • RQ1Can a single, general-purpose counterfactual generator reduce annotation effort in data augmentation and evaluation while maintaining or improving model performance?
  • RQ2To what extent can controllable, application-agnostic counterfactual generation improve model explanation beyond existing attribution-based methods?
  • RQ3How effective is Polyjuice in revealing systematic model behaviors and errors that are missed by human experts or standard evaluation protocols?
  • RQ4Can the same set of generated counterfactuals support multiple downstream tasks, including training, evaluation, explanation, and error analysis?
  • RQ5What are the limitations of the current approach in terms of coverage, bias, and effectiveness, especially when perturbations are subtle or context-sensitive?

Key findings

  • Polyjuice reduces annotation effort by approximately 70% in data augmentation and contrast set generation compared to manual creation.
  • The model generates fluent, diverse, and semantically close counterfactuals, with control mechanisms retrieving perturbations that are unlikely to be sampled from standard language models.
  • Polyjuice-generated counterfactuals significantly improve model generalization and help identify model vulnerabilities in three distinct NLP tasks.
  • When combined with state-of-the-art explanation techniques, Polyjuice counterfactuals reveal model failures—such as insensitive behavior to key words like 'great' or 'kids'—that are missed by feature attribution alone.
  • Counterfactual error analysis using Polyjuice uncovers systematic behaviors, such as differential model responses to various negation forms, enabling deeper insight into model robustness.
  • Despite its strengths, the model is not exhaustive and may favor certain perturbation patterns (e.g., negative sentiment words) due to training data bias, highlighting the need for careful human oversight.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.