This paper introduces SparseMAP, a novel framework for structured inference in machine learning. It bridges the gap between selecting a single "best" structure and considering every possible structure, offering a differentiable, sparse, and interpretable alternative for deep learning models.
The Challenge of Structured Prediction
In structured prediction, models output complex objects with internal dependencies, such as dependency trees in linguistics or protein foldings in biology. The number of possible structures is typically combinatorial (exponentially large), making it impossible to enumerate them all.
Historically, researchers have relied on two main strategies:
- MAP (Maximum A Posteriori) Inference: This approach finds the single highest-scoring structure. While efficient, it is "brittle" and non-differentiable, making it difficult to integrate as a hidden layer within a neural network trained via backpropagation.
- Marginal Inference (e.g., CRFs): This method assigns a probability to every possible structure. Although differentiable, it produces "dense" distributions (assigning tiny probabilities to millions of irrelevant structures) and is computationally expensive. For certain problems, like linear assignment (matching), calculating these marginals is #P-complete and thus intractable.
The authors seek a "middle ground": an inference method that is differentiable like marginals, yet sparse and efficient like MAP.
Introducing SparseMAP
SparseMAP serves as a structured generalization of the sparsemax operator.
- The Objective: Instead of using the entropic regularization found in traditional marginal inference (which leads to dense distributions), SparseMAP employs a squared $\ell_2$ penalty. This encourages the model to assign exactly zero probability to the vast majority of structures, focusing its probability mass on a small, high-quality subset.
- The Solver: SparseMAP can be solved using an Active Set method. This algorithm iteratively calls a "MAP oracle"—a black-box solver that finds the best single structure—to build a small set of relevant structures.
- Differentiability: The authors derive an efficient method to backpropagate through the SparseMAP layer. Crucially, the computational complexity of the backward pass depends only on the number of selected structures, not the total number of possible structures.
- Loss Function: By introducing a new loss function based on Fenchel-Young duality, SparseMAP can also be utilized as the final output layer of a network.
Key Insights and Applications
SparseMAP was evaluated on Natural Language Processing (NLP) tasks, including Non-projective Dependency Parsing (using the Universal Dependencies dataset) and Natural Language Inference (NLI, using SNLI and MultiNLI).
- The Power of the MAP Oracle: SparseMAP’s primary advantage is that it only requires a way to find the best structure. This enables the use of complex structures, like linear assignments, as hidden layers in neural networks—a feat previously considered too difficult due to the intractability of marginal inference for matchings.
- Natural Handling of Ambiguity: Because SparseMAP can select a handful of structures, it naturally represents ambiguity. If a sentence has two valid parses, SparseMAP can assign 50% probability to each, whereas MAP would arbitrarily pick one, and Marginal inference would waste probability mass on thousands of impossible trees.
Results and Efficiency
SparseMAP and its margin-based variant outperformed standard CRFs and Structured SVMs on 4 out of 5 languages in dependency parsing.
- Sparsity in NLI: In the NLI task, SparseMAP achieved competitive accuracy with standard "softmax" attention but was orders of magnitude sparser. While softmax aligns every word to every other word, SparseMAP's matching variant produced non-zero alignments for only 8-15% of word pairs.
- Interpretability: By ignoring the "long tail" of improbable structures, the model becomes more computationally efficient and less prone to overfitting on noise. Visualizations demonstrate that SparseMAP picks a small number of "clean" global structures, making it significantly easier for humans to understand model predictions compared to dense marginal distributions.
Limitations and Future Work
While highly modular, SparseMAP still requires an efficient MAP solver for the specific structure being used; without one, the method cannot be applied. Additionally, the Active Set solver can introduce implementation overhead by moving data between the GPU and CPU, though the authors note that inference speeds up as the model becomes more "certain" during training. Future directions include exploring regularizers beyond the squared $\ell_2$ norm and applying SparseMAP to more complex combinatorial problems like multi-target tracking.
Summary updated