Hierarchical Mamba Meets Hyperbolic Geometry: A New Paradigm for Structured Language Embeddings

Sarang Patil, Ashish Parmanand Pandey, Ioannis Koutis, Mengjia Xu

TL;DR

Hierarchical Mamba (HiM) is a novel framework that merges the linear-time efficiency of the Mamba2 state-space model with hyperbolic geometry to capture the latent tree-like hierarchies inherent in natural language. By projecting text representations into Poincaré or Lorentz manifolds with learnable curvature, HiM drastically outperforms flat Euclidean models on complex hierarchical reasoning tasks while avoiding the quadratic computational scaling of Transformers.

What Problem Does This Paper Address?

Natural language is inherently structured like a tree, filled with hierarchies of abstraction, syntax, and specificity (e.g., sport $\rightarrow$ skating $\rightarrow$ skateboarding). However, standard large language models (LLMs) like Transformers typically map text into flat Euclidean spaces. This mismatch forces the model to distort distances when trying to represent complex, exponentially expanding taxonomies.

To make matters worse, standard Transformer encoders scale quadratically ($O(L^2)$) with sequence length. When dealing with long text sequences embedded in deep hierarchical structures—such as medical ontologies or text ontologies—Transformers become computationally prohibitive. The authors set out to design an architecture that can natively understand hierarchical relationships without sacrificing computational scalability.

Methods

The authors introduce Hierarchical Mamba (HiM), which replaces the traditional Transformer backbone with Mamba2 blocks to achieve linear-time ($O(L)$) complexity.

Figure 1: Overview of the Hierarchical Mamba (HiM) model, integrating Mamba2 blocks with hyperbolic projections to the Poincaré ball (via tangent-based mapping) and Lorentzian manifold (via cosine/sine-based mapping), enabling efficient and hierarchy-aware language embeddings for long-range reasoning tasks.

The core innovation lies in how the model handles geometry:

  1. Direct Hyperbolic Projection: The sequence embeddings generated by Mamba2 are projected directly onto either a Poincaré ball (bounded space) or a Lorentzian manifold (unbounded space) using a learnable curvature parameter ($K = -1/c$).
  2. Stabilized Operations: To prevent numerical instability and exploding gradients in the unbounded Lorentzian space, the authors implement curvature-bounded Maclaurin (Taylor) series approximations for the hyperbolic functions ($\cosh$ and $\sinh$).
  3. Hyperbolic Loss Functions: Instead of standard cross-entropy, HiM is optimized using a weighted combination of:
  4. Centripetal Loss: Dynamically forces parent nodes closer to the origin of the manifold than their children, mimicking how a tree expands outward from a root.
  5. Clustering Loss: Groups semantically related entities together while pushing unrelated ones apart using hard negative sampling.

As a foundation, the authors also introduce SentenceMamba-16M, a compact, 16-million parameter Mamba2 model trained from scratch using triplet contrastive loss to generate high-quality sentence embeddings.

Datasets

The framework was evaluated across four structured ontology datasets that vary in scale and hierarchical complexity (measured by their tree-likeness, or $\delta$-hyperbolicity):

  • DOID (Disease Ontology ID): A structured representation of human diseases.
  • FoodOn: A comprehensive ontology standardizing food-related terminology.
  • WordNet (Noun): A well-known lexical database organizing nouns into hypernym-hyponym relationships.
  • SNOMED-CT: A massive, highly complex clinical terminology system used in electronic health records.

Key Insights and Ideas

  • Manifold Matching: The choice between Poincaré and Lorentz geometries depends heavily on the dataset's structure. The Lorentz model is exceptionally well-suited for deeply nested, strictly tree-like structures (low $\delta$-hyperbolicity like DOID and SNOMED-CT) because its unbounded nature avoids boundary instabilities. Conversely, the Poincaré ball handles less strict, flatter hierarchies (like FoodOn) slightly better.
  • Breaking the Quadratic Bottleneck: By pairing hyperbolic geometry with Mamba2 instead of a Transformer, the authors achieved true linear scaling. Doubling the sequence length results in an exact $2\times$ increase in FLOPs and MACs while keeping memory consumption completely constant.
  • Origin as the Ultimate Root: The centripetal loss successfully aligns geometric distance from the origin with hierarchical depth. General concepts naturally anchor near the center, while specific sub-categories branch out toward the fringes.

Key Results

The authors evaluated HiM on two downstream tasks: mixed-hop prediction (estimating exact hierarchical distance) and multi-hop inference (predicting indirect, transitive relationships).

Quantitative performance comparison between Euclidean baselines and HiM variants
  • Surpassing Euclidean Baselines: Both HiM variants vastly outperformed standard Euclidean models. For instance, on the DOID dataset's mixed-hop prediction task, HiM-Lorentz achieved an F1 score of 0.821, compared to just 0.436 for the fine-tuned Euclidean baseline.
  • Mamba vs. Transformer: When pitted against a randomly initialized Hyperbolic Transformer baseline (HiT*), HiM consistently delivered superior F1 scores across different parameter scales (16M and 32M) and curvature settings, proving that state-space models blend seamlessly with non-Euclidean geometry.
  • Outperforming GPT-4o Zero-Shot: In a zero-shot evaluation on WordNet, both HiM variants outperformed GPT-4o by a clear margin (HiM-Poincaré F1 of 0.859 vs. GPT-4o F1 of 0.750), highlighting the power of explicit hierarchical inductive biases over raw parameter scale.

Limitations and Future Work

While robust, HiM's performance degrades significantly under low-curvature settings ($K = -1/d$), indicating that the model relies heavily on a tightly curved space to maintain its hierarchical structure.

For future directions, the authors suggest exploring more sophisticated temporal dependency modeling within long-range hierarchical classifications. Additionally, they propose integrating CLIP-style pretraining to extend HiM into multimodal domains (combining text and images) for tasks like hierarchical visual question answering.

Summary updated

BibTeX
@misc{patil2025hierarchical,
  author = {Sarang Patil and Ashish Parmanand Pandey and Ioannis Koutis and Mengjia Xu},
  title = {{Hierarchical Mamba Meets Hyperbolic Geometry: A New Paradigm for Structured Language Embeddings}},
  year = {2025},
  eprint = {2505.18973},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2505.18973},
}
Figure