TACO: Token-Aware Context Optimization for Structured OpenStreetMap Query Generation
Open Access
- 24 September 2026
- journal article
- Published by Association for Computing Machinery (ACM) in Proceedings of the ACM on Management of Data
- Vol. 4 (4) , 1-27
Abstract
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.Keywords
Funding Information
- Research Grants Council of the Hong Kong Special Administrative Region, China (N_PolyU5179\/25)
- Research Grants Council of the Hong Kong Special Administrative Region, China (PolyU25600624)
- Innovation and Technology Fund (ITS\/052\/23MX)
- Innovation and Technology Fund (PRP\/009\/22FX)
- Innovation and Technology Fund (PRP\/004\/25FX)
- The Hong Kong Polytechnic University (P0058790)
This publication has 23 references indexed in Scilit:
- DataVisT5: A Pre-Trained Language Model for Jointly Understanding Text and Data Visualization2025
- prompt4vis: prompting large language models with example mining for tabular data visualizationThe VLDB Journal, 2025
- Natural Language Interfaces for Tabular Data Querying and Visualization: A SurveyIEEE Transactions on Knowledge and Data Engineering, 2024
- Metasql: A Generate-Then-Rank Framework for Natural Language to SQL Translation2024
- PURPLE: Making a Large Language Model a Better SQL Writer2024
- K2: A Foundation Language Model for Geoscience Knowledge Understanding and Utilization2024
- Few-shot Text-to-SQL Translation using Structure and Content Prompt LearningProceedings of the ACM on Management of Data, 2023
- Synthesizing Natural Language to Visualization (NL2VIS) Benchmarks from NL2SQL Benchmarks2021
- A note on maximizing a submodular set function subject to a knapsack constraintOperations Research Letters, 2004
- The budgeted maximum coverage problemInformation Processing Letters, 1999