CA-RNN: Using Context-Aligned Recurrent Neural Networks for Modeling Sentence Similarity

Qin Chen, Qinmin Hu, Jimmy Xiangji Huang, Liang He

Abstract

Modeling sentence similarity is a fundamental task in natural language processing, yet traditional recurrent neural networks (RNNs) often process sentence pairs in isolation, failing to capture fine-grained interactions during the encoding phase. We present the Context-Aligned Recurrent Neural Network (CA-RNN), which introduces a context-alignment gating mechanism directly into the recurrent unit. By identifying word alignments and allowing the RNN to "peek" at the context of aligned words in the paired sentence, CA-RNN effectively narrows the contextual gap between related sentences. Experimental results on TREC-QA, WikiQA, and MSRP datasets demonstrate that CA-RNN achieves state-of-the-art performance, particularly in asymmetric tasks like question answering.

1. Introduction

Recurrent Neural Networks (RNNs) have long been the workhorses of Natural Language Processing. However, when processing sentence pairs—such as a question and a candidate answer—they typically model each sentence in isolation. While attention mechanisms are frequently used to link sentences, these interactions usually occur after the RNN has completed its pass, or they involve coarse-grained influences that can introduce noise.

The CA-RNN addresses this by surgically injecting relevant, fine-grained information from one sentence into the other during the encoding process. By integrating a context-alignment gating mechanism directly into the recurrent unit, the model allows the RNN to "peek" at the context of aligned words in a paired sentence while it is still generating its own hidden states.

2. Methodology

The CA-RNN architecture introduces two primary innovations to the standard RNN framework: Word Alignment Detection and Context Alignment Gating.

2.1 Word Alignment Detection

Before the recurrent pass begins, the model identifies relationships between words in Sentence A and Sentence B. Two strategies are employed:

  • Overlap-based: Identifies exact matches between tokens.
  • Semantic-based: Utilizes external tools (e.g., Stanford CoreNLP) to identify synonyms or semantically related terms, ensuring that concepts like "USA" and "United States" are correctly linked.

2.2 Context Alignment Gating

This mechanism is the core of the CA-RNN. When the RNN processes a word in Sentence B that is aligned with a word in Sentence A, it performs two critical steps:

  1. Relevance Measurement: A gate calculates the appropriate amount of context to "absorb" from the aligned word in Sentence A, based on the current hidden state and the global representation of the other sentence.
  2. Context Absorption: The model updates its current hidden state by blending it with the context of the aligned word. This information is then naturally propagated to all subsequent words in the sequence.
Architecture of the CA-RNN model showing word alignment and context alignment gating.

3. Experimental Results

The model was evaluated on three standard benchmarks: TREC-QA (answer selection), WikiQA (open-domain QA), and MSRP (paraphrase identification).

3.1 Performance Metrics

On the TREC-QA dataset, the CA-RNN achieved a Mean Average Precision (MAP) of 0.8227, significantly outperforming the previous state-of-the-art of 0.8010. Similar gains were observed on WikiQA, where it reached a MAP of 0.7358. For the MSRP paraphrase task, the model achieved an accuracy of 77.3% and an F1 score of 84.0, proving competitive with top-tier neural approaches.

Performance comparison of the CA-RNN model across TREC-QA, WikiQA, and MSRP datasets.

3.2 Key Insights

  • Directionality: In QA tasks, the relationship is asymmetric. Results indicate that using the question's context to model the answer (Q2A) is significantly more effective than the reverse (A2Q). This aligns with the human cognitive process of evaluating an answer's relevance in the context of a specific question.
  • Semantic Alignment: Semantic-based alignment consistently outperformed simple word overlap, highlighting the importance of understanding synonyms for deep similarity modeling.

4. Discussion and Conclusion

The CA-RNN narrows the "contextual gap" by allowing related sentences to influence each other's representations in the hidden space. Unlike standard attention mechanisms that act as a post-processing step, CA-RNN's internal gating acts as a filter, reducing noise by only "listening" to the other sentence when a meaningful alignment is detected.

Future work may involve learning these alignments end-to-end within the neural network to reduce dependency on external aligners and exploring the model's utility in broader tasks such as Textual Entailment and Information Retrieval.

Summary updated

BibTeX
@inproceedings{chen2018ca,
  author = {Qin Chen and Qinmin Hu and Jimmy Xiangji Huang and Liang He},
  title = {{CA-RNN: Using Context-Aligned Recurrent Neural Networks for Modeling Sentence Similarity}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2018},
  doi = {10.1609/aaai.v32i1.11273},
}
Figure