Abstract
Measuring semantic similarity between Chinese sentences is a critical task in Natural Language Processing (NLP), yet it faces unique challenges due to the character-based nature of the language. Traditional Siamese networks often process sentences independently, failing to capture intricate inter-sentence dependencies. This paper introduces CATsNet (Cross-ATtention Siamese Network), an architecture that leverages cross-attention mechanisms and Bi-LSTM layers to explicitly model interactions between sentence pairs. Evaluated on the LCQMC dataset, CATsNet achieves a state-of-the-art accuracy of 83.15%, demonstrating significant improvements over standard self-attention and recurrent models.
Introduction
In Chinese NLP, the character serves as the primary semantic unit. Unlike many European languages where word boundaries are clear, Chinese sentence meaning is heavily dependent on the specific arrangement of characters. Two sentences may share a high degree of character overlap but convey entirely different meanings.
Standard approaches to Semantic Textual Similarity (STS) often utilize Siamese networks to encode sentences into fixed-length vectors before computing a similarity metric. However, these "independent encoding" strategies ignore the contextual nuances that arise when sentences are compared directly. To address this, the researchers propose CATsNet, which integrates cross-attention to allow the representation of one sentence to be informed by the other during the encoding phase.
Methodology: The CATsNet Architecture
The CATsNet framework is built upon a Siamese structure where two sub-networks share weights. The core innovation lies in the interaction layers.
Cross-Attention Mechanism
While standard Transformers use self-attention to relate tokens within a single sequence, CATsNet employs a cross-attention mechanism. Here, the Query (Q) and Key (K) matrices are derived from the first sentence, while the Value (V) matrix is sourced from the second (and vice versa). This design ensures that the resulting embedding for each sentence is intrinsically linked to the content of its pair.
Bi-LSTM Integration
To capture sequential and local dependencies—which are often missed by pure attention mechanisms—the traditional Feed-Forward Network (FFN) in the Transformer block is replaced with a Bidirectional Long Short-Term Memory (Bi-LSTM) layer. This hybrid approach combines the global context of attention with the sequential modeling strengths of RNNs.
Focal Loss
To mitigate class imbalance issues common in large-scale matching datasets, the model utilizes Focal Loss. This loss function prioritizes "hard" examples (misclassified pairs) during training, leading to more robust classification boundaries.
Experimental Setup and Results
The model was evaluated using the Large-scale Chinese Question Matching Corpus (LCQMC), which contains over 238,000 training pairs sourced from real-world Q&A platforms. The task is a binary classification: determining if two questions are semantically equivalent.
Performance Comparison
CATsNet was compared against several baseline architectures, including standard Siamese LSTMs and CNNs. The results indicate that the transition from self-attention to cross-attention provides a substantial performance boost (~3.38%). Furthermore, replacing the MLP/FFN with a Bi-LSTM (CATsNet) yields the highest overall accuracy.
| Architecture | Accuracy (%) |
|---|---|
| Siamese LSTM | 68.63 |
| Siamese Bi-LSTM | 68.64 |
| Siamese Convolutional | 77.31 |
| Siamese Self-Attention | 78.61 |
| Siamese Cross-Attention MLP | 81.99 |
| CATsNet (Ours) | 83.15 |
Discussion and Conclusion
The success of CATsNet underscores the importance of inter-sentence interaction in Chinese STS. By allowing the model to "look" at both sentences simultaneously through cross-attention, it becomes more resilient to character-overlap pitfalls. The integration of Bi-LSTM further refines these representations by maintaining local sequence order.
Future research will explore the applicability of CATsNet to other character-based languages and investigate methods to reduce the computational overhead associated with cross-attention in real-time production environments.
Reference: Wang, Z., Zhang, X., & Tan, Y. (2021). Chinese Sentences Similarity via Cross-Attention Based Siamese Network. arXiv:2104.08787v2 [cs.CL].
Summary updated