Skip to main content
QUICK REVIEW

[Paper Review] KnowCoder: Coding Structured Knowledge into LLMs for Universal Information Extraction

Zixuan Li, Yutao Zeng|arXiv (Cornell University)|Mar 12, 2024
Natural Language Processing TechniquesComputer Science5 citations
TL;DR

KnowCoder introduces a code-style schema representation and a two-phase learning framework for universal information extraction with LLMs, achieving strong performance in few-shot, zero-shot, and supervised settings across NER, RE, and EE tasks.

ABSTRACT

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 $ extbf{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 $ extbf{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 $ extbf{12.5%}$ and $ extbf{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 $ extbf{7.5%}$ under the supervised setting.

Motivation & Objective

  • Develop a unified, LLM-friendly schema representation to capture complex UIE knowledge (taxonomies, constraints, and post-processing).
  • Build a large-scale code-style schema library covering tens of thousands of concepts from Wikidata.
  • Propose a two-phase learning framework to enhance schema understanding (code pretraining) and schema following (instruction tuning).
  • Demonstrate strong generalization and performance gains across NER, RE, and EE tasks in various data regimes (few-shot, zero-shot, low-resource, supervised).
  • Release schema library, data, code, and models for further research.

Proposed method

  • Introduce a code-style schema representation: Entity, Relation, Event classes, with class inheritance for taxonomies, type hints for constraints, class comments for definitions, and class methods for post-processing.
  • Construct a large code-style schema library from Wikidata (over 29k entity types, 876 relation types, 519 event types).
  • Two-phase learning framework: (i) schema understanding via code pretraining on schema definitions and instance codes (around 1.5B automatically constructed data); (ii) schema following via instruction tuning on schema-aware prompts and tasks.
  • Refinement leveraging human-annotated IE datasets to further boost performance across tasks.
  • Training details include big-context LLaMA2-base-7B as backbone, schema importing strategies, and LoRA-based parameter-efficient fine-tuning for later phases.
  • Evaluation on 33 IE datasets across NER, RE, and EE, with comparisons to multiple baselines and SOTA results.

Experimental results

Research questions

  • RQ1Can a unified code-style schema representation enable LLMs to understand and follow diverse UIE schemas?
  • RQ2Does a two-phase learning framework (code pretraining + instruction tuning) improve generalization to unseen schemas and performance on UIE tasks?
  • RQ3How does KnowCoder perform under few-shot, zero-shot, low-resource, and supervised settings across NER, RE, and EE?
  • RQ4What is the impact of refining KnowCoder with human-annotated IE datasets when using a unified schema library?
  • RQ5Is a large-scale, code-style schema library effective for simultaneous use of multiple IE datasets?

Key findings

  • KnowCoder’s code-style schema representation supports a unified view over 29k+ entity types, 876 relation types, and 519 event types and yields strong UIE capabilities.
  • After ~1.5B auto-annotated data for code pretraining, KnowCoder achieves 49.8% relative F1 improvement over LLaMA2 in few-shot NER.
  • Post-instruction tuning, KnowCoder shows strong zero-shot and low-resource generalization on unseen schemas, with up to 12.5% (zero-shot) and 21.9% (low-resource) average relative improvements over baselines.
  • With refinement on human-annotated IE datasets, KnowCoder achieves up to 7.5% absolute improvements across IE tasks in supervised settings.
  • In zero-shot results, KnowCoder-7B attains 46.3 average F1 on NER with SU-only pretraining, demonstrating substantial gains over LLaMA2-7B and outpacing several refined baselines in this setting.
  • Ablation shows schema understanding and following phases both contribute significantly; removing shaping phases degrades performance, especially the schema following step.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.