Mitigating spatial hallucination in large language models for path planning via prompt engineering
Spatial reasoning in Large Language Models (LLMs) serves as a foundation for embodied intelligence. However, even in simple maze environments, LLMs often struggle to plan correct paths due to hallucination issues. To address this, we propose S2ERS, an LLM-based technique that integrates entity and relation extraction with the on-policy reinforcement learning algorithm Sarsa for optimal path planning. We introduce three key improvements: (1) To tackle the hallucination of spatial, we extract a graph structure of entities and relations from the text-based maze description, aiding LLMs in accurately comprehending spatial relationships. (2) To prevent LLMs from getting trapped in dead ends due to context inconsistency hallucination by long-term reasoning, we insert the state-action value function Q into the prompts, guiding the LLM's path planning. (3) To reduce the token consumption of LLMs, we utilize multi-step reasoning, dynamically inserting local Q-tables into the prompt to assist the LLM in outputting multiple steps of actions at once. Our comprehensive experimental evaluation, conducted using closed-source LLMs ChatGPT 3.5, ERNIE-Bot 4.0 and open-source LLM ChatGLM-6B, demonstrates that S2ERS significantly mitigates the spatial hallucination issues in LLMs, and improves the success rate and optimal rate by approximately 29% and 19%, respectively, in comparison to the SOTA CoT methods.
Authors
- Jie Ou (ORCID: https://orcid.org/0000-0002-1159-2043)
- Hongjie Zhang (ORCID: https://orcid.org/0000-0001-9565-3378)
- Chaosheng Feng (ORCID: https://orcid.org/0000-0002-1797-5280)
- Hourui Deng
Institutions
- University of Electronic Science and Technology of China (CN)
- Sichuan Normal University (CN)
Publication Details
- Journal
- Scientific Reports
- Published
- 2025-03-14
- DOI
- https://doi.org/10.1038/s41598-025-93601-5
- Citations
- 8
- Primary Topic
- Topic Modeling
- Type
- article
- Field-Weighted Citation Impact
- 19.85
Funders
- Sichuan Province Science and Technology Support Program