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.


翻译:大语言模型(LLMs)允许用户通过将自然语言问题转换为可执行查询来查询数据库。尽管在Text2SQL、Text2SPARQL和Text2Cypher等任务上取得了显著进展,但现有方法大多侧重于改进提示工程、微调或迭代优化。然而,这些方法通常未显式强制结构约束(如语法有效性和模式一致性),这可能降低可靠性——因为生成的查询必须同时满足语法规则和数据库模式约束才能执行。本研究探讨了如何在Text2Cypher的测试时推理中应用结构约束,重点通过生成后验证提升查询正确性。我们扩展了一个基于置信度的推理框架,引入顺序过滤流程,在最终聚合前结合了置信度评分、语法验证和模式约束。这使得我们能够分析不同类型约束对生成查询的影响。基于两个指令微调模型的实验表明:基于语法的过滤可提升句法有效性;模式感知过滤通过强制与数据库结构的一致性进一步提高执行质量。然而,更强的过滤也会导致空预测数量增加并降低执行覆盖率。总体而言,本研究证明了在测试时添加简单结构检查可提升Text2Cypher生成的可靠性,并清晰阐释了语法约束与模式约束的差异化贡献。

0
下载
关闭预览

相关内容

大型语言模型的高效提示方法综述
专知会员服务
75+阅读 · 2024年4月2日
自然语言处理中的语言模型预训练方法
PaperWeekly
14+阅读 · 2018年10月21日
深度学习文本分类方法综述(代码)
中国人工智能学会
28+阅读 · 2018年6月16日
TextInfoExp:自然语言处理相关实验(基于sougou数据集)
全球人工智能
12+阅读 · 2017年11月12日
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
国家自然科学基金
5+阅读 · 2014年12月31日
国家自然科学基金
6+阅读 · 2014年12月31日
国家自然科学基金
3+阅读 · 2014年12月31日
国家自然科学基金
11+阅读 · 2012年12月31日
VIP会员
最新内容
定向能反无人机系统最新发展动态
专知会员服务
0+阅读 · 19分钟前
从燃煤战舰到算法战争:水面指挥的永恒要求
专知会员服务
0+阅读 · 36分钟前
《通过小型无人机系统将情报能力“作战化”》
消耗优势:美军的“精确规模化”概念
专知会员服务
8+阅读 · 6月15日
相关基金
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
国家自然科学基金
5+阅读 · 2014年12月31日
国家自然科学基金
6+阅读 · 2014年12月31日
国家自然科学基金
3+阅读 · 2014年12月31日
国家自然科学基金
11+阅读 · 2012年12月31日
Top
微信扫码咨询专知VIP会员