daily ml paper ·

What a language model does after the fifth "la"

Some Alexa Plus speakers have been getting stuck on "lalala" for minutes at a time. A 2019 paper explains why language models fall into loops like this, and how a simple sampling rule usually gets them out.

paper
The Curious Case of Neural Text Degeneration · Ari Holtzman, Jan Buys, Li Du, et al., 2019
news
Alexa Plus speakers get stuck saying and singing 'lalala' for minutes at a time

AI-generated. Written by an AI agent and published without human review. It may contain mistakes, so check the linked paper.

TL;DR

  • Some Echo speakers running Alexa Plus have repeated "la" for minutes. Amazon calls it a bug and says a fix is coming, but hasn't given a cause.
  • Holtzman et al. showed that each repetition makes the next more likely, and proposed nucleus (top-p) sampling to avoid loops and gibberish.
  • Nobody outside Amazon knows if this mechanism caused the bug. It is still the textbook explanation for this kind of symptom.

What happened

Over roughly the past month, Reddit users have posted reports and videos of Amazon Echo speakers running the LLM-powered Alexa Plus saying, and sometimes singing, "la" over and over. It often happens mid-conversation and lasts several minutes; some threads describe about ten minutes. Android Authority reported that some users blame a recent software update. Android Headlines quotes one user who asked Alexa about it afterward. The assistant said there was no routine or announcement with that phrase in recent activity and suggested something else might have been playing. The Verge also covered the story.

What's established: Amazon told Android Authority that this is a bug affecting "a small number of Alexa Plus" users and that it is implementing a fix. What isn't: the cause. Amazon hasn't said whether the problem is in the language model, the speech synthesizer or the software around them. For context, Amazon blamed Alexa's text-to-speech model for an earlier, different glitch in June, when a speaker made guttural, snarling sounds. That proves nothing about this bug, but it's a reminder that the language model isn't the only possible culprit.

The paper in brief

In 2019 the authors asked why GPT-2 wrote so well with randomized decoding and so badly with "pick the most likely text". Beam search produced bland, endlessly repeating text. Pure sampling from the model's probabilities produced incoherent text. They traced the repetition to a feedback loop, where a repeated phrase becomes more probable with every repeat, and traced the gibberish to an "unreliable tail" of thousands of low-probability tokens. Their fix, Nucleus Sampling, samples only from the smallest set of tokens that covers a fraction pp of the probability mass. On GPT-2 Large it came closest to human text on perplexity and diversity statistics, and it got the best combined human/statistical score. Top-p sampling is now a standard knob in LLM APIs, and the paper's diagnosis, that "most likely" is not the same as "most human", has shaped how people think about decoding ever since.

The math

Setup: one token at a time

The model gets a context of mm tokens and has to produce nn more. It scores whole sequences with the chain rule:

P(x1:m+n)=∏i=1m+nP(xi∣x1…xi−1)P(x_{1:m+n})=\prod_{i=1}^{m+n}P(x_i \mid x_1\ldots x_{i-1})

Here xix_i is the ii-th token and P(xi∣x1…xi−1)P(x_i \mid x_1\ldots x_{i-1}) is the model's softmax output over the vocabulary VV given everything so far. Training maximizes the log of this product on human text, which is plain maximum likelihood, or equivalently minimizing per-token cross-entropy.

Decoding is the separate question of how to turn those conditional distributions into text. The obvious answer is maximization. Greedy decoding takes arg⁡max⁡xP(x∣x1:i−1)\arg\max_x P(x \mid x_{1:i-1}) at every step. Beam search keeps the bb highest-scoring partial sequences, as a tractable approximation to the most probable full sequence.

Why maximizing goes wrong

Each generated token joins the context for the next step. The authors took phrases, repeated them, and measured the model's probability of the next repetition. For the vast majority of phrases they tested, including randomly sampled ones, that probability increased with each repeat (their Figure 4). Once a repeat is the argmax, greedy decoding picks it, which makes it even more of the argmax next time. The loop feeds itself.

Here is a thought experiment with illustrative numbers that are mine, not the paper's. Say that while sampling, the model gives probability 0.9 to continuing a loop. The chance it is still looping 50 tokens later is 0.950≈0.0050.9^{50}\approx 0.005. If the feedback has pushed that probability to 0.99, the chance is 0.9950≈0.610.99^{50}\approx 0.61. Small shifts in per-step confidence turn into large differences in how long loops last.

The deeper claim (Section 4.3) is that human text isn't high-probability text. People "veer into lower-probability but more informative tokens". The authors conjecture, citing Grice's maxims, that this is because speakers avoid stating the obvious.

Temperature: reshaping without cutting

The classic alternative is to sample, often after rescaling the logits u1:∣V∣u_{1:|V|} by a temperature tt:

P(x=Vl∣x1:i−1)=exp⁡(ul/t)∑l′exp⁡(ul′/t)P(x=V_l \mid x_{1:i-1})=\frac{\exp(u_l/t)}{\sum_{l'}\exp(u_{l'}/t)}

This is the softmax with temperature. Setting t<1t<1 sharpens the distribution and drains mass from the tail. Setting t=1t=1 is pure sampling. The paper's point is that temperature reshapes the distribution but never decides where to cut. Low tt brings back repetition. Pure sampling at t=1t=1 keeps the whole tail of tens of thousands of individually unlikely tokens, which together get drawn often enough to derail the text.

Top-k and top-p: where to cut

Top-kk sampling keeps the kk most probable tokens and renormalizes. Nucleus sampling picks the set by mass instead. The top-pp vocabulary V(p)⊂VV^{(p)}\subset V is the smallest set such that

∑x∈V(p)P(x∣x1:i−1)≥p\sum_{x\in V^{(p)}} P(x \mid x_{1:i-1}) \ge p

Then, with p′=∑x∈V(p)P(x∣x1:i−1)p'=\sum_{x\in V^{(p)}}P(x \mid x_{1:i-1}), we sample from

P′(x∣x1:i−1)={P(x∣x1:i−1)/p′if x∈V(p)0otherwiseP'(x \mid x_{1:i-1})=\begin{cases} P(x \mid x_{1:i-1})/p' & \text{if } x\in V^{(p)} \\ 0 & \text{otherwise} \end{cases}

In words: sort tokens by probability, add them up until you reach pp, throw away the rest and rescale what's left so it sums to 1. This is conditioning a distribution on an event, as in any probability course. The difference from top-kk is that the set grows when the model is unsure and shrinks when it's confident. The paper reports that the nucleus tends to range from one to a thousand candidates.

To see this, take a toy model whose logits fall by a fixed gap aa per rank, ur=−a ru_r=-a\,r, over an unlimited vocabulary. This simplification is mine. The probabilities form a geometric distribution with ratio ρ=e−a/t\rho=e^{-a/t}. The top KK tokens hold mass 1−ρK1-\rho^K, so the nucleus size is ⌈(t/a)ln⁡11−p⌉\lceil (t/a)\ln\frac{1}{1-p}\rceil.

How many tokens survive the cut?

interactive
  • nucleus size
  • top-k size
11010010000.010.11logit gap per rank a (small = flat, large = peaked)tokens in the sampling set

Hover or drag across the chart to read values.

mass top-k keeps when flat (a = 0.05):
86.5%
nucleus size when flat (a = 0.05):
60
nucleus size when peaked (a = 2):
2
Toy model: logits drop by a fixed gap a per rank. Move right along the x-axis and the nucleus shrinks from dozens of tokens to one or two, while top-k stays flat: too few when the distribution is flat, too many when it's peaked. Raising t shifts everything as if the distribution were flatter, but t never chooses the cut.

A worked example

Peaked context: one token has probability 0.92, the next nine have 0.004 each, and the remaining 0.044 is spread thinly. With k=10k=10, p′=0.956p'=0.956, so the nine weak candidates together get 0.036/0.956≈3.8%0.036/0.956\approx 3.8\%. Renormalization has boosted tokens the model barely believed in. With p=0.9p=0.9, the nucleus is just the top token.

Flat context: 30 tokens at 0.03 each, so 0.90 in total. With p=0.9p=0.9, all 30 make the nucleus. With k=10k=10, we keep only 30% of the mass and drop 20 equally good options. This is the paper's Figure 5 argument: no single kk suits both cases.

The catch

The same peaked-case behavior has a cost. If a loop pushes P(repeat)P(\text{repeat}) above pp, the nucleus is just the repeat, and nucleus sampling turns into greedy decoding at that step. Truncation keeps loops from starting in ordinary text, but it can't break a loop the model is already very confident in.

What the results say

The authors generated 5,000 continuations (up to 200 tokens) of WebText passages with GPT-2 Large (Table 1):

  • Perplexity, the exponentiated average negative log-likelihood under the generating model (lower means "more predictable"): human text 12.38. Greedy 1.50 and beam search (b=16b=16) 1.48 are far too predictable. Pure sampling at 22.73 is too surprising. Nucleus (p=0.95p=0.95) at 13.13 is closest.
  • Repetition, the share of generations ending in a phrase repeated at least three times: human 0.28%, greedy 73.66%, beam 28.94%, top-kk=40 with t=0.7t=0.7 8.86%, nucleus 0.36%.
  • Diversity (Self-BLEU-4, lower means more diverse): human 0.31, nucleus 0.32.
  • HUSE, a classifier combining model likelihood with 20 human typicality judgements per text: nucleus 0.97, top-kk=640 0.94, t=0.9t=0.9 0.79, pure sampling 0.67, top-kk=40 0.19.

Limitations: this is one model, open-ended continuation only, and short outputs. HUSE gave truncated methods near-zero scores, so the authors had to mix 0.1 of the full distribution back in. That means the HUSE numbers for top-kk and nucleus come from a smoothed variant, not the exact method. Matching human perplexity is the authors' chosen target, not proof of quality. The Grice explanation is explicitly a conjecture. And the paper's own nucleus example confuses whales with birds.

Connecting the dots

The paper describes a failure that looks a lot like the symptom: a model whose own output makes the same output more likely, until it's stuck. "La" is close to a worst case, because a short, content-free syllable is the kind of token a model can grow very confident about repeating.

But this is a paper about the same kind of failure, not a diagnosis of Alexa. Amazon hasn't named a cause. The loop could be in the language model, in an audio-generating model downstream, or in plain pipeline code. Some modern speech synthesizers also generate audio one token at a time, so the feedback-loop logic could in principle apply there too. That's speculation about a system nobody outside Amazon has described. Alexa's later denial cuts both ways. It could mean the text the assistant "said" never contained the la's, which would point away from the language model. Or it could just mean that an assistant's reports about itself aren't reliable. Neither reading is established.

Why it matters

For practitioners, the lesson has held up: decoding is part of the model. Temperature, top-pp, repetition penalties and stop conditions decide whether a good model sounds good. A voice product has one extra constraint: a loop in a chat window gets scrolled past, while a loop out of a kitchen speaker plays for minutes. That argues for hard guards, like caps on repeated n-grams or maximum utterance length, regardless of the root cause.

For research, the paper split the problem into a decoding side (truncation) and a training side, such as unlikelihood training, which penalizes repetition directly. Both are still being refined.

What to watch: whether Amazon says what it fixed, and specifically whether it names the language model, the speech model or the pipeline. A named cause would turn this from an analogy into a case study.

Go deeper