ViR²: Beam-guided semantic and syntactic example selection for prompting Vietnamese Text-to-SQL

Authors

  • Dinh Minh Hoa
  • Tran Thien Khai*

Abstract

Text-to-Structured Query Language (SQL) enables natural language interfaces to databases, yet its performance in low-resource languages such as Vietnamese is limited due to scarce annotated data and translation noise. Existing few-shot prompting methods for large language models (LLMs) typically rely on semantic similarity or random sampling, which often results in redundant or syntactically misaligned in-context examples. To address this limitation, we propose Vietnamese Intelligent Retrieval and Re-ranking (ViR²), a two-stage, unsupervised example selection framework that first performs semantic retrieval and then applies beam-guided re-ranking to jointly optimise syntactic alignment and intra-set diversity. ViR² is fully language-agnostic and schema-free, making it suitable for low-resource and cross-lingual Text-to-SQL scenarios. Experiments on ViText2SQL demonstrate that ViR² achieves 23.33% Exact Match (EM) and 87.83% component-level F1, outperforming Random, Skill-KNN, ASTRES, and DICL by up to 5 EM points. Ablation studies confirm that Part of Speech (POS) -based syntactic re-ranking and beam search are the principal contributors to performance gains, while maintaining practical single query latency. By combining semantic relevance with syntactic diversity optimisation, ViR² provides a robust and extensible approach for few-shot Text-to-SQL in low-resource and multilingual environments.

Keywords:

beam-guided re-ranking, example selection, few-shot prompting, low-resource languages, Text-to-SQL

DOI:

https://doi.org/10.31276/VJSTE.2025.0089

Classification number

1.2, 1.3

Author Biographies

Dinh Minh Hoa

Faculty of Information Technology, Ho Chi Minh City University of Technology, 475A Dien Bien Phu Street, Thanh My Tay Ward, Ho Chi Minh City, Vietnam

Faculty of Information Technology, Ho Chi Minh City University of Foreign Languages - Information Technology, 828 Su Van Hanh Street, Hoa Hung Ward, Ho Chi Minh City, Vietnam

Tran Thien Khai

Faculty of Information Technology, Ho Chi Minh City University of Industry and Trade, 140 Le Trong Tan Street, Tay Thanh Ward, Ho Chi Minh City, Vietnam

Downloads

Published

2026-07-17

Received 7 November 2025; revised 4 February 2026; accepted 26 February 2026

How to Cite

Dinh Minh Hoa, & Tran Thien Khai. (2026). ViR²: Beam-guided semantic and syntactic example selection for prompting Vietnamese Text-to-SQL. Vietnam Journal of Science, Technology and Engineering. https://doi.org/10.31276/VJSTE.2025.0089

Issue

Section

Mathematics and Computer Science