Infusing Prompts with Syntax and Semantics

Anton Bulle Labate, Fábio Gagliardi CozmanarXiv 2024 · DOI · arXiv

Abstract

Translating natural language questions into SQL queries (NL2SQL) remains a significant challenge for Large Language Models (LLMs), particularly in low-resource linguistic environments. This paper presents a novel "linguistic infusion" prompting strategy that explicitly incorporates syntactic dependency trees and semantic Abstract Meaning Representation (AMR) into model prompts. Our findings demonstrate that this approach significantly improves performance for languages such as Portuguese and French, allowing smaller encoder-decoder models to surpass previous state-of-the-art results while achieving up to a fourfold increase in training efficiency.

Introduction

While Large Language Models (LLMs) have demonstrated remarkable capabilities in code generation, they often struggle with complex linguistic structures in NL2SQL tasks. These "failure modes" typically arise from a misunderstanding of how modifiers relate to nouns or how various clauses interact within a sentence. This problem is exacerbated in non-English languages where models have less exposure to native linguistic rules during pre-training.

Traditionally, addressing these gaps required architectural modifications or the curation of massive multilingual datasets—both of which are computationally prohibitive. This study proposes a lighter, more efficient alternative: enriching the input prompt with explicit linguistic metadata.

Methodology

The proposed pipeline requires no changes to the underlying model architecture, making it highly adaptable. The process follows a structured four-step workflow:

  1. Parsing: Input questions are processed through external linguistic tools (e.g., Spacy for syntax and amrlib for semantics).
  2. Syntactic Infusion: Core relations such as subjects, objects, and conjunctions are extracted from dependency trees and linearized into a simplified text string.
  3. Semantic Infusion: The sentence's underlying meaning is captured using Abstract Meaning Representation (AMR), which identifies "who is doing what to whom" regardless of specific phrasing. This graph is then linearized.
  4. Concatenation and Execution: The raw question and the linguistic strings are bundled into a single prompt and fed into the RESDSQL framework, utilizing a RoBERTa encoder for schema linking and a T5 or Bart model for query generation.
Figure 1: The linguistic infusion pipeline, showing the integration of parsed syntactic and semantic data into the model prompt.

Experimental Setup and Datasets

The methodology was evaluated using the Spider benchmark, the industry standard for NL2SQL. To test cross-lingual robustness, the researchers utilized:

  • Spider (English): The baseline high-resource dataset.
  • CSpider (Chinese): A manually verified translation.
  • Romance Languages: Automatically translated versions of Spider for French, Portuguese, and Spanish, which underwent manual quality reviews.

Key Results

The infusion of linguistic information led to new state-of-the-art (SOTA) results for Portuguese and French. Specifically, the researchers reported Exact Match (EM) scores of 0.752 for Portuguese and 0.749 for French, significantly outperforming previous benchmarks.

As shown in the comparative data, the addition of syntax and AMR consistently improves performance across different model architectures (T5 and Bart) and languages. Notably, for the Bart model in Portuguese, the inclusion of these features dramatically increased execution accuracy during the early stages of training.

Figure 2: Comparative performance metrics (EM, EX, vEM, vEX) for T5 and Bart models across French, Spanish, and Portuguese.

Discussion and Insights

The Data-Linguistic Trade-off

A primary insight from this research is the inverse relationship between available training data and the utility of explicit linguistic rules. In high-resource languages like English, models "absorb" syntax through sheer volume. In low-resource scenarios, providing a linguistic "cheat sheet" in the prompt effectively fills this knowledge gap.

Training Efficiency

Linguistic infusion acts as a powerful catalyst for model convergence. Models trained with syntax and semantics for only 32 epochs frequently outperformed baseline models trained for 128 epochs. This represents a substantial reduction in the computational resources required to deploy high-performing NL2SQL systems.

Semantics vs. Syntax

Across most experiments, semantic information (AMR) provided a more significant performance boost than syntactic dependency trees. This suggests that capturing the abstract intent of a query is more beneficial for SQL generation than understanding the specific grammatical structure of the input sentence.

Conclusion

Explicitly infusing prompts with syntactic and semantic metadata provides a robust and efficient pathway for improving NL2SQL performance in low-resource languages. By bridging the gap between natural language and structured queries through external linguistic parsers, researchers can achieve SOTA results with smaller models and significantly less training time. Future work will explore the application of these prompting patterns to decoder-only architectures and broader NLP tasks.

Summary updated

BibTeX
@misc{labate2024infusing,
  author = {Anton Bulle Labate and Fábio Gagliardi Cozman},
  title = {{Infusing Prompts with Syntax and Semantics}},
  year = {2024},
  eprint = {2412.06107},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2412.06107},
}
Figure