KnowCoder: Coding Structured Knowledge into LLMs for Universal Information Extraction

📄 arXiv: 2403.07969v2 📥 PDF

作者: Zixuan Li, Yutao Zeng, Yuxin Zuo, Weicheng Ren, Wenxuan Liu, Miao Su, Yucan Guo, Yantao Liu, Xiang Li, Zhilei Hu, Long Bai, Wei Li, Yidan Liu, Pan Yang, Xiaolong Jin, Jiafeng Guo, Xueqi Cheng

分类: cs.LG, cs.AI

发布日期: 2024-03-12 (更新: 2024-03-14)


💡 一句话要点

提出KnowCoder以解决通用信息提取问题

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 通用信息提取 大型语言模型 模式表示 代码生成 知识提取

📋 核心要点

  1. 现有的通用信息提取方法在处理复杂模式和知识结构时存在局限性,难以实现高效的知识提取。
  2. KnowCoder通过引入代码风格的模式表示和两阶段学习框架,提升了LLM对模式的理解和遵循能力。
  3. 实验结果显示,KnowCoder在多个设置下均显著提升了信息提取性能,尤其在少样本和零样本场景中表现优异。

📝 摘要(中文)

本文提出了KnowCoder,一个大型语言模型(LLM),用于通过代码生成进行通用信息提取(UIE)。KnowCoder旨在开发一种统一的模式表示,使LLM能够轻松理解,并通过有效的学习框架鼓励LLM遵循模式,准确提取结构化知识。为此,KnowCoder引入了一种代码风格的模式表示方法,将不同模式统一转换为Python类,从而以LLM友好的方式捕捉复杂的模式信息。我们还构建了一个覆盖超过30,000种知识类型的代码风格模式库,这是目前为止最大的UIE模式库。通过代码预训练和指令微调的两阶段学习框架,KnowCoder在少样本设置下相较于LLaMA2实现了49.8%的F1提升,并在零样本和低资源设置下分别实现了12.5%和21.9%的相对改进。

🔬 方法详解

问题定义:本文旨在解决通用信息提取(UIE)中的知识提取效率低下和模式理解不足的问题。现有方法在处理复杂的知识结构时,往往难以有效提取信息,导致性能瓶颈。

核心思路:KnowCoder通过引入一种代码风格的模式表示,将不同的模式统一转换为Python类,从而使得LLM能够更好地理解和遵循这些模式。这种设计不仅提高了模式的可读性,还增强了模型对复杂知识结构的捕捉能力。

技术框架:KnowCoder的整体架构包括两个主要阶段:首先是代码预训练,利用自动构建的数据集进行模型的初步训练;其次是指令微调,通过人类注释的数据进一步提升模型的模式遵循能力。

关键创新:KnowCoder的最大创新在于其代码风格的模式表示方法和两阶段学习框架。这种方法与现有的模式表示方式有本质区别,能够更有效地捕捉复杂的知识结构。

关键设计:在模型训练过程中,KnowCoder采用了大规模的自动构建数据集(约1.5B),并通过精心设计的损失函数和网络结构来优化模型性能。此外,模型的参数设置经过多次实验验证,以确保最佳的学习效果。

🖼️ 关键图片

fig_0
fig_1
fig_2

📊 实验亮点

KnowCoder在多个实验设置中表现出色,经过代码预训练后,相较于LLaMA2在少样本设置下实现了49.8%的F1提升。在零样本和低资源设置下,KnowCoder分别实现了12.5%和21.9%的相对改进,显示出强大的泛化能力。此外,在监督设置下,KnowCoder基于统一模式表示的改进达到了7.5%。

🎯 应用场景

KnowCoder在通用信息提取领域具有广泛的应用潜力,尤其适用于需要从大量非结构化数据中提取结构化知识的场景,如信息检索、知识图谱构建和智能问答系统等。未来,该技术可能会推动更高效的知识管理和信息处理方式,提升各行业的数据利用效率。

📄 摘要(原文)

In this paper, we propose KnowCoder, a Large Language Model (LLM) to conduct Universal Information Extraction (UIE) via code generation. KnowCoder aims to develop a kind of unified schema representation that LLMs can easily understand and an effective learning framework that encourages LLMs to follow schemas and extract structured knowledge accurately. To achieve these, KnowCoder introduces a code-style schema representation method to uniformly transform different schemas into Python classes, with which complex schema information, such as constraints among tasks in UIE, can be captured in an LLM-friendly manner. We further construct a code-style schema library covering over $\textbf{30,000}$ types of knowledge, which is the largest one for UIE, to the best of our knowledge. To ease the learning process of LLMs, KnowCoder contains a two-phase learning framework that enhances its schema understanding ability via code pretraining and its schema following ability via instruction tuning. After code pretraining on around $1.5$B automatically constructed data, KnowCoder already attains remarkable generalization ability and achieves relative improvements by $\textbf{49.8%}$ F1, compared to LLaMA2, under the few-shot setting. After instruction tuning, KnowCoder further exhibits strong generalization ability on unseen schemas and achieves up to $\textbf{12.5%}$ and $\textbf{21.9%}$, compared to sota baselines, under the zero-shot setting and the low resource setting, respectively. Additionally, based on our unified schema representations, various human-annotated datasets can simultaneously be utilized to refine KnowCoder, which achieves significant improvements up to $\textbf{7.5%}$ under the supervised setting.