Document-Level In-Context Few-Shot Relation Extraction via Pre-Trained Language Models

Yilmazcan Ozyurt, Stefan Feuerriegel, Ce Zhang

TL;DR

REPLM is a novel framework that brings document-level relation extraction into the era of in-context few-shot learning, eliminating the need for costly fine-tuning and error-prone Named Entity Recognition (NER) pipelines. By intelligently retrieving and aggregating multiple sets of relevant examples from distantly supervised data, it achieves state-of-the-art performance across six major datasets and even uncovers correct relations missing from standard human-annotated benchmarks.

What Problem Does This Paper Address?

Extracting structured knowledge (triplets like subject-relation-object) from unstructured text is a cornerstone of NLP, but doing so at the document level is notoriously difficult. Unlike sentence-level extraction, document-level tasks require reasoning across multiple sentences and handling a vast number of potential entity pairs.

Existing state-of-the-art methods suffer from three major bottlenecks:

  1. Computational Overhead: They typically require fine-tuning large language models (LMs), which is expensive and must be repeated every time a new relation type or a better base model is introduced.
  2. Error Propagation: Most methods rely on a separate NER step. If the NER model misses an entity, the relation extraction step is doomed to fail.
  3. Annotation Scarcity: Fine-tuning requires large amounts of human-labeled data, which is slow and costly to produce.

While in-context learning (ICL) has worked for sentence-level tasks, scaling it to documents—where the number of relations can be high—has remained a significant research gap.

Table 1: Comparison of relevant relation extraction methods.

Methods

The authors introduce REPLM (Relation Extraction via Pre-trained Language Models), a framework that reformulates relation extraction as a triplet generation task guided by in-context examples.

The workflow consists of three main stages:

  1. Candidate Selection: Instead of human labels, REPLM uses a "distantly supervised" pool of documents (automatically labeled via external knowledge bases). It uses semantic filtering (via SBERT embeddings) to find the $N$ documents most similar to the target document for a specific relation.
  2. Multi-Set Construction: To avoid the biases inherent in picking just one set of examples (like recency bias), the framework constructs $L$ different sets of $K$ examples. Each set is weighted based on its average similarity to the target document.
  3. Probabilistic Aggregation: The LM is prompted with these example sets to generate triplets. REPLM then aggregates these outputs in a probabilistic framework, ranking candidate triplets by their joint probability across all sets.

Crucially, REPLM does not require NER as an input; the model learns to identify both the entities and their relations directly from the provided context and examples.

Overview of the REPLM framework, showing the encoding, retrieval, and aggregation steps.

Datasets

The framework was evaluated on a diverse range of benchmarks:

  • DocRED: The largest document-level relation extraction dataset (96 relation types).
  • Biomedical Datasets: CDR (Chemical-Disease Relation) and GDA (Gene-Disease Association).
  • Sentence-Level Datasets: CONLL04, NYT, and ADE.

Key Insights and Ideas

  • Better than Human Labels? The authors found that REPLM often extracted correct relations that were simply missing from the "gold standard" DocRED development set. When validated against an external knowledge base (Wikidata), REPLM's performance lead over baselines grew significantly.
  • Learning vs. Memory: To prove the model wasn't just reciting facts from its pre-training memory, the authors ran an experiment replacing all entity names with random, non-existent strings. The model still performed nearly as well, confirming it was truly learning to extract relations from the provided context.
  • Seamless Scaling: Because it uses ICL, REPLM can be upgraded to more powerful models (like moving from GPT-JT to GPT-4o) without any re-training. The results showed a clear performance boost as the backbone LM improved.
  • Robustness to Noise: The framework proved robust to different hyperparameter choices (like temperature and probability thresholds), making it practical for real-world deployment where tuning data might be scarce.

Key Results

REPLM achieved state-of-the-art results across the board, outperforming over 30 baseline methods.

  • DocRED Performance: On the standard DocRED benchmark, REPLM achieved a Micro F1 score of 35.09, a massive +27% improvement over the best-performing baseline, REBEL-sent (27.52).
  • External KB Validation: When evaluated against Wikidata to account for missing labels, the gap widened further: REPLM hit an F1 of 36.51 compared to REBEL's 20.30—an 80% improvement.
  • Model Scaling: Using GPT-4o as a backbone, REPLM reached an F1 of 68.35 on DocRED, demonstrating that the framework scales exceptionally well with model capability.
Figure 2: F1 scores per relation type (darker = better). Missing color means that no correct predictions were made for this relation. F1 scores are normalized by the maximum value for each relation. Relations are in decreasing order of their number of knowledge triplets.

Limitations and Future Work

  • Context Window Constraints: For very long documents or relations with many examples, the LM's context window can become a bottleneck. The authors limited $K=5$ for DocRED to fit everything in.
  • Temporal Validity: The model sometimes extracts relations that were true in the past but are now outdated (e.g., sports team memberships). Future work could involve incorporating temporal reasoning to identify the time period for which a relation is valid.
  • Distant Supervision Quality: The framework relies on a high-quality pool of distantly supervised data. If the initial pool is extremely noisy, the quality of the in-context examples may suffer.

Summary updated

BibTeX
@misc{ozyurt2023document,
  author = {Yilmazcan Ozyurt and Stefan Feuerriegel and Ce Zhang},
  title = {{Document-Level In-Context Few-Shot Relation Extraction via Pre-Trained Language Models}},
  year = {2023},
  eprint = {2310.11085},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2310.11085},
}
Figure