Abstract
Natural language is inherently hierarchical, yet standard Large Language Models (LLMs) rely on Euclidean embeddings that struggle to represent deep taxonomic structures without significant distortion. We present Hierarchical Mamba (HiM), a framework that combines the linear-time efficiency of Mamba2 state-space models with the structural advantages of hyperbolic geometry. By embedding language into non-Euclidean manifolds like the Poincaré ball and Lorentz model, HiM captures complex linguistic hierarchies far more effectively than flat Euclidean models. Our 16M-parameter model outperforms massive models like GPT-4o on specialized taxonomic reasoning tasks, demonstrating the power of geometric inductive biases.
Introduction: The Representational Bottleneck
Modern NLP architectures face two primary challenges when dealing with structured data like syntax trees or medical ontologies. First, Euclidean space is "flat." As a hierarchy grows deeper and wider, a flat space lacks the volume to represent parent-child relationships without crowding or distortion. Second, the standard Transformer architecture suffers from quadratic complexity ($O(L^2)$), making long-sequence hierarchical reasoning computationally expensive.
Hierarchical Mamba (HiM) addresses these by marrying the $O(L)$ scaling of Mamba2 with the "tree-shaped" volume of hyperbolic manifolds.
Methodology
The HiM framework introduces several architectural innovations to bridge state-space models and non-Euclidean geometry.
SentenceMamba-16M and Hyperbolic Projections
At its core, HiM uses a compact 16-million-parameter encoder based on the Mamba2 architecture. Unlike Transformers, Mamba2 utilizes selective state-space models (SSMs) to maintain linear efficiency. The model projects sentence-level representations into either the Poincaré ball (a bounded sphere) or the Lorentz manifold (an unbounded hyperboloid).
To ensure training stability in these non-Euclidean spaces, the authors employ Maclaurin (Taylor) approximations for hyperbolic functions ($cosh$ and $sinh$) within the Lorentz model, preventing gradient explosions.
Dual-Component Hyperbolic Loss
Optimization is driven by a weighted combination of two losses:
- Centripetal Loss: Pulls "parent" entities toward the manifold's origin.
- Clustering Loss: Groups "sibling" entities together while maintaining separation from unrelated nodes.
Experimental Results
HiM was evaluated across four diverse ontology datasets: DOID (diseases), FoodOn (food terminology), WordNet (noun hierarchies), and SNOMED-CT (clinical terminology).
Performance and Efficiency
The results demonstrate a significant leap over Euclidean baselines. In the DOID dataset, the F1 score improved from approximately 0.43 in Euclidean space to 0.82 using HiM-Lorentz.
The model also confirmed Mamba’s linear scaling properties: doubling sequence length resulted in a linear increase in FLOPs while memory consumption remained constant, a stark contrast to Transformer-based encoders.
Transitive Reasoning
A key strength of HiM is "multi-hop inference" (e.g., deducing that if a 'poodle' is a 'dog' and a 'dog' is a 'mammal', then a 'poodle' is a 'mammal'). Flat-embedding models often fail here due to accumulated spatial distortion, whereas HiM’s geometric bias preserves these transitive relationships.
Discussion and Future Work
The synergy between Mamba and hyperbolic geometry is clear: Mamba handles the "length" of data, while hyperbolic geometry handles the "depth" of complexity. While the Lorentz model proved more robust for large-scale systems like SNOMED-CT, the Poincaré ball excelled at capturing fine-grained distinctions in shallower hierarchies.
Future research will focus on scaling these geometric biases into generative LLMs and multimodal models (e.g., CLIP-style hierarchies). Additionally, investigating the behavior of these manifolds during massive-scale general pretraining remains a critical next step.
Summary updated