Current generative knowledge graph construction approaches usually fail to capture structural knowledge by simply flattening natural language into serialized texts or a specification language. However, large generative language model trained on structured data such as code has demonstrated impressive capability in understanding natural language for structural prediction and reasoning tasks. Intuitively, we address the task of generative knowledge graph construction with code language model: given a code-format natural language input, the target is to generate triples which can be represented as code completion tasks. Specifically, we develop schema-aware prompts that effectively utilize the semantic structure within the knowledge graph. As code inherently possesses structure, such as class and function definitions, it serves as a useful model for prior semantic structural knowledge. Furthermore, we employ a rationale-enhanced generation method to boost the performance. Rationales provide intermediate steps, thereby improving knowledge extraction abilities. Experimental results indicate that the proposed approach can obtain better performance on benchmark datasets compared with baselines. Code and datasets are available in https://github.com/zjunlp/DeepKE/tree/main/example/llm.
翻译:当前生成式知识图谱构建方法通常通过将自然语言简单序列化为文本描述或规范语言,难以捕获结构化知识。然而,基于代码这类结构化数据训练的大规模生成语言模型,已在自然语言理解与结构化预测及推理任务中展现出卓越能力。本文直观地提出利用代码语言模型解决生成式知识图谱构建任务:给定代码格式的自然语言输入,目标生成可表示为代码补全任务的三元组。具体而言,我们设计了模式感知提示,有效利用知识图谱内部的语义结构。由于代码本身具备结构特性(如类与函数定义),其可作为先验语义结构知识的有效建模工具。此外,我们采用原理增强生成方法提升性能,通过提供中间步骤增强知识抽取能力。实验表明,本文方法在基准数据集上相较于基线方法取得了更优性能。代码与数据集见https://github.com/zjunlp/DeepKE/tree/main/example/llm。