Introduction
In Natural Language Processing (NLP), many tasks require comparing two sentences—for example, deciding if one sentence entails another or if a sentence correctly answers a specific question. Most existing neural models approach this in one of two ways: word-level matching or sentence-level matching. Word-level matching compares words one-by-one, often ignoring hierarchical language structure. Sentence-level matching compresses the entire sentence into a single vector, which can lose fine-grained details of phrase relationships.
While some models incorporate sentence structure, they typically rely on external, "black-box" parsers. These parsers are non-differentiable, meaning the matching model cannot correct parser errors during training, leading to error propagation. This paper introduces Structured Alignment Networks (SAN), a method for matching sentences by comparing their latent tree structures in an end-to-end, differentiable fashion.
Methods
The core innovation of the Structured Alignment Network is its ability to consider every possible span (sequence of words) in a sentence rather than just individual words.
Latent Tree Induction
The model uses a differentiable CKY (Cocke-Kasami-Younger) chart. For every possible span in a sentence, the model calculates a score representing the likelihood of that span being a "constituent" (a valid syntactic unit like a noun phrase). This is achieved using a differentiable version of the inside-outside algorithm, allowing the model to marginalize over all possible tree structures.
Span Representation and Structured Attention
Each span is represented by a vector derived from a bidirectional LSTM. The model then computes attention between all spans in Sentence A and all spans in Sentence B. Crucially, these attention weights are re-normalized by the marginal likelihood of the spans, focusing the "matching energy" on likely structural units. Because the entire system is differentiable, the model learns to induce structures that are specifically useful for the matching task without explicit grammar supervision.
Key Results
The authors evaluated SAN on two major benchmarks: SNLI (Stanford Natural Language Inference) and TREC-QA (answer sentence selection).
- SNLI: The Structured Alignment model achieved 86.3% accuracy, outperforming the word-level "Decomposable Attention" baseline (85.8%) and several other complex LSTM-based models.
- TREC-QA: The model achieved a Mean Average Precision (MAP) of 0.786, significantly higher than the word-level baseline (0.764).
Qualitative Analysis
Visualizing the CKY charts and span alignments reveals that the model successfully identifies meaningful constituents. For example, it can resolve classic ambiguities, such as correctly attaching "with green feathers" to "lingerie" rather than "women" based on the context of the matching task.
Discussion
One of the most striking findings is that structure emerges naturally from the matching objective. By comparing spans like "is in Seattle" to "based in Washington state," the model captures "ideal units of comparison" more effectively than word-to-word alignment.
However, this approach comes with increased computational complexity. The inside-outside algorithm has a complexity of $O(n^3)$, making the model roughly 5 to 8 times slower than simpler word-level attention models. Future work involves optimizing these dynamic programming methods for GPUs and applying latent structure induction to more complex tasks like machine reading comprehension.
Summary updated