自研模型内化数据库结构,大幅降低文本转SQL的调用成本
Schema on the Inside: A Two-Phase Fine-Tuning Method for High-Efficiency Text-to-SQL at Scale
- 分两阶段微调让模型记住数据库模式,无需长提示
- 输入token减少99%以上,执行成功率98.4%
- 适合高并发场景下的本地化文本转SQL应用
将大型专有API语言模型应用于文本转SQL任务面临显著行业挑战:依赖大量带模式的提示导致每字词的API成本高昂且延迟高,阻碍大规模生产部署。我们提出一种专用于对话机器人的自托管80亿参数模型,服务于印度最大幻想体育平台Dream11的姊妹应用CriQ,可回答用户关于板球统计数据的查询。其创新的两阶段监督微调方法使模型能够内化整个数据库模式,无需长上下文提示。输入令牌数从17,000降至不足100,降幅超99%,并以高效本地推理替代昂贵的外部API调用。系统实现98.4%的执行成功率和92.5%的语义准确率,显著优于使用Google Gemini Flash 2.0的提示工程基线(95.6%执行率,89.4%语义准确率)。该结果展示了在大规模生产环境中,使用领域专用、自托管语言模型实现高精度、低延迟文本转SQL应用的可行路径。
原文摘要 · Abstract (English)
Applying large, proprietary API-based language models to text-to-SQL tasks poses a significant industry challenge: reliance on massive, schema-heavy prompts results in prohibitive per-token API costs and high latency, hindering scalable production deployment. We present a specialized, self-hosted 8B-parameter model designed for a conversational bot in CriQ, a sister app to Dream11, India's largest fantasy sports platform with over 250 million users, that answers user queries about cricket statistics. Our novel two-phase supervised fine-tuning approach enables the model to internalize the entire database schema, eliminating the need for long-context prompts. This reduces input tokens by over 99%, from a 17k-token baseline to fewer than 100, and replaces costly external API calls with efficient local inference. The resulting system achieves 98.4% execution success and 92.5% semantic accuracy, substantially outperforming a prompt-engineered baseline using Google's Gemini Flash 2.0 (95.6% execution, 89.4% semantic accuracy). These results demonstrate a practical path toward high-precision, low-latency text-to-SQL applications using domain-specialized, self-hosted language models in large-scale production environments.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。