Solving Aspect Category Sentiment Analysis as a Text Generation Task

Jian Liu, Zhiyang Teng, Leyang Cui, Hanmeng Liu, Yue Zhang

Abstract

Aspect category sentiment analysis (ACSA) has attracted increasing research attention. The dominant methods make use of pre-trained language models by learning effective aspect category-specific representations and adding specific output layers to its pre-trained representation. We consider a more direct way of making use of pre-trained language models by casting the ACSA tasks into natural language generation tasks, using natural language sentences to represent the output. Our method allows more direct use of pre-trained knowledge in seq2seq language models by directly following the task setting during pre-training. Experiments on several benchmarks show that our method gives the best reported results, having large advantages in few-shot and zero-shot settings.

Introduction

In Aspect-Based Sentiment Analysis (ABSA), the goal is to identify specific aspect categories mentioned in a text and determine the sentiment associated with each. For instance, in a restaurant review, a model must distinguish between sentiments regarding "food" and "service." Traditionally, this has been treated as a classification problem: a sentence is passed through a model like BERT, and a classification head predicts a label.

However, this standard approach suffers from two primary drawbacks. First, it involves indirect knowledge use, as the newly added classification layers are uninitialized and do not benefit from the model's extensive pre-training. Second, it often relies on unnatural inputs, such as concatenating aspect names to sentences in ways that differ significantly from the natural language patterns the model encountered during pre-training. This paper proposes reframing ACSA as a natural language generation task to overcome these limitations.

Methodology

The Generative Framework

Instead of predicting a discrete label ID, the proposed method utilizes BART, a pre-trained sequence-to-sequence (seq2seq) model, to generate descriptive natural language sentences. By framing the task as text reconstruction, the model's fine-tuning objective aligns more closely with its pre-training objective.

Comparison of BART classification, Masked Language Modeling (MLM), and the proposed BART generation architecture.

Template-Based Learning

The core of this approach is the use of natural language templates for both Aspect Category Detection (ACD) and Sentiment Analysis (ACSA):

  • ACD Template: "The [category] category is discussed" or "is not discussed."
  • ACSA Template: "The sentiment polarity of [category] is [positive/negative/neutral]."

Inference via Ranking

To prevent the model from generating hallucinated or invalid text, the authors employ a ranking-based inference strategy. Rather than free-form generation, the model acts as a ranker. It calculates the log-probability of producing every possible valid template string (e.g., scoring "is positive" against "is negative"). The string with the highest probability is selected as the final prediction. This leverages the model's generative intuition while maintaining strict label constraints.

The template-based ranking mechanism for scoring aspect detection and sentiment polarity.

Key Insights

  • Semantic Labeling: Unlike arbitrary numerical labels in a classifier, words like "positive" or "negative" carry inherent semantic meaning. The model enters the task already "understanding" these concepts from its pre-training on massive corpora.
  • Implicit Aspect Detection: The generative approach excels at identifying "zero-frequency" aspects—categories that are implied by context but not explicitly named (e.g., identifying "ambience" from the phrase "dim and cozy lighting").
  • Joint Learning: The framework naturally supports a joint model that performs detection and sentiment analysis simultaneously, mitigating the error propagation common in traditional two-step pipelines.

Experimental Results

The researchers evaluated the BART-generation model on several benchmarks, including SemEval-2014, Rest14-hard, and the MAMS dataset.

  • State-of-the-Art Performance: The model outperformed previous classification-based benchmarks across the board. Notably, on the challenging MAMS dataset—where every sentence contains multiple aspects with conflicting polarities—it achieved a record 83.13% accuracy.
  • Few-Shot and Zero-Shot Dominance: The method's most striking advantage is in data-scarce environments. With only 10 training examples per category, the generation model achieved 82.01% accuracy on Rest14, while a standard BERT classifier managed only 38.57%. Its ability to understand the semantics of labels also allows for strong zero-shot performance in new domains.

Conclusion and Future Work

Reframing ACSA as a generation task allows for a more effective transfer of pre-trained knowledge. While the ranking-based inference introduces some computational overhead compared to simple classification heads, the gains in accuracy and data efficiency are substantial. Future research may extend this generative framework to more complex tasks, such as extracting full opinion triplets (Aspect, Sentiment, and Opinion Word).

Summary updated

BibTeX
@inproceedings{liu2021solving,
  author = {Jian Liu and Zhiyang Teng and Leyang Cui and Hanmeng Liu and Yue Zhang},
  title = {{Solving Aspect Category Sentiment Analysis as a Text Generation Task}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2021},
  doi = {10.18653/v1/2021.emnlp-main.361},
}
Figure