Combining Transformers with Natural Language Explanations

Federico Ruggeri, Marco Lippi, Paolo TorroniarXiv 2021

This paper presents a novel way to make Transformer models more interpretable by equipping them with a "memory" of natural language explanations. By grounding classification decisions in human-readable rationales, the authors demonstrate that we can achieve explainable AI without sacrificing—and sometimes even improving—predictive performance.

TL;DR

The authors propose memBERT and memDistilBERT, architectures that extend standard Transformers with an external memory containing plain-text explanations. By using a "strong supervision" technique, the models learn to retrieve the most relevant human-written rationale for a given prediction, making the "black box" of deep learning significantly more transparent.

What Problem Does This Paper Address?

While Transformers (like BERT or GPT) have revolutionized NLP, they remain notoriously difficult to interpret. Common techniques like "attention maps" often fail to provide a faithful or human-understandable explanation of why a model made a specific choice.

Furthermore, most existing methods for "injecting" domain knowledge into models require translating that knowledge into rigid, formal logic or complex graphs. This is time-consuming and often loses the nuance of human expertise. The authors tackle two challenges:

  1. How can we use unstructured plain text (the way experts actually write) as a source of domain knowledge?
  2. How can we ensure the model actually uses this knowledge to justify its outputs in a way that makes sense to a human?

Methods

The authors leverage the framework of Informed Machine Learning, which blends traditional data-driven learning with prior human knowledge (see Figure 1).

Figure 1: Information flow in informed machine learning. From [7]

Their specific architecture, shown in Figure 2, is a Memory-Augmented Transformer. Here is how it works:

  1. Encoding: A shared Transformer (like BERT) encodes both the input text and a set of "memory slots" (sentences containing explanations).
  2. Memory Lookup: The model compares the input's embedding against the memory embeddings to calculate similarity scores.
  3. Memory Extraction & Reasoning: It selects the most relevant explanations and combines them with the original input embedding.
  4. Classification: The final prediction is made based on this combined "informed" representation.
Figure 2: The memory-augmented transformer architecture.

A key contribution is Strong Supervision (SS). Instead of just letting the model figure out which memory slot to use (Weak Supervision), the authors use a max-margin loss function during training to force the model to assign higher similarity scores to the "correct" human-annotated rationales. To handle large memories, they also introduce smart sampling strategies that prioritize the most informative snippets of text during training.

Datasets

The approach was validated on two distinct, challenging domains:

  • ToS-30 (Legal): A dataset of online Terms of Service clauses. The task is to detect "unfair" clauses (e.g., unilateral termination). The memory contains legal rationales written by experts explaining why certain language is unfair.
  • IBM2015 (Argument Mining): A dataset focused on claim detection. Here, the memory consists of "evidence" (facts or study results) that support specific claims.

Key Insights and Ideas

  • Natural Language as a Formalism: You don't need complex logic gates to inject knowledge. Plain English rationales are effective "anchors" for a model's reasoning process.
  • The Power of Strong Supervision: Without explicit guidance, models often use memory as a "bag of words" to boost accuracy without truly "understanding" the rationale. Strong Supervision ensures the model is "right for the right reasons."
  • Performance Gains in Low-Data Regimes: In categories with very few examples (like "Arbitration" clauses), the external memory acted as a powerful regularizer, helping the model generalize better than a standard BERT model.
  • Sampling as Curriculum Learning: The authors found that sampling a subset of the memory isn't just a computational necessity; it can prevent the model from overfitting to specific, noisy memory slots.

Key Results

  • Classification: The memory-augmented models consistently outperformed standard CNN and LSTM baselines. In many cases, they matched or slightly exceeded the performance of "vanilla" BERT, proving that interpretability doesn't have to come at a cost.
  • Explainability: With Strong Supervision, the model successfully ranked the correct human rationale in the top 3 positions for 55-80% of cases across all legal categories.
  • Efficiency: The sampling strategies allowed the models to scale to memories with hundreds of elements while running on standard consumer-grade hardware.

Limitations and Future Work

The authors note that their current priority-based sampling learns which memory slots are important for the entire dataset, rather than which ones are important for a specific input. This led to "quasi-uniform" distributions in the argument mining task, where relations are very sparse.

Future work aims to develop input-conditioned sampling, where the model learns to dynamically retrieve knowledge based on the specific nuances of the query. They also suggest moving from retrieving existing explanations to generating new ones based on the evidence stored in memory.

Summary updated

BibTeX
@misc{ruggeri2021combining,
  author = {Federico Ruggeri and Marco Lippi and Paolo Torroni},
  title = {{Combining Transformers with Natural Language Explanations}},
  year = {2021},
  eprint = {2110.00125},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2110.00125},
}
Figure