解耦结构与语义:模式表示如何影响基于大语言模型(LLM)的SQL生成
Disentangling Structure and Semantics: How Schema Representation Affects LLM-Based SQL Generation
浏览论文内容
中文总结 AI 辅助
本文通过6×3析因实验发现,基于LLM的文本转SQL中,语义线索对性能的影响大于结构线索,有意义的标识符可弥补结构缺失,而丰富结构元数据无法改善名称不明确的情况。
中文摘要 AI 辅助
基于LLM的文本转SQL流程将数据库模式作为文本读取,该模式同时包含结构线索(表、键、关系)和语义线索(表名与列名);现有研究均单独考察了这两个维度,未明确二者的影响程度是否相当、能否相互替代。本文提出一项受控的6×3析因设计,将结构层级L₁—L₆(从非规范化宽表到含外键与显式连接路径的第三范式(3NF)模式)与语义层级S₁—S₃(匿名、缩写、描述性标识符)交叉组合,在397条经修正的BIRD问题上开展评估,全程使用相同的标准答案;为支持最低结构层级,本文针对9个BIRD数据库生成了第一范式(1NF)与第二范式(2NF)变体。针对9个规模从0.5B到旗舰级的模型,研究发现两个维度间存在非对称替代关系:有意义的名称可弥补结构缺失,但当名称不明确时,更丰富的结构元数据无法恢复性能;该结果在9个数据库中的8个均成立,且随模型规模变化出现(3B以下可忽略)。在结构维度内,主导因素是规范化本身,而非3NF之上的元数据,这表明对于当前基于LLM的文本转SQL,实际瓶颈在于语义落地而非关系暴露。
英文摘要
LLM-based text-to-SQL pipelines read the database schema as text, which carries both structural cues (tables, keys, relationships) and semantic cues (table and column names); prior work has studied each axis in isolation, leaving open how they compare in magnitude and whether they substitute for one another. We present a controlled 6 times 3 factorial design crossing structural levels L_1--L_6 (from a denormalised wide table to a 3NF schema with foreign keys and explicit join paths) with semantic levels S_1--S_3 (anonymous, abbreviated, descriptive identifiers), evaluated on 397 corrected BIRD questions with identical gold queries throughout; we materialise 1NF and 2NF variants for nine BIRD databases to support the lowest structural levels. Across nine models from 0.5B to flagship scale we find an asymmetric substitution between the two axes, meaningful names compensate for missing structure but richer structural metadata does not recover performance when names are opaque, which reproduces in 8 of 9 databases and emerges with model scale (negligible below 3B). Within the structural axis the dominant lever is normalisation itself, not metadata layered on top of 3NF, suggesting that for current LLM-based text-to-SQL the practical bottleneck is semantic grounding rather than relational exposure.