Understanding the Mechanics of SPIGOT: Surrogate Gradients for Latent Structure Learning

Tsvetomila Mihaylova, Vlad Niculae, André F. T. Martins

Abstract

Latent structure models are a powerful tool for modeling language data: they can mitigate the error propagation and annotation bottleneck in pipeline systems, while simultaneously uncovering linguistic insights about the data. One challenge with end-to-end training of these models is the argmax operation, which has null gradient. In this paper, we focus on surrogate gradients, a popular strategy to deal with this problem. We explore latent structure learning through the angle of pulling back the downstream learning objective. In this paradigm, we discover a principled motivation for both the straight-through estimator (STE) as well as the recently-proposed SPIGOT - a variant of STE for structured models. Our perspective leads to new algorithms in the same family. We empirically compare the known and the novel pulled-back estimators against the popular alternatives, yielding new insight for practitioners and revealing intriguing failure cases.

Introduction

In deep learning, we often want models to discover hidden (latent) structures in data, such as dependency trees in a sentence or clusters in a dataset. These structures are usually "discrete," meaning the model must make a hard choice via an argmax operation. However, the argmax function is a "gradient killer": its derivative is zero almost everywhere, breaking the chain rule during backpropagation. Consequently, the encoder responsible for choosing the structure never learns from the downstream task's errors.

Common solutions include stochastic sampling (e.g., REINFORCE), which is often noisy, or continuous relaxations (e.g., Softmax), which lose the discrete property. Surrogate gradients, like the Straight-Through Estimator (STE), offer a middle ground by pretending the gradient is non-zero during the backward pass, but they often lack a solid theoretical foundation.

The Pulled-Back Loss Framework

This work introduces the concept of a pulled-back loss to provide a principled foundation for surrogate gradients. Instead of trying to differentiate through the argmax, the downstream loss (how well the final task was performed) is used to "pull back" a target for what the latent structure should have been.

Conceptual framework of surrogate gradients: (a) the gradient killer problem, (b) pulling back a target z, and (c) pulling back a target μ from the downstream task.

Under this framework, the authors show that STE and the recently proposed SPIGOT method are actually performing a single step of optimization toward this "pulled-back" target using a perceptron loss. This insight allows for the derivation of new, more stable algorithms:

  • SPIGOT-CE: Uses Cross-Entropy loss for more robust "pseudo-supervision."
  • SPIGOT-EG: Employs Exponentiated Gradient updates.

Empirical Evaluation and Results

The methods were evaluated on synthetic categorical data, the Stanford Sentiment Treebank (SST), and Stanford Natural Language Inference (SNLI).

A striking finding is the trade-off between task accuracy and structure recovery. While "relaxed" models like Softmax often achieve the highest task accuracy, they fail to recover the actual latent structure, effectively "cheating" by mixing multiple structures together. In contrast, surrogate gradient methods like SPIGOT-CE successfully recover interpretable structures while maintaining competitive performance.

Comparison of validation accuracy and V-measure (structure recovery) over training epochs. While Softmax achieves high accuracy, it fails to recover the latent structure (low V-measure) compared to SPIGOT variants.

On synthetic data with 10 clusters, Softmax reached 86% accuracy but only a 75% V-measure (clustering quality). SPIGOT-CE achieved 83.5% accuracy with a nearly perfect 94.8% V-measure, demonstrating its ability to truly "find" the underlying clusters. On NLP tasks like SST, SPIGOT variants were top performers, producing more informative and linguistically plausible trees than flat or relaxed alternatives.

Discussion and Conclusion

While surrogate gradients provide superior structure recovery, they face challenges. In complex tasks like SNLI, discrete methods still lag slightly behind soft relaxations in raw accuracy. Additionally, the "pulled-back" target depends on the current decoder's quality; a poorly trained decoder can provide noisy "pseudo-labels" early in training, leading to a "blind leading the blind" scenario.

Despite these limitations, the theoretical grounding of SPIGOT as a pulled-back optimization process provides a clear path forward for developing models that learn discrete, human-interpretable structures without sacrificing the benefits of end-to-end training.

Summary updated

BibTeX
@inproceedings{mihaylova2020understanding,
  author = {Tsvetomila Mihaylova and Vlad Niculae and André F. T. Martins},
  title = {{Understanding the Mechanics of SPIGOT: Surrogate Gradients for Latent Structure Learning}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2020},
  doi = {10.18653/v1/2020.emnlp-main.171},
}
Figure