通过筛选相关模式提升文本转图数据库查询的准确率与效率
Enhancing Text2Cypher with Schema Filtering
- 仅保留查询相关的数据库模式元素,减少无关信息干扰
- 显著降低提示词长度与生成成本,尤其对小模型效果更明显
- 适合资源受限场景或追求低成本部署的应用者
知识图谱通过节点、关系和属性表示复杂数据。Cypher 是图数据库的强大查询语言,支持高效建模与查询。近年来,大语言模型使自然语言问题到 Cypher 查询的转换成为可能——即 Text2Cypher。常见做法是将数据库模式纳入提示词,但复杂模式会引入噪声、增加幻觉并提高计算开销。模式筛选通过仅包含相关模式元素,提升了查询生成效果并降低令牌消耗。本文探讨了多种用于 Text2Cypher 的模式筛选方法,并分析其对令牌长度、性能与成本的影响。结果表明,模式筛选能有效优化 Text2Cypher,尤其在小模型上表现突出。与以往研究一致,大模型因具备更长上下文能力,受益较少,但模式筛选仍可为其节省成本。
原文摘要 · Abstract (English)
Knowledge graphs represent complex data using nodes, relationships, and properties. Cypher, a powerful query language for graph databases, enables efficient modeling and querying. Recent advancements in large language models allow translation of natural language questions into Cypher queries - Text2Cypher. A common approach is incorporating database schema into prompts. However, complex schemas can introduce noise, increase hallucinations, and raise computational costs. Schema filtering addresses these challenges by including only relevant schema elements, improving query generation while reducing token costs. This work explores various schema filtering methods for Text2Cypher task and analyzes their impact on token length, performance, and cost. Results show that schema filtering effectively optimizes Text2Cypher, especially for smaller models. Consistent with prior research, we find that larger models benefit less from schema filtering due to their longer context capabilities. However, schema filtering remains valuable for both larger and smaller models in cost reduction.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。