Introduction
Spatio-temporal (ST) data, which captures information across both space and time, is fundamental to critical domains like urban planning, traffic management, and environmental monitoring. Despite its importance, analyzing this data remains challenging. Specialized ST models are often too narrow, while Large Language Models (LLMs) struggle with numerical precision and geospatial logic. This paper introduces STReason, a modular framework designed to bridge this gap by decomposing complex natural language queries into executable "ST Programs."
The Spatio-temporal Reasoning Gap
Current analytical approaches face a significant "capabilities gap." Specialized models, while accurate for specific tasks like forecasting, cannot explain the underlying causes of patterns or handle nuanced constraints (e.g., "find anomalies specifically on weekends"). Conversely, LLMs possess strong reasoning capabilities but frequently hallucinate numerical patterns and fail to grasp complex physical dependencies inherent in ST data. Furthermore, most existing systems require data in rigid tensor formats, creating a barrier for non-expert users.
The STReason Framework
STReason acts as an automated data scientist, translating high-level intent into precise analytical steps. The framework operates in two primary stages:
- Command Generator: Using an LLM as a high-level planner, this stage leverages In-Context Learning and a structured Function Pool. It translates a user's natural language query into an "ST Program"—a sequence of modular commands such as
LOAD_DATA,ANALYZE_TREND, andDETECT_ANOMALY. - Command Interpreter: This stage executes the generated program using 12 specialized modules. These include state-of-the-art ST prediction models and data processing sub-routines that ensure grounded, factually accurate results.
The modularity of STReason is key to its success. By providing a "Function Pool" that defines the syntax and purpose of each tool, the framework ensures the LLM stays grounded in the specific capabilities of the underlying ST models.
Experimental Evaluation
The researchers evaluated STReason using four real-world datasets covering traffic flow (PEMS-BAY, METR-LA) and air quality (Beijing, Shenzhen). To rigorously test the framework, the authors developed a new benchmark consisting of 150 structured instances, each featuring a complex query, an executable program, and a ground-truth answer.
STReason was compared against six advanced LLMs, including GPT-4o and DeepSeek-V3. The results demonstrated significant improvements across several metrics:
- Constraint Adherence: STReason achieved a perfect 100% score, accurately following all user-specified constraints.
- Factuality: The framework reached 84.44% accuracy, vastly outperforming DeepSeek-V3 (32.83%) and GPT-4o Mini (29.22%).
- Forecasting Precision: STReason maintained lower error rates (MAE of 7.63) compared to direct LLM inference (7.87).
Key Insights
A primary takeaway is that LLMs are most effective when used as narrators and planners rather than calculators. By offloading numerical "heavy lifting" to specialized modules, STReason avoids the common pitfalls of LLM hallucination. Furthermore, the program-based output enhances interpretability, allowing users to inspect every intermediate step of the analysis. In a blind study, 74.1% of experts preferred STReason's structured and comprehensive answers over baseline models.
Conclusion and Future Work
STReason represents a significant step toward accessible, high-precision spatio-temporal reasoning. While the framework currently relies on manually curated in-context examples, future iterations aim to incorporate automated example retrieval and expand into multimodal environments, integrating satellite imagery and map data. By combining the reasoning breadth of LLMs with the analytical depth of specialized models, STReason provides a robust foundation for the next generation of urban and environmental intelligence.
Summary updated