TL;DR
Autoregressive language models often fall into repetitive "degeneration" loops when generating text. This paper introduces Contrastive Token (CT) learning, an auxiliary training objective that directly contrasts the ground-truth label token against recently generated preceding tokens using the hidden state as an anchor. By suppressing likely repetitive tokens relative to positive targets—without accidentally boosting irrelevant vocabulary—CT dramatically slashes repetition and improves generation diversity with simple greedy decoding.
What Problem Does This Paper Address?
Standard autoregressive language models (LMs) are trained using cross-entropy (CE) to predict the next token. At test time, especially during open-ended generation, LMs frequently suffer from neural text degeneration: they get stuck in loops, repeating tokens, phrases, or entire sentences.
Standard cross-entropy penalizes all non-target tokens equally, meaning recently generated words (which are prone to repetitive loops) are penalized no harder than irrelevant words across the vocabulary. Prior fixes like Unlikelihood Training (UL) attempt to explicitly push down the probability of preceding tokens. However, UL operates unilaterally on negative tokens without directly tying them to the target token. Mathematically, this can unintentionally boost random, irrelevant words, introduce prediction uncertainty, and lead to ungrammatical continuations at later decoding steps.
Methods
The authors introduce Contrastive Token Learning (CT), which frames token prediction as an N-pair contrastive objective:
- Contrastive Objective: At time step $t$, the hidden state $\mathbf{h}_t$ serves as the anchor. The model contrasts the logit of the positive ground-truth token $x_t$ against the logits of a set of negative candidate tokens $S_t^N$: $$\mathcal{L}_{CT}^t = \log \left( 1 + \sum_{x_t^- \in S_t^N} \exp(\mathbf{h}_t^\top \mathbf{W}_{x_t^-} - \mathbf{h}_t^\top \mathbf{W}_{x_t}) \right)$$
- Negative Token Selection: Rather than treating all preceding tokens as negatives (which introduces excessive noise late in the sequence), CT selects the preceding $M$ tokens ($S_t^N = \{x_{t-M}, \dots, x_{t-1}\} \setminus \{x_t\}$). Crucially, $S_t^N$ is kept as a multiset—frequently occurring recent tokens appear multiple times, penalizing frequent repeaters more aggressively.
- Combined Training: The model is trained on a joint loss: $\mathcal{L}^t = \mathcal{L}_{CE}^t + \mathcal{L}_{CT}^t$. CE ensures the correct token receives the highest likelihood, while CT actively pushes down recently seen tokens relative to the target.
[ Hidden State h_t (Anchor) ]
/ \
(Pull together) (Push away)
/ \
[ Positive Token x_t ] [ Preceding M Tokens (Multiset S_t^N) ]
Datasets
The authors evaluated CT on two generation tasks:
- Language Modeling: Evaluated on Wikitext-103, fine-tuning GPT-2 Small.
- Open-Domain Dialogue Generation: Evaluated using a 400M-distilled BlenderBot on a combined dialogue benchmark consisting of PersonaChat, Empathetic Dialogues, Wizard of Wikipedia, BlendedSkillTalk, and DailyDialog.
No new benchmarks were introduced; all evaluations used established standard datasets.
Key Insights and Ideas
- Clean Gradient Dynamics: A gradient analysis reveals that in CT, the gradient with respect to non-context irrelevant tokens is strictly zero. In contrast, UL's gradient inadvertently increases the probability of irrelevant tokens, and CE suppresses all non-target tokens uniformly.
- Anchor at Hidden States, Contrast at Embeddings: While previous contrastive NLP methods contrast hidden states across sequence positions, CT uses the contextual hidden state as an anchor to contrast token output embeddings (logits).
- Fixing the Probability Distribution: Probability heatmaps show that standard CE becomes overconfident in later sequence stages, driving loops. Sequence-level unlikelihood (UL-TS) swings too far the other way, becoming completely uncertain and generating gibberish. CT maintains balanced variance throughout generation, mirroring human text distributions.
- Greedy Search Suffices: Instead of relying on stochastic sampling (top-$k$, nucleus) or heuristic search penalties (contrastive search) that compromise coherence, CT fixes the learned representations so that simple greedy search produces diverse, low-repetition text.
Key Results
- Dramatic Repetition Drop (Language Modeling): Under greedy search on Wikitext-103, CT drops 4-gram repetition (rep-4) from 50.93% (GPT-2 CE) and 14.42% (UL-TS) down to 1.52%, nearing the human level (1.14%).
- Lexical Diversity: Vocabulary usage expanded dramatically: CT generated 21,562 unique 1-grams (
uniq-1), outperforming sequence-level unlikelihood (14,378) and standard GPT-2 (12,787). - Open-Domain Dialogue: Under greedy decoding, CT achieved a rep-1 rate of 9.19% (vs. 25.77% for BlenderBot CE and 15.58% for UL-TS), close to the human baseline of 8.33%.
- Human Evaluation: Evaluators preferred CT over decoding-based baselines like Top-$k$ (58% vs. 36% win rate) and SimCTG-CS (55% vs. 35% win rate) for overall quality, citing significant gains in coherence and reduced repetitiveness.
Limitations and Future Work
- Short-Context Perplexity: CT slightly increases 512-token sequence perplexity (+0.66 points) but shows a larger spike on very short 50-token sequences (
ppl-srises to 52.77), indicating potential distribution distortion on brief contexts. - Remaining Degeneration: While token/phrase loops are largely eliminated, occasional high-level semantic or sentence-level repetitions still persist.
- Scale Constraints: Experiments were limited to smaller models (GPT-2 Small, BlenderBot-400M) due to compute constraints. Testing CT during large-scale pre-training (e.g., LLaMA, GPT-3 scale) or applying it to encoder-only architectures (e.g., BERT) remains future work.
Summary updated