Code4Struct: Code Generation for Few-Shot Event Structure Prediction

Xingyao Wang, Sha Li, Heng Ji
10/23/2022
cs.CL

Official code: xingyaoww/code4struct (44 stars, HTML, GPL-3.0, last commit 2024-01-07).

Abstract

Large Language Model (LLM) trained on a mixture of text and code has demonstrated impressive capability in translating natural language (NL) into structured code. We observe that semantic structures can be conveniently translated into code and propose Code4Struct to leverage such text-to-structure translation capability to tackle structured prediction tasks.

Show full abstract

As a case study, we formulate Event Argument Extraction (EAE) as converting text into event-argument structures that can be represented as a class object using code. This alignment between structures and code enables us to take advantage of Programming Language (PL) features such as inheritance and type annotation to introduce external knowledge or add constraints. We show that, with sufficient in-context examples, formulating EAE as a code generation problem is advantageous over using variants of text-based prompts. Despite only using 20 training event instances for each event type, Code4Struct is comparable to supervised models trained on 4,202 instances and outperforms current state-of-the-art (SOTA) trained on 20-shot data by 29.5% absolute F1. Code4Struct can use 10-shot training data from a sibling event type to predict arguments for zero-resource event types and outperforms the zero-shot baseline by 12% absolute F1.

View on arXivView PDF

Code Implementations(1)

GPL-3.0

Official repo for ACL 2023 paper Code4Struct: Code Generation for Few-Shot Structured Prediction from Natural Language.

442HTML, PythonOct 22, 20222 years agoGPL-3.0

Similar Papers

Cite this paper

@article{wang2022codestruct,
  title  = {Code4Struct: Code Generation for Few-Shot Event Structure Prediction},
  author = {Xingyao Wang and Sha Li and Heng Ji},
  year   = {2022},
  eprint = {2210.12810},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2210.12810}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2210.12810.svg)](https://codeofpaper.com/paper/2210.12810)

Discussion