An Orchestrated, Safety-Constrained LLM Pipeline for Querying Relational Databases and Natural-Language Summarization: Extending to Graph-Augmented Verifiability
This paper presents a comprehensive, production-oriented framework that enables Large Language Models (LLMs) to safely query relational databases and generate natural-language summaries of results. Unlike traditional Text-to-SQL approaches, the proposed system emphasizes enterprise-grade safety, verifiability, and correctness by integrating multi-layered safeguards, schema-aware reasoning, and graph-validated planning. The framework introduces a novel Graph-Constrained Chain-of-Thought (GC-CoT) module that compels LLMs to generate explicit join plans rooted in a knowledge graph representation of the database schema. A deterministic Graph Validator Module (GVM) verifies these plans, preventing hallucinated relationships and ensuring semantically valid SQL generation. The system further incorporates a Trusted Execution Grammar, AST-based SQL validation, schema summarization, sampling, and multi-dialect strategy abstraction to guarantee secure, read-only execution across heterogeneous database engines. Extensive evaluations on enterprise datasets and public benchmarks (Spider, BIRD) demonstrate substantial improvements in execution accuracy, semantic correctness, safety, and reliability compared with baseline LLM-only or pruning-based approaches. The paper also provides a detailed threat model, cost/latency optimization strategies, multimodal extensions, and implementation guidelines suitable for real-world deployment in data-intensive enterprises.
Publication Details
- Journal
- Zenodo (CERN European Organization for Nuclear Research)
- Published
- 2025-11-23
- DOI
- https://doi.org/10.5281/zenodo.17686958
- Primary Topic
- Graph Theory and Algorithms
- Type
- article
- Field-Weighted Citation Impact
- 0.00