GPT-RE: In-context Learning for Relation Extraction using Large Language Models

Zhen Wan, Fei Cheng, Zhuoyuan Mao, Qianying Liu, Haiyue Song, Jiwei Li, Sadao Kurohashi

Abstract

In spite of the potential for ground-breaking achievements offered by large language models (LLMs) (e.g., GPT-3) via in-context learning (ICL), they still lag significantly behind fully-supervised baselines (e.g., fine-tuned BERT) in relation extraction (RE). This is due to the two major shortcomings of ICL for RE: (1) low relevance regarding entity and relation in existing sentence-level demonstration retrieval approaches for ICL; and (2) the lack of explaining input-label mappings of demonstrations leading to poor ICL effectiveness. In this paper, we propose GPT-RE to successfully address the aforementioned issues by (1) incorporating task-aware representations in demonstration retrieval; and (2) enriching the demonstrations with gold label-induced reasoning logic. We evaluate GPT-RE on four widely-used RE datasets, and observe that GPT-RE achieves improvements over not only existing GPT-3 baselines, but also fully-supervised baselines. Specifically, GPT-RE achieves SOTA performances on the Semeval and SciERC datasets, and competitive performances on the TACRED and ACE05 datasets. Additionally, a critical issue of LLMs revealed by previous work, the strong inclination to wrongly classify NULL examples into other pre-defined labels, is substantially alleviated by our method.

Introduction

Relation Extraction (RE) is a fundamental NLP task aimed at identifying semantic relationships between entities within text. While Large Language Models (LLMs) like GPT-3 have transformed many NLP domains through In-Context Learning (ICL), they have historically underperformed in RE compared to smaller, task-specific fine-tuned models like BERT. This performance gap stems from two primary issues: standard retrieval methods often select semantically similar but relationally irrelevant demonstrations, and LLMs often fail to grasp the underlying logic connecting an input sentence to its relation label. Furthermore, LLMs exhibit a "NULL bias," frequently hallucinating relations when none exist.

The GPT-RE Framework

To bridge this gap, we introduce GPT-RE, a framework that enhances ICL for relation extraction through two key innovations: task-aware demonstration retrieval and gold label-induced reasoning.

The overall framework of GPT-RE, showcasing the integration of task-aware retrieval and gold label-induced reasoning into the prompt construction process.

Task-aware Demonstration Retrieval

Standard retrieval relies on sentence-level similarity, which is often insufficient for RE. GPT-RE employs two specialized strategies:

  1. Entity-Prompted Embedding: The context is reconstructed to explicitly highlight the entities of interest (e.g., "The relation between 'Entity A' and 'Entity B' in the context..."), allowing the retriever to focus on the relevant part of the sentence.
  2. Fine-tuned Relation Representation: We utilize a smaller, fine-tuned RE model (e.g., PURE) to generate embeddings. These embeddings capture structural relational information rather than just surface semantics, ensuring that retrieved demonstrations share the same logical structure as the test input.

Gold Label-induced Reasoning

Inspired by Chain-of-Thought prompting, GPT-RE enriches demonstrations with explanations. We utilize the LLM to generate a "Reason" for why a gold label applies to a specific demonstration. By including these reasoning steps in the final prompt, the model learns the logic required to map complex textual patterns to abstract relation labels, effectively acting as a bridge between input and output.

Experimental Evaluation

We evaluated GPT-RE on four major benchmarks: Semeval 2010 Task 8, TACRED, SciERC, and ACE05. These datasets span general and scientific domains, providing a robust test for the framework's versatility.

Key Results

GPT-RE demonstrates significant improvements over both standard GPT-3 baselines and fully-supervised models.

Performance comparison of GPT-RE against fine-tuning baselines and standard GPT-3 ICL on Semeval and TACRED.
  • State-of-the-Art Performance: GPT-RE achieved SOTA results on Semeval (91.90 Micro-F1) and SciERC (69.00 Micro-F1), surpassing top-tier fully supervised baselines.
  • Closing the Gap on TACRED: On the challenging TACRED dataset, GPT-RE reached 72.14 Micro-F1, a massive leap from previous GPT-3 baselines (~33.45) and competitive with supervised models.
  • Data Efficiency: GPT-RE is particularly effective in low-resource settings. With only 10% of training data, it maintains a substantial lead over fine-tuned models, which typically require larger datasets to achieve high performance.

Discussion and Analysis

Our analysis reveals that the quality of retrieved demonstrations is more critical than quantity. GPT-RE with 5-shot demonstrations often outperforms 30-shot standard ICL. Furthermore, the use of task-aware representations significantly mitigates the "NULL problem," where LLMs overpredict relations. By providing the model with more accurate examples of "no relation" cases during retrieval, we reduce the tendency to hallucinate labels.

Conclusion and Future Work

GPT-RE proves that LLMs can excel at complex structural extraction tasks like RE when provided with the right context and reasoning logic. While the framework significantly alleviates the NULL bias and improves performance, challenges remain regarding the high inference cost of LLMs and the dependency on external models for retrieval. Future research will focus on making LLMs more self-sufficient in generating their own task-aware representations and further refining the handling of the NULL class.

Summary updated

BibTeX
@inproceedings{wan2023gpt,
  author = {Zhen Wan and Fei Cheng and Zhuoyuan Mao and Qianying Liu and Haiyue Song and Jiwei Li and Sadao Kurohashi},
  title = {{GPT-RE: In-context Learning for Relation Extraction using Large Language Models}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  url = {https://openreview.net/forum?id=mTiHLHu3sP},
}
Figure