Source-linked AI summary

SENSESHIFT: Continuous Sentiment-Controlled Text Generation via Encoder-based Mask Infilling

Shahed Masoudian, Markus Frohmann, Emmanouil Karystinaios, Navid Rekabsaz, Markus Schedl

arXiv:2608.24304v1cs.CLcs.AI

TL;DR

Fine-grained sentence-level sentiment control within long-form text remains underexplored because prior CTG methods commonly rely on decoder architectures, coarse labels, or document-level signals. SENSESHIFT uses an encoder with bidirectional attention, quantized sentence-level sentiment tokens, and iterative mask infilling. Across story and review generation, it reports stronger sentiment control with preserved fluency, contextual fitness, and out-of-domain robustness than larger decoder baselines.

  • Problem

    Sentence-level fine-grained sentiment control in long-form text is underexplored, while prior methods commonly use decoder architectures and coarse or document-level sentiment controls.

  • Method

    SENSESHIFT uses bidirectional encoder attention, quantized sentence-level sentiment tokens, and iterative mask infilling to generate locally controlled sentences.

  • Results

    SENSESHIFT achieves the strongest overall performance, with MODERNBERT-E-0.4B reaching the lowest perplexity, 53.6 on Story, while maintaining near-zero ∆f across domains.

  • Takeaways & Limitations

    SENSESHIFT provides an encoder-centric alternative for fine-grained sentiment-aware generation that preserves sentiment adherence, fluency, and contextual fitness across in-domain and out-of-domain settings.

  • Takeaways & Limitations

    Training uses narrow TinyStories and review corpora, limiting strong claims about generalization to news, social media, or formal writing.

Abstract

from arXiv · show

Recent controllable text generation (CTG) for sentiment control has largely focused on decoder-based large language models, making causal attention the dominant paradigm. While effective for fluent generation, these models still struggle to satisfy complex constraints and follow fine-grained sentiment signals specified by users. Existing sentiment-aware CTG methods typically simplify the problem by treating sentiment either as a coarse categorical label (e.g., positive or negative) or as a single fine-grained control signal applied to an entire document. Consequently, more challenging settings such as sentence-level sentiment control within long-form text remain underexplored. To address these limitations, we introduce SenseShift , an encoder-based framework for fine-grained sentence-level CTG. Unlike standard decoder architectures, SenseShift leverages bidirectional attention, quantized sentiment signals, and iterative mask infilling to generate local sentences conditioned on target sentiment intensity. Empirical evaluations on story and review generation demonstrate that SenseShift achieves stronger sentiment controllability while maintaining text quality and robustness to out-of-domain generation compared to larger decoder-based baselines.

1 Introduction

SENSESHIFT targets underexplored sentence-level, fine-grained sentiment control in long-form text by replacing decoder-based causal generation with encoder-based bidirectional mask infilling. It combines quantized sentiment signals with contextual generation and outperforms larger decoder baselines while preserving fluency and contextual fit.

  • Existing sentiment-aware CTG commonly uses decoder models, coarse polarity labels, or document-level controls, leaving sentence-level fine-grained rewriting underexplored.
  • Decoder prompting can produce unstable or weak control for ambiguous sentiment targets, including difficulty distinguishing sentiment intensity.
  • SENSESHIFT uses bidirectional attention, quantized sentiment signals, and iterative mask infilling to generate locally controlled sentences using prior and posterior context.
  • SENSESHIFT consistently outperforms prompting, activation steering, and instruction-tuned decoder baselines on sentiment control while maintaining fluency and contextual fit.

2 Related Work

Prior sentiment-control methods largely use categorical or document-level controls and decoder architectures. SENSESHIFT instead combines fine-grained positional control with encoder-based bidirectional infilling.

  • Early latent-variable, recurrent, decoding-time, and supervised methods generally treat sentiment as a categorical polarity signal.
  • Related fine-grained methods control standalone sentences, story endings, or text parts, but remain limited in positional scope, categorical sentiment, or decoder architecture.
  • SENSESHIFT differs from masked decoder infilling by using an encoder that jointly attends to surrounding context and quantized sentiment intensity.

3 Methodology

SENSESHIFT constructs sentence-level sentiment controls automatically, trains an encoder with persistent conditioning tokens, and generates replacements through iterative mask infilling with beam scoring.

  • VADER supplies sentence-level sentiment scores that are quantized into local control tokens placed before their respective sentences.
  • Control-aware MLM keeps sentiment tokens visible and raises the masking ratio to 40% so reconstruction uses sentiment anchors and surrounding context.
  • Iterative infilling addresses incoherence from parallel masked-token prediction by mimicking sequential and beam-search generation.
  • During inference, the target sentence is masked and regenerated one token at a time using surrounding document context, neighboring signals, and a user-defined target sentiment.
  • Beam scoring uses length-normalized log probability and a diversity penalty to reduce short-completion bias and repetitive candidates.

4 Experimental Setup

Experiments train and test SENSESHIFT across story and review corpora, compare it with multiple decoder-based control paradigms, and evaluate sentiment adherence, fluency, contextual fitness, and human preference.

  • Experimental Setup: SENSESHIFT uses MODERNBERT encoder models with 149M and 395M parameters, substantially smaller than several decoder baselines.
  • Datasets: Training and testing span TinyStories and service reviews, with models trained independently by dataset and evaluated both in-domain and out-of-domain.
  • Baselines: Baselines cover prompting, instruction tuning, token instruction tuning, activation steering, and models ranging from 28M to 120B parameters.
  • Evaluation Metrics: Evaluation measures sentiment error, categorical sentiment accuracy, target-sentiment correlation, perplexity, and contextual fitness based on similarity and entity overlap.
  • Evaluation Metrics: The fitness metric combines preceding- and following-context similarity with entity overlap, while ∆f measures relative change from the original sentence.
  • Human Evaluation: Human evaluation compares SENSESHIFT with token-tuned GEMMA2-2B on 100 documents using contextual fit, grammaticality, and sentiment alignment criteria.

5 Results and Discussion

SENSESHIFT shows strong sentiment control across story and review generation while preserving contextual fit, fluency, and robustness across evaluation conditions. Its encoder-based approach generally outperforms decoder baselines, including larger models, on sentiment alignment and contextual preservation.

  • Baseline analysis: Prompting benefits from scale but can reduce contextual fit, instruction tuning yields uneven gains, and activation steering performs poorly for fine-grained sentence-level sentiment control.OSS-120B achieves the highest prompting correlation and accuracy, while steering produces low correlations, 0.28–0.39 accuracy, and perplexity up to 221.
  • Overall comparison: SENSESHIFT achieves the strongest overall performance, combining low perplexity, small sentiment deviation, and high in-domain sentiment accuracy.MODERNBERT-E-0.4B reaches 53.6 perplexity on Story, 0.20 sentiment deviation on Story, and 0.78 in-domain accuracy on Story.
  • Overall comparison: MODERNBERT-E-0.4B maintains near-zero contextual-fitness change across in-domain and out-of-domain settings, while SENSESHIFT remains competitive or better on most out-of-domain metrics.The out-of-domain block is intended as a robustness check rather than a generalization claim.
  • Sentiment following analysis: Sentiment control varies with target intensity, sentence position, and generation length, but SENSESHIFT maintains a robust advantage across these conditions.Decoder models generally improve with later sentence positions or longer generations, whereas MODERNBERT-E-0.4B shows distinct trends, including stronger improvement toward later positions.
  • Human evaluation: MODERNBERT-E-0.4B receives higher satisfactory sentiment-following judgments than GEMMA2-2B while preserving contextual coherence.The corresponding rates are 31.0% for MODERNBERT-E-0.4B and 28.3% for GEMMA2-2B.
  • Human evaluation: 73.5% of human evaluations rated MODERNBERT-E-0.4B equivalent to or better than GEMMA2-2B, despite using 395M rather than 2B parameters.Annotators found the models equally fluent in 85.0% of samples and equally contextually fitting in 46.9% of cases.

6 Conclusion

SENSESHIFT is introduced as a lightweight encoder-based framework for fine-grained sentiment-aware in-text generation. It uses quantized sentence-level sentiment tokens and modified sequential mask prediction to produce coherent text following fine-grained signals.

  • SENSESHIFT is a lightweight generative framework based on encoder language models for fine-grained sentiment-aware in-text generation.
  • The framework conditions encoder mask prediction with quantized sentence-level sentiment tokens.
  • Modified sequential mask prediction produces coherent text that follows fine-grained sentiment signals.

7 Limitations and Ethical Consideration

The authors identify limitations in sentiment scoring, training data, evaluation, contextual editing analysis, and baseline coverage, while noting misuse risks from coherent sentiment edits.

  • Sentiment Analysis: VADER improves speed and keeps the framework lightweight but is less sensitive to implicit or contextually nuanced sentiment.Reported ∆s values should therefore be interpreted with this scoring constraint.
  • Evaluation: Human disagreement over sentiment polarity and intensity limits how precisely SENSESHIFT can be evaluated against a true sentiment label.
  • Training Corpora and Sentiment Distribution: Training on TinyStories and a review corpus limits claims about generalization to news, social media, and formal writing.Rare extreme sentiment values, especially negative ones, make fine-grained control at the sentiment tails harder.
  • Contextual Effects: Editing errors depend on surrounding sentiment, with more positive context requiring more edits to reverse polarity; this effect was not analyzed further.
  • Baseline Selection and Compute Constraints: Fixed compute constraints prevented evaluation of the largest available open-weight models, narrowing baseline coverage.
  • Ethical Consideration: Fluent, contextually coherent sentiment edits may be difficult to distinguish from originals, creating misuse potential without provenance tracking and safeguards.

A.1 Problem Statement and Motivation

The authors motivate moving beyond prompt-only control because GPT4O-MINI endings show weak intensity separation, positive bias under negative targets, and compressed sentiment ranges.

  • Prompt-Control Motivation: GPT4O-MINI endings show weak separation between adjective and intensified-adjective conditions, indicating limited intensity control.
  • Prompt-Control Motivation: Negative targets can produce a distributional shift toward more positive sentiment.
  • Prompt-Control Motivation: Prompted endings rarely reach sentiment extremes because their score ranges are compressed.

A.2 Baselines

The paper evaluates four decoder-based baseline paradigms: prompting, instruction tuning, token instruction tuning, and activation steering.

  • Baseline Types: Prompting is included as a decoder-based baseline paradigm.
  • Baseline Types: Instruction tuning is included as a decoder-based baseline paradigm.
  • Baseline Types: Token instruction tuning is included as a decoder-based baseline paradigm.
  • Baseline Types: Activation steering is included as a decoder-based baseline paradigm.

A.2.1 Prompts

The baselines use prompts or masked inputs to rewrite a target sentence toward a specified sentiment while preserving fit with the surrounding text. Variants differ in whether the target sentence remains visible and whether special sentiment tokens are added.

  • Prompting: Prompt quality matters because slight changes can vary decoder outputs and sentiment-following accuracy.The authors iteratively modified and reevaluated instructions to identify effective prompts.
  • Prompting: Prompting supplies the full text and asks the model to replace the target sentence with one having the requested sentiment.The prompt asks the model to preserve coherence with the overall text and output only the replacement sentence.
  • Prompting: Prompting was changed from masked-sentence generation because asking for a sentence that fits the location performed inaccurately.
  • Instruction Tuning: Instruction tuning masks the target sentence so the model predicts missing text without leaking the original sentence.
  • Token Instruction Tuning: Token instruction tuning adds SENSESHIFT sentiment tokens and a [MISSING_SENTENCE] token as 22 special untrainable tokens.
  • Prompt Formulation: The prompting formulation asks for a target sentiment value while retaining overall textual coherence.

A.2.2 Activation Steering

Activation steering adapts contrastive activation directions for continuous sentence-level sentiment control, with strength dynamically scaled to target sentiment. The broader evaluation also examines context position, mask size, editing behavior, and human judgments of generated rewrites.

  • Activation Steering: Contrastive pairs with extreme sentiment values provide activation directions for steering models toward desired attribute shifts.The setup samples 10k pairs per dataset, using sentences with |σsi| > 0.9.
  • Activation Steering: Dynamic multiplier scaling adapts activation-steering strength to the target sentiment value, enabling more fine-grained continuous modulation.The original approach primarily targets categorical control, while this adaptation varies strength according to sentiment.
  • Iterative Infilling: Iterative mask infilling reduces perplexity by 5–10× across model sizes and training domains, including a Story reduction from 869.9 to 53.6.Sentiment error also falls by 0.15–0.25, while fitness drift remains near zero compared with whole-mask prediction.
  • Control Robustness: ∆s reaches 0.72 when large mask counts interact with strongly negative targets, while mask size has only a modest effect at neutral-to-positive targets.The strongest interaction occurs across all three heatmaps, indicating that additional generation freedom is most problematic for difficult negative targets.
  • Control Robustness: Mid-document positions from 0.44–0.69 yield the lowest ∆s, whereas errors increase moderately toward later positions and larger mask counts.The interaction between position and mask count is approximately additive.
  • Out-of-Domain Editing: Out-of-domain review editing remains coherent and fluent in both sentiment directions despite training exclusively on stories.The reported review edits use 8 edits for a negative shift and 6 edits for a positive shift.
Loading 2608.24304v1…