NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

In-Context Example Retrieval from Multi-Perspectives for Few-Shot Aspect-Based Sentiment Analysis

Qianlong Wang, Hongling Xu, Keyang Ding, Bin Liang, Ruifeng XuCOLING 2024

Abstract

In this paper, we focus on few-shot aspect-based sentiment analysis (ABSA) and try to solve it with the in-context learning (ICL) paradigm. However, the effectiveness of ICL is highly affected by retrieved in-context examples. Previous works generally leverage the semantic similarity between the candidate examples and test input to retrieve examples. However, they may yield sub-optimal results for this task. This is because considering only the overall semantic perspective may leave some useful examples, which have syntactic structural relevance to the test input or share identical sentiments and similar aspects to one unretrievable. To address this shortcoming, we advocate retrieving in-context examples for few-shot ABSA by simultaneously considering three perspectives: overall semantics, syntactic structure relevance, and aspect-sentiment semantics. To achieve this, we construct positive and negative pairs from these three perspectives and train the demonstration retriever using contrastive learning. Experimental results on four ABSA datasets show that our retrieval framework can significantly outperform baselines across the board. Moreover, to understand factors influencing ICL performance on few-shot ABSA, we conduct extensive analysis in various scenarios, which can inspire and advance future research.

Introduction

Aspect-Based Sentiment Analysis (ABSA) is a fine-grained sentiment analysis task that identifies specific targets (aspects) and their associated sentiment polarities within a text. For example, in the sentence "The food was great but the service was slow," ABSA identifies food as positive and service as negative.

Performing ABSA in few-shot scenarios typically relies on In-Context Learning (ICL), where a Large Language Model (LLM) is provided with a task description and a few labeled examples. However, LLM performance is highly sensitive to the choice of these examples. Traditional retrieval methods rely on overall semantic similarity, which often fails to capture the structural or label-specific nuances required for accurate ABSA. This paper proposes a novel framework that retrieves examples based on multiple perspectives to provide better guidance for the model.

Methodology: Multi-Perspective Retrieval

Overview of the Multi-Perspective Demonstration Retriever and the In-Context Learning pipeline.

The core of the proposed framework is a Multi-Perspective Demonstration Retriever. Unlike standard retrievers that use a single embedding, this system is trained via contrastive learning to recognize relevance across three distinct dimensions:

  1. Overall Semantics: This perspective uses BERT-based embeddings to find examples with similar topical content to the test input.
  2. Syntactic Structure Relevance: To capture the grammatical "shape" of a sentence, the retriever converts text into Part-of-Speech (POS) sequences (e.g., "The coffee is good" becomes DT NN VBZ JJ). This helps the model identify how aspects and modifiers relate structurally.
  3. Aspect-Sentiment Semantics: This perspective focuses on the labels themselves. By converting (aspect, sentiment) pairs into natural language templates, the retriever finds examples that share similar sentiment-target dynamics.

During inference, the retriever ranks candidates across these three perspectives and selects the top-$k$ most relevant examples to populate the LLM's prompt.

Experimental Results

The framework was evaluated on four standard ABSA benchmarks: Lap14 (laptops), Rest14 (restaurants), Books, and Clothing. To simulate a true few-shot scenario, the candidate pool was limited to only 100 labeled samples per dataset.

F1 performance across different numbers of in-context examples on the Rest14 and Lap14 datasets.

Key Findings

  • Superior Performance: In 2-shot settings, the framework improved F1 scores by 4.73% to 12.14% over the state-of-the-art EPR retriever.
  • The Power of Syntax: Syntactic relevance proved to be a remarkably strong signal. Matching the grammatical structure of a sentence often provided better guidance for the LLM than matching the topic alone.
  • Efficiency: The researchers found that just 2 well-retrieved examples often outperformed 8 randomly selected ones, highlighting the importance of retrieval quality over context window quantity.
  • Model Agnosticism: The method demonstrated consistent gains across various LLMs, including LLaMA (7B to 30B), GPT-J-6B, and ChatGPT.

Conclusion

This work demonstrates that multi-perspective retrieval significantly enhances the effectiveness of In-Context Learning for few-shot ABSA. By considering syntactic and label-specific semantics alongside topical similarity, the retriever provides more relevant and structurally helpful examples to the LLM. Future work may explore more granular syntactic representations, such as dependency trees, to further refine the retrieval process.

Summary updated

BibTeX
@inproceedings{wang2024context,
  author = {Qianlong Wang and Hongling Xu and Keyang Ding and Bin Liang and Ruifeng Xu},
  title = {{In-Context Example Retrieval from Multi-Perspectives for Few-Shot Aspect-Based Sentiment Analysis}},
  booktitle = {International Conference on Computational Linguistics},
  year = {2024},
  url = {https://openreview.net/forum?id=JUr87YRTnf},
}
Figure