用预定义函数替代直接生成SQL,提升核电数据查询的准确与可维护性。
Enhancing Accuracy and Maintainability in Nuclear Plant Data Retrieval: A Function-Calling LLM Approach Over NL-to-SQL
- 通过调用预审函数生成查询,避免直接生成不可验证的SQL。
- 相比传统NL-to-SQL,错误率显著降低,维护成本更可控。
- 适合对安全性要求高的工业系统,如核电站数据管理。
核电站运行数据检索因决策关键性,需极高准确性和透明度。传统自然语言转SQL(NL-to-SQL)虽易用,但用户难以验证生成的SQL,且老旧数据库结构复杂,导致查询生成困难,易出错,降低可信度。本文提出一种基于函数调用的大模型新范式:预先定义一组经审核的专用函数,代表常见查询场景。查询通过调用这些函数执行,其内部封装已验证的SQL逻辑。该方法在保证安全的前提下,由专家提前审查和优化函数代码,而非现场生成。尽管需投入资源构建函数库,但可借助NL-to-SQL工具辅助生成初始代码,使专家专注验证。实验对比显示,该方法在准确性和可维护性上优于直接生成。本研究强调了可用性与安全性的平衡,为关键系统提供了可落地的数据检索框架。
原文摘要 · Abstract (English)
Retrieving operational data from nuclear power plants requires exceptional accuracy and transparency due to the criticality of the decisions it supports. Traditionally, natural language to SQL (NL-to-SQL) approaches have been explored for querying such data. While NL-to-SQL promises ease of use, it poses significant risks: end-users cannot easily validate generated SQL queries, and legacy nuclear plant databases -- often complex and poorly structured -- complicate query generation due to decades of incremental modifications. These challenges increase the likelihood of inaccuracies and reduce trust in the approach. In this work, we propose an alternative paradigm: leveraging function-calling large language models (LLMs) to address these challenges. Instead of directly generating SQL queries, we define a set of pre-approved, purpose-specific functions representing common use cases. Queries are processed by invoking these functions, which encapsulate validated SQL logic. This hybrid approach mitigates the risks associated with direct NL-to-SQL translations by ensuring that SQL queries are reviewed and optimized by experts before deployment. While this strategy introduces the upfront cost of developing and maintaining the function library, we demonstrate how NL-to-SQL tools can assist in the initial generation of function code, allowing experts to focus on validation rather than creation. Our study includes a performance comparison between direct NL-to-SQL generation and the proposed function-based approach, highlighting improvements in accuracy and maintainability. This work underscores the importance of balancing user accessibility with operational safety and provides a novel, actionable framework for robust data retrieval in critical systems.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。