arXiv:2501.17174cs.DBcs.AI2025-01被引 17

用提取式方法高效精准定位文本转SQL所需数据库字段

Extractive Schema Linking for Text-to-SQL

  • 将解码器模型改造为提取式链接,只选相关表列
  • 在小上下文窗口下仍保持高准确率,比生成式快3倍以上
  • 适合对精度和速度都有要求的实时数据库查询系统

文本转SQL正成为真实数据库的实用接口。主流范式为跨库或无模式依赖,支持训练时未见的数据库结构。数据库模式包含表、列、列类型及表间外键关系。实际应用中,单个查询仅涉及模式中一小部分字段。将完整模式放入大模型提示词可能超出有限上下文窗口,即使足够也代价高昂。此外,聚焦相关部分可提升生成准确性。模式链接旨在识别问题相关的模式片段。此前工作使用图神经网络、生成式大模型和交叉编码器分类器。本文提出一种新方法,将仅解码器架构的大模型适配到提取式模式链接任务,计算效率更高且准确率优于生成式方法。该提取式方案还支持对链接精确率-召回率权衡的细粒度控制。

原文摘要 · Abstract (English)

Text-to-SQL is emerging as a practical interface for real world databases. The dominant paradigm for Text-to-SQL is cross-database or schema-independent, supporting application schemas unseen during training. The schema of a database defines the tables, columns, column types and foreign key connections between tables. Real world schemas can be large, containing hundreds of columns, but for any particular query only a small fraction will be relevant. Placing the entire schema in the prompt for an LLM can be impossible for models with smaller token windows and expensive even when the context window is large enough to allow it. Even apart from computational considerations, the accuracy of the model can be improved by focusing the SQL generation on only the relevant portion of the database. Schema linking identifies the portion of the database schema useful for the question. Previous work on schema linking has used graph neural networks, generative LLMs, and cross encoder classifiers. We introduce a new approach to adapt decoder-only LLMs to schema linking that is both computationally more efficient and more accurate than the generative approach. Additionally our extractive approach permits fine-grained control over the precision-recall trade-off for schema linking.

文本转SQL模式链接大模型应用

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