Search

Search papers and lessons

AudioLM: A Language Modeling Approach to Audio Generation

Zalán Borsos, Raphaël Marinier, Damien Vincent et al. · 2022

AudioLM generates audio by predicting discrete tokens with language models in three stages, first meaning and then fine sound, so speech and piano continuations stay coherent.

On this page

  • Colour = topic mix
  • Calculus
  • Discrete math
  • Neural network basics
  • Linear algebra
  • Probability
  • Architectures
  • ReadReady to readNot yet

TL;DR

AudioLM is a way to generate sound, including speech and piano music, by treating audio as a sequence of discrete tokens and predicting the next token with a Transformer language model. It works in three stages. The first stage models semantic tokens, which carry the meaning of the whole clip, so the content stays consistent over time. The later stages fill in the acoustic detail that makes the sound high quality. From a 3-second speech prompt it continues speech in the same voice, and it also produces piano continuations that keep the melody and rhythm of the prompt.

Builds on: Language Model, Autoregressive Model, Transformer, Vector Quantization · Leads to: the later generation of token-based audio models that followed this design, such as generative models of speech and music that predict codec tokens with a language model

Why it mattered

Before this work, high-fidelity audio models and long-range audio models were usually different systems. Neural waveform models could sound excellent but wandered: on speech without strong conditioning they produced babble. Language models could keep structure over long spans, but the audio they were applied to was low quality or limited to one speaker. AudioLM showed that one recipe could give both, by letting a language model work on tokens that carry both kinds of information.

The recipe spread. Later systems for speech and music generation predicted codec tokens with a language model in a similar way. The authors also trained a classifier that detects speech generated by the model, which the paper presents as part of its approach to the risks of realistic continuations.

The problem

Audio is long. A second of 16 kHz speech has 16,000 samples, and a language model that attends over every sample cannot see more than a few seconds at once, because the cost of standard self-attention grows with the square of the sequence length. Working in a compact token space solves that, but it creates a tradeoff, which is the core difficulty the paper addresses.

Tokens that reconstruct the sound well are many and fine-grained, so the sequence is long and the model sees little context. Tokens that capture meaning, such as the phonetic content of speech, are short and easy to model over long spans, but they discard the acoustic detail that makes audio sound real. A model trained on only the fine tokens produces sound with the right voice but babble. A model trained on only the meaning tokens produces intelligible-looking structure that cannot be turned back into a convincing sound. The paper's point is that the two kinds of token should be modeled together, in a fixed order.

How it works

Take a tiny instance of the pipeline. A 10-second clip at 16 kHz has T=160,000T = 160{,}000 samples. The paper's two tokenizers turn it into fewer symbols.

  1. Acoustic tokens from a codec. A SoundStream codec maps the waveform to embeddings at 50 frames per second. Each frame is quantized by a stack of 12 vector quantizers, each with a vocabulary of 1024 symbols. In 10 seconds that is 500×12=6,000500 \times 12 = 6{,}000 acoustic tokens. Check: 50 frames times 10 seconds is 500 frames.
  2. Semantic tokens from a masked model. A separate pre-trained model, w2v-BERT, processes the same clip and produces features at 25 frames per second. Its intermediate layer is clustered with k-means into 1024 groups, and each frame gets its cluster index. In 10 seconds that is 250250 semantic tokens. Check: 25 frames times 10 seconds is 250.
  3. Stage one: predict the semantic tokens. A decoder-only Transformer learns to predict each semantic token from the ones before it. It sees 250 tokens, which is a short sequence, so it can cover many seconds of structure. Check: the sequence is 250 long, not 160,000.
  4. Stage two: predict the coarse acoustic tokens. A second Transformer predicts the acoustic tokens of the four coarsest quantizers, conditioned on the full semantic sequence. Each semantic frame has two acoustic frames, and each has four coarse tokens, so the stage sees 250×8=2,000250 \times 8 = 2{,}000 tokens. Check: 500×4=2,000500 \times 4 = 2{,}000.
  5. Stage three: predict the fine acoustic tokens. A third Transformer predicts the remaining eight quantizer levels, conditioned on the coarse tokens. It runs on chunks of 3 seconds, so its context stays short. Check: a 3-second chunk has 150 acoustic frames, and eight levels give 1,200 tokens per chunk.
  6. Decode. The full token set goes back through the SoundStream decoder, which rebuilds the waveform at 16 kHz.

For a continuation, the steps are the same but start from a prompt. The prompt is mapped to its semantic and coarse acoustic tokens, the first stage continues the semantic sequence, the second and third stages fill in the acoustic tokens for the continuation, and the decoder outputs the audio of both prompt and continuation.

flowchart LR
  W["Waveform"] --> S["Semantic tokens, 25 per second"]
  W --> A["Acoustic tokens, 50 frames per second, 12 levels"]
  S --> L1["Stage 1: language model over semantic tokens"]
  L1 --> L2["Stage 2: coarse acoustic tokens, 4 levels"]
  A --> L2
  L2 --> L3["Stage 3: fine acoustic tokens, 8 levels, 3 second chunks"]
  L3 --> D["SoundStream decoder"]
  D --> O["Output waveform"]

The math

Let the waveform be xx and let enc\text{enc} map it to a token sequence h=enc(x)h = \text{enc}(x) with far fewer tokens than samples. A decoder-only Transformer is trained to maximise the likelihood of the tokens:

∏t=1T′p(ht∣h<t),\prod_{t=1}^{T'} p(h_t \mid h_{\lt t}),

where h<th_{\lt t} means all tokens before position tt. At inference the model samples the next token from this distribution, one token at a time, and the detokenizer maps the sampled sequence back to audio.

Step 1 in symbols: the token counts

The SoundStream encoder produces TA=T/320T_A = T/320 frames, because 16,000 divided by 50 is 320. Each frame has QQ quantizer indices, so the acoustic tokens form a matrix YY with TAT_A rows and QQ columns. With N=1024N = 1024 symbols per quantizer, each token carries log⁡21024=10\log_2 1024 = 10 bits, so the bitrate with QQ levels is 50⋅Q⋅1050 \cdot Q \cdot 10 bits per second. For Q=4Q = 4 that is 2000 bits per second, and for Q=12Q = 12 it is 6000. The semantic tokens are TS=T/640T_S = T/640, since 25 frames per second is 640 samples per frame, and at K=1024K = 1024 they carry 25⋅10=25025 \cdot 10 = 250 bits per second.

Step 2 in symbols: the flattened sequence

The acoustic tokens are flattened in row-major order, so the sequence has length TA⋅QT_A \cdot Q. Each stage predicts the next token of its own sequence given everything before it. The second stage models p(ytq∣z,y<t≤Q′,yt<q)p(y_t^q \mid z, y_{\lt t}^{\le Q'}, y_t^{\lt q}) for the coarse levels q≤Q′q \le Q', where zz is the full semantic sequence. The third stage models p(ytq∣y≤Q′,y<t>Q′,yt<q)p(y_t^q \mid y^{\le Q'}, y_{\lt t}^{\gt Q'}, y_t^{\lt q}) for the fine levels q>Q′q \gt Q'.

Step 3 in symbols: the hierarchy

The model factorises the joint distribution as

p(z,y)=p(z)⋅p(y≤Q′∣z)⋅p(y>Q′∣y≤Q′),p(z, y) = p(z) \cdot p(y^{\le Q'} \mid z) \cdot p(y^{\gt Q'} \mid y^{\le Q'}),

with the first factor learned by stage one, the second by stage two, and the third by stage three. The paper justifies the hierarchy by a conditional independence assumption: given the past semantic tokens, the semantic tokens are close to independent of past acoustic tokens, so p(zt∣z<t,y<t)≈p(zt∣z<t)p(z_t \mid z_{\lt t}, y_{\lt t}) \approx p(z_t \mid z_{\lt t}).

Step 4 in symbols: sampling

Each stage samples with temperature. The paper uses temperatures of 0.6, 0.8 and 0.6 for the three stages. A temperature below 1 sharpens the distribution toward the most likely tokens, which the authors found gave a good balance between diversity and consistency. For a token distribution pp and temperature τ\tau, the sampling distribution is proportional to p1/τp^{1/\tau}, so τ=0.6\tau = 0.6 raises the likely tokens to the power 1/0.6≈1.671/0.6 \approx 1.67.

Step 5 in symbols: the per-token count

For every semantic token there are 2Q′2Q' coarse acoustic tokens and 2(Q−Q′)2(Q - Q') fine ones, because acoustic frames come twice as often as semantic frames. With Q′=4Q' = 4 and Q=12Q = 12 that is 8 coarse and 16 fine tokens per semantic token. This is the ratio that sets how much work each stage does.

Results

Meaning survives the tokens. The authors run a speech recognizer on audio generated from ground-truth semantic tokens. The word error rate is 2.5 percent on the original recordings, 2.6 percent on SoundStream reconstructions, 6.0 percent for AudioLM, and 6.6 percent for GSLM, a prior textless speech model. The paper reads this as the semantic tokens carrying the content, and AudioLM does slightly better than the prior system (6.0 against 6.6). The error rates in the paper are measured against transcripts, so they say how intelligible the speech is, not how natural it sounds.

Speaker identity lives in the acoustic tokens. A speaker classifier reaches about 100 percent accuracy on reconstructions. When acoustic tokens are sampled from fixed semantic tokens, accuracy drops to 3.2 percent, against a chance level of about 0.3 percent over 291 speakers. The semantic tokens therefore carry little speaker information.

Continuations keep the speaker. From 3-second prompts of unseen speakers, the classifier finds the same speaker in the 7-second continuation with 92.6 percent accuracy.

Linguistic knowledge. On the zero-shot sWUGGY and sBLIMP tests, AudioLM reaches 71.5 percent on sWUGGY (all pairs), 83.7 percent on the in-vocabulary subset, and 64.7 percent on sBLIMP. The paper reports that the sBLIMP score is about 8 percent relative above the previous best, CPC-BERT, at 59.9.

Human judgement is weak. In a subjective test, 10 raters judged 100 samples (1,000 ratings in total) and picked the correct label (original or synthetic) 51.2 percent of the time, which the authors report as not significantly different from chance (p=0.23p = 0.23).

Detection works. A convolutional classifier separates AudioLM continuations from SoundStream-compressed originals with 98.6 percent accuracy on a balanced evaluation set.

Piano. With the piano model trained on 40,000 hours of recordings, raters preferred AudioLM's continuations over a version trained only on acoustic tokens in 83.3 percent of 15 pairs.

The limits are as important. The speech evaluations rely on one recognizer and one set of speakers, the subjective test has 10 raters, and the piano test uses 15 pairs. The paper acknowledges that proper nouns and sentence endings are the main sources of recognition errors, and that generated audio can carry background noise from the training data.

Reading guide

  1. Introduction. Maps the goal onto the two kinds of tokens. Read it with language modeling and Self-Supervised Learning in mind.
  2. Related work. Covers neural waveform models, the textless speech line, and Jukebox. Helpful background: WaveNet for autoregressive waveform modeling, and HuBERT for the discrete speech units the semantic tokens resemble.
  3. Section III-A and III-B. The three components and the tradeoff. Needs Vector Quantization and Autoregressive Model. Table I is the key result of this section.
  4. Section III-C and III-D. The three stages and the inference modes. Needs Transformer and Softmax Temperature.
  5. Section IV-A and IV-B. Data and model sizes. The Transformer details are standard Transformer settings.
  6. Section IV-C to IV-E. The probes of what each token type carries. Needs K-Means Clustering for the semantic tokens and Automatic Speech Recognition for the transcripts used to score them.
  7. Section IV-F to IV-I. Continuations, subjective tests, detection and piano. Needs Cross-Entropy Loss for the likelihood training.
  8. Section V and VI. Conclusion and the broader impact discussion.

Check yourself

QuestionRecall: why does AudioLM use two kinds of token instead of only one?Show answer

Semantic tokens are short and capture meaning, so a language model can keep long-term structure over many seconds. Acoustic tokens reconstruct the sound well but are long and fine-grained. Using only the semantic tokens gives poor audio, and using only the acoustic tokens gives babble, so the two are modeled together in a hierarchy.

QuestionComputation: a clip is 10 seconds long at 16 kHz. Using the frame rates in the paper, how many semantic tokens and how many acoustic tokens does the first and second stage see at 4 coarse levels?Show answer

The semantic sequence has 25×10=25025 \times 10 = 250 tokens. The acoustic frames number 50×10=50050 \times 10 = 500, and with 4 coarse levels the second stage sees 500×4=2,000500 \times 4 = 2{,}000 acoustic tokens. The second stage is also conditioned on the 250 semantic tokens.

QuestionWhy: the paper's speaker classifier scores 3.2 percent on acoustic generation, far above chance but low. What does that say about where speaker identity is stored?Show answer

Speaker identity is mostly stored in the acoustic tokens. If the semantic tokens carried the speaker, sampling new acoustic tokens from the same semantic tokens would keep the same speaker, but it does not. The low score means the speaker changes when only the acoustic tokens are resampled, which points to the acoustic tokens as the place where speaker identity is kept.

QuestionApplied: a team wants a model that writes short piano pieces. They train only the fine acoustic tokens and find that the output sounds clean but meanders with no clear melody. What does the paper suggest they add, and why?Show answer

The paper suggests adding a stage that models a sequence carrying melody and rhythm before the acoustic tokens are generated, which is the role of the semantic tokens. Only the acoustic tokens give clean sound but no long-term structure. In the paper's piano experiments, raters preferred the full hierarchical model in 83.3 percent of pairs for consistent melody.

Sources

Read the full paper

Zalán Borsos, Raphaël Marinier, Damien Vincent et al., 2022. arXiv:2209.03143