Optimizing singular value based similarity measures for document similarity comparisons

Jarkko Lagus, Arto KlamiICNLSP 2022

Introduction

In natural language processing, calculating the similarity between long documents remains a significant challenge. Traditional methods often rely on simple pooling techniques—such as taking the mean or maximum of word embeddings—to create a single 1D vector representation. While computationally efficient, this "bag-of-words" approach discards critical structural and fine-grained information. Conversely, modern Transformer-based models capture these nuances but are prohibitively expensive to run on documents spanning dozens of pages, such as legal filings or patents.

This paper explores a middle ground: maintaining the efficiency of static word embeddings (like fastText) while upgrading the document representation from a 1D vector to a 2D covariance matrix. By representing documents as $d \times d$ matrices, the authors can leverage the mathematical properties of singular values to define more expressive similarity metrics.

Methodology

Instead of averaging word vectors, a document is represented as a covariance matrix of its constituent word embeddings. To compare two document matrices ($A$ and $B$), the authors utilize the Schatten $p$-norm, which operates on the singular values (SVs) of the matrices. The core contribution of this work is the introduction of learnable variants of these measures:

  1. Optimized $p$-norm ($S_{opt}$): The model learns the optimal $p$ parameter for the Schatten norm through backpropagation.
  2. Weighted $p$-norm ($S_{w,p}$): Learnable weights are assigned to each singular value, acting as an attention mechanism that prioritizes specific components of the matrix.
  3. Neural Network Measure ($D_{NN}$): A multi-layer perceptron (MLP) processes the singular values of the cross-covariance matrix ($A^T B$) to output a similarity score, bypassing rigid mathematical definitions in favor of learned patterns.

These models are trained using a triplet loss function, designed to rank highly relevant documents (anchors and positive samples) closer together than less relevant ones.

Experimental Setup

The methods were evaluated using a dataset of 3,500 full-length US patent applications. Patents are uniquely suited for this task due to their length and hierarchical structure. The evaluation was split into two sets:

  • Claims: Shorter, precise legal definitions (avg. 1,907 characters).
  • Descriptions: Long, technical narratives (avg. 37,754 characters).

Relevance was determined by patent citations: "X citations" (prior art leading to rejection) served as positive samples, while "A citations" (general background) served as negative samples.

Key Insights and Ideas

One of the most significant findings was that quasinorms outperform proper norms. The best results for the Schatten $p$-norm were consistently achieved when $p < 1$. Although these values do not satisfy the triangle inequality required for a formal mathematical norm, they empirically capture document similarity more effectively in this high-dimensional space.

Furthermore, the model demonstrated that only a fraction of the information is necessary for accurate retrieval. In the weighted $p$-norm experiments, the model learned to focus almost exclusively on the top ~10 singular values, effectively zeroing out the remaining 290. This suggests that the most critical semantic information is concentrated in the primary components of the covariance matrix.

Evolution of singular value weights and the p parameter during training, illustrating the model's convergence toward specific singular values.

Key Results

The proposed matrix-based metrics significantly outperformed the standard baseline of mean vector pooling with cosine similarity. As shown in the table below, the neural network approach ($D_{NN}$) provided the most substantial gains, particularly on the long "Descriptions" documents where traditional measures often struggle with noise.

Comparison of retrieval accuracy across different similarity measures on patent Claims and Descriptions.
  • Baseline Accuracy: 0.566 (Claims) / 0.553 (Descriptions).
  • $S_{opt}$ Accuracy: 0.603 (Claims) / 0.574 (Descriptions).
  • $D_{NN}$ Accuracy: 0.642 (Claims) / 0.652 (Descriptions).

The fact that $D_{NN}$ maintained high performance on the massive "Descriptions" set highlights the robustness of using singular values as features for a learnable similarity metric.

Conclusion

By representing documents as covariance matrices and learning similarity measures based on singular values, this research provides a powerful alternative to simple vector pooling. The $D_{NN}$ approach, in particular, demonstrates that flexibility in the similarity metric allows the model to adapt to the specific nuances of complex datasets like patents. Future work may involve applying these matrix-based measures to contextual embeddings from Transformer models to further enhance representation richness.

Summary updated

BibTeX
@inproceedings{lagus2022optimizing,
  author = {Jarkko Lagus and Arto Klami},
  title = {{Optimizing singular value based similarity measures for document similarity comparisons}},
  booktitle = {ICNLSP},
  year = {2022},
}
Figure