Minimizing Hyperbolic Embedding Distortion with LLM-Guided Hierarchy Restructuring

Melika Ayoughi, Pascal Mettes, Paul Groth · DOI

Introduction

Hyperbolic geometry has emerged as the natural mathematical home for hierarchical data, such as taxonomies and ontologies. Because hyperbolic space expands exponentially—mirroring the branching nature of trees—it can represent complex hierarchies with significantly lower dimensionality than Euclidean space. However, the quality of these embeddings is highly sensitive to the specific structure of the input hierarchy. This paper addresses the challenge of "embedding distortion," where the distance between points in the vector space fails to accurately reflect their distance in the original hierarchy.

The Problem: Human Logic vs. Geometric Efficiency

Most existing ontologies are designed by human knowledge engineers for logical consistency, readability, or domain-specific utility. Unfortunately, these human-centric designs are often suboptimal for geometric algorithms. Previous research indicates that "wide" hierarchies with high branching factors and single inheritance (where each node has only one parent) are the easiest to embed with low distortion.

Manually restructuring massive ontologies like ImageNet to meet these geometric criteria is labor-intensive and requires specialized expertise. The authors propose a novel solution: using Large Language Models (LLMs) to act as "geometric consultants" that automatically restructure hierarchies to minimize distortion while maintaining semantic integrity.

Methodology: LLM-Guided Restructuring

The authors developed a multi-step pipeline to transform complex ontologies into geometrically optimized structures:

  1. Hierarchy Reformatting: To accommodate LLM context limits, hierarchies (often in JSON or RDF) are converted into a compact textual representation using a pre-order Depth-First Search (DFS).
  2. Prompt-based Restructuring: The LLM (specifically GPT-4o or DeepSeek-V3) is tasked with restructuring the hierarchy based on four geometric desiderata:
  3. Prioritize Width: Flatten deep, narrow chains into "bushier" structures.
  4. Ignore Balance: Allow subtrees to be uneven if it reduces depth.
  5. Node Complexity: Add intermediate nodes if they help clarify the structure.
  6. Single Inheritance: Ensure every node has exactly one parent.
  7. Post-prompt Validation: A verification system ensures the LLM has not "hallucinated" new nodes and that all original leaf nodes—the primary data targets—are preserved.
  8. Embedding and Evaluation: The restructured trees are embedded using state-of-the-art methods (Hadamard and HS-DTE) and measured for average and worst-case distortion.

Experimental Results

The approach was evaluated across 16 diverse datasets, ranging from general vision (ImageNet-21K) to specialized domains like robotics (Core50), biology (BioTrove), and material science (Matador).

Key Findings

  • Consistent Distortion Reduction: LLM-guided restructuring reduced embedding distortion in nearly every case. For instance, on the Pizza dataset, average distortion dropped by over 50% using the Hadamard method.
  • Width is King: The most significant factor in reducing distortion was "flattening"—reducing the depth of the tree to increase the branching factor.
  • Model Performance: DeepSeek-V3 generally outperformed GPT-4o in generating structures that resulted in lower distortion scores.
  • Scalability via Code: For massive hierarchies like ImageNet-21K (over 74,000 nodes), the authors found that asking the LLM to write a restructuring function (Python code) was more effective than asking it to rewrite the hierarchy directly.

Discussion and Explainability

One of the primary advantages of using LLMs over black-box optimization is explainability. The LLM provides clear justifications for its changes, such as: "Flattening deep chains where intermediate nodes have a single child and no additional semantic weight." This transparency allows knowledge engineers to evaluate the trade-off between geometric optimization and the potential loss of semantic nuance.

Limitations and Future Work

While the method preserves leaf nodes, the process of "flattening" inevitably removes some intermediate categories. Future research will investigate how this loss of intermediate semantic information affects downstream tasks like image classification or recommendation systems. Additionally, the authors plan to explore whether LLMs can assist in the ground-up creation of new ontologies that are pre-optimized for hyperbolic spaces.

Conclusion

By leveraging the reasoning capabilities of LLMs, this research provides a scalable way to bridge the gap between human-designed knowledge structures and the requirements of hyperbolic geometry. The result is a significant reduction in embedding distortion across a wide array of domains, paving the way for more accurate hierarchical representations in machine learning.

Summary updated

BibTeX
@inproceedings{ayoughi2025minimizing,
  author = {Melika Ayoughi and Pascal Mettes and Paul Groth},
  title = {{Minimizing Hyperbolic Embedding Distortion with LLM-Guided Hierarchy Restructuring}},
  booktitle = {K-CAP},
  year = {2025},
  doi = {10.1145/3731443.3771357},
}
Figure