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.
Figures & tables
Figure 1: SenseShift VS decoder-based prompting for sentiment CTG. Based on a given text, target sentence and sentiment, SenseShift places sentiment tokens before each sentence. encoder-architecture allows SenseShift to predict masked tokens attending to each target sentiment while distinguishing prior context from posterior.
Model
Story Evaluation
Review Evaluation
PPL old
PPL new↓
Δs↓
Δf↑
Corr. ↑
Acc. ↑
PPL old
PPL new↓
Δs↓
Δf↑
Corr. ↑
Acc. ↑
Prompting
ModernBert-D-28m
80.6
255.5
0.56
-0.29*
0.07
0.36
222.3
161.2
0.69
-0.13*
-0.19
0.23
Llamma3.2-3b
81.1
118.1
0.50
-0.05*
0.25
0.41
239.4
113.1
0.51
-0.00
0.21
0.38
Gemma2-2b
88.6
139.2
0.56
-0.00
0.15
0.37
245.1
117.3
0.55
0.02*
0.14
0.37
Gemma2-9b
83.6
126.2
0.39
-0.03*
0.65
0.55
268.3
97.8
0.44
0.00
0.53
0.50
Table 1: Overall comparison between baselines and SenseShift . Significantly different changes ( p -value<0.01) compared to the 0 baseline are marked with an asterisk. Note that columns under green are same models trained on story and columns under red are same models trained on review. in table PPLold refers to perplexity of the original sentence calculated using GPT-2 and PPLnew refers to generated sentence perplexity
Figure 2: Δs across three evaluation dimensions. Shaded regions indicate variance. Left: Δs vs. target sentiment. Center: Δs vs. relative sentence position. Right: Δs vs. number of masked tokens.
Criterion
Gemma2-2b
SenseShift
Both
Neither
Fitness
22.1
23.0
46.9
8.0
Fluency
6.2
6.2
85.0
2.7
Sentiment
28.3
31.0
28.3
12.4
Overall
18.9
20.1
53.4
7.7
Table 2: Users preference ( % ) of sentences generated by ModernBert-E-0.4b -story vs Gemma2-2b trained with Token-Instruction-Tuning. Rows correspond to evaluation criteria: contextual fitness, grammatical correctness, and sentiment following.
Appendix figures & tables10 assets
Supplementary material from the paper’s appendix.
Appendix
Figure 3: Sentiment of story ending written by GPT4o-Mini for Negative, Positive, and Neutral ending with and without intensifying adverb "Very" in the prompt.
Statistics
TinyStories
Yelp
Num Samples
4439352
252085
Positive (>0.2)
53.7%
41.0%
Negative (<-0.2)
0.3%
4.3%
Neutral
46.0%
54.8%
Text
Avg Sentences
14.2 ± 7.77
6.4 ± 4.86
Appendix
Table 3: Dataset statistics for the train splits. Sentiment scores are in [−1,1] .
State
Hyperparameter
Prompt/Steer
Inst-Tune
Token-Inst-Tune
SenseShift
Training
Learning rate (lr)
–
1e-5
1e-5
1e-5
Batch size (bs)
–
32
32
50
Dropout (dp)
–
0.0
0.0
0.0
Warmup steps
–
500
500
500
Epochs
–
30
30
50
Weight decay
–
0.01
0.01
0.01
Appendix
Table 4: Default hyperparameters used across different training paradigms for controllability. * value for Qwen is 1024 to ensure finalizing thinking process.
Model
Train
Story Generation
Review Generation
Ppl. ↓
Δs↓
Δf↑
Corr. ↑
Acc. ↑
Ppl. ↓
Δs↓
Δf↑
Corr. ↑
Acc. ↑
Whole Mask Prediction
ModernBert-E-0.15b
Story
596.8
0.42
-0.01
0.54
0.44
303.1
0.44
-0.02*
0.48
0.38
Review
482.9
0.50
-0.04*
0.27
0.31
325.2
0.43
-0.01
0.55
0.44
ModernBert-E-0.4b
Story
869.9
0.4
-0.039*
0.55
0.5
571.3
0.43
0.01
0.48
0.39
Review
426.3
0.50
-0.041*
0.29
0.32
288.8
0.44
-0.013
0.51
0.41
Appendix
Table 5: Comparison between Iterative Mask Infilling and Whole Mask prediction
Criterion
Gemma2-2b
SenseShift
Both
Neither
Fitness
17.2
23.4
54.7
4.7
Grammar
4.7
4.7
89.1
1.6
Sentiment
29.7
28.1
31.2
10.9
Overall
17.2
18.8
58.3
5.7
Appendix
Table 6: Human preference evaluation on the Story domain (n=55 sentence pairs). The specific model used for evaluation is ModernBert-E-0.4b trained on stories. Similarity to Original is reported as a diagnostic metric and excluded from the Overall score.
Criterion
Gemma2-2b
SenseShift
Both
Neither
Fitness
27.7
23.4
36.2
12.8
Grammar
8.5
8.5
78.7
4.3
Sentiment
25.5
36.2
23.4
14.9
Overall
20.6
22.7
46.1
10.6
Appendix
Table 7: Human preference evaluation on the Review domain (OOD n=45 sentence pairs). The specific model used for evaluation is ModernBert-E-0.4b trained on stories. Similarity to Original is reported as a diagnostic metric and excluded from the Overall score.
Figure 4: Mean Δs as a joint function for the ModernBert-E-0.4b -story. Left: Target sentiment vs. relative sentence position. Center: Target sentiment vs. number of masked tokens. Right: Relative sentence position vs. number of masked tokens. Lower values (green) indicate better sentiment control.
Figure 5: Interactive demo of SenseShift . Users can choose or randomly select data from both dataset and edit different sentences with their desired sentiment intensity
Figure 6: Qualitative examples of iterative sentiment editing on a story (in-distribution). Each subfigure shows the sentiment arc (top) and annotated text (bottom).
Figure 7: Qualitative examples of iterative sentiment editing on a hotel review (out-of-distribution). Each subfigure shows the sentiment arc (top) and annotated text (bottom).
Controllable text generation steers language models toward desired attributes, formats, audiences, and constraints while preserving useful, natural text.
The prevalence of Large Language Models (LLMs) in critical applications highlights the need for controlled language generation methods that are both computationally efficient and enjoy performance guarantees. To address this need, we use a common model of concept semantics as linearly represented in an LLM's latent space. In particular, we take the view that natural language generation traces a trajectory in this continuous semantic space, realized by the language model's hidden activations. This view permits a control-theoretic treatment of text generation in latent space, in which we propose Linear Semantic Control (LiSeCo), a lightweight, gradient-free intervention that dynamically steers trajectories away from regions corresponding to undesired meanings. In particular, we propose to directly intervene, in an online fashion, the activations of the token that is being generated in embedding space. Crucially, LiSeCo does not simply steer activations towards a desirable region. Instead, it relies on classical techniques from control theory to precisely control activations in a context-dependent way, and guarantees that they are brought into a specific pre-defined region of embedding space that corresponds to allowed semantics. The intervention is computed in closed form according to an optimal controller formulation, minimally impacting generation time. This control of the activations in embedding space allows for fine-grained steering of attributes of the generated sequence. We demonstrate that our approach is effective on different tasks -- toxicity, sentiment, and language (English/Spanish) steering -- while maintaining text quality.
Emily Cheng, Carmen Amo Alonso
Universitat Pompeu Fabra, Barcelona, Spain · Stanford University, CA, USA
Controllable generation requires language models to realize output characteristics such as reading level, politeness, and toxicity. Existing steering methods are often indirect, require access to internal activations, or depend on auxiliary trained models. We propose SWAI, a training-free inference-time method that addresses these limitations by steering directly in logit space using corpus-derived token statistics. SWAI computes z-normalized one-vs-rest log-odds scores from labeled corpora and biases high-scoring tokens only within the model's top-K candidate set, allowing control to favor target-characteristic tokens while preserving contextually plausible choices. Across readability, politeness, and toxicity control, SWAI consistently improves over prompt-based and prior logit-level baselines without modifying model parameters, accessing internal layers, or training an auxiliary model. Selectivity and lookup-table ablations show that the gains come from target-specific statistical scores rather than generic logit perturbation. These results indicate that effective steering does not require learned controllers when the logit intervention is guided by target-specific statistics under high-probability candidates.
Hyeseon An, Shinwoo Park, Hyundong Jin +1
Department of Computer Science, Yonsei University, Seoul, South Korea
Audiobook narration, conversational agents, and audiovisual dubbing require fine-grained control over emotion and pacing within an utterance, yet many text-to-speech (TTS) systems remain limited to utterance-level conditioning. We propose a unified post-training framework for natural-language segment-level emotion and duration control. Supervised fine-tuning (SFT) establishes instruction following, while group relative policy optimization (GRPO) further improves control accuracy using emotion, duration, content, and speaker rewards. Without modifying the pretrained architecture or adding inference-time control modules, our method improves fine-grained controllability while preserving intelligibility and speaker identity, demonstrating post-training as an effective way to extend pretrained TTS models.
Lianru Gao, Yujie Guo, Yong Qin
TMCC, College of Computer Science, Nankai University, Tianjin, China