SSEmb: A Joint Structural and Semantic Embedding Framework for Mathematical Formula Retrieval

Ruyin Li, Xiaoyu ChenarXiv 2025 · DOI

Mathematical Information Retrieval (MIR) is a specialized field where traditional text-based search engines often fall short. Formulas are not merely strings; they are hierarchical structures where the same symbols can carry vastly different meanings depending on their context. SSEmb addresses these challenges by jointly modeling a formula's internal structure and its surrounding natural language context.

The Core Challenges in MIR

The authors identify two primary hurdles in formula retrieval:

  1. Structural vs. Semantic Divergence: Formulas with identical structures (e.g., $a^2 + b^2 = c^2$) can appear in unrelated fields like geometry or number theory. Conversely, semantically related concepts may be expressed through different structural forms.
  2. Fragility of Graph Data: Standard Graph Contrastive Learning (GCL) techniques, such as randomly dropping nodes, often break the mathematical validity of a formula, leading to poor model training.

The SSEmb Framework

SSEmb utilizes a dual-module system designed to respect both the rigid logic of mathematics and the descriptive nuances of natural language.

The SSEmb framework architecture, illustrating the joint structural (StructEmb) and semantic (SemEmb) modules integrated into a two-stage retrieval pipeline.

1. StructEmb: Structural Embedding

This module represents formulas as Operator Graphs (OPG), a compact representation that shares identical subtrees to optimize space. To train the model, the authors employ a novel GCL technique called Substructure Substitution.

Instead of random deletions, the framework progressively replaces leaf or parent nodes with "wildcards." This approach prioritizes the formula's computational "skeleton" over specific variable names, mimicking how mathematicians identify core identities. A Graph Isomorphism Network (GIN) then encodes these graphs into 400-dimensional structural vectors.

Illustration of the substructure substitution strategy, showing first, second, and third-order substitutions used for graph data augmentation.

2. SemEmb: Semantic Embedding

To capture the context that defines a formula's usage, the SemEmb module extracts up to 1024 characters of surrounding text. It utilizes a pre-trained Sentence-BERT model (all-MiniLM-L6-v2) to generate semantic embeddings that complement the structural data.

3. Two-Stage Retrieval Pipeline

To maintain efficiency across massive datasets, SSEmb employs a two-stage process:

  • First-stage Ranking: A rapid search through millions of formulas using structural embeddings to identify the top 500,000 candidates.
  • Second-stage Ranking: A refined re-ranking of the top candidates using a weighted fusion of both structural and semantic similarity scores.

Evaluation and Key Insights

The framework was evaluated on the ARQMath-3 benchmark, which contains over 28 million formulas from Math Stack Exchange.

  • State-of-the-Art Performance: SSEmb outperformed previous embedding-based models like TangentCFT2ED by over 5 percentage points in P'@10 and nDCG'@10. When combined with traditional matching systems (Approach0) via Reciprocal Rank Fusion, it achieved a record nDCG'@10 of 0.7837.
  • The Importance of Context: Ablation studies confirmed that the semantic module is vital; structural similarity alone is insufficient for determining relevance in complex mathematical queries.
  • Augmentation Matters: The hierarchical nature of substructure substitution—where higher-order substitutions are applied less frequently—is crucial for learning robust structural representations.

Conclusion

SSEmb demonstrates that combining structural graph learning with semantic text analysis significantly improves the precision of mathematical formula retrieval. While the current weighted fusion strategy is effective, future work will explore more sophisticated cross-modal fusion techniques and expand the framework's application to full-text answer retrieval.

Summary updated

BibTeX
@misc{li2025ssemb,
  author = {Ruyin Li and Xiaoyu Chen},
  title = {{SSEmb: A Joint Structural and Semantic Embedding Framework for Mathematical Formula Retrieval}},
  year = {2025},
  eprint = {2508.04162},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2508.04162},
}
Figure