Skip to main content
QUICK REVIEW

[论文解读] CodeKGC: Code Language Model for Generative Knowledge Graph Construction

Zhen Bi, Jing Chen|arXiv (Cornell University)|Apr 18, 2023
Topic ModelingComputer Science被引用 8
一句话总结

CodeKGC 将知识图构建重新表述为代码生成任务,通过将自然语言输入转换为代码风格的提示,利用模式感知提示和推理增强生成,在零-shot 和少-shot 设置下在 ADE、CoNLL04、SciERC 上超越基线。

ABSTRACT

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.

研究动机与目标

  • 通过利用结构化代码表示来实现端到端的知识图谱构建,而避免易出错的流水线。
  • 提出一种代码格式化的提示设计,通过 Python 类定义对 KG 模式进行编码,以保持语义结构。
  • 引入推理增强的生成机制,提供中间推理步骤并引导实体/关系的提取。
  • 在三个基准(ADE、CoNLL04、SciERC)上,在零-shot和少-shot设置下评估 CodeKGC,以证明相较基线的有效性。

提出的方法

  • 将 KG 三元组转换为 Python 代码格式,使用基类(Entity、Relation、Triple)来编码模式。
  • 使用具模式感知的提示,通过代码继承嵌入 KG 约束和类型以实现结构化生成。
  • 可选地将推理过程(链式推理风格)并入提示中,以指引生成过程中的多步推理。
  • 骨干语言模型包括 Code-davinci-002、text-davinci-002 和 text-davinci-003,在零-shot和少-shot设置中;还探索了一个在代码结构化 KG 数据上预训练的小型 Code-LM 用于 Q4。
  • 通过在 ADE、CoNLL04、SciERC 上的关系严格微 F1 来评估;报告零-shot 和少-shot结果;对模式提示和推理的消融分析。

实验结果

研究问题

  • RQ1CodeKGC 在ADE、CoNLL04、SciERC 的零-shot和少-shot KG 构建中与基线相比的表现如何?
  • RQ2具模式感知的代码提示对保持生成的 KG 结构有何影响?
  • RQ3推理增强的生成是否提升知识提取的准确性以及对复杂/多重关系的处理?
  • RQ4相较于大规模 Code-LLMs,较小的代码语言模型如何影响 CodeKGC 的性能?

主要发现

  • CodeKGC 使用基于代码的提示,在零-shot和少-shot 设置下,在三个数据集上均优于 UIE 和普通文本提示。
  • 具模式感知的提示和推理增强的生成都对性能提升有贡献,特别是在 CoNLL04 上;推理有帮助,但在小样本时冗长提示可能造成负担。
  • CodeKGC 比普通提示在处理重叠关系和长距离依赖时更强,尤其是在代码支撑的模型下。
  • 一个在代码结构化 KG 数据上预训练的更小的代码 LM 可以接近 UIE 与 CodeKGC 的性能,具备语义理解与代码格式化的优势。

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。