基于语义模式的提示大型语言模型实现面向领域问答的文本到Cypher转换

Prompting large language models based on semantic schema for text-to-Cypher transformation towards domain Q&A

Decision Support Systems · 2025
被引 4
ABS 3

中文导读

提出T2CSS方法,通过将领域本体提炼为轻量语义模式并自适应过滤相关信息,引导大型语言模型生成准确的Cypher查询,在实验中达到86%准确率,减少非技术用户使用知识图谱的维护成本。

Abstract

Translating natural language inquiries into executable Cypher queries (text-to-Cypher) is a persistent bottleneck for non-technical teams relying on knowledge graphs (KGs) in fast-changing industrial settings. Rule and template converters need frequent updates as schemas evolve, while supervised and fine-tuned parsers require recurring training. This study proposes a schema-guided prompting approach, namely text-to-Cypher with semantic schema (T2CSS), to align large language models (LLMs) with domain knowledge for producing accurate Cypher. T2CSS distils a domain ontology into a lightweight semantic schema and uses adaptive filtering to inject the relevant subgraph and essential Cypher rules into the prompt for constraining generation and reducing schema-agnostic errors. This design keeps the prompt focused and within context length limits while providing the necessary domain grounding. Comparative experiments demonstrate that T2CSS with GPT-4 outperformed baseline models and achieved 86 % accuracy in producing correct Cypher queries. In practice, this study reduces retraining and maintenance effort, shortens turnaround times, and broadens KG access for non-experts. • A T2CSS prompting approach that guides LLMs with the domain schema is proposed. • A systematic semantic schema to cover multifaceted concepts is designed. • An information filtering mechanism to select the relevant information is proposed. • Results achieve 86 % accuracy in translating user inquiries to Cypher statements.

知识图谱自然语言处理大型语言模型数据库查询