Abstract
Automated sentiment analysis of online-education reviews is useful for understanding learner feedback. Classification-based methods usually capture only document-level polarity. They may miss aspect-level signals and may collapse to the majority class under the heavy imbalance typical of course reviews. When the task is reformulated as generation, document-level and aspect-level outputs can be unified. However, out-of-vocabulary aspect labels, parsing failures, and weakly grounded links between granularities may also be introduced. Multi-perspective and Holistic Evaluation T5 (MHE-T5), a model built on the Text-to-Text Transfer Transformer (T5), is proposed as a constrained multi-granularity generative model. It emits aspect-level and document-level sentiment in one schema. The model combines grammar/finite-state machine (FSM)-constrained decoding, a document–aspect consistency coupling with a proved alignment property, and a cross-granularity contrastive objective. The decoding guarantee is limited to schema parse-validity and closed-vocabulary conformity; it does not guarantee semantic correctness of the selected aspect or polarity. Across four datasets, including a large rating-derived Coursera corpus, two human-annotated education aspect-based sentiment analysis (ABSA) datasets, and the standard Multi-Aspect Multi-Sentiment (MAMS) benchmark, generative models improve macro-averaged F1-score (Macro-F1) over Bidirectional Encoder Representations from Transformers (BERT) by 0.36 to 0.61 on the three datasets that carry discriminative baselines. MHE-T5 attains the highest document-level Macro-F1 among the evaluated benchmarks while providing formal schema-level guarantees on the closed-vocabulary settings. A controlled comparison with DeepSeek-V3 on identical examples, used as a large language model (LLM) baseline, shows that the fine-tuned 220M model is a competitive schema-constrained fine-grained aspect extractor under the fixed protocol.
1. Introduction
Online education has produced massive volumes of learner reviews whose sentiment, when mined accurately, lets platforms and instructors locate weaknesses and optimize course content, teaching, and learning resources [1,2,3,4]. A single review often expresses different sentiments towards different facets. The course content may be praised while the workload or the assessment is criticized, so a single document-level label is insufficient. Effective feedback analysis therefore requires multi-granularity understanding, namely the aspect-level polarities and the document-level overall sentiment, together.
Most deployed systems still treat the task as document-level classification with a pre-trained encoder [5,6], discarding aspect-level signal. Generative ABSA offers a unified alternative in which a text-to-text model emits the aspects and their polarities as a structured string [7,8,9]. Yet, published critiques show that the naïve generative recipe has several weaknesses. First, out-of-vocabulary aspect labels and parsing fragility remain because an unconstrained decoder can emit aspect labels that have no analogue in the input or malformed strings that break the downstream parser. Second, ungrounded bridging is common because document-level and aspect-level sentiments are typically just concatenated in one sequence, with no formal guarantee that the document label is consistent with the aspect labels. Third, thin validation remains an issue because results are often reported on a single, easy corpus with single-run numbers, leaving robustness and significance unestablished.
These limitations are addressed by MHE-T5, a constrained multi-granularity generative model built on T5. The individual mechanisms build on prior work in constrained decoding, document–aspect modeling, and contrastive learning; the principal contribution is their integration within a unified, task-specific framework rather than the invention of each component in isolation. An FSM-constrained decoder restricts the output to a fixed schema whose aspect slots are drawn from a closed, corpus-derived vocabulary, yielding formal schema parse-validity and vocabulary conformity in the closed-vocabulary setting. Within the integrated framework, this constraint reduces reliance on post hoc parsing. A document–aspect consistency coupling provides a learned, sign-preserving aggregation with a conditional alignment property and a measurable diagnostic, while a cross-granularity contrastive objective structures the aspect representations. The auxiliary objectives are trained so that they do not destabilize the generator, allowing MHE-T5 to retain competitive generative accuracy while adding schema-level controls and diagnostics.
Evaluation is conducted on four datasets. They include the large rating-derived Coursera corpus, two human-annotated education ABSA datasets (Education Review Dataset for Aspect-based Sentiment Analysis (EduRABSA) and the Coursera split of Multilingual Aspect-Based Sentiment Analysis (M-ABSA)), and the standard MAMS benchmark. Comparison is made against discriminative pre-trained language models (PLMs) and modern generative-ABSA models (T5/Generative Aspect-based Sentiment Analysis (GAS) and InstructABSA), and a large prompting LLM (DeepSeek-V3, 671B mixture-of-experts (MoE), 5-shot) is additionally reported on an identical test subset. The evaluation uses multi-seed runs with seed-level tests. Paired bootstrap is used as an uncertainty check, and effect sizes are reported descriptively. Accordingly, the contributions below are framed at the level of framework integration and empirical validation rather than as claims that the individual components are new.
- An integrated multi-granularity ABSA framework combining schema-constrained generation, document–aspect consistency coupling, and cross-granularity representation learning. Under a known closed vocabulary, its decoding component provides provable schema validity, zero out-of-vocabulary aspect labels, and zero category drift.
- Within this framework, a monotone document–aspect aggregation with a conditional alignment property and a measurable consistency rate is used as a consistency regulariser and an inference-time diagnostic.
- An empirical study across four datasets with a current baseline panel, multi-seed significance testing, an aspect-drift/parse-validity analysis under domain shift, a low-resource study, and a prompting-LLM comparison under a fixed protocol.
2. Related Work
2.1. Generative Aspect-Based Sentiment Analysis
Generative ABSA now uses output templates and task-specific prompting to reduce parsing errors. Dynamic order template prediction improves generative ABSA by adapting the output order to each instance [8]. Multilingual zero-shot generation and constrained cross-lingual decoding further show that schema control is needed when aspect labels must remain valid across domains or languages [7,10]. LLM-oriented studies report competitive coarse sentiment performance, but also show that aspect extraction still benefits from task-specific structure, synthetic data, or error-correction objectives [9,11,12]. Aspect-enhanced prompting is studied for unsupervised domain adaptation [13]. Sparse attention and residual joint learning are used for aspect-category sentiment analysis [14]. A duality-driven LLM reinforcement method is used for aspect sentiment triplet extraction [15]. These strands motivate the proposed integration. Existing studies have explored structured generation, constrained decoding, and cross-granularity modeling in related settings; MHE-T5 combines them in one multi-granularity ABSA framework. In this integrated setting, schema validity is enforced by construction (Section 3.2), while document- and aspect-level predictions are linked through the conditional alignment property analyzed in Section 3.3.
2.2. LLM and Prompting Approaches to ABSA
With instruction-following LLMs, prompting-based ABSA has been studied extensively [9,11,16,17]. The consistent finding of these reality checks is that zero/few-shot Generative Pre-trained Transformer (GPT)-class models, while competitive in coarse polarity, still trail fine-tuned models on structured aspect-level extraction. This finding is tested on education data with a direct comparison against the prompting model DeepSeek-V3 [18] (Section 4.6) and the released evaluation harness, so modern prompting methods are included in the comparison. Related benchmarks evaluate LLMs for review sentiment classification and domain-specific sentiment analysis. Event-based sentiment modeling is also used as a structured comparison setting [6,19,20].
2.3. Multi-Granularity and Document–Aspect Modeling
Joint modeling of global and local sentiment remains active in structured-sentiment research. Structured-sentiment studies examine document–aspect links and knowledge-augmented extraction [21,22,23,24]. Cross-granularity contrastive learning has also been used to structure aspect-level representations for triplet extraction [25]. Building on this literature, MHE-T5 attaches the aggregation to a generative decoder and analyzes a conditional alignment property, providing a learned, sign-preserving alternative to simple string concatenation.
2.4. Constrained and Structured Decoding
Constrained decoding guarantees that generated text obeys a formal grammar. Automata-based constraints and grammar engines provide token-level control [26,27]. Constrained cross-lingual ABSA decoding and self-consistent structured generation with LLMs give related uses [7,9]. This idea is adapted to multi-granularity sentiment through an FSM compiled from the output schema with categories restricted to a closed, corpus-derived vocabulary, yielding formal schema validity and zero category drift. Building on prior constrained-generation frameworks that enforce formal-language membership, MHE-T5 combines grammar control with document–aspect consistency coupling and polarity-aware contrastive slot structuring in a sentiment-specific architecture.
3. Method
Multi-granularity sentiment analysis is reformulated as constrained structured generation. Unlike prior generative ABSA that fine-tunes a text-to-text model and parses free-form output heuristically, MHE-T5 adds three mechanisms on top of the T5 backbone. The first mechanism is a grammar/FSM-constrained decoder that enforces schema-valid, closed-vocabulary output with zero category drift. This is a syntactic and vocabulary-level constraint. The second mechanism is a document–aspect consistency coupling with a provable alignment property. The third mechanism is a cross-granularity structured-attention objective. M1 denotes schema-constrained structured decoding. M2 denotes document–aspect consistency coupling, and M3 denotes cross-granularity structured attention. M1 operates at inference and needs no retraining; M2 and M3 are auxiliary training objectives. The overall architecture is shown in Figure 1, built on the T5 encoder–decoder backbone of Figure 2.
Figure 1.
The MHE-T5 model. The review is encoded once; the decoder generates a single structured sequence containing the per-aspect (category, polarity) tuples and the overall document polarity. Aspect slots are constrained to a closed vocabulary (M1); auxiliary heads read the aspect/overall decoder states for the consistency coupling (M2) and contrastive structuring (M3).
Figure 2.
The T5 encoder–decoder backbone, with multi-head self-attention, relative position encoding, and encoder–decoder cross-attention.
3.1. Task Formulation
Let an input review be a token sequence . Let be a closed set of aspect categories and = {pos, neg, neu} the polarity set. The target is a single string Y in the language of the schema grammar :
with , , and . The model learns , jointly emitting the aspect-level tuples and the document-level polarity in one decode. Equation (1) is a single context-free schema, which removes the ambiguity of order-dependent concatenation criticized in prior work. Figure 3 shows an example online-education review with its multiple aspects, and Figure 4 the corresponding structured output target.
Figure 3.
Example online-education review. Different facets (course content, instructor, platform, and learning experience) carry different sentiment, motivating multi-granularity analysis.
Figure 4.
Construction of the structured output. Per-aspect ratings are mapped to polarity labels, paired with their aspect categories, and combined with the document-level overall polarity into the single schema string of Equation (1).
3.2. Schema-Constrained Structured Decoding (M1)
is compiled into a finite-state automaton whose edges are token-id sequences obtained by encoding canonical fragments with the model tokenizer (so matching is on the model’s own sub-word units, never on a detokenize/retokenize round-trip). At decoding step t, given the generated prefix , the function returns the set of tokens that keep on an accepting path of ; all other logits are masked to . Category slots are restricted to the token tries of , polarity slots to , and a bound K on the number of aspects forces the automaton to the closing; overall= transition.
Proposition 1
(Validity and closedness). For any input, the string Y produced by greedy/beam decoding under ρ satisfies both and every emitted category . Consequently parse-validity is , the out-of-vocabulary aspect-label rate is 0, and category drift is 0 under the closed vocabulary.
Proof.
By construction accepts exactly the token sequences whose decoding lies in with categories drawn from . At every step returns precisely the tokens that extend along some accepting path; tokens off all accepting paths receive logit and cannot be selected. Hence every prefix, and in particular the terminated sequence, is a prefix of an accepting path. Termination occurs only when the end-of-sequence (EOS) token is emitted, which permits solely in the accepting state end, reached only after a complete; overall= suffix. Therefore and each category sub-span equals some . The bound K guarantees end is reachable within tokens, so decoding cannot diverge. □
3.3. Document–Aspect Consistency Coupling (M2)
Let be the decoder hidden state at the slot that emits , and at the slot that emits . A shared polarity head gives and over (pos, neg, neu). Define ordinal scores si = qi(pos) − qi (neg) ∈ [−1, 1] and learned non-negative weights . The aggregate and its document distribution are
with . The consistency objective trains the document head towards the detached aggregation, (soft cross-entropy, stop-gradient on g). The polarity head and the weights and g are optimized on detached decoder states, so they act as calibrated probes that regularize the model without perturbing the generation path (which alone is shaped by the sequence cross-entropy (CE) loss and remains as stable as vanilla T5). The document↔aspect bridge in the generated sequence is induced by the schema’s autoregressive order because the overall token is decoded conditioned on every previously generated aspect tuple, not concatenated independently. This relation is quantified by a consistency rate, defined as the fraction of reviews whose generated document label matches the aspect majority (≈0.79). The aggregation g additionally defines an audit label whose conditional relation to unanimous, confident aspect predictions is characterized by Proposition 2. In the analysis, the equal-weight instance is reported as an aspect-majority vote. The decoder-generated holistic label remains the primary predictor, while g runs alongside it as a consistency audit. Together, the autoregressive conditioning, the measured consistency rate, and the conditional aggregation result provide evidence against the “mere concatenation” criticism.
Proposition 2
(Alignment soundness). Assume (so ). If all mentioned aspects are unanimous with majority polarity and confident, i.e., shares the sign of c with for every i with , and the learned margin satisfies , then . Moreover g is monotone non-decreasing in , and is a convex combination of the .
Proof.
Take = pos (the case neg is symmetric). Then for all i with ; since and , . The logits of are . As , , and by assumption, so the pos logit strictly dominates and = pos. Because , . Monotonicity follows since ∂g(pos), and convexity is immediate as and the weights are normalized. □
Propositions 1 and 2 establish different formal properties under explicit conditions. Proposition 1 applies when the FSM is used with a known closed inventory: it ensures that the output is parseable and that every category token belongs to that inventory. In practice, this removes malformed outputs and known-taxonomy drift before downstream aggregation, but it does not establish that an allowed category or polarity is the correct prediction. Proposition 2 gives a sufficient alignment result at the consistency optimum when aspect polarities are unanimous and confident and . These conditions describe clear cases rather than all realistic education reviews, which may contain mixed, neutral, weak, sarcastic, or incorrectly extracted aspects. When they are not met, the aggregation remains a monotone consistency diagnostic and the decoder-generated document label remains the primary prediction. Thus, the propositions support schema-safe integration and consistency auditing under their stated assumptions; neither is a guarantee of prediction quality, aspect recovery, or robustness in realistic settings.
3.4. Cross-Granularity Structured Attention (M3)
To give the document head a structured (non-concatenative) view of aspects, a supervised contrastive term over the aspect-slot representations in a batch is added. With polarity labels as supervision and temperature ,
where denotes the aspect slots sharing i’s polarity. This pulls same-polarity aspects together and pushes different-polarity ones apart, sharpening the routing from the overall slot to the aspect segments.
3.5. Training Objective
The model is trained end-to-end with the sequence cross-entropy on Equation (1) plus the auxiliary terms:
where anchors the shared polarity head to the gold slot polarities. The three auxiliary terms are back-propagated only into the auxiliary heads (, , g and the contrastive projector), not into the decoder, so the generative backbone is optimized solely by ; this keeps training as stable as vanilla T5 while still learning calibrated heads for the consistency and interpretability analyses. Setting recovers vanilla generative T5, the lower rung of the ablation cascade (Section 4).
4. Experiments
4.1. Datasets
Evaluation is performed on four datasets spanning rating-derived and human-annotated, education and standard-benchmark settings (Table 1). Coursera is the large-scale document-level education corpus; its labels are derived from star ratings and it is heavily positive-skewed. EduRABSA [4] and M-ABSA [28] provide human-annotated aspect categories, opinions, and polarities on education reviews, replacing rating-derived pseudo-labels. EduRABSA is linguistically demanding, with 81.8% of reviews mentioning multiple aspects and 49.1% containing conflicting polarities. MAMS is used as the standard ABSA benchmark; by construction it has multiple aspects with differing polarities in every sentence, stress-testing the document–aspect bridge. The multi-aspect and conflict rates in Table 1 quantify that the human-annotated and benchmark sets are markedly more complex than the rating-derived Coursera data. These four datasets are used to evaluate the proposed mechanisms in complementary and defined settings. They are not used to claim unrestricted cross-domain generality.
Table 1.
Dataset statistics. Cat denotes categories, Len denotes length, Asp denotes aspects, Multi denotes multi-aspect reviews, Conf denotes conflicting-polarity reviews, dist. denotes distribution, doc denotes document-level, and N/A denotes not applicable.
All splits are unified into the schema of Equation (1); aspect categories form the closed vocabulary for EduRABSA and M-ABSA, while MAMS uses given open aspect terms and is evaluated without the closed-vocabulary FSM mask.
4.2. Baselines and Implementation
A broad and current panel is used for comparison. The discriminative document-level classifiers include BERT, BERT+long short-term memory (LSTM), deep pyramid convolutional neural network (DPCNN), and RoBERTa (Robustly optimized BERT pretraining approach). These model families are retained as discriminative baselines in transformer and sentiment-analysis comparisons [5,6,29]. The generative ABSA baselines include vanilla T5 (GAS-style) [7,8,10] and InstructABSA [30]. A prompting LLM, DeepSeek-V3 [18], a 671B-parameter MoE model, is evaluated with 5-shot prompting. Because the LLM call is paid and rate-limited, it is evaluated on a fixed , seed-0 subset of each test set; for a like-for-like comparison, the fine-tuned models are scored on the identical 300 examples (Section 4.6, Table 2). For aspect-level comparison, SensoryT5 [31] and generative ABSA baselines [7,8,10] are additionally referenced. MHE-T5 uses the T5-base backbone (220 M). Unless otherwise stated, fine-tuned runs use three epochs with seeds , a training batch size of 16 and an evaluation batch size of 32, AdamW with a learning rate of and weight decay , a linear schedule with a warm-up ratio followed by linear decay, gradient-norm clipping at , bf16 mixed precision, and maximum source and target lengths of 256 and 128 tokens, respectively. For MHE-T5, , , , and ; the auxiliary losses are linearly ramped during the first epoch. Generation is deterministic greedy decoding (beam width 1, without sampling) with at most 128 new tokens. Free and FSM-constrained decoding use the same checkpoint and generation settings. On the closed-vocabulary datasets, M1 applies the token-level FSM mask at every decoding step and permits at most aspect tuples. DeepSeek-V3 uses temperature 0 and a maximum of 128 output tokens with the fixed five-shot prompt. Experiments are run on a single NVIDIA RTX 5070 Ti (16 GB) GPU (NVIDIA, Santa Clara, CA, USA). The main comparisons (Table 3, Table 4 and Table 5) are run over three seeds and reported as mean ± std. Rows without standard deviations are single-run diagnostics or fixed-subset baselines. They follow the protocols stated in their respective sections. They are not used as the main basis for seed-level significance claims. The implementation, preprocessing scripts, prompts, dataset splits, processed outputs, and evaluation code will be made available by the corresponding author upon reasonable request after the related materials are curated.
Table 2.
Prompting LLM comparison on an identical test subset. Asp-F1 and Val denote aspect-level F1 and parse-validity; N/A denotes not applicable, as the Coursera corpus carries no aspect-level annotations.
Table 3.
Document-level results in accuracy and Macro-F1. Acc denotes accuracy, and MaF1 denotes Macro-F1.
Table 4.
Aspect-level (category, polarity) micro-F1 of generative models.
Table 5.
Component ablation in accuracy, Macro-F1, consistency rate and aspect-majority Macro-F1. Cons. rate denotes consistency rate, and Maj. MaF1 denotes aspect-majority Macro-F1.
4.3. Evaluation Metrics and Protocol
For document-level sentiment, accuracy and macro-/weighted-F1 are reported (macro-F1 is the primary metric given class imbalance). For aspect-level extraction, (category, polarity) tuple micro-/macro-F1 are reported. Under domain shift, aspect precision, recall, and F1 are computed against target-domain gold tuples for each decoding schema. For the structured output, the reported measures are parse-validity, the aspect-drift rate (ADR, fraction of generated categories absent from the vocabulary; defined only on the closed-vocabulary datasets), and opinion-fidelity rate (OFR). Parse-validity and ADR measure structural validity and vocabulary conformity. They are therefore reported separately from predictive accuracy and aspect-level F1. Seed-level Welch tests are used for the result discussions because each main comparison has three training seeds. Cohen’s d is reported as a descriptive effect size and is interpreted cautiously. Paired bootstrap tests are used as a paired uncertainty check on held-out predictions. The sampling unit is one held-out review. The same resampled index set is applied to both models. Each comparison uses 1000 bootstrap samples with seed 0. The and percentiles define a confidence interval for the metric difference. The significance threshold is . No multiple-comparison correction is applied. The reported p values are interpreted as planned comparisons, following evaluation guidance on uncertainty reporting and confidence intervals for language-model evaluation [32].
4.4. Main Results
Table 3 reports document-level Accuracy and Macro-F1.
The generative reformulation is effective under class imbalance. The discriminative classifiers BERT, RoBERTa and BERT+LSTM attain high accuracy but collapse to the majority class, yielding a Macro-F1 of only on the -positive Coursera corpus, on EduRABSA, and on MAMS. The generative models lift Macro-F1 to between and . The added BERT-CW baseline reaches Macro-F1 scores of , , and , which reduces the collapse but remains below MHE-T5. Relative to BERT, MHE-T5 raises Macro-F1 by on Coursera, by on EduRABSA, and by on MAMS, as Figure 5 shows. The collapse is specific to the standard cross-entropy classifiers; the imbalance-robust DPCNN fares better, yet MHE-T5 still exceeds DPCNN by on the saturated Coursera corpus, by on EduRABSA, and by on MAMS. This explains the high-accuracy and low-F1 anomaly of the discriminative models reported in the original study and supports the generative formulation.
Figure 5.
Radar view of Macro-F1 under class imbalance. Standard cross-entropy classifiers collapse to the majority class, whereas MHE-T5 obtains higher Macro-F1 than the evaluated discriminative baselines on EduRABSA and MAMS.
MHE-T5 attains the highest document-level Macro-F1 among the evaluated models on the three main document-level datasets. On MAMS, where every sentence carries aspects of conflicting polarity, it reaches a Macro-F1 of , ahead of vanilla T5 at . On EduRABSA it reaches a Macro-F1 of , again the highest among all models, and on the saturated Coursera corpus it leads at . These multi-aspect, mixed-sentiment cases dominate authentic course reviews and are cases in which a single document label is least informative. Where accuracy saturates, especially on Coursera at approximately for every generative model, MHE-T5 adds schema-level output reliability while maintaining competitive accuracy. Seed-level Welch tests are further conducted on Macro-F1. Cohen’s d is reported as a descriptive effect size. MHE-T5 is compared with T5 and InstructABSA on each dataset. For the comparison with T5, the values are on Coursera, on EduRABSA, and on MAMS. For the comparison with InstructABSA, the values are , , and on the same three datasets. These values show that the document-level Macro-F1 gains are statistically supported on Coursera and EduRABSA when MHE-T5 is compared with T5. A statistically supported gain over InstructABSA is also observed on EduRABSA. The remaining differences are treated as numerical improvements rather than statistically reliable gains.
4.5. Aspect-Level Results
Table 4 reports aspect-level (category, polarity) micro-F1 for the generative models.
MHE-T5 attains the highest aspect-level F1 among the evaluated generative models on all three aspect-level datasets, reaching on EduRABSA, on M-ABSA, and on MAMS, ahead of the retained generative baselines in every case. Under free decoding all generative models reach near-perfect parse-validity, with a per-seed minimum of , but not always . The constrained decoder (M1), which is applied to MHE-T5 as a decoding-time module, additionally guarantees schema parse-validity, a zero out-of-vocabulary aspect-label rate, and zero category drift on the closed-vocabulary category-based education datasets. Seed-level Welch tests are also conducted on aspect micro-F1. Cohen’s d is reported as a descriptive effect size. MHE-T5 is compared with T5 and InstructABSA on each aspect-level dataset. For the comparison with T5, the values are on EduRABSA, on M-ABSA, and on MAMS. For the comparison with InstructABSA, the values are , , and on the same three datasets. These values indicate that the aspect-level gains over InstructABSA are statistically supported on all three datasets. The gain over T5 is statistically supported on EduRABSA. On M-ABSA and MAMS, the gains over T5 are small and are therefore described as modest numerical improvements.
The variation across datasets is consistent with differences in annotation granularity, schema type, and label distribution (Table 1). Coursera contains no aspect annotations and is strongly positive-skewed; document accuracy is consequently close to saturation, and the aspect-oriented mechanisms provide little additional predictive signal. EduRABSA, in contrast, provides 24 closed categories and averages 3.10 aspects per review, with multi-aspect and conflicting-polarity reviews, providing substantially richer supervision for cross-granularity modeling. M-ABSA is smaller, with 1278 training reviews, only 0.99 aspects per review, and a conflict rate; the signal available to the coupling and contrastive components is therefore limited. MAMS presents a different difficulty: it uses open aspect terms and every sentence contains multiple conflicting polarities. The closed-vocabulary benefit of M1 is unavailable, while the unanimity condition in Proposition 2 does not describe the benchmark’s typical cases. These differences help explain why the empirical margins vary and reinforce that the formal properties concern output structure and conditional consistency rather than dataset-independent prediction gains. This interpretation is based on the reported dataset statistics and ablations rather than on a separate causal analysis.
4.6. Comparison with a Prompting LLM
A modern instruction-following LLM is evaluated under a fixed 5-shot prompt. Table 2 and Figure 6 report the comparison on the same evaluation subset. The setting is a fixed-prompt evaluation rather than a prompt-engineering study.
Figure 6.
Heatmap comparison between the prompting LLM (DeepSeek-V3, 5-shot) and fine-tuned generative models on the identical subset. The aspect-F1 panels show higher MHE-T5 scores under this fixed protocol on the difficult education and benchmark datasets, while the validity panel separates empirical parse success from the M1 schema guarantee.
Against DeepSeek-V3 (671B-parameter MoE, 5-shot) on an identical subset, a fine-tuned model nearly smaller achieves higher aspect-F1 in these tests and is the only model with a schema-level validity guarantee. The competence of the LLM is mainly confined to coarse document polarity, where it is competitive, for example reaching an accuracy of on M-ABSA. On the fine-grained structured task, the LLM has lower aspect-F1 in this fixed-prompt comparison. Its aspect-F1 is lower than that of the highest-scoring fine-tuned model on all three aspect datasets and lower than that of every fine-tuned model on two of the three datasets. The aspect-F1 of the LLM versus the highest-scoring fine-tuned model is against on EduRABSA, against on M-ABSA, and against on MAMS. A prompting LLM at 5-shot emits plausible but schema-misaligned aspect terms and categories, which strict tuple matching penalizes. In this setting, a fine-tuned 220M model gives higher fine-grained extraction scores.
The LLM also does not internalize dataset-specific aggregation conventions. On MAMS, where every sentence carries conflicting-polarity aspects and the document label is therefore “neutral” by construction, DeepSeek-V3 collapses to an accuracy of and a Macro-F1 of , whereas the fine-tuned models remain near in accuracy. This is the document↔aspect coupling that MHE-T5’s M2 mechanism learns. Prompting also does not guarantee schema validity. DeepSeek-V3’s free-decoding parse-validity ranges from on MAMS to and is never guaranteed; MHE-T5 under constrained decoding attains schema validity with ADR by construction (Section 4.8). This comparison supports the use of a schema-constrained fine-tuned model. The prompting LLM is a competitive document classifier but a weaker, unconstrained aspect extractor. The LLM is evaluated on a single subset per dataset. This result is therefore interpreted as evidence under a fixed 5-shot protocol and the sampled evaluation subset.
4.7. Ablation Study
Table 5 isolates the mechanisms.
By design the auxiliary heads are trained off the generation path. The mechanisms therefore add guarantees and diagnostics while preserving accuracy. The ablation results are interpreted as reliability and document–aspect coupling added to a competitive generator. They do not show that each auxiliary objective independently produces a large accuracy gain. The consistency coupling M2 yields a modest gain on EduRABSA, from to Macro-F1 over vanilla T5. The full model reaches the main-result EduRABSA score of Macro-F1 and raises MAMS Macro-F1 from to . The contrastive term M3 has a limited but neutral-to-positive effect. The purpose of the mechanisms is reliability added to competitive accuracy, not a universal accuracy lift. (A coupled variant that routes the consistency gradient into the decoder was also tested; it is unstable (validity collapsing to 0 on some seeds) and gives no accuracy benefit, so the detached design is used. The detached design keeps the document and aspect link in the autoregressive schema order and the inference-time aggregation g). The consistency rate, the fraction of reviews whose generated document label agrees with the aspect majority, is high at approximately , providing a measurable diagnostic signal that the document label is associated with the aspect predictions rather than simply concatenated with them. This supports the alignment intuition of Proposition 2 and quantifies the document–aspect coupling beyond the Macro-F1 increment alone. Every configuration certifies schema validity and ADR on the closed-vocabulary datasets under constrained decoding. The detached design is also what allows decoding and training refinements to be added without weakening the structural guarantees.
4.8. Constrained Decoding Validity and Category Drift
Table 6.
Domain-shift schema diagnostics with target-domain aspect matching.
Figure 7.
Schema-inventory diagnostic under domain shift. Target-schema decoding reduces ADR to zero by construction, but aspect F1 remains low. This separates vocabulary conformity from target-aspect selection.
In distribution, free decoding of a trained model already parses well and emits only a small fraction of out-of-vocabulary categories, with an aspect-drift rate of about . Constrained decoding sets parse-validity to and ADR to 0 with no loss in F1. Under domain shift, ADR must be interpreted with care. If the target-domain schema is used, ADR is 0 by construction. This confirms vocabulary conformity, not correct aspect selection. We therefore decode each shifted model with the source-domain schema, the target-domain schema, and the combined schema. Precision, recall, and F1 are computed against target-domain gold tuples. With the source schema or the combined schema, the model still selects source-domain categories, so ADR is and target F1 is . With the target schema, ADR becomes . The EduRABSA to M-ABSA F1 is , and the reverse F1 is . These values show that M1 controls the output vocabulary, while semantic target-aspect generalization remains difficult under disjoint vocabularies. The zero-ADR guarantee assumes that the target-domain aspect inventory is known at decoding time. If this inventory is unavailable, the structural schema and polarity slots can still be enforced, but zero category drift relative to an unknown taxonomy cannot be claimed.
4.9. Low-Resource Evaluation
The EduRABSA training set is varied from 25 to 3600 reviews (Figure 8). Accuracy decreases gradually down to a few hundred examples, with MHE-T5 tracking vanilla T5. The analysis focuses on free-decoding schema validity in the extreme low-resource regime. At 200 or more reviews it is ≈, but it drops to at 50 reviews and to at 25 reviews. A model trained on so little data cannot reliably emit the schema at all. Constrained decoding (M1) holds schema validity at at every training size. In this regime the schema-level constraint separates parseable structured output from output that is almost entirely unparseable.
Figure 8.
Low-resource study on EduRABSA. Free-decoding parse-validity collapses below training reviews and reaches at , while M1 certifies schema validity at every size; document accuracy rises with data.
4.10. Interpretability and Case Studies
Beyond aggregate metrics, the structured output can be inspected directly. Each prediction is a human-readable list of (aspect, polarity) pairs plus an overall label. The aggregation g shows how a document label is assigned. As a concrete example, for the conflicting review “Very interesting material. The course is not challenging but it does require some practice. Exams can be pretty long.” MHE-T5 produces Content=positive | Difficulty=neutral | Assessment=negative ; overall=neutral. The prediction separates the praised content from the criticized assessment and assigns a neutral overall label that matches the gold annotation. Similarly, “Course is interesting but weekly assignments are brutal” yields Course=positive | Assessment=negative ; overall=neutral. The opinion-fidelity rate (OFR, the fraction of matched-category aspects with the correct polarity) is also reported as a quantitative interpretability measure. On EduRABSA, MHE-T5 attains OFR , i.e., when an aspect category is correctly identified its polarity is right about of the time.
4.11. Efficiency and Deployment
MHE-T5 uses the 220M-parameter T5-base backbone and is evaluated on a single NVIDIA RTX 5070 Ti GPU with 16 GB memory. To quantify the runtime cost of M1, free decoding and FSM-constrained decoding are compared under the same checkpoint and generation settings. The finite-state mask is compiled once for each dataset schema and is reused during inference. CUDA synchronization is applied before and after generation timing. Latency is averaged over the measured test examples after two warm-up batches. Throughput is measured as reviews per second. Peak GPU memory is recorded during generation. The benchmark also records training time for the measured seed. It is s on EduRABSA and s on M-ABSA under the same three-epoch setting. These single-seed timing values are used only as deployment diagnostics.
Table 7 shows that constrained decoding changes latency from to ms per review on EduRABSA. It changes latency from to ms per review on M-ABSA. The displayed relative latency changes are and . The largest observed absolute slowdown is ms per review. Throughput remains at least reviews/s on a single 16 GB GPU. Peak GPU memory remains essentially unchanged, with a maximum displayed difference of GB. The runtime analysis is based on direct latency, throughput, and memory measurements. Overall, constrained decoding introduces a limited absolute latency cost. These costs are limited in this deployment setting. Schema-valid and closed-vocabulary output is guaranteed by constrained decoding. The structured prediction can therefore be integrated directly into instructor-facing aggregation without a post hoc parsing stage.
Table 7.
Inference-time comparison between free decoding and FSM-constrained decoding on closed-vocabulary datasets.
5. Conclusions
MHE-T5 is presented as a constrained multi-granularity generative model for sentiment analysis of online-education reviews that jointly produces aspect- and document-level sentiment in a single schema. Its principal contribution is the integration of grammar/FSM-constrained decoding, document–aspect consistency coupling, and cross-granularity contrastive representation learning within one task-specific framework rather than any component in isolation. Across four datasets, the framework is evaluated against discriminative, generative, and prompting-LLM baselines under the stated protocol; the fixed comparison shows higher fine-grained aspect extraction scores for the fine-tuned model. The cross-dataset analysis indicates that saturation, the frequency of multi-aspect conflict, and schema openness limit the expectation of a uniform performance gain. The propositions establish schema closedness and conditional document–aspect alignment under explicit assumptions; prediction quality is established empirically and is not guaranteed by those propositions. The domain-shift and low-resource analyses further show that decoding constraints preserve parseability and known-vocabulary conformity but do not remove errors in target-aspect selection. Future work will extend the integrated framework to multimodal and cross-domain review streams and to interactive instructor-facing dashboards.
Author Contributions
Conceptualization, S.G.; methodology, S.G.; software, S.G.; validation, Y.K. and L.C.; formal analysis, S.G. and Y.K.; investigation, S.G.; data curation, Y.K.; writing—original draft preparation, S.G.; writing—review and editing, Y.K. and L.C.; visualization, S.G.; supervision, L.C. All authors have read and agreed to the published version of the manuscript.
Funding
This research was funded by the 2025 Hunan Provincial Education Science Planning Project, “Research on the Application of Generative Natural Language Processing Technology in Emotional Guidance and Interactive Classroom Teaching”, grant number XJK25QXX003.
Institutional Review Board Statement
Not applicable.
Informed Consent Statement
Not applicable.
Data Availability Statement
The implementation, preprocessing scripts, prompts, dataset splits, processed outputs, and evaluation code will be made available by the corresponding author upon reasonable request after the related materials are curated.
Acknowledgments
The authors thank the maintainers of the public review and ABSA datasets used in this study.
Conflicts of Interest
The authors declare no conflicts of interest.
References
- Pineda-Briseño, A.; Oblitas Cruz, J.; Sánchez, L.C.; Sanchez, W.; Baltazar, R. A Context-Aware Framework for Sentiment Analysis of Student Feedback to Inform Educational Strategies in Latin America. Educ. Sci. 2026, 16, 399. [Google Scholar] [CrossRef] [Scilit]
- Mammadova, E.; Mentzer, N.; Waitoller, F.R.; Traynor, A. A Comparative NLP-Based Sentiment Analysis of Basic Psychological Needs and Engagement Among Students with and Without Disability Accommodations in a Design Thinking Course with HyFlex Settings. Educ. Sci. 2026, 16, 457. [Google Scholar] [CrossRef] [Scilit]
- Hussain, T.; Yu, L.; Asim, M.; Ahmed, A.; Wani, M.A. Enhancing E-Learning Adaptability with Automated Learning Style Identification and Sentiment Analysis: A Hybrid Deep Learning Approach for Smart Education. Information 2024, 15, 277. [Google Scholar] [CrossRef] [Scilit]
- Hua, Y.C.; Denny, P.; Wicker, J.; Taskova, K. EduRABSA: An Education Review Dataset for Aspect-based Sentiment Analysis Tasks. arXiv 2025, arXiv:2508.17008. [Google Scholar]
- Tzimiris, S.; Nikiforos, S.; Nikiforos, M.N.; Mouratidis, D.; Kermanidis, K.L. A Comparative Evaluation of Transformer-Based Language Models for Topic-Based Sentiment Analysis. Electronics 2025, 14, 2957. [Google Scholar] [CrossRef] [Scilit]
- Alawaji, R.; Aloraini, A. Sentiment Analysis of Digital Banking Reviews Using Machine Learning and Large Language Models. Electronics 2025, 14, 2125. [Google Scholar] [CrossRef] [Scilit]
- Smid, J.; Priban, P.; Kral, P. Improving Generative Cross-lingual Aspect-Based Sentiment Analysis with Constrained Decoding. arXiv 2025, arXiv:2508.10369. [Google Scholar]
- Jun, Y.; Lee, H. Dynamic Order Template Prediction for Generative Aspect-Based Sentiment Analysis. In Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics (Volume 2: Short Papers); Association for Computational Linguistics: Stroudsburg, PA, USA, 2025; pp. 614–626. [Google Scholar] [CrossRef] [Scilit]
- Hellwig, N.C.; Fehle, J.; Kruschwitz, U.; Wolff, C. nchellwig at SemEval-2026 Task 3: Self-Consistent Structured Generation (SCSG) for Dimensional Aspect-Based Sentiment Analysis Using Large Language Models. In Proceedings of the 20th International Workshop on Semantic Evaluation; Association for Computational Linguistics: Stroudsburg, PA, USA, 2026; pp. 37–47. [Google Scholar] [CrossRef] [Scilit]
- Shahana, S.A.; Afrin, N.N.; Anwar, M.M.; Jahan, I. Gen-mABSA-T5: A Multilingual Zero-Shot Generative Framework for Aspect-Based Sentiment Analysis. In Proceedings of the Second Workshop on Bangla Language Processing; Association for Computational Linguistics: Stroudsburg, PA, USA, 2025; pp. 142–150. [Google Scholar] [CrossRef] [Scilit]
- Wang, Q.; Ding, K.; Gao, H.; Wang, H.; Xu, R. Error Comparison Optimization for Large Language Models on Aspect-Based Sentiment Analysis. In Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers); Association for Computational Linguistics: Stroudsburg, PA, USA, 2025; pp. 18630–18646. [Google Scholar] [CrossRef] [Scilit]
- Neveditsin, N.; Lingras, P.; Mago, V.K. From Annotation to Adaptation: Metrics, Synthetic Data, and Aspect Extraction for Aspect-Based Sentiment Analysis with Large Language Models. In Proceedings of the 2025 Conference of the Nations of the Americas Chapter of the Association for Computational Linguistics: Human Language Technologies (Volume 4: Student Research Workshop); Association for Computational Linguistics: Stroudsburg, PA, USA, 2025; pp. 142–161. [Google Scholar] [CrossRef] [Scilit]
- Lu, B.; Shirai, K.; Kertkeidkachorn, N. Aspect-Enhanced Prompting Method for Unsupervised Domain Adaptation in Aspect-Based Sentiment Analysis. Information 2025, 16, 411. [Google Scholar] [CrossRef] [Scilit]
- Kim, J.; Kil, H. Sparse Attention-Based Residual Joint Network for Aspect-Category-Based Sentiment Analysis. Mathematics 2025, 13, 2437. [Google Scholar] [CrossRef] [Scilit]
- Li, X.; Zhang, K.; Han, D. Duality-Driven Aspect Sentiment Triplet Extraction with LLM and Iterative Reinforcement. Symmetry 2025, 17, 642. [Google Scholar] [CrossRef] [Scilit]
- Jiang, B.; Wan, Y.; Ju, S. Heuristic-enhanced Candidates Selection strategy for GPTs tackle Few-Shot Aspect-Based Sentiment Analysis. arXiv 2024, arXiv:2404.06063. [Google Scholar]
- Zhang, W.; Deng, Y.; Liu, B.; Pan, S.J.; Bing, L. Sentiment Analysis in the Era of Large Language Models: A Reality Check. In Proceedings of the Findings of the Association for Computational Linguistics: NAACL 2024; Association for Computational Linguistics: Stroudsburg, PA, USA, 2024; pp. 3881–3906. [Google Scholar]
- DeepSeek-AI. DeepSeek-V3 Technical Report. arXiv 2024, arXiv:2412.19437. [Google Scholar] [CrossRef] [Scilit]
- Roumeliotis, K.I.; Margaris, D.; Spiliotopoulos, D.; Vassilakis, C. Large Language Models as Explainable AI Ensemble Aggregators for Business Review Sentiment Analysis: A Comparative Study with Classical Ensembles. Appl. Sci. 2026, 16, 6479. [Google Scholar] [CrossRef] [Scilit]
- Kulkarni, A.; Dogra, V. Event-Based Sentiment Analysis of Financial News Using Large Language Models: A Comprehensive Framework Integrating RAG, GNNs, and Multi-Agent Systems. Information 2026, 17, 558. [Google Scholar] [CrossRef] [Scilit]
- Zulkhazhav, A.; Bekmanova, G.; Yergesh, B.; Nazyrova, A.; Lamasheva, Z.; Aimicheva, G. A Multi-Level Hybrid Architecture for Structured Sentiment Analysis. Electronics 2026, 15, 249. [Google Scholar] [CrossRef] [Scilit]
- Li, X.; Zhang, K. Contrastive Learning Pre-Training and Quantum Theory for Cross-Lingual Aspect-Based Sentiment Analysis. Entropy 2025, 27, 713. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Li, S.; Luo, W. Knowledge-Augmented Graph Convolutional Network for Aspect Sentiment Triplet Extraction. Appl. Sci. 2026, 16, 1250. [Google Scholar] [CrossRef] [Scilit]
- Sattar, M.U.; Hasan, R.; Palaniappan, S.; Mahmood, S.; Khan, H.W. Beyond Polarity: Forecasting Consumer Sentiment with Aspect- and Topic-Conditioned Time Series Models. Information 2025, 16, 670. [Google Scholar] [CrossRef] [Scilit]
- Li, Q.; Wen, W.; Qin, J. Boundary-Driven Table-Filling with Cross-Granularity Contrastive Learning for Aspect Sentiment Triplet Extraction. In Proceedings of the ICASSP 2025—2025 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP); IEEE: Piscataway, NJ, USA, 2025. [Google Scholar]
- Koo, T.; Liu, F.; He, L. Automata-based constraints for language model decoding. arXiv 2024, arXiv:2407.08103. [Google Scholar]
- Dong, Y.; Ruan, C.F.; Cai, Y.; Lai, R.; Xu, Z.; Zhao, Y.; Chen, T. XGrammar: Flexible and Efficient Structured Generation Engine for Large Language Models. arXiv 2024, arXiv:2411.15100. [Google Scholar]
- Wu, C.; Ma, B.; Liu, Y.; Zhang, Z.; Deng, N.; Li, Y.; Chen, B.; Zhang, Y.; Xue, Y.; Plank, B. M-ABSA: A Multilingual Dataset for Aspect-Based Sentiment Analysis. In Proceedings of the 2025 Conference on Empirical Methods in Natural Language Processing; Association for Computational Linguistics: Stroudsburg, PA, USA, 2025. [Google Scholar]
- Mamyrbayev, O.; Mussayeva, D.; Kurmetkan, T. Enhanced Sentiment Analysis of E-Commerce Product Reviews Using Luong Attention-Based Bi-LSTM. Information 2026, 17, 398. [Google Scholar] [CrossRef] [Scilit]
- Scaria, K.; Gupta, H.; Goyal, S.; Sawant, S.A.; Mishra, S.; Baral, C. InstructABSA: Instruction Learning for Aspect Based Sentiment Analysis. In Proceedings of the 2024 Conference of the North American Chapter of the Association for Computational Linguistics (NAACL), Short Papers; Association for Computational Linguistics: Stroudsburg, PA, USA, 2024. [Google Scholar]
- Zhao, Q.; Yuan, Y.; Long, Y.; Xu, G.; Wang, J. Leveraging sensory knowledge into Text-to-Text Transfer Transformer for enhanced emotion analysis. Inf. Process. Manag. 2025, 62, 103876. [Google Scholar] [CrossRef] [Scilit]
- Wang, G.; Chen, Z.; Li, B.; Xu, H. Cer-Eval: Certifiable and Cost-Efficient Evaluation Framework for Large Language Models. arXiv 2025, arXiv:2505.03814. [Google Scholar]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license.







