SparseMAP: Differentiable Sparse Structured Inference

Vlad Niculae, André F. T. Martins, Mathieu Blondel, Claire Cardie

Introduction

In machine learning, predicting combinatorial structures—such as parse trees, sequence tags, or word alignments—is a fundamental challenge. When integrating these structures into deep neural networks, researchers typically face a dilemma between two inference strategies:

  1. MAP (Maximum A Posteriori) Inference: Finds the single highest-scoring structure. While computationally tractable for many problems, it is piecewise constant and discontinuous, making it unsuitable for gradient-based backpropagation.
  2. Marginal Inference: Computes a probability distribution over all possible structures. While smooth and differentiable, it is often computationally intractable for complex problems (like linear assignment) and produces "dense" outputs, assigning non-zero probability to every possible structure, including nonsensical ones.

SparseMAP bridges this gap by providing a differentiable inference method that is computationally tractable, handles complex structures, and yields sparse, interpretable outputs.

Methodology

SparseMAP is a structured extension of the sparsemax activation function. It shifts the inference objective from the negative entropy penalty used in marginal inference (which forces dense probabilities) to a squared $L_2$ penalty.

Geometric comparison of SparseMAP against MAP and Marginal inference on the marginal polytope.

L2 Regularization and Optimization

Geometrically, the $L_2$ penalty projects the solution onto the faces of the marginal polytope, resulting in a sparse combination of just a few highly probable structures. While solving this objective directly is difficult due to the exponential number of possible structures, the authors demonstrate that it can be solved efficiently using an Active Set algorithm. This algorithm only requires a standard MAP solver as a subroutine (an "oracle"), making it applicable to any problem where MAP inference is possible.

Efficient Backpropagation

Because SparseMAP is continuous, it is differentiable almost everywhere. The backward pass is highly efficient because the Jacobian only needs to be computed for the small set of "active" structures identified during the forward pass. This allows SparseMAP to serve as a drop-in replacement for CRFs or Structured SVMs via a new family of structured Fenchel-Young losses.

Key Insights

A MAP Oracle is All You Need

By relying solely on a MAP oracle, SparseMAP unlocks differentiable inference for problems where marginal inference is mathematically intractable (#P-complete). For instance, researchers can now utilize the Hungarian algorithm to create differentiable, sparse bipartite matchings within a neural network.

Built-in Interpretability

Unlike the dense "mush" of weights produced by standard attention mechanisms, SparseMAP outputs a crisp, small set of structures. If a sentence is linguistically ambiguous, SparseMAP might return exactly two valid parse trees with a specific probability split, ignoring the millions of incorrect alternatives.

SparseMAP produces a sparse set of interpretable structures, such as alignments, for a given sentence.

Experimental Results

Dependency Parsing

Evaluated on the Universal Dependencies (UD) dataset across five languages, models trained with SparseMAP loss outperformed standard CRF and Structured SVM losses in four out of five cases. In English, Margin-SparseMAP achieved 87.34% accuracy, surpassing the CRF's 86.74%.

Natural Language Inference (NLI)

In latent word alignment tasks on SNLI and MultiNLI, SparseMAP achieved competitive accuracy (86.62% on SNLI) while being orders of magnitude sparser than softmax. SparseMAP assigned non-zero alignment scores to only 8% to 19% of word pairs, compared to 100% for softmax, significantly enhancing model interpretability.

Conclusion

SparseMAP offers a powerful alternative for structured prediction in deep learning. By combining the tractability of MAP inference with the differentiability of marginal inference—while adding the benefits of sparsity—it enables more interpretable and efficient models for complex combinatorial tasks.

Summary updated

BibTeX
@inproceedings{niculae2018sparsemap,
  author = {Vlad Niculae and André F. T. Martins and Mathieu Blondel and Claire Cardie},
  title = {{SparseMAP: Differentiable Sparse Structured Inference}},
  booktitle = {International Conference on Machine Learning},
  year = {2018},
  url = {https://openreview.net/forum?id=Rqnnh_tWMPV},
}
Figure