arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2605.10318cs.CL
收藏

基于语法和模式意识的文本到Cypher扩展

Extending Confidence-Based Text2Cypher with Grammar and Schema Aware Filtering

Neo4j(Neo4j公司)

Makbule Gulcin Ozsoy

AI总结:

本文研究如何在文本到Cypher推理中利用结构约束提高查询正确性,通过扩展置信度框架加入序列过滤过程,结合置信度评分、语法验证和模式约束,提升生成查询的可靠性。

摘要:

大型语言模型(LLMs)允许用户通过自然语言查询数据库,将问题转换为可执行查询。尽管在文本到SQL、文本到SPARQL和文本到Cypher任务上取得了显著进展,但大多数现有方法集中在更好的提示、微调或迭代细化上。然而,它们往往没有显式地施加结构约束,如语法有效性和模式一致性。这会降低可靠性,因为生成的查询必须满足语法规则和数据库模式约束才能执行。在本文中,我们研究如何在测试时间推理中使用结构约束进行文本到Cypher。我们专注于生成后验证以提高查询正确性。我们扩展了一个基于置信度的推理框架,加入一个序列过滤过程,结合置信度评分、语法验证和模式约束,在最终聚合前进行。这使我们能够分析不同约束类型如何影响生成查询。我们的实验表明,基于语法的过滤提高了语法有效性,模式意识的过滤进一步通过强制与数据库结构的一致性提高了执行质量。然而,更强的过滤也增加了空预测的数量并减少了执行覆盖范围。总体而言,我们展示了在测试时间添加简单的结构检查如何提高文本到Cypher生成的可靠性,并提供了语法和模式约束如何以不同方式贡献的更清晰视角。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑