arXiv:2502.16747cs.CLcs.AI2025-02中稿 · ACL被引 5

用合成数据增强长表结构,让大模型更懂复杂数据库查询

SQLong: Enhanced NL2SQL for Longer Contexts with LLMs

  • 通过添加合成表结构和数据,模拟长上下文场景
  • 在Spider和BIRD上微调后,性能显著优于标准数据集
  • 适合处理真实世界复杂数据库的NL2SQL应用

开放权重的大语言模型(LLMs)在自然语言转SQL(NL2SQL)任务中表现显著提升。然而,当数据库模式规模增大导致上下文变长时,其效果会下降。为解决此问题,我们提出SQLong,一种新颖且高效的數據增強框架,旨在提升LLM在长上下文下的NL2SQL性能。该方法通过在现有数据库模式中加入从训练数据中采样的合成CREATE TABLE命令及对应的数据行,生成增强数据集,从而在微调与评估阶段有效模拟长上下文场景。在Spider和BIRD数据集上的实验表明,使用SQLong增强数据微调的LLM性能显著优于基于标准数据集训练的模型。这证明了SQLong的实际可行性及其在复杂数据库场景下提升NL2SQL能力的潜力。

原文摘要 · Abstract (English)

Open-weight large language models (LLMs) have significantly advanced performance in the Natural Language to SQL (NL2SQL) task. However, their effectiveness diminishes when dealing with large database schemas, as the context length increases. To address this limitation, we present SQLong, a novel and efficient data augmentation framework designed to enhance LLM performance in long-context scenarios for the NL2SQL task. SQLong generates augmented datasets by extending existing database schemas with additional synthetic CREATE TABLE commands and corresponding data rows, sampled from diverse schemas in the training data. This approach effectively simulates long-context scenarios during finetuning and evaluation. Through experiments on the Spider and BIRD datasets, we demonstrate that LLMs finetuned with SQLong-augmented data significantly outperform those trained on standard datasets. These imply SQLong's practical implementation and its impact on improving NL2SQL capabilities in real-world settings with complex database schemas.

NL2SQL大模型数据增强长上下文

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