用知识图谱让LLM零样本生成精准查询,解决科研数据难访问问题
Natural Language Access to Domain-Specific Metadata: A Reusable Framework for LLM Query Generation

- 构建领域本体+LLM零样本生成SPARQL查询,无需微调或检索增强
- 在神经影像数据集上实现100%查询准确率,关键依赖语义标注与可读命名
- 适合需隐私保护的科研数据平台,支持本地部署与跨领域复用
研究人员常需回答领域特定档案中的临时问题,却缺乏编写结构化元数据查询的能力。本文表明:当领域词汇与语义通过精心设计的Web本体语言(OWL)本体表达后,大语言模型(LLM)可在零样本条件下,无需微调、检索增强或多代理协调,生成准确的结构化查询。我们提出自然语言知识图谱查询(NLKGQ)系统,包含帮助研究者以自然语言提问的网页界面,以及一个领域无关的转换器,将问题通过LLM转化为SPARQL并执行于知识图谱。开发流程始于在形式化OWL本体中捕获领域词汇与语义;随后通过领域特定代码从档案源提取元数据并导入由本体定义的知识图谱。两者均设计为跨领域可复用。我们在大规模神经影像研究档案的元数据上验证系统,评估多个LLM与本体表示方式。最优配置在领域专家构建的测试集上达到100%准确率。消融实验显示,实体名称可读性与语义注释是影响准确性的主导因素,优于模型选择或提示工程。我们还对比了SPARQL与自动生成的SQL数据库作为查询后端,结果表明OWL的结构特性在LLM驱动查询生成中具有显著优势。由于涉及人类受试者数据,演示领域要求在中等机构硬件上使用本地LLM以保障隐私。
原文摘要 · Abstract (English)
Researchers need to answer ad-hoc questions about the contents of domain-specific archives but often lack the expertise to write structured queries on the metadata. We show that when domain vocabulary and semantics are captured in a well-designed Web Ontology Language (OWL) ontology, Large Language Models (LLMs) can generate accurate structured queries zero-shot, without fine-tuning, retrieval augmentation, or multi-agent orchestration. We present the Natural Language Knowledge Graph Query (NLKGQ) system, a framework and development process that enables natural language access to metadata in such archives. The framework includes a web interface that helps researchers pose natural language questions, which a domain-agnostic harness translates to SPARQL via an LLM and executes against a knowledge graph. The development process begins with capturing domain vocabulary and semantics in a formal OWL ontology. Domain-specific code then extracts metadata from archive sources and imports it into a knowledge graph defined by the ontology. Both are designed for reuse across domains. We demonstrate the system on metadata derived from a large-scale neuroimaging research archive, evaluating multiple LLMs and ontology representations. The best configurations achieve 100% accuracy on a competence and regression question set developed with domain experts. An ablation study across eight ontology representations reveals that readable entity names and semantic annotations are the dominant factors in accuracy, more significant than model choice or prompt engineering. We also compare SPARQL to an auto-generated SQL database as query backends, showing that OWL's structural features provide a substantial advantage over SQL DDL for LLM-driven query generation. Our demonstration domain also requires local LLMs on modest institutional hardware to address privacy concerns for human subject data.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。