Introduction
Aspect-based Sentiment Analysis (ABSA) is a granular task in natural language processing that involves identifying specific sentiment polarities for distinct targets within a text. Unlike general sentiment analysis, which assigns a single label to a sentence, ABSA must distinguish between multiple entities and their respective attributes (e.g., "The food was excellent, but the service was abysmal").
Despite the power of Large Language Models (LLMs), ABSA remains challenging due to two primary factors: domain sensitivity and the architectural rigidity of LLMs. Sentiment expressions are often domain-specific; for instance, the word "small" may be a positive attribute for a microchip but a negative one for a hotel room. Furthermore, while traditional NLP techniques utilize dependency parsing and part-of-speech tagging to capture these nuances, injecting such structural linguistic features into "black-box" LLMs is difficult without extensive fine-tuning or architectural modification.
To address these issues, we introduce FaiMA (Feature-aware In-context Learning for Multi-domain ABSA), a framework that utilizes In-Context Learning (ICL) as a mechanism to inject linguistic, domain, and sentiment features into LLMs via intelligent demonstration selection.
The FaiMA Framework
FaiMA moves beyond standard semantic-based retrieval for ICL, instead treating the selection of demonstration examples as a multi-faceted feature-matching problem. The framework consists of three core pillars:
1. Multi-head Graph Attention Network Encoder (MGATE)
Rather than relying on a generic text encoder, FaiMA employs a custom Multi-head Graph Attention Network (GAT). This encoder is designed with three specialized heads to capture distinct information types:
- Linguistic Head: Focuses on syntactic structure and part-of-speech patterns.
- Domain Head: Captures context specific to the industry or subject matter.
- Sentiment Head: Identifies the underlying emotional polarity and intensity.
2. Heuristic-driven Contrastive Learning
To train the MGATE, we developed a heuristic-driven approach to quantify similarity across the three feature dimensions. By applying contrastive learning, the encoder is taught to distinguish between sentences that are merely topically similar and those that share deep structural or sentiment-based commonalities. This ensures that the vector space effectively clusters examples based on their utility for the ABSA task.
3. Feature-aware Retrieval and Inference
During the inference phase, FaiMA utilizes the trained MGATE and the FAISS library to perform a similarity search. Instead of retrieving the top N most similar items overall, it retrieves a balanced set of examples—typically one highly relevant linguistic match, one domain match, and one sentiment match. These examples are then prepended to the prompt of a fine-tuned LLaMA-2-7b model, providing the LLM with the necessary "contextual vision" to process the input sentence.
The MD-ASPE Dataset
To evaluate FaiMA's cross-domain capabilities, we introduced MD-ASPE, the first comprehensive multi-domain ABSA benchmark. This dataset aggregates 16,000 sentences across nine diverse domains, including:
- Standard Benchmarks: 14Restaurant, 14Laptop, and Twitter.
- Specialized Domains: Device, Service, Books, Clothing, Hotel, and Financial News.
This benchmark provides a rigorous environment for testing how well a model can generalize sentiment patterns from one domain (e.g., electronics) to another (e.g., finance).
Experimental Results
Our evaluation demonstrates that FaiMA significantly outperforms both traditional Small Language Models (SLMs) and standard LLM prompting strategies.
- Performance Gains: LLaMA-FaiMA achieved an average Macro-F1 score of 75.62% across all domains, representing a 2.07% improvement over the previous state-of-the-art (T5-Paraphrase at 73.55%) and a substantial jump from standard LLaMA-SFT (70.54%).
- Domain Consistency: The framework showed particular strength in domains with formal linguistic structures, such as "Books" and "Restaurant," where syntactic patterns are highly predictive of sentiment targets.
- Retrieval Accuracy: Using GPT-3.5 as an evaluator, we confirmed that the MGATE encoder successfully retrieved relevant feature-matched examples in over 50% of cases across all domains, with domain-specific retrieval showing the highest precision.
Key Insights
ICL as a Feature Injector
The success of FaiMA suggests that LLMs do not necessarily require weight updates to understand complex linguistic structures. By providing examples that mirror the syntactic or sentiment complexity of the input, the LLM can "perceive" these features through its context window. This positions ICL as a powerful tool for feature engineering in the LLM era.
The Primacy of Linguistics
Ablation studies conducted during the research revealed that linguistic features (syntax and structure) are the most critical components for ABSA. Removing the linguistic head from MGATE resulted in a more significant performance degradation than removing either the domain or sentiment heads, proving that how a sentence is constructed is often more vital for ABSA than what the sentence is about.
Limitations and Future Work
While FaiMA represents a significant step forward, it is not without limitations. The computational overhead of using a 7B-parameter model is considerably higher than traditional BERT-based models. Additionally, the current framework focuses on Aspect-Sentiment pairs; future iterations will aim to address more complex tasks, such as Aspect-Sentiment-Opinion-Category (ASOC) quadruple extraction. We also plan to expand the MD-ASPE dataset to include even more diverse and low-resource domains to further test the limits of cross-domain adaptation.
Summary updated