Skip to main content

Thank you for visiting nature.com. You are using a browser version with limited support for CSS. To obtain the best experience, we recommend you use a more up to date browser (or turn off compatibility mode in Internet Explorer). In the meantime, to ensure continued support, we are displaying the site without styles and JavaScript.

Advertisement

Scientific Reports
  • View all journals
  • Search
  • My Account Login
  • Content Explore content
  • About the journal
  • Publish with us
  • Sign up for alerts
  • RSS feed
  1. nature
  2. scientific reports
  3. articles
  4. article
RiemannInfer: improving transformer inference through Riemannian geometry
Download PDF
Download PDF
  • Article
  • Open access
  • Published: 29 January 2026

RiemannInfer: improving transformer inference through Riemannian geometry

  • Runze Mao1,3,
  • Zhengyuan Zhang2,3,
  • Mengyao Yang1,3,
  • Hui Xie2,3,
  • Shengjun Wei1,3 &
  • …
  • Changzhen Hu1,3 

Scientific Reports , Article number:  (2026) Cite this article

We are providing an unedited version of this manuscript to give early access to its findings. Before final publication, the manuscript will undergo further editing. Please note there may be errors present which affect the content, and all legal disclaimers apply.

Subjects

  • Mathematics and computing
  • Physics

Abstract

Understanding the reasoning process of Large Language Models(LLMs) is crucial for interpreting their decision-making mechanisms. However, existing methods primarily rely on conditional probability distributions within the model, resulting in computationally inefficient reasoning processes and difficulties in constructing rigorous logical chains. This paper presents RiemannInfer, an innovative computational framework based on Riemannian geometry for optimizing LLM reasoning paths. Our approach stems from a key observation: the hidden states formed through attention mechanisms and contextual encoding in the Transformer can be represented as high-dimensional vector spaces that encapsulate global dependencies captured by the model. Building on this insight, we first apply topology-preserving dimensionality reduction to these hidden states, then construct a Riemannian manifold structure utilizing attention distribution features. Notably, We discover a close relationship between the attention mechanism to the geodesics and the curvature of Riemannian manifolds. Based on this foundation, we implement efficient inference work calculation through geodesic and curvature to realize reasoning path planning, which not only significantly enhances inference efficiency but also provides geometric interpretations of model decision processes. Extensive experiments on various models, including LLaMA, GPT-4, and DeepSeek, demonstrate that RiemannInfer significantly improves the reasoning accuracy of LLMs and exhibits excellent effectiveness and robustness. This research provides a novel geometric perspective for enhancing the interpretability and efficient reasoning of LLMs.

Data availability

The data that support the findings of this study are available from the corresponding author upon reasonable request.

References

  1. He, J., Xiao, S., Huang, S., Li, J. & Wang, D. Mokan: A multi-omics data analysis framework using kolmogorov-arnold networks. IEEE J. Biomed. Health Inform, pp 1-11 (2025).

  2. Achiam, J. et al. Gpt-4 technical report. arXiv preprint arXiv:2303.08774 (2023).

  3. Anil, R. et al. Palm 2 technical report. arXiv preprint arXiv:2305.10403 (2023).

  4. Wang, Q., Wang, Z., Su, Y., Tong, H. & Song, Y. Rethinking the bounds of llm reasoning: Are multi-agent discussions the key? arXiv preprint arXiv:2402.18272 (2024).

  5. Feng, G. et al. Towards revealing the mystery behind chain of thought: a theoretical perspective. Adv. Neural Inf. Process. Syst. 36, 70757–70798 (2023).

    Google Scholar 

  6. Wei, J. et al. Chain-of-thought prompting elicits reasoning in large language models. Adv. Neural Inf. Process. Syst. 35, 24824–24837 (2022).

    Google Scholar 

  7. Yao, S. et al. Tree of thoughts: Deliberate problem solving with large language models. Adv. Neural Inf. Process. Syst. 36, 11809–11822 (2023).

    Google Scholar 

  8. Besta, M. et al. Graph of thoughts: Solving elaborate problems with large language models. Proc. AAAI Conf. Artif. Intell. 38, 17682–17690 (2024).

    Google Scholar 

  9. Mishra, V. et al. Investigating the shortcomings of llms in step-by-step legal reasoning. arXiv preprint arXiv:2502.05675 (2025).

  10. Blair-Stanek, A., Holzenberger, N. & Van Durme, B. Can gpt-3 perform statutory reasoning? In: Proceedings of the Nineteenth International Conference on Artificial Intelligence and Law, pp. 22–31 (2023).

  11. Qiao, S. et al. Reasoning with language model prompting: A survey. arXiv preprint arXiv:2212.09597 (2022).

  12. Benfenati, A. & Marta, A. A singular riemannian geometry approach to deep neural networks i. theoretical foundations. Neural Netw. 158, 331–343. https://doi.org/10.1016/j.neunet.2022.11.022 (2023).

    Google Scholar 

  13. Gruffaz, S. & Sassen, J. Riemannian metric learning: Closer to you than you imagine. arXiv preprint arXiv:2503.05321 (2025).

  14. McDuff, D. et al. Towards accurate differential diagnosis with large language models. Nature 642, 451–457 (2025).

    Google Scholar 

  15. Lu, J. et al. Where views meet curves: Virtual anchors for hyperbolic multi-view graph diffusion. In: Proceedings of the 33rd ACM International Conference on Multimedia, pp. 2131–2140 (2025).

  16. Vaswani, A. et al. Attention is all you need. Adv. Neural Inf. Process. Syst. 30, (2017).

  17. Beltagy, I., Peters, M.E. & Cohan, A. Longformer: The long-document transformer. arXiv preprint arXiv:2004.05150 (2020).

  18. Gao, L., Madaan, A., Zhou, S., Alon, U., Liu, P., Yang, Y., Callan, J. & Neubig, G. Pal: Program-aided language models. In: International Conference on Machine Learning, pp. 10764–10799 (PMLR, 2023).

  19. Guu, K., Lee, K., Tung, Z., Pasupat, P. & Chang, M. Retrieval augmented language model pre-training. In: International Conference on Machine Learning, pp. 3929–3938 (PMLR, 2020).

  20. Amizadeh, S., Palangi, H., Polozov, A., Huang, Y. & Koishida, K. Neuro-symbolic visual reasoning: Disentangling. In: International Conference on Machine Learning, pp. 279–290 (PMLR, 2020).

  21. Ganea, O., Bécigneul, G. & Hofmann, T. Hyperbolic neural networks. Adv. Neural Inf. Process. Syst. 31, (2018).

  22. Nickel, M. & Kiela, D. Poincaré embeddings for learning hierarchical representations. Adv. Neural Inf. Process. Syst. 30, (2017).

  23. Chami, I., Abu-El-Haija, S., Perozzi, B., Ré, C. & Murphy, K. Machine learning on graphs: A model and comprehensive taxonomy. J. Mach. Learn. Res. 23(89), 1–64 (2022).

    Google Scholar 

  24. Pan, Y.-T., Chou, J.-L. & Wei, C.-S. Matt: A manifold attention network for eeg decoding. Adv. Neural Inf. Process. Syst. 35, 31116–31129 (2022).

    Google Scholar 

  25. McInnes, L., Healy, J. & Melville, J. Umap: Uniform manifold approximation and projection for dimension reduction. arXiv preprint arXiv:1802.03426 (2018).

  26. Bécigneul, G. & Ganea, O.-E. Riemannian adaptive optimization methods. arXiv preprint arXiv:1810.00760 (2018).

  27. Wang, H. et al. Manifold-based verbalizer space re-embedding for tuning-free prompt-based classification. Proc. AAAI Conf. Artif. Intell. 38, 19126–19134 (2024).

    Google Scholar 

  28. Sun, L. et al. Motif-aware riemannian graph neural network with generative-contrastive learning. Proc. AAAI Conf. Artif. Intell. 38, 9044–9052 (2024).

    Google Scholar 

  29. Pope, P., Zhu, C., Abdelkader, A., Goldblum, M. & Goldstein, T. The Intrinsic Dimension of Images and Its Impact on Learning (2021). arXiv:2104.08894.

  30. Dijkstra, E.W. A note on two problems in connexion with graphs. In: Edsger Wybe Dijkstra: His Life, Work, and Legacy, pp. 287–290 (2022).

  31. Grattafiori, A., Dubey, A., Jauhri, A., Pandey, A. & Kadian, A. The Llama 3 Herd of Models arXiv:2407.21783 (2024).

  32. OpenAI, Achiam, J., Adler, S., Agarwal, S. & Ahmad, L. GPT-4 Technical Report arXiv:2303.08774 (2024).

  33. DeepSeek-AI, Guo, D., Yang, D., Zhang, H. & Song, J. DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learning arXiv:2501.12948 (2025).

Download references

Funding

This research did not receive funding.

Author information

Authors and Affiliations

  1. School of Cyberspace Science and Technology, Beijing Institute of Technology, No. 5, South Street, 100081, Beijing, Asia, China

    Runze Mao, Mengyao Yang, Shengjun Wei & Changzhen Hu

  2. School of Computer Science and Technology, Beijing Institute of Technology, No. 5, South Street, 100081, Beijing, Asia, China

    Zhengyuan Zhang & Hui Xie

  3. Beijing Key Laboratory of Software Security Engineering Technology, 100081, Beijing, Asia, China

    Runze Mao, Zhengyuan Zhang, Mengyao Yang, Hui Xie, Shengjun Wei & Changzhen Hu

Authors
  1. Runze Mao
    View author publications

    Search author on:PubMed Google Scholar

  2. Zhengyuan Zhang
    View author publications

    Search author on:PubMed Google Scholar

  3. Mengyao Yang
    View author publications

    Search author on:PubMed Google Scholar

  4. Hui Xie
    View author publications

    Search author on:PubMed Google Scholar

  5. Shengjun Wei
    View author publications

    Search author on:PubMed Google Scholar

  6. Changzhen Hu
    View author publications

    Search author on:PubMed Google Scholar

Contributions

All authors contributed to the study’s conception and design. Material preparation, data collection and analysis were performed by Runze Mao, Hui Xie, Zhengyuan Zhang, and Mengyao Yang. The first draft of the manuscript was written by Runze Mao and all authors commented on previous versions of the manuscript. As tutors, Prof. Changzhen Hu, and Prof. Shengjun Wei made contributions to reviewing and revising it for intellectual content. All authors read and approved the final manuscript.

Corresponding author

Correspondence to Shengjun Wei.

Ethics declarations

Competing interests

The authors declare no competing interests.

Additional information

Publisher’s note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Rights and permissions

Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article’s Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article’s Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecommons.org/licenses/by/4.0/.

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Mao, R., Zhang, Z., Yang, M. et al. RiemannInfer: improving transformer inference through Riemannian geometry. Sci Rep (2026). https://doi.org/10.1038/s41598-026-37328-x

Download citation

  • Received: 17 November 2025

  • Accepted: 21 January 2026

  • Published: 29 January 2026

  • DOI: https://doi.org/10.1038/s41598-026-37328-x

Share this article

Anyone you share the following link with will be able to read this content:

Sorry, a shareable link is not currently available for this article.

Provided by the Springer Nature SharedIt content-sharing initiative

Keywords

  • Riemannian Geometry
  • Large Language Models
  • Topological Dimensionality Reduction
  • Reasoning Path Planning
  • Inference Work Calculation
Download PDF

Advertisement

Explore content

  • Research articles
  • News & Comment
  • Collections
  • Subjects
  • Follow us on Facebook
  • Follow us on Twitter
  • Sign up for alerts
  • RSS feed

About the journal

  • About Scientific Reports
  • Contact
  • Journal policies
  • Guide to referees
  • Calls for Papers
  • Editor's Choice
  • Journal highlights
  • Open Access Fees and Funding

Publish with us

  • For authors
  • Language editing services
  • Open access funding
  • Submit manuscript

Search

Advanced search

Quick links

  • Explore articles by subject
  • Find a job
  • Guide to authors
  • Editorial policies

Scientific Reports (Sci Rep)

ISSN 2045-2322 (online)

nature.com sitemap

About Nature Portfolio

  • About us
  • Press releases
  • Press office
  • Contact us

Discover content

  • Journals A-Z
  • Articles by subject
  • protocols.io
  • Nature Index

Publishing policies

  • Nature portfolio policies
  • Open access

Author & Researcher services

  • Reprints & permissions
  • Research data
  • Language editing
  • Scientific editing
  • Nature Masterclasses
  • Research Solutions

Libraries & institutions

  • Librarian service & tools
  • Librarian portal
  • Open research
  • Recommend to library

Advertising & partnerships

  • Advertising
  • Partnerships & Services
  • Media kits
  • Branded content

Professional development

  • Nature Awards
  • Nature Careers
  • Nature Conferences

Regional websites

  • Nature Africa
  • Nature China
  • Nature India
  • Nature Japan
  • Nature Middle East
  • Privacy Policy
  • Use of cookies
  • Legal notice
  • Accessibility statement
  • Terms & Conditions
  • Your US state privacy rights
Springer Nature

© 2026 Springer Nature Limited

Nature Briefing AI and Robotics

Sign up for the Nature Briefing: AI and Robotics newsletter — what matters in AI and robotics research, free to your inbox weekly.

Get the most important science stories of the day, free in your inbox. Sign up for Nature Briefing: AI and Robotics