arXiv:2506.12234cs.DBcs.AI2025-06被引 1

用自然语言生成准确SQL,无需懂数据库

Datrics Text2SQL: A Framework for Natural Language to SQL Query Generation

  • 基于检索增强生成,结合文档和示例构建知识库
  • 通过语义检索获取上下文,生成语法正确且语义匹配的SQL
  • 适合非技术人员快速查询数据库,提升数据访问效率

Text-to-SQL系统使用户能用自然语言查询数据库,降低数据分析门槛。但面临歧义表述、领域术语和复杂模式关系等挑战。本文提出Datrics Text2SQL,一种基于检索增强生成(RAG)的框架,通过整合数据库文档、问答示例构建知识库,并将其转化为向量嵌入,按语义相似度检索。系统利用检索到的上下文生成语法正确、语义一致的SQL代码。论文详述了架构设计、训练方法与检索逻辑,展示了如何在不依赖SQL知识的情况下,实现用户意图与数据库结构之间的精准对齐。

原文摘要 · Abstract (English)

Text-to-SQL systems enable users to query databases using natural language, democratizing access to data analytics. However, they face challenges in understanding ambiguous phrasing, domain-specific vocabulary, and complex schema relationships. This paper introduces Datrics Text2SQL, a Retrieval-Augmented Generation (RAG)-based framework designed to generate accurate SQL queries by leveraging structured documentation, example-based learning, and domain-specific rules. The system builds a rich Knowledge Base from database documentation and question-query examples, which are stored as vector embeddings and retrieved through semantic similarity. It then uses this context to generate syntactically correct and semantically aligned SQL code. The paper details the architecture, training methodology, and retrieval logic, highlighting how the system bridges the gap between user intent and database structure without requiring SQL expertise.

Text2SQL自然语言数据库RAG

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。