用历史SQL日志构建领域知识库,提升文本转SQL准确率
ORANGE: An Online Reflection ANd GEneration framework with Domain Knowledge for Text-to-SQL
- 从历史查询日志中提取领域知识,动态构建数据库专属知识库
- 在多个基准上显著提升复杂查询的翻译准确率,尤其适合专业场景
- 通过嵌套思维链跟踪元组语义,确保生成知识的可靠性
大型语言模型在自然语言转SQL任务中表现优异,但其通用知识与数据库的领域语义之间仍存在显著差距。历史翻译日志蕴含丰富的领域内知识,其中的SQL查询天然反映了数据库模式的实际使用模式。现有方法主要优化单次推理过程,却未能积累过往翻译中的领域知识。本文提出ORANGE,一种在线自进化框架,通过解析翻译日志中的SQL查询,构建数据库特定的知识库。通过累积包含模式与数据语义的领域知识,ORANGE逐步缩小语义差距,提升后续查询的准确性。为保障可靠性,我们提出一种新的嵌套思维链式SQL-to-Text策略,结合元组语义追踪,减少知识生成中的语义错误。多基准实验验证了ORANGE的实用性,证明其在真实场景下处理复杂、领域特定查询的有效性。
原文摘要 · Abstract (English)
Large Language Models (LLMs) have demonstrated remarkable progress in translating natural language to SQL, but a significant semantic gap persists between their general knowledge and domain-specific semantics of databases. Historical translation logs constitute a rich source of this missing in-domain knowledge, where SQL queries inherently encapsulate real-world usage patterns of database schema. Existing methods primarily enhance the reasoning process for individual translations but fail to accumulate in-domain knowledge from past translations. We introduce ORANGE, an online self-evolutionary framework that constructs database-specific knowledge bases by parsing SQL queries from translation logs. By accumulating in-domain knowledge that contains schema and data semantics, ORANGE progressively reduces the semantic gap and enhances the accuracy of subsequent SQL translations. To ensure reliability, we propose a novel nested Chain-of-Thought SQL-to-Text strategy with tuple-semantic tracking, which reduces semantic errors during knowledge generation. Experiments on multiple benchmarks confirm the practicality of ORANGE, demonstrating its effectiveness for real-world Text-to-SQL deployment, particularly in handling complex and domain-specific queries.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。