作者投稿和查稿 主编审稿 专家审稿 编委审稿 远程编辑

计算机工程 ›› 2025, Vol. 51 ›› Issue (9): 129-138. doi: 10.19678/j.issn.1000-3428.0069410

• 人工智能与模式识别 • 上一篇    下一篇

基于关系感知图神经网络的Text-to-SQL方法

曹渝昆1,*(), 王天浩1, 李云峰2, 陈明1, 李晶晶1, 刘元旻1   

  1. 1. 上海电力大学计算机科学与技术学院, 上海 201306
    2. 中国商飞上海航空工业(集团)有限公司信息中心, 上海 201203
  • 收稿日期:2024-02-22 修回日期:2024-04-22 出版日期:2025-09-15 发布日期:2025-09-26
  • 通讯作者: 曹渝昆
  • 基金资助:
    国家自然科学基金(61802249)

Text-to-SQL Method Based on Relation-aware Graph Neural Network

CAO Yukun1,*(), WANG Tianhao1, LI Yunfeng2, CHEN Ming1, LI Jingjing1, LIU Yuanmin1   

  1. 1. College of Computer Science and Technology, Shanghai University of Electric Power, Shanghai 201306, China
    2. IT Center, COMAC Shanghai Aviation Industrial (Group) Co., Ltd., Shanghai 201203, China
  • Received:2024-02-22 Revised:2024-04-22 Online:2025-09-15 Published:2025-09-26
  • Contact: CAO Yukun

摘要:

Text-to-SQL语义解析任务旨在将自然语言问题转化为可执行的SQL语句。近年来, 许多研究将预训练模型等方法应用到该任务中, 并取得了一定的进展。然而, 现有的预训练模型没有针对Text-to-SQL任务进行重新训练, 不能很好地适应任务的场景语义特征信息, 从而影响模型的解析性能。同时, 许多方法还容易忽略自然语言问题与数据库模式间的关系, 造成解析过程中语义模糊的问题。为解决这些问题, 提出一种新的RGA-T5模型来完成Text-to-SQL语义解析任务。该模型在预训练模型T5中引入了关系感知异构图神经网络(HGNN), 将输入的实体与关系构建为异构图上的节点, 并通过应用图神经网络(GNN)实现模型对输入序列的语义关系感知。同时, 还提出空间门控适配器, 对其参数进行训练实现对预训练模型的微调, 使模型能够针对该任务适应不同场景下的语义特征信息, 减少无关信息的引入。实验结果表明, 该模型在Spider数据集上相较于其他先进的Text-to-SQL解析方法取得了一定程度的性能提升, 验证了所提方法的有效性。

关键词: 语义解析, 预训练模型, 异构图神经网络, 空间门控单元, 适配器

Abstract:

Text-to-SQL semantic parsing task aims to transform natural language problems into executable SQL statements. In recent years, many researchers have applied methods such as pre-training models to this task and have made some progress. However, because existing pre-training models are not re-trained for Text-to-SQL tasks, they cannot adapt well to the scene semantic feature information of the task, which affects the parsing performance of the models. At the same time, many methods are prone to ignoring the relationship between natural language questions and database schemes, which results in semantic ambiguities in the parsing process. To solve these problems, this paper proposes a new RGA-T5 model for Text-to-SQL semantic parsing, which introduces a relation-aware Heterogeneous Graph Neural Network (HGNN) into the pre-training model T5, constructs the input entities and relations as nodes on the heterogeneous graph, and realizes semantic relation-awareness of the input sequences of the model by applying the Graph Neural Network (GNN). Simultaneously, the method also proposes a spatial gating adapter, the parameters of which are trained to realize fine-tuning of the model so that the model can be adapted to the semantic feature information in different scenarios for this task and reduce the introduction of irrelevant information. The experimental results show that the proposed method improves the performance over other advanced Text-to-SQL parsing methods on the Spider dataset, thereby verifying the model's effectiveness.

Key words: semantic parse, pre-training model, Heterogeneous Graph Neural Network (HGNN), spatial gating unit, adapter