Uma Abordagem Baseada em Grafos de Conhecimento para Consulta a Bancos de Dados Relacionais em Linguagem Natural

Resumo


Embora os Grandes Modelos de Linguagem (LLMs) tenham impulsionado avanços em interfaces em linguagem natural para bancos de dados, a tarefa NL2SQL ainda sofre com ambiguidades semânticas e consultas complexas. Neste trabalho, propomos o uso de Grafos de Conhecimento (GCs) como representação semântica de um esquema relacional, integrados a LLMs para apoiar a geração de consultas SQL. A abordagem inclui a construção automática de GCs, estratégias de Prompt Engineering e um mecanismo de refinamento automático baseado em falhas de execução. Em uma avaliação preliminar sobre um subconjunto de 36 domínios do benchmark Spider, a abordagem alcançou 95,34% de acurácia de execução. Os resultados indicam o potencial da integração GCs-LLMs para aumentar a robustez em NL2SQL.
Palavras-chave: NL2SQL, Grafos de Conhecimento, Grandes Modelos de Linguagem, Bancos de Dados Relacionais

Referências

Campêlo, R. A., Laender, A. H. F., and Da Silva, A. S. (2023). Using Knowledge Graphs to Generate SQL Queries from Textual Specifications. In Sales, T. P., Araújo, J., Borbinha, J., and Guizzardi, G., editors, Advances in Conceptual Modeling, volume 14319, pages 85–94. Springer Nature Switzerland, Cham. Series Title: Lecture Notes in Computer Science.

Dong, X., Zhang, C., Ge, Y., Mao, Y., Gao, Y., Chen, l., Lin, J., and Lou, D. (2023). C3: Zero-shot Text-to-SQL with ChatGPT. Version Number: 1.

Fensel, D., Şimşek, U., Angele, K., Huaman, E., Kärle, E., Panasiuk, O., Toma, I., Umbrich, J., and Wahler, A. (2020). Knowledge Graphs: Methodology, Tools and Selected Use Cases. Springer International Publishing, Cham.

Gao, D., Wang, H., Li, Y., Sun, X., Qian, Y., Ding, B., and Zhou, J. (2024). Text-to-SQL Empowered by Large Language Models: A Benchmark Evaluation. Proceedings of the VLDB Endowment, 17(5):1132–1145.

Kim, H., So, B.-H., Han, W.-S., and Lee, H. (2020). Natural language to SQL: where are we today? Proceedings of the VLDB Endowment, 13(10):1737–1750.

Liu, X., Shen, S., Li, B., Ma, P., Jiang, R., Zhang, Y., Fan, J., Li, G., Tang, N., and Luo, Y. (2024). A Survey of Text-to-SQL in the Era of LLMs: Where are we, and where are we going? Version Number: 6.

Nascimento, E. R., Avila, C. V. S., Izquierdo, Y. T., García, G. M., Andrade, L. F. L., Silva, M. O., Facina, M. S. P., Lemos, M., and Casanova, M. A. (2026). A Text-to-SQL strategy based on large language models and knowledge graphs for real-world databases. Data & Knowledge Engineering, 164:102580.

Pourreza, M. and Rafiei, D. (2023). DIN-SQL: Decomposed In-Context Learning of Text-to-SQL with Self-Correction. In Oh, A., Naumann, T., Globerson, A., Saenko, K., Hardt, M., and Levine, S., editors, Advances in Neural Information Processing Systems, volume 36, pages 36339–36348. Curran Associates, Inc.

Renze, M. (2024). The Effect of Sampling Temperature on Problem Solving in Large Language Models. In Findings of the Association for Computational Linguistics: EMNLP 2024, pages 7346–7356, Miami, Florida, USA. Association for Computational Linguistics.

Xu, W., Zhu, H., Yan, L., Liu, C., Han, P., Duan, S., and Pan, J. Z. (2025). TS-SQL: Test-driven Self-refinement for Text-to-SQL. In Christodoulopoulos, C., Chakraborty, T., Rose, C., and Peng, V., editors, Findings of the Association for Computational Linguistics: EMNLP 2025, pages 2864–2889, Suzhou, China. Association for Computational Linguistics.

Yu, T., Zhang, R., Yang, K., Yasunaga, M., Wang, D., Li, Z., Ma, J., Li, I., Yao, Q., Roman, S., Zhang, Z., and Radev, D. (2018). Spider: A Large-Scale Human-Labeled Dataset for Complex and Cross-Domain Semantic Parsing and Text-to-SQL Task. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pages 3911–3921, Brussels, Belgium. Association for Computational Linguistics.

Zhang, H., Cao, R., Chen, L., Xu, H., and Yu, K. (2023). ACT-SQL: In-Context Learning for Text-to-SQL with Automatically-Generated Chain-of-Thought. In Bouamor, H., Pino, J., and Bali, K., editors, Findings of the Association for Computational Linguistics: EMNLP 2023, pages 3501–3532, Singapore. Association for Computational Linguistics.
Publicado
08/09/2026
CAMPÊLO, Robson A.; LAENDER, Alberto H. F.; DA SILVA, Altigran S.. Uma Abordagem Baseada em Grafos de Conhecimento para Consulta a Bancos de Dados Relacionais em Linguagem Natural. In: SIMPÓSIO BRASILEIRO DE BANCO DE DADOS (SBBD), 41. , 2026, São Carlos/SP. Anais [...]. Porto Alegre: Sociedade Brasileira de Computação, 2026 . p. 770-776. ISSN 2763-8979. DOI: https://doi.org/10.5753/sbbd.2026.249341.