DOI: 10.1145/3837126 ISSN: 2836-6573

TACO: Token-Aware Context Optimization for Structured OpenStreetMap Query Generation

Zhuoyue Wan, Wentao Hu, Hwanhee Kim, Chen Jason Zhang, Shuaimin Li, Yuanfeng Song, Ming Deng, Xiao-Yong Wei, Raymond Chi-Wing Wong

Generating executable structured queries for OpenStreetMap (OSM) from natural language remains a challenging task due to the rigid syntax of OverpassQL and the steep learning curve it presents to end-users. While steering Large Language Models (LLMs) via demonstration contexts offers a promising solution, existing retrieval-based approaches typically neglect the critical constraint of token budgets. This oversight often leads to prohibitive inference costs and ignores the combinatorial nature of context selection, resulting in suboptimal performance. Furthermore, the lack of reliable benchmarks hinders rigorous evaluation in this domain.

To address these challenges, we first introduce OsmNL , a robust benchmark curated via a human-in-the-loop pipeline to resolve alignment noise in prior datasets. Building upon this foundation, we formulate the construction of optimal demonstration contexts under constraints as a Budgeted Example Subset Mining ( BESM ) problem. We analyze BESM as an NP-hard optimization task that admits a submodular objective, theoretically balancing semantic relevance with structural diversity. Leveraging this property, we propose TACO (

T
oken-
A
ware
C
ontext
O
ptimization), a principled framework that instantiates a family of budget-aware algorithms to navigate the trade-off between approximation guarantees and computational efficiency. Extensive experiments on OsmNL show that TACO establishes a new state-of-the-art, achieving superior accuracy compared to strong baselines while reducing token consumption by over 50%, thereby offering a robust and cost-efficient solution for large-scale geospatial query interfaces.