arXiv:2605.10318cs.CL2026-05被引 2

通过语法和模式过滤提升自然语言转Cypher查询的可靠性

Extending Confidence-Based Text2Cypher with Grammar and Schema Aware Filtering

论文配图:Extending Confidence-Based Text2Cypher with Grammar and Schema Aware Filtering
图 1 · 摘自论文原文
  • 测试时引入语法与数据库结构双重校验,增强查询正确性
  • 语法过滤使语法有效率提升,模式过滤显著改善执行成功率
  • 适合关注数据库查询生成可靠性的研究者和开发者

大型语言模型(LLMs)可通过将自然语言问题转换为可执行查询,实现用户对数据库的自然语言访问。尽管在Text2SQL、Text2SPARQL和Text2Cypher等任务上取得进展,多数方法仍聚焦于提示优化、微调或迭代修正,但往往未显式施加结构约束(如语法合法性与模式一致性)。这会降低生成查询的可靠性,因查询必须同时满足语法规则与数据库结构要求才能执行。本文研究如何在测试阶段利用结构约束改进Text2Cypher生成。我们扩展了一种基于置信度的推理框架,引入序列化过滤流程:结合置信度评分、语法验证与模式约束,在最终聚合前进行筛选。实验使用两个指令微调模型表明,语法过滤可提高语法有效性;模式感知过滤进一步提升执行质量。然而更强过滤也导致空预测增多、执行覆盖率下降。结果表明,测试时加入简单结构检查可显著提升生成可靠性,并揭示了语法与模式约束对性能的不同影响。

原文摘要 · Abstract (English)

Large language models (LLMs) allow users to query databases using natural language by translating questions into executable queries. Despite strong progress on tasks such as Text2SQL, Text2SPARQL, and Text2Cypher, most existing methods focus on better prompting, fine-tuning, or iterative refinement. However, they often do not explicitly enforce structural constraints, such as syntactic validity and schema consistency. This can reduce reliability, since generated queries must satisfy both syntax rules and database schema constraints to be executable. In this work, we study how structured constraints can be used in test-time inference for Text2Cypher. We focus on post-generation validation to improve query correctness. We extend a confidence-based inference framework with a sequential filtering process that combines confidence scoring, grammar validation, and schema constraints before final aggregation. This lets us analyze how different constraint types affect generated queries. Our experiments with two instruction-tuned models show that grammar-based filtering improves syntactic validity. Schema-aware filtering further improves execution quality by enforcing consistency with the database structure. However, stronger filtering also increases the number of empty predictions and reduces execution coverage. Overall, we show that adding simple structural checks at test time improves the reliability of Text2Cypher generation, and we provide a clearer view of how syntax and schema constraints contribute differently.

文本转查询图数据库可靠性提升语法约束

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