Skip to main content
QUICK REVIEW

[Paper Review] AllenNLP Interpret: A Framework for Explaining Predictions of NLP Models

Eric Wallace, Jens Tuyls|arXiv (Cornell University)|Sep 19, 2019
Explainable Artificial Intelligence (XAI)Computer Science23 references14 citations
TL;DR

AllenNLP Interpret is an open-source, extensible framework that enables instance-level interpretation of NLP models using gradient-based saliency maps and adversarial attacks. It provides model-agnostic APIs, reusable visualization components, and seamless integration with AllenNLP, allowing practitioners and researchers to interpret diverse models—including BERT and BiDAF—across tasks like named entity recognition and masked language modeling with minimal code changes.

ABSTRACT

Neural NLP models are increasingly accurate but are imperfect and opaque---they break in counterintuitive ways and leave end users puzzled at their behavior. Model interpretation methods ameliorate this opacity by providing explanations for specific model predictions. Unfortunately, existing interpretation codebases make it difficult to apply these methods to new models and tasks, which hinders adoption for practitioners and burdens interpretability researchers. We introduce AllenNLP Interpret, a flexible framework for interpreting NLP models. The toolkit provides interpretation primitives (e.g., input gradients) for any AllenNLP model and task, a suite of built-in interpretation methods, and a library of front-end visualization components. We demonstrate the toolkit's flexibility and utility by implementing live demos for five interpretation methods (e.g., saliency maps and adversarial attacks) on a variety of models and tasks (e.g., masked language modeling using BERT and reading comprehension using BiDAF). These demos, alongside our code and tutorials, are available at https://allennlp.org/interpret .

Motivation & Objective

  • Address the lack of flexible, reusable tools for interpreting NLP models across diverse architectures and tasks.
  • Reduce the implementation burden for practitioners and interpretability researchers who want to apply or extend interpretation methods.
  • Enable interpretation of state-of-the-art contextual models like BERT and ELMo, which lack traditional embedding matrices.
  • Provide interactive, reusable visualizations to improve model transparency and user trust.
  • Support both live demos and batch processing for scalable interpretation workflows.

Proposed method

  • Provides model- and task-agnostic APIs to compute input gradients, enabling gradient-based interpretation across any AllenNLP model.
  • Implements three saliency methods: Vanilla Gradient, Integrated Gradients, and SmoothGrad, each using the model’s own prediction in the loss calculation.
  • Introduces a context-independent embedding matrix derived from the last non-contextual layer of models like ELMo and BERT to enable discrete token search in adversarial attacks.
  • Uses the AllenNLP Demo web framework with reusable HTML/JavaScript components for interactive visualization of saliency and adversarial perturbations.
  • Supports plug-and-play integration of new models and interpretation methods via modular tutorials and minimal code changes.
  • Enables both online interactive demos and offline batch processing for interpretation results.

Experimental results

Research questions

  • RQ1How can interpretation methods be made accessible and reusable across diverse NLP models and tasks?
  • RQ2What challenges arise when applying gradient-based and adversarial interpretation methods to context-dependent models like BERT?
  • RQ3How can a unified framework reduce the engineering burden for deploying interpretation tools in practice?
  • RQ4Can reusable front-end components significantly simplify the deployment of interactive model interpretation tools?
  • RQ5How can existing interpretation methods be adapted to work with modern contextual embeddings that lack discrete embedding matrices?

Key findings

  • AllenNLP Interpret enables interpretation of any AllenNLP model using gradient-based saliency and adversarial attacks with minimal code changes.
  • The framework successfully supports interpretation of contextual models like BERT and ELMo by constructing a context-independent embedding matrix for discrete token search in adversarial attacks.
  • Interactive visualizations for saliency and adversarial examples are implemented with a single line of HTML, demonstrating high reusability and low integration overhead.
  • Live demos show model biases, such as a SQuAD model relying on lexical overlap, and decision rules, such as a NER model predicting 'Location' based on 'in downtown'.
  • The toolkit enables diagnosis of model errors, such as a sentiment model being misled by the trigram 'tony hawk style'.
  • The framework supports both real-time interactive interpretation and offline batch processing, enhancing its utility across research and deployment settings.

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.