DIN-SQL: Decomposed In-Context Learning of Text-to-SQL with Self-Correction 论文阅读 NeurIPS 2023
论文贡献可以总结如下:
1. 通过任务分解提高基于LLM的文本到SQL模型的性能。
2. 引入针对任务复杂度的自适应提示策略。
3. 在提示的背景下解决模式链接挑战。
4. 使用LLM进行自我纠错。
整体架构图:
将问题分解成更小的子问题,解决每个子问题,并使用这些解决方案来构建原始问题的解决方案。
上述各个module基于prompt实现,下面是对各个module的展开。
-
Schema Linking Module:
Schema Linking负责在自然语言查询中识别对数据库模式和条件值的引用。
Prompt示例:
#Find the schema_links for generating SQL queries for each question based on the database schema and Foreign keys.
Table city, columns=[,City_ID,Official_Name,Status,Area_km_2,Population,Census_Ranking]
Table competition_record, columns = [*,Competition_ID,Farm_ID,Rank]
Table farm, columns = [*,Farm_ID,Year,Total_Horses,Working_Horses,
Total_Cattle,Oxen,Bulls,Cows,Pigs,Sheep_and_Goats]
Table farm_competition, columns = [*,Competition_ID,Year,Theme,H