SPECTRA: Sparse Structured Text Rationalization

Nuno Miguel Guerreiro, André F. T. Martins

Introduction

Deep learning models are frequently criticized for being "black boxes," providing little insight into their decision-making processes. To address this, researchers employ selective rationalization, where a model identifies a subset of the input—a "rationale"—to justify its prediction. Ideally, these rationales should be both sparse (concise) and structured (e.g., contiguous phrases rather than scattered words).

The Limitations of Current Approaches

Historically, selective rationalization has relied on two main paradigms, each with significant drawbacks:

  1. Stochastic Methods: These treat rationales as random binary masks. While flexible, they are notoriously difficult to train, requiring high-variance gradient estimators like REINFORCE. This often leads to "brittle" models that are highly sensitive to initialization and hyperparameters.
  2. Deterministic Sparse Attention: These methods are easier to train via backpropagation but offer limited control. They struggle to enforce specific structural constraints, such as ensuring a rationale forms a continuous, readable sentence or adheres to a strict word budget.
Comparison of SPECTRA with existing rationalization methods across key technical properties.

The SPECTRA Framework

SPECTRA (Sparse Structured Text Rationalization) bridges this gap by formulating rationale extraction as a constrained optimization problem on a factor graph. By replacing standard attention or random sampling with an LP-SparseMAP layer, the authors create a fully differentiable, deterministic framework.

Key Technical Innovations

  • Factor Graphs and Logic Constraints: SPECTRA represents explanations as variables within a graph. "Factors" are added to enforce specific rules. For instance, a BUDGET factor ensures the model highlights no more than a fixed percentage of text, while a PAIR factor encourages the selection of adjacent words.
  • H:SeqBudget: A novel factor designed specifically for text highlighting. It combines sequence modeling for contiguity with a hard budget constraint for sparsity, utilizing an efficient, modified Viterbi algorithm.
  • Differentiable Inference: Because LP-SparseMAP is a continuous relaxation of a discrete problem, the entire system is end-to-end differentiable. This allows for stable training using standard backpropagation without the noise inherent in stochastic sampling.

Experimental Evaluation

The authors evaluated SPECTRA across several challenging tasks:

  • Text Highlighting: Sentiment analysis and classification on datasets including SST, AgNews, IMDB, Hotels, and BeerAdvocate. The latter two are critical as they contain human-annotated rationales for direct evaluation.
  • Natural Language Inference (NLI): Word alignment tasks on SNLI and MNLI, as well as heuristic analysis using the HANS dataset to detect "cheats" like simple word overlap.

Key Results and Insights

SPECTRA demonstrates that deterministic models can be both more stable and more controllable than their stochastic counterparts.

Predictive performance of SPECTRA compared to stochastic and deterministic baselines across five classification datasets.
  • Predictive Power: As shown in the results above, SPECTRA matches or outperforms state-of-the-art models like HardKuma and Sparse Attention. Notably, it achieved a Macro $F_1$ of 0.91 on the Hotels dataset.
  • Explanation Quality: On the BeerAdvocate dataset, SPECTRA's token-level $F_1$ for matching human rationales (0.61) significantly outperformed stochastic baselines, which ranged from 0.19 to 0.42. By enforcing contiguity, SPECTRA produces meaningful phrases rather than "salt and pepper" keywords.
  • Training Stability: Across multiple random seeds, SPECTRA exhibited much lower variance in performance compared to REINFORCE-based models, making it a far more reliable tool for practitioners.

Conclusion

SPECTRA offers a modular and robust framework for interpretable AI. By treating rationalization as structured prediction, it provides the precision of constrained optimization with the ease of differentiable training. While it introduces some computational overhead compared to simple softmax layers, the gains in stability and explanation quality make it a compelling choice for building trustworthy NLP systems.

Reference: Guerreiro, N. M., & Martins, A. F. T. (2021). SPECTRA: Sparse Structured Text Rationalization. Proceedings of EMNLP 2021.

Summary updated

BibTeX
@inproceedings{guerreiro2021spectra,
  author = {Nuno Miguel Guerreiro and André F. T. Martins},
  title = {{SPECTRA: Sparse Structured Text Rationalization}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2021},
  doi = {10.18653/v1/2021.emnlp-main.525},
}
Figure