Match-SRNN: Modeling the Recursive Matching Structure with Spatial RNN

Shengxian Wan, Yanyan Lan, Jun Xu, Jiafeng Guo, Liang Pang, Xueqi Cheng

Abstract

Semantic matching, which aims to determine the matching degree between two texts, is a fundamental problem for many NLP applications. Recently, deep learning approach has been applied to this problem and significant improvements have been achieved. In this paper, we propose to view the generation of the global interaction between two texts as a recursive process: i.e. the interaction of two texts at each position is a composition of the interactions between their prefixes as well as the word level interaction at the current position. Based on this idea, we propose a novel deep architecture, namely Match-SRNN, to model the recursive matching structure. Firstly, a tensor is constructed to capture the word level interactions. Then a spatial RNN is applied to integrate the local interactions recursively, with importance determined by four types of gates. Finally, the matching score is calculated based on the global interaction. We show that, after degenerated to the exact matching scenario, Match-SRNN can approximate the dynamic programming process of longest common subsequence. Thus, there exists a clear interpretation for Match-SRNN. Our experiments on two semantic matching tasks showed the effectiveness of Match-SRNN, and its ability of visualizing the learned matching structure.

Introduction

Semantic matching—determining the relevance or similarity between two pieces of text—is a cornerstone of NLP tasks like Information Retrieval (IR) and Question Answering (QA). Historically, models have followed two primary paradigms:

  1. Representation-based models: These encode each sentence into a vector independently and then compare them (e.g., via cosine similarity). These often miss fine-grained interactions between specific words.
  2. Interaction-based models: These build a similarity matrix between all word pairs. However, many existing interaction models use hierarchical structures like CNNs that rely on fixed window sizes, often failing to capture long-distance dependencies or the recursive nature of sentence alignment.

This paper argues that matching is inherently recursive: the interaction between two sentences at a specific point depends on how well their preceding parts (prefixes) matched. To address this, the authors introduce Match-SRNN.

Methodology

Match-SRNN models the matching process as a recursive composition of local interactions. The architecture consists of three main components:

  • Neural Tensor Network (NTN): Instead of simple cosine similarity, the model uses an NTN to produce a rich similarity vector for every word pair $(w_i, v_j)$ between the two sentences, forming a 2D "interaction tensor."
  • Spatial RNN (2D-GRU): While a standard RNN moves in one dimension, a Spatial RNN moves across the 2D interaction tensor. To calculate the state at position $(i, j)$, the model integrates three previous states: $(i-1, j)$, $(i, j-1)$, and $(i-1, j-1)$.
  • Four-Way Gating: To manage information flow, the authors extended the Gated Recurrent Unit (GRU) to include four update gates ($z_l, z_t, z_d, z_i$). These gates decide the relative importance of the "left" neighbor, "top" neighbor, "diagonal" neighbor, or the current word-level interaction.
The Match-SRNN architecture: from word interaction tensor to spatial RNN and final linear layer.

Theoretical Interpretation: Approximation of LCS

A significant contribution of this work is the proof that Match-SRNN can approximate the dynamic programming process of the Longest Common Subsequence (LCS) algorithm. By viewing matching as a 2D recursive process, the model essentially searches for an optimal alignment path through the similarity matrix. This provides a rare level of interpretability for a deep learning model; the "matching path" can be visualized by backtracing the gates with the highest activation values.

Visualization of (a) LCS, (b) Soft LCS, and (c) Match-SRNN gates, demonstrating how the model learns to approximate the matching path.

Experiments and Results

The model was evaluated on two distinct tasks:

  • Community Question Answering (QA): Using a dataset from Yahoo! Answers (~60,000 pairs), Match-SRNN achieved a Precision@1 of 0.785, significantly outperforming BM25 (0.579) and the CNN-based MatchPyramid (0.764).
  • Paper Citation (PC): In predicting citations between academic abstracts, Match-SRNN reached an Accuracy of 0.898, outperforming all tested deep learning baselines.

Beyond metrics, the authors demonstrated that the model correctly identifies and "locks onto" key phrases. For example, in a QA pair about a "memory stick error," the internal gates clearly highlighted the alignment between the words "memory," "stick," and "error" across the two sentences.

Conclusion

Match-SRNN successfully bridges the gap between deep learning and classical algorithms by modeling the recursive structure of text matching. While 2D RNNs present computational challenges regarding parallelization and scalability to very long documents, the model's superior performance and interpretability make it a powerful tool for semantic matching tasks. Future work may focus on optimizing the 2D interaction tensor for larger-scale document processing.

Summary updated

BibTeX
@inproceedings{wan2016match,
  author = {Shengxian Wan and Yanyan Lan and Jun Xu and Jiafeng Guo and Liang Pang and Xueqi Cheng},
  title = {{Match-SRNN: Modeling the Recursive Matching Structure with Spatial RNN}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {2016},
  url = {https://openreview.net/forum?id=SJWSINzubr},
}
Figure