---
kind: concept
slug: text-style-transfer
title: Text style transfer
summary: >-
  Rewrites a sentence into another style while keeping its meaning. Only one card so far: a tag-and-generate method that adds polite phrases to neutral requests. A tagger marks where phrases go, then a generator fills them in. Its politeness BLEU-self is 70.44 against 11.83 for DRG, at 89.50 against 90.25 accuracy. Author-reported.
tags: [style-transfer, politeness, tagging, text-generation]
papers: ["2004.14257"]
related: [controllable-text-generation, sequence-to-sequence-learning]
status: draft
updated_at: 2026-11-15
---

## Overview

The task is to take a sentence written in one style and produce a sentence in
a target style with the same content. Classic benchmarks use two opposite
poles, such as positive and negative reviews [arxiv:2004.14257 §1]. Politeness
is harder, because the source side is neutral: it has no polite markers to
remove, so the system must add wording rather than swap it [arxiv:2004.14257
§1] [arxiv:2004.14257 §4.2].

The invariant the method keeps is the content of the source. It edits by
inserting target-style phrases into the source sentence, so the original words
stay in place [arxiv:2004.14257 §4.2]. Older methods instead retrieve a
similar sentence from the other style and delete and replace words
[arxiv:2004.14257 §2].

## Variants

Only one paper with a card covers this concept so far. Its tagger comes in
two forms, and the paper compares them on two datasets.

### Add-tagger for neutral sources

The tagger is trained only on target-style sentences. Each training source is
the target sentence with its style phrases deleted, and the tagger learns to
put position tags where those phrases were [arxiv:2004.14257 §4.2] [arxiv:2004.14257
eq. 4]. Because the source needs no phrases, this suits a neutral input. It is
the variant the authors use for politeness [arxiv:2004.14257 §4.2]. The
generator, trained on tagged sentences paired with the original target, then
fills each tag with a phrase [arxiv:2004.14257 §4.3] [arxiv:2004.14257 eq. 5].
Card: [Politeness Transfer: A Tag and Generate Approach](/papers/2004.14257).

### Replace-tagger for styled sources

The tagger is trained on source-style sentences, with the source phrases
replaced by tags [arxiv:2004.14257 §4.2] [arxiv:2004.14257 eq. 3]. This
needs the input to carry phrases that can be removed. Table 5 reports it on
Yelp and Captions only [arxiv:2004.14257 tab. 5].

### Combined tagger

The authors also report a combined tagger that uses both training sets
[arxiv:2004.14257 tab. 5]. On Yelp it gives the highest BLEU-r of the three
taggers (22.46) with accuracy 72.5, between the two single variants. On
Captions it gives the highest BLEU-r (18.51) but the lowest accuracy of the
three (82.17) [arxiv:2004.14257 tab. 5].

## When to use which

| Situation | Use | Why |
|---|---|---|
| Input is neutral, with no style phrases to delete (for example, plain requests to become polite) | Add-tagger | The paper's own setting; the add-tagger is trained for this case [arxiv:2004.14257 §4.2] |
| Input already carries phrases of the source style that can be cut out | Replace-tagger | Trained for that case [arxiv:2004.14257 §4.2]; it reaches 86.6 accuracy on Yelp against 53.2 for the add-tagger [arxiv:2004.14257 tab. 5] |
| Accuracy matters and the data looks like Captions, not Yelp | Add-tagger, checked on your data | On Captions the add-tagger reaches 93.17 accuracy and 15.63 BLEU-r, against 84.5 and 15.04 for the replace-tagger. On Yelp the add-tagger reached only 53.2 [arxiv:2004.14257 tab. 5] |
| Content overlap (BLEU-r) matters more than accuracy | Combined tagger | Highest BLEU-r on Yelp and Captions, but accuracy falls to 72.5 and 82.17 [arxiv:2004.14257 tab. 5] |

The paper gives these results on its own datasets and under its own metrics
only. They do not show which tagger is better for a new domain
[arxiv:2004.14257 §5].

Constraints the paper states for its method:

- **Data.** Two labelled corpora are needed: target-style sentences for the
  add-tagger, plus, for the replace-tagger, source-style sentences
  [arxiv:2004.14257 §4.2]. The politeness data is built from Enron emails and
  scored with an external classifier; the 800-sentence test set is
  hand-annotated [arxiv:2004.14257 §3.1].
- **Models.** Two sequence-to-sequence transformers, a tagger and a generator,
  with four layers and hidden size 512 in the paper's setting [arxiv:2004.14257
  §5]. Inference runs both models with beam size 5 [arxiv:2004.14257 §5].
- **Effort.** The phrase scoring in [arxiv:2004.14257 eq. 1] and [arxiv:2004.14257
  eq. 2] is simple counting, but the method runs two trained models at
  inference time, each with beam search [arxiv:2004.14257 §4].
- **Evaluation.** Politeness accuracy comes from a classifier trained on other
  data, so accuracy inherits that classifier's biases [arxiv:2004.14257 §5].

## Implementation sketch

Two-stage pipeline for the add-tagger. Phrase scores come from tf-idf ratios
between the target and source corpora [arxiv:2004.14257 eq. 1]. Phrases are
then normalised with smoothing exponent 0.75 [arxiv:2004.14257 eq. 2]
[arxiv:2004.14257 §5].

```pseudocode
# Score candidate phrases by target-to-source tf-idf ratio
# [arxiv:2004.14257 eq. 1]
# Smooth with exponent gamma = 0.75, then normalise
# [arxiv:2004.14257 eq. 2]
def phrase_scores(target_sents, source_sents, gamma):
    ...
# Training pairs for the add-tagger: phrases deleted in, tags out
# [arxiv:2004.14257 §4.2]
def tagger_pairs(target_sents, phrases):
    ...
# Train the tagger on those pairs, then the generator on tagged-to-target
# pairs [arxiv:2004.14257 §4.3]
# Inference: tagger proposes tags (reranked to prefer more tags), generator
# fills them [arxiv:2004.14257 §5]
def transfer(source, tagger, generator):
    tagged = beam_search(tagger, source, beam=5, prefer_tags=True)
    return beam_search(generator, tagged, beam=5)
```

Where variants differ: the replace-tagger changes only the tagger's training
pairs, which are built from source-style sentences [arxiv:2004.14257 §4.2].
The rest of the pipeline is the same [arxiv:2004.14257 §4.2].

Implementers should check the paper's phrase-selection threshold
[arxiv:2004.14257 §4.1] against the released code before copying it. The
code applies it differently from the paper's literal wording; see the
[card's Paper vs code section](/papers/2004.14257).

## Contradictions

Within the paper, the BLEU-r gain on Captions is given two ways. The text says
3.64 [arxiv:2004.14257 §5], while the table difference between 15.63 and 11.78
is 3.85 [arxiv:2004.14257 tab. 2]. The paper gives no reason for the gap.

No disagreements with other papers are known, because only one card covers
this concept so far.

## Papers

- [Politeness Transfer: A Tag and Generate Approach](/papers/2004.14257): tags
  positions for phrase insertion on neutral sentences, then generates the
  phrases. Politeness BLEU-self 70.44 against 11.83 for DRG, at accuracy 89.50
  against 90.25 (author-reported).
