Structured Semantic Information Helps Retrieve Better Examples for In-Context Learning Applied to Few-Shot Relation Extraction

Aunabil Chakma, Mihai Surdeanu, Eduardo Blanco

TL;DR

This paper introduces a novel hybrid example selection framework that transforms 1-shot relation extraction into a more robust few-shot setting for in-context learning. By combining LLM-generated examples with realistic sentences retrieved from unannotated corpora based on deep syntactic-semantic similarity, the approach achieves a balanced similarity-diversity trade-off. The resulting system sets a new state-of-the-art on the challenging FS-TACRED benchmark without requiring any model fine-tuning.

What Problem Does This Paper Address?

Relation Extraction (RE)—identifying how entities in a text are related (e.g., place of birth or employer)—is a cornerstone of knowledge graph construction and question answering. However, traditional RE requires massive training sets. Few-Shot Relation Extraction (FSRE) attempts to solve this by providing only a definition and a single "gold" example (1-shot).

While Large Language Models (LLMs) can tackle this via In-Context Learning (ICL), their performance heavily depends on the quality and diversity of the prompt examples. Existing selection methods either rely on surface-level sentence embeddings (like SBERT) that capture topic rather than structure, or use LLMs to generate examples, which often lack structural diversity and result in near-duplicates. This paper addresses the challenge of automatically finding both relation-faithful and structurally diverse examples to boost ICL performance.

Methods

The authors propose a hybrid framework to automatically scale a 1-shot setup into a 5- or 10-shot prompt (visualized in Overview of the hybrid approach). The pipeline consists of:

Figure 1: Our approach to in-context learning for 1-shot relation extraction. Our method complements the (gold) 1-shot ("Support sentence" in the figure) with 4 or 9 additional examples, turning the setup into a few-shot setting (5- or 10-shot), generated using shallower LLM-based methods (i.e., paraphrasing the gold example, or generating new examples based on the relation definition) or deeper methods using the underlying syntactic-semantic representations of candidate examples. When combining these strategies, the resulting few-shot relation extraction system achieves better results across two corpora (FS-TACRED and FS-FewRel) and two language models (Qwen3 and Gemma3).
  1. NER-based Filtering: A preprocessing step that uses the LLM to verify if entity types in the query sentence match the target relation's constraints, discarding up to 86% of irrelevant candidate relations to save compute.
  2. LLM-based Generation: The model either paraphrases the gold example or generates new ones from scratch based on the relation definition.
  3. Syntactic-Semantic Retrieval: Instead of standard sentence embeddings, they extract the shortest syntactic dependency path between entity pairs. They use a self-supervised model called SoftMatcher to index and retrieve sentences from a 2.3M sentence subset of the UMBC WebBase corpus that share deep structural similarity with the gold example.
  4. Diversity Clustering: Retrieved candidates are clustered using $k$-means or $k$-means++ to select structurally diverse representatives, preventing redundancy.
  5. Hybrid Selection: The final prompt combines the gold example with a curated mix of LLM-generated (semantically close) and retrieved (structurally diverse) examples.

Datasets

The framework was evaluated on two major few-shot benchmarks:

  • FS-TACRED: A challenging few-shot reformulation of TACRED characterized by a very high proportion of "none-of-the-above" (NOTA) instances (~97%).
  • FS-FewRel: A customized subset of the FewRel dataset containing relations that structurally align with TACRED's entity types (~95% NOTA).

Note: The authors explicitly avoided the FS-NYT dataset because its relations rely heavily on well-known celebrity/location facts, which leak into the LLM's parametric knowledge and skew evaluation.

Key Insights and Ideas

  • The Similarity-Diversity Sweet Spot: Pure LLM paraphrasing creates examples that are too similar to the gold standard, offering little new signal. Conversely, extreme diversity can cause the model to drift away from the target relation. The hybrid approach hits the "Goldilocks zone" by balancing the semantic coverage of LLM generation with the realistic structural variety of corpus retrieval.
  • Syntax Beats Surface Embeddings: Standard SBERT embeddings cluster sentences by topic (e.g., grouping all sentences about politics). In contrast, embedding the shortest dependency path isolates the precise linguistic mechanism connecting the subject and object, ensuring relation faithfulness regardless of the sentence topic.

Key Results

  • The hybrid approach consistently outperformed all baseline strategies across different LLM families (Qwen3 and Gemma3).
  • On the rigorous FS-TACRED benchmark, the hybrid method using Qwen3-4B achieved an F1 score of 27.6, establishing a new state-of-the-art and outperforming dedicated, fine-tuned models like SoftRules and Anchor+gen. rules (detailed in Quantitative results on FS-TACRED and Comparison with SOTA).
  • Scaling the model to Qwen3-14B pushed the performance even higher to an F1 of 37.8.
  • Interestingly, smaller models (4B parameters) benefited significantly more from structured example selection than very large models (e.g., Gemma3-12B), which showed inconsistent gains or slight degradation due to prompt sensitivity.
Quantitative results on FS-TACRED
Comparison with SOTA

Limitations and Future Work

  • Corpus Alignment: The retrieval strategy relies on an unannotated corpus that naturally contains the target relations. If a relation is highly niche, retrieval might fail to find good matches.
  • Rule Inaccuracies: The lexico-syntactic rule extraction pipeline can occasionally introduce errors or noise into the semantic space.
  • Model Sensitivity: Different LLMs respond uniquely to prompt structures, suggesting that future work should explore individual model tailoring rather than a one-size-fits-all prompt template.

Summary updated

BibTeX
@inproceedings{chakma2026structured,
  author = {Aunabil Chakma and Mihai Surdeanu and Eduardo Blanco},
  title = {{Structured Semantic Information Helps Retrieve Better Examples for In-Context Learning Applied to Few-Shot Relation Extraction}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2026},
  doi = {10.18653/v1/2026.acl-long.1664},
}
Figure