On Controllable Sparse Alternatives to Softmax

Anirban Laha, Saneem A. Chemmengath, Priyanka Agrawal, Mitesh M. Khapra, Karthik Sankaranarayanan, Harish G. Ramaswamy

TL;DR

Softmax is the ubiquitous "easy button" for probability distributions in machine learning, but its inability to produce true zeros makes it computationally inefficient and hard to interpret. This paper introduces a unified framework that treats Softmax and its variants as special cases, offering two new controllable alternatives—sparsegen-lin and sparsehourglass—that allow researchers to precisely dial in the desired level of sparsity without sacrificing performance.

What Problem Does This Paper Address?

In deep learning, we often need to turn a vector of raw scores (logits) into a probability distribution. Softmax is the standard tool for this, but it has a major drawback: it is "dense." Even the most irrelevant items in a list receive a tiny, non-zero probability.

This lack of sparsity is problematic for two reasons. First, it hurts interpretability—in an attention mechanism, it’s harder to explain why a model looked at every single word in a sentence rather than just the three important ones. Second, it’s inefficient for large-scale tasks like multilabel classification with thousands of tags. While "sparsemax" exists, it lacks a "knob" to control exactly how sparse the output should be. Furthermore, there is a theoretical tension between translation invariance (shifting all scores by a constant doesn't change the output) and scale invariance (multiplying scores by a constant doesn't change the output).

Methods

The authors propose a generalized framework called sparsegen. It defines the probability mapping as a projection of a transformed input vector onto a simplex, regularized by a squared L2 norm.

Key components include:

  • sparsegen-lin: A linear extension of sparsemax. It introduces a parameter $\lambda$ that acts as a sparsity controller. By adjusting $\lambda$, you can move from a uniform distribution to a "hardmax" (where only one item gets 100% probability).
  • sparsehourglass: A novel formulation designed to bridge the gap between scale and translation invariance. It uses a "mirror point" function to handle negative inputs gracefully while maintaining Lipschitz continuity (a property essential for stable training).
  • New Convex Loss Functions: The authors move away from standard cross-entropy. They derive piecewise-linear "hinge-like" loss functions based on the geometric constraints of their sparse mappings. These losses are specifically designed to encourage the model to produce zeros where appropriate.

Datasets

The researchers evaluated their methods across three distinct areas:

  1. Synthetic Multilabel Data: Generated using scikit-learn to test how the models handle varying label densities and document lengths.
  2. Real-world Multilabel Classification: Benchmark datasets including Birds, Scene, and Emotions.
  3. Natural Language Processing (NLP):
  4. Neural Machine Translation (NMT): The French-English (FR-EN) pair from the NMT-Benchmark.
  5. Abstractive Summarization: The Gigaword dataset, along with DUC 2003 and DUC 2004 for testing generalization.

Key Insights and Ideas

  • The "Sparsity Knob": The most significant insight is that sparsity shouldn't be an all-or-nothing property. By parameterizing the L2 regularization ($\lambda$), the authors provide a way to tune the "crispness" of the model's attention or classification.
  • Unification: The paper shows that Softmax, Sparsemax, and Spherical Softmax aren't just different ideas; they are specific points in the same mathematical space defined by the sparsegen framework.
  • Hinge > Huber: For sparse mappings, the authors found that their proposed hinge-style losses outperformed the Huber-like losses previously used with sparsemax. The hinge loss is more aggressive at pushing irrelevant scores to zero.
  • Invariance Trade-offs: The sparsehourglass model reveals that you can adaptively trade off between scale and translation invariance using a single parameter ($q$), allowing the model to be tuned for specific domain requirements.

Key Results

  • Multilabel Performance: On synthetic data, the proposed hinge loss variants consistently achieved higher F-scores and better sparsity alignment than the standard sparsemax+huber approach.
  • Translation: In FR-EN translation, sparsegen-lin achieved a BLEU score of 37.27, outperforming both Softmax (36.38) and Sparsemax (36.73).
  • Summarization: On the Gigaword task, sparsegen-lin yielded a ROUGE-L score of 33.37, significantly higher than Softmax's 32.15.
  • Visual Interpretability: Attention heatmaps generated with sparsegen-lin ($\lambda = 0.75$) are visibly "cleaner." They focus on fewer, more relevant words compared to the blurry, spread-out attention of Softmax.

Limitations and Future Work

While sparsehourglass provides a way to balance invariance properties, it does not satisfy both scale and translation invariance simultaneously for a fixed parameter. The choice of the anchor point $q$ remains a hyperparameter that needs tuning.

The authors suggest several promising directions for future research:

  • Applying these sparse formulations to Memory Networks to make read/write operations more efficient.
  • Exploring their utility in Knowledge Distillation, where a sparse teacher might provide clearer signals to a student model.
  • Testing these functions in Reinforcement Learning settings where sparse action distributions could improve exploration.

Summary updated

BibTeX
@inproceedings{laha2018controllable,
  author = {Anirban Laha and Saneem A. Chemmengath and Priyanka Agrawal and Mitesh M. Khapra and Karthik Sankaranarayanan and Harish G. Ramaswamy},
  title = {{On Controllable Sparse Alternatives to Softmax}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2018},
  url = {https://openreview.net/forum?id=Hy-W5_-_WS},
}
Figure