Valid Text-to-SQL Generation with Unification-based DeepStochLog

Ying Jiao, Luc De Raedt, Giuseppe Marra
3/17/2025
cs.CLcs.AI

Official code: ML-KULeuven/deepstochlog-lm (5 stars, Apache-2.0, last commit 2025-09-02).

Abstract

Large language models have been used to translate natural language questions to SQL queries. Without hard constraints on syntax and database schema, they occasionally produce invalid queries that are not executable. These failures limit the usage of these systems in real-life scenarios. We propose a neurosymbolic framework that imposes SQL syntax and schema constraints with unification-based definite clause grammars and thus guarantees the generation of valid queries. Our framework also builds a bi-directional interface to language models to leverage their natural language understanding abilities. The evaluation results on a subset of SQL grammars show that all our output queries are valid. This work is the first step towards extending language models with unification-based grammars. We demonstrate this extension enhances the validity, execution accuracy, and ground truth alignment of the underlying language model by a large margin. Our code is available at https://github.com/ML-KULeuven/deepstochlog-lm.

View on arXivView PDF

Code Implementations(1)

Apache-2.0

Repository for NeSy2024 paper Valid Text-to-SQL Generation with Unification-based DeepStochLog

51Prolog, PythonJul 16, 20241 years agoApache-2.0

Similar Papers

Cite this paper

@article{jiao2025valid,
  title  = {Valid Text-to-SQL Generation with Unification-based DeepStochLog},
  author = {Ying Jiao and Luc De Raedt and Giuseppe Marra},
  year   = {2025},
  eprint = {2503.13342},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2503.13342v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2503.13342.svg)](https://codeofpaper.com/paper/2503.13342)

Discussion