arXiv:2412.10434cs.CLcs.AI2024-12被引 15

用多智能体协作让大模型更准地把自然语言转成图数据库查询语句

NAT-NL2GQL: A Novel Multi-Agent Framework for Translating Natural Language to Graph Query Language

  • 设计三个协作智能体:预处理、生成、纠错,分工完成查询转换
  • 在金融图数据库上构建新数据集,实验显示准确率显著优于现有方法
  • 适合想做自然语言查图数据或开发智能数据库助手的研究者

大型语言模型(LLMs)的兴起已深刻影响多个领域,包括数据库研究。针对非关系型数据库中的图数据库,利用LLM将自然语言转化为图查询语言(NL2GQL)成为热点。尽管已有进展,但现有方法多依赖简化流程,忽视了LLM自主规划与协作的潜力。为此,我们提出NAT-NL2GQL——一种新型多智能体框架。该框架包含三个协同智能体:预处理器负责实体识别、查询重写、路径链接和模式提取;生成器是基于NL-GQL数据微调的LLM,生成对应GQL语句;纠错器根据执行结果反馈修正查询或上下文。由于高质量开源nGQL语法的NL2GQL数据集稀缺,我们构建了基于金融图数据库的StockGQL数据集,开源地址:https://github.com/leonyuancode/StockGQL。在StockGQL和SpCQL数据集上的实验表明,该方法显著优于基线模型,展现了其在推动NL2GQL研究方面的潜力。

原文摘要 · Abstract (English)

The emergence of Large Language Models (LLMs) has revolutionized many fields, not only traditional natural language processing (NLP) tasks. Recently, research on applying LLMs to the database field has been booming, and as a typical non-relational database, the use of LLMs in graph database research has naturally gained significant attention. Recent efforts have increasingly focused on leveraging LLMs to translate natural language into graph query language (NL2GQL). Although some progress has been made, these methods have clear limitations, such as their reliance on streamlined processes that often overlook the potential of LLMs to autonomously plan and collaborate with other LLMs in tackling complex NL2GQL challenges. To address this gap, we propose NAT-NL2GQL, a novel multi-agent framework for translating natural language to graph query language. Specifically, our framework consists of three synergistic agents: the Preprocessor agent, the Generator agent, and the Refiner agent. The Preprocessor agent manages data processing as context, including tasks such as name entity recognition, query rewriting, path linking, and the extraction of query-related schemas. The Generator agent is a fine-tuned LLM trained on NL-GQL data, responsible for generating corresponding GQL statements based on queries and their related schemas. The Refiner agent is tasked with refining the GQL or context using error information obtained from the GQL execution results. Given the scarcity of high-quality open-source NL2GQL datasets based on nGQL syntax, we developed StockGQL, a dataset constructed from a financial market graph database. It is available at: https://github.com/leonyuancode/StockGQL. Experimental results on the StockGQL and SpCQL datasets reveal that our method significantly outperforms baseline approaches, highlighting its potential for advancing NL2GQL research.

自然语言查询图数据库多智能体LLM应用

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