Text-to-SQL aims to translate natural language questions into executable SQL queries over relational databases. Despite the remarkable progress achieved by Large Language Models (LLMs), these systems still face challenges in capturing implicit semantic relationships between concepts expressed in user queries and database schema elements. To address this limitation, this thesis proposes an extension of a Text-to-SQL framework evaluated on the BIRD benchmark through the integration of a Knowledge Graph constructed from database schema information and subsequently enriched with additional semantic knowledge. In the first stage, a graph was generated from the structural information available in the databases of the BIRD development set, including tables, attributes, and relationships among entities. The graph was then expanded by incorporating semantic triples generated through an approach inspired by AutoSchemaKG, a framework that leverages Large Language Models for automated knowledge extraction and dynamic schema induction. The generated triples underwent refinement and validation processes to ensure their semantic consistency and quality. The resulting Knowledge Graph was integrated into the Text-to-SQL pipeline through a dedicated retrieval agent responsible for identifying semantic information relevant to the user's natural language question. This information is provided as additional context to the language model, complementing the traditional schema-linking mechanisms already employed by the framework. To ensure the quality and robustness of the constructed Knowledge Graph, a dedicated evaluation phase was conducted prior to its integration, employing appropriate graph-quality metrics alongside an LLM-as-a-Judge approach. Finally, the proposed end-to-end approach was evaluated on the BIRD benchmark by comparing the original system configuration with the semantically enhanced version. The experimental results indicate that incorporating semantic knowledge derived from a Knowledge Graph can improve domain understanding and support the generation of more accurate SQL queries, highlighting the potential of Knowledge Graphs as a complementary source of structured knowledge for LLM-based Text-to-SQL systems.

SEMANTIC KNOWLEDGE GRAPHS FOR TEXT-TO-SQL OPTIMIZATION: CONSTRUCTION, ENRICHMENT, AND EVALUATION

DE LEONARDIS, ANTONIO
2025/2026

Abstract

Text-to-SQL aims to translate natural language questions into executable SQL queries over relational databases. Despite the remarkable progress achieved by Large Language Models (LLMs), these systems still face challenges in capturing implicit semantic relationships between concepts expressed in user queries and database schema elements. To address this limitation, this thesis proposes an extension of a Text-to-SQL framework evaluated on the BIRD benchmark through the integration of a Knowledge Graph constructed from database schema information and subsequently enriched with additional semantic knowledge. In the first stage, a graph was generated from the structural information available in the databases of the BIRD development set, including tables, attributes, and relationships among entities. The graph was then expanded by incorporating semantic triples generated through an approach inspired by AutoSchemaKG, a framework that leverages Large Language Models for automated knowledge extraction and dynamic schema induction. The generated triples underwent refinement and validation processes to ensure their semantic consistency and quality. The resulting Knowledge Graph was integrated into the Text-to-SQL pipeline through a dedicated retrieval agent responsible for identifying semantic information relevant to the user's natural language question. This information is provided as additional context to the language model, complementing the traditional schema-linking mechanisms already employed by the framework. To ensure the quality and robustness of the constructed Knowledge Graph, a dedicated evaluation phase was conducted prior to its integration, employing appropriate graph-quality metrics alongside an LLM-as-a-Judge approach. Finally, the proposed end-to-end approach was evaluated on the BIRD benchmark by comparing the original system configuration with the semantically enhanced version. The experimental results indicate that incorporating semantic knowledge derived from a Knowledge Graph can improve domain understanding and support the generation of more accurate SQL queries, highlighting the potential of Knowledge Graphs as a complementary source of structured knowledge for LLM-based Text-to-SQL systems.
2025
SEMANTIC KNOWLEDGE GRAPHS FOR TEXT-TO-SQL OPTIMIZATION: CONSTRUCTION, ENRICHMENT, AND EVALUATION
LLM
Knowledge Graph
Text-To-SQL
File in questo prodotto:
Fulltext non presente su UNITESI – Verifica la disponibilità della tesi in formato cartaceo interrogando il Catalogo di Ateneo

I documenti in UNITESI sono protetti da copyright e tutti i diritti sono riservati, salvo diversa indicazione.

Utilizza questo identificativo per citare o creare un link a questo documento: https://hdl.handle.net/20.500.14253/78470