Querying an astronomical database using large language models: the ALeRCE text-to-SQL system

📄 arXiv: 2606.18108v1 📥 PDF

作者: P. A. Estevez, J. Espejo-Moreira, S. Sanfeliu-Alvarez, F. Forster, A. M. Munoz Arancibia, G. Cabrera-Vives, F. E. Bauer, A. Bayo, M. Catelan, R. Dastidar, L. Hernandez-Garcia, J. A. Intriago, G. Pignata

分类: astro-ph.IM, cs.AI

发布日期: 2026-06-16


💡 一句话要点

提出基于大语言模型的文本到SQL系统以查询天文数据库

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 文本到SQL 大语言模型 天文数据库 自然语言处理 查询生成 自我纠正 数据查询

📋 核心要点

  1. 现有的文本到SQL系统在处理复杂查询时常常面临性能下降的问题,尤其是在天文数据查询场景中。
  2. 本文提出了一种逐步生成框架,包含多个模块,旨在提高文本到SQL转换的准确性和可靠性。
  3. 实验结果显示,Claude Opus 4.6在简单查询中达到0.97的完美匹配率,复杂查询的性能也显著优于基线模型。

📝 摘要(中文)

本文开发了一种基于大语言模型(LLMs)的文本到SQL系统,利用上下文学习应用于自动学习快速分类事件(ALeRCE)天文数据库。该系统允许用户用自然语言查询数据库,并生成可执行的SQL查询。为评估系统性能,构建了110对自然语言与SQL的配对数据集。提出的逐步生成框架包括模式链接、查询分类、提示分解和自我纠正四个模块。实验结果表明,该框架在多种复杂性查询中均优于直接推断基线,且自我纠正模块有效减少了执行错误。

🔬 方法详解

问题定义:本文旨在解决现有文本到SQL系统在复杂查询中的性能不足,特别是在天文数据库查询场景下的挑战。现有方法在处理多样化和复杂的自然语言查询时,往往无法生成准确的SQL语句,导致查询失败或错误。

核心思路:论文提出的逐步生成框架通过将查询过程分解为多个模块,逐步提高生成SQL的准确性。通过这种方式,系统能够更好地理解用户的意图并生成相应的SQL查询。

技术框架:整体架构包括四个主要模块:模式链接(将自然语言与数据库模式关联)、查询分类(识别查询类型)、提示分解(将复杂查询分解为简单部分)和自我纠正(在生成后进行错误修正)。

关键创新:最重要的技术创新在于逐步生成框架的设计,使得系统能够在不同复杂度的查询中保持高性能。这种方法与传统的直接推断方法本质上不同,后者往往无法有效处理复杂查询。

关键设计:在实验中,使用了13种不同的LLM,并通过上下文学习和提示工程技术进行评估。关键参数包括完美匹配率(PM),用于评估行标识符和列标识符的准确性。

🖼️ 关键图片

fig_0
fig_1
fig_2

📊 实验亮点

实验结果表明,Claude Opus 4.6在简单查询中实现了0.97的完美匹配率,列标识符的匹配率为0.94。随着查询复杂度的增加,性能依然优于基线模型,显示出该系统在处理复杂查询时的有效性。

🎯 应用场景

该研究的潜在应用领域包括天文学数据分析、科学研究中的数据查询以及任何需要自然语言与数据库交互的场景。通过简化查询过程,用户能够更高效地获取所需信息,推动科学研究的进展。

📄 摘要(原文)

We develop a text-to-SQL (structured query language) system based on large language models (LLMs) using in-context learning and apply it to the Automatic Learning for the Rapid Classification of Events (ALeRCE) astronomical database. ALeRCE is a community broker for the Zwicky Transient Facility and the Vera C. Rubin Observatory. The system enables users to query the database in natural language (NL) and generates executable SQL queries. To develop and evaluate the system, we constructed a dataset of 110 NL/SQL pairs. We propose a step-by-step generation framework comprising four modules: schema linking, query classification, prompt decomposition, and self-correction. The performance of thirteen LLMs is evaluated using in-context learning and prompt engineering techniques. Text-to-SQL performance is assessed using the perfect-match (PM) rate for row identifiers (e.g., object identifiers) and column identifiers (i.e., column names). The proposed step-by-step framework consistently outperforms a direct-inference baseline, while the self-correction module consistently reduces execution errors. For Claude Opus 4.6, PM performance on row (column) identifiers is high for simple queries, reaching 0.97 (0.94), and decreases with query complexity to 0.44 (0.72) for medium queries and 0.59 (0.49) for hard queries. Among the thirteen evaluated models, the best-performing LLMs for the text-to-SQL task are Claude Opus 4.6, Gemini 2.5 Pro, Gemini 3 Flash, and GPT-5.2-Codex.