A codec for a language model
Mimi is the audio tokenizer of Moshi, Kyutai's spoken-dialogue model: Moshi hears and speaks in Mimi's codes. A codec made for a language model has two jobs that a codec made for transmission (see the EnCodec tab) does not. It should make few tokens a second, because each token costs the language model a step. And its first code should carry what is being said, not only how it sounds, so that the model can learn language from it.
The checkpoint on this page, kyutai/mimi, has 79.3 M parameters. It encodes 24 kHz audio into 12.5 frames a second of 512 numbers. A split residual vector quantizer then turns each frame into one code from a single semantic codebook and up to 31 from acoustic codebooks, each of 2,048 vectors (11 bits). Moshi uses the first 8 codes of each frame, 1.1 kbps. The page records the whole 2.04 s LibriSpeech clip “where is my brother now”, every quantizer step at every frame, and the model's decode from 1, 2, 4, 8 and 32 codes per frame.
Down to 12.5 frames a second
The Audio → 12.5 frames a second column draws the encoder with the shapes of this run. The clip, resampled to 48,960 samples, passes a convolution with kernel 7 and four blocks, each a residual unit, an ELU and a strided causal convolution, with strides 4, 5, 6 and 8. That gives 960 samples a step, 25 steps a second: 51 steps of 1,024 channels for the clip, mapped to 512 by one more convolution. An 8-layer causal transformer with 8 heads then mixes the steps, each attending to the last 250, and a stride-2 convolution halves the rate:
A frame covers 80 ms, six times EnCodec's 13.3 ms, so the clip makes 26 frames, the last partly padding: the columns of the Encoder output heatmap. The decoder has a matching transformer after the quantizer; the two transformers hold 50.4 M of the model's 79.3 M parameters.
Split quantization
The Split quantization column holds two quantizers that read the same 512-number frame , each through its own linear projection to 256 numbers. The semantic quantizer is one codebook : . The acoustic quantizer is a residual vector quantizer, as on the EnCodec tab, over its own projection, with codebooks giving codes :
Decoding from the first codes projects each quantizer's sum back to 512 numbers and adds the two:
The Semantic and Acoustic ladders show what is left of each projected frame after each codebook. The acoustic codebooks never see what the semantic code left: they quantize , not a residual of the semantic step. At frame 12, where the page opens, the semantic codebook takes its projection's norm from 13.0 to 9.46, and the first acoustic codebook takes its own from 3.58 to 2.17. Averaged over the clip, a norm of 6.95 is left after the semantic codebook, 1.83 after the first acoustic codebook and 0.46 after all 31. The two ladders live in different spaces, so their bars do not compare.
Distilling meaning into the first code
What makes code 1 semantic is a training loss, not its place. The Moshi paper distils WavLM, a self-supervised speech model, into the semantic quantizer. WavLM turns 16 kHz audio into 1,024-number embeddings at 50 Hz; average pooling with kernel 8 and stride 4 brings them to Mimi's 12.5 Hz. A linear projection maps the semantic quantizer's output to 1,024 numbers, and the loss is the cosine distance to the pooled embedding :
The pooling looks at future frames, which is allowed because WavLM is only needed in training. SpeechTokenizer had distilled HuBERT into the first level of a single RVQ, so the later levels quantized what the semantic code left. Moshi's authors found that this distillation worked against audio quality, and split the quantizer: rather than one RVQ with 8 levels, a plain VQ for the semantic code and an RVQ with 7 levels in parallel, their outputs summed. The released checkpoint has 31 acoustic codebooks; Moshi uses the first 7.
Two more choices from the paper: in training, quantization is applied to a random half of the sequences, and Mimi is trained with adversarial and feature-matching losses only, without a reconstruction loss, which the authors report lowers objective metrics but improves listeners' ratings.
Codes and bitrate
The Tokens: 8 codes per frame column shows the code ids: row 1 is the semantic code, rows 2 to 8 the acoustic codes Moshi models, and below them the 24 further codebooks of the checkpoint. Each code is 11 bits, so
2,288 bits for the clip's 26 frames, and 4.4 kbps with all 32 codebooks. That is 100 codes a second where EnCodec at 6 kbps makes 8 × 75 = 600. The panel under the ids, Codebook 1 at frame 12 when the page opens, shows one nearest-vector step inside the quantizer's 256-number space, with the five nearest vectors.
What each code carries
The Codes per frame strip plays the model's decode from the first 1, 2, 4, 8 and 32 codes of every frame, with log-mel spectrograms, waveform SNR and mel error against the 24 kHz input; the toolbar's codes per frame buttons pick one. The mel error falls steadily: 11.25 dB from the semantic code alone, then 8.42 and 6.18 dB, 5.28 dB at Moshi's 8 codes and 3.90 dB from all 32. The SNR is below zero for one and two codes (−1.04 and −0.78 dB: the error has more energy than the signal) and reaches 5.35 dB at 8 codes and 11.26 dB at 32. Mimi was never asked to match the waveform sample by sample, so the mel error says more about these decodes than the SNR does.
The last decode is an experiment: acoustic codes 2 to 8 without the semantic code. Its SNR, 4.37 dB, is 1 dB below the 8-code decode's, but its mel error, 7.50 dB, is worse than that of the first four codes (6.18 dB). On this clip the seven acoustic codes do not stand in for what the semantic code holds.
Where Mimi came from
AudioLM (2022) split audio generation between two tokenizers: semantic tokens, the discretized activations of a masked language model pre-trained on audio, for long-term structure, and SoundStream's acoustic codes for sound. SpeechTokenizer (2023) merged them into one residual quantizer. Mimi (2024) keeps one tokenizer but splits its quantizer, and drops to 12.5 frames a second with a transformer on each side of the bottleneck, all causal so that Moshi can stream.
Moshi models the 8 codes of each frame with an RQ-Transformer: a large temporal transformer steps from frame to frame, and a small depth transformer predicts that frame's codes one after another. The acoustic codes are delayed by one or two frames relative to the semantic code, which the paper reports greatly improves generation.
Papers
- Moshi: a speech-text foundation model for real-time dialogue Introduces Mimi, the codec this tab records: the 12.5 Hz causal encoder with transformers, the split RVQ, WavLM distillation and adversarial-only training, and Moshi's RQ-Transformer over its codes.
- SpeechTokenizer: Unified Speech Tokenizer for Speech Large Language Models Semantic and acoustic tokens from one residual quantizer, with HuBERT distilled into its first level: the design Mimi's split quantizer revises.
- WavLM: Large-Scale Self-Supervised Pre-Training for Full Stack Speech Processing The self-supervised speech model whose embeddings Mimi's semantic codebook is distilled toward.
- AudioLM: a Language Modeling Approach to Audio Generation Generates audio as semantic tokens then acoustic codec tokens from two tokenizers, the split Mimi folds into one codec.
- SoundStream: An End-to-End Neural Audio Codec The convolutional codec with a residual vector quantizer and quantizer dropout that Mimi's encoder, decoder and acoustic quantizer build on.
- Autoregressive Image Generation using Residual Quantization The RQ-Transformer: one transformer across positions and a small one across a position's residual codes, the structure Moshi uses over Mimi's codes.