arXiv:2509.21674cs.DBcs.AI2025-09AAAI

让大模型一步步推理数据库查询,透明可控。

QueryGym: Step-by-Step Interaction with Relational Databases

  • 要求模型分步执行关系代数操作,确保可解释性
  • 提供表预览、列采样等交互动作,支持动态探索
  • 适合研究错误修复、强化学习查询生成的科研人员

我们提出 QueryGym,一个用于构建、测试和评估基于大模型的查询规划代理的交互式环境。现有框架常将代理绑定于特定查询语言方言或隐藏其推理过程;QueryGym 要求代理显式构造关系代数操作序列,实现与引擎无关的评估和透明的逐步规划。该环境以 Gymnasium 接口实现,提供包括模式信息、中间结果和执行反馈在内的观测信号,并接收代表数据库探索(如预览表、采样列值、获取唯一值)及关系代数操作(如过滤、投影、连接)的动作。我们阐述了设计动机与系统架构。在演示中,通过对比当前主流大模型的数据库查询方式,展示了该环境的实用性。QueryGym 可作为错误修复、透明性研究及查询生成强化学习的实用测试平台。相关演示见 https://ibm.biz/QueryGym。

原文摘要 · Abstract (English)

We introduce QueryGym, an interactive environment for building, testing, and evaluating LLM-based query planning agents. Existing frameworks often tie agents to specific query language dialects or obscure their reasoning; QueryGym instead requires agents to construct explicit sequences of relational algebra operations, ensuring engine-agnostic evaluation and transparent step-by-step planning. The environment is implemented as a Gymnasium interface that supplies observations -- including schema details, intermediate results, and execution feedback -- and receives actions that represent database exploration (e.g., previewing tables, sampling column values, retrieving unique values) as well as relational algebra operations (e.g., filter, project, join). We detail the motivation and the design of the environment. In the demo, we showcase the utility of the environment by contrasting it with contemporary LLMs that query databases. QueryGym serves as a practical testbed for research in error remediation, transparency, and reinforcement learning for query generation. For the associated demo, see https://ibm.biz/QueryGym.

大模型数据库推理

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