AI / ML · 2024

Emotion Translation with Transformers

Rewrite the emotion of a sentence without changing what it says. A study in controllable generation — and in how tangled sentiment and semantics really are.

Milad Farazian · Charlie Floeder · Rizq Khateeb · Harshit Shah · Yash Sharma

PythonTransformersNLPControllable Generation

The problem

Take a neutral sentence — “The meeting is at 3pm.” — and re-render it as joyful, angry, or melancholic, while keeping the fact intact. It sounds like style transfer, but it isn't: sentiment and semantics are entangled. Push the emotion too hard and the model starts inventing content (“the meeting I've been dreading all week”); hold the meaning too tightly and the emotion never lands. The interesting work is the tension between those two failure modes.

The approach

Three architectures

GPT-2 (decoder-only), BART, and T5 (encoder-decoder) — chosen to compare how the architecture itself shapes the meaning-preservation trade-off.

Three regimes

Zero-shot, few-shot, and supervised fine-tuning across all three, so the gain from actually training could be separated from what prompting alone buys.

The dual objective

An output only counts if it hits the target emotion AND preserves the source's factual content — success on one axis alone is a failure.

Why it stuck with me

This was a graduate coursework project at USC, and it's the earliest version of the question I still work on: how do you make a language model do the thing you asked, and only the thing you asked? Emotion translation is that question in miniature — the model must change one dimension and hold everything else still. The production version of the same instinct is Honest, where an eval harness checks that a model's answer stayed grounded in the facts it was given.