Why Representations?

Almost every system in the prior reading group sessions assumed it could already see audio in a useful form. DDSP took pitch and loudness as input. The transcription models took mel-spectrograms. Music generation models like VampNet took discrete audio tokens. None of them learned, from scratch, what audio means; they were each handed a representation and asked to do work on top of it. This session is about the layer underneath: how a model learns a representation in the first place, and what choices it makes about what to preserve.

We’re working through three papers that span two paradigms. CLAP — Contrastive Language-Audio Pretraining — is the audio-side port of the CLIP recipe: pair an audio encoder with a text encoder and train them to agree on which (audio, caption) pairs go together. We cover two CLAP papers, the original Microsoft CLAP (Elizalde et al., 2022) and LAION-CLAP (Wu et al., 2023) which scaled it up by an order of magnitude, because their differences are instructive about what scale and engineering buy you on top of a fixed objective. MERT — Music undERstanding model with large-scale self-supervised Training — Li et al., 2024 takes the opposite approach: learn from audio alone, hide chunks of the signal, predict what was hidden, no language anywhere in the loop. CLAP yields representations that are describable (queryable with a natural-language sentence); MERT yields representations that are characterizable (they encode pitch, harmony, and timbre as features for downstream tasks, but cannot be queried in words). Both are useful; the design choices are revealing.

Core Concepts

textaudioshared space

Contrastive Alignment

CLAP trains two encoders (one for text, one for audio) to project their inputs into a shared vector space. The objective is geometric: matched (audio, caption) pairs should land near each other, mismatched pairs far apart. The text encoder gives the audio embedding a vocabulary; once aligned, you can query audio with sentences and vice versa, even for categories the model has never been explicitly trained to classify.

audiotext

Batch Negatives

Contrastive learning needs negative examples (pairs that should be pushed apart) and CLAP gets them for free: every other item in the batch is treated as a negative for any given positive. A batch of N pairs yields N positives along the diagonal and N(N−1) negatives off-diagonal. This is why contrastive methods benefit so much from large batch sizes; more batch members means harder negatives, which means stronger gradient.

???predict masked

Masked Acoustic Modeling

MERT borrows the recipe from BERT (text) and HuBERT (speech): randomly mask spans of input frames, then ask a Transformer encoder to reconstruct what was hidden from surrounding context. No labels, no captions, just the audio. The bet is that to fill in a missing chunk of music, the network must implicitly model harmony, rhythm, and timbre, which makes the resulting features useful for downstream tasks like pitch detection or genre classification.

encoderacousticEnCodec RVQ codesmusicalCQT (pitch/harmony)masked audio

Dual Teachers

MERT's central design choice: one teacher signal is not enough for music. The acoustic teacher (EnCodec RVQ indices) captures timbre and texture but is pitch-agnostic; the musical teacher (CQT) captures pitch and harmonic relationships but ignores fine acoustic detail. Training the encoder to reconstruct both forces it to preserve information that either teacher alone would discard. This is the paper's principal contribution over a straightforward HuBERT-on-music port.

CLAP: A Technique With Several Implementations

“CLAP” names a technique — Contrastive Language-Audio Pretraining — before it names any one paper. The technique is the CLIP recipe ported to audio: pair an audio encoder with a text encoder, project both into a shared vector space, train with the symmetric InfoNCE loss so that matched (audio, caption) pairs land near each other and mismatched pairs land apart. At least two notable implementations exist, and we’ll walk through both before getting into the math, because they make the same big idea concrete in revealingly different ways.

Two notable implementations

Microsoft CLAP
Elizalde et al., 2022 · arXiv:2206.04769
Audio encoder
CNN14 from PANN · 80.8M params · 2048-dim output
Text encoder
BERT-base uncased · 110M params · 768-dim [CLS]
Shared space
1024-dim via 2 learnable projections
Training data
~128K pairs from FSD50K, ClothoV2, AudioCaps, MACS
Schedule
40 epochs, Adam(1e−3), batch 32–768, audio = 5s @ 44.1kHz
Temperature
Learnable, initialized to 0.007 (very low → sharp softmax)
Audio length
Fixed 5-second clips
original · coined the name for audio
LAION-CLAP
Wu et al., 2023 · arXiv:2211.06687
Audio encoder
HTSAT (hierarchical audio Transformer) · 768-dim · (PANN-14 evaluated as alternative)
Text encoder
RoBERTa-base, 768-dim · (BERT & CLIP tower also tried, RoBERTa wins)
Shared space
512-dim via 2-layer MLPs, L2-normalized
Training data
~2.5M pairs · LAION-Audio-630K + AudioCaps/Clotho + 1.9M AudioSet via K2C
Schedule
45 epochs, Adam(1e−4), batch 768 → 2,304 → 4,608 by scale, audio = 10s @ 48kHz
Temperature
Learnable, log-space (the codebase inherits CLIP's log(1/0.07) default; not pinned in the paper)
Audio length
Variable via Attention Feature Fusion
scaled-up · most-used in downstream systems today

The walkthrough below uses LAION-CLAP’s specifics where the engineering diverges (because Feature Fusion and K2C are LAION-only), but the loss-function math and the geometric intuition apply equally to both. After training, the encoders from either model are useful in isolation: the audio encoder becomes a general-purpose feature extractor, and the joint geometry enables zero-shot classification and retrieval.

The symmetric InfoNCE loss, line by line

For a batch of N matched pairs, let Eia, Eit ∈ ℝ512 be the unit-normalized audio and text embeddings. Because they live on the unit sphere, the inner product Eia · Ejt equals their cosine similarity. The training objective is:

ℒ = −12N Σi=1N [ log exp(Eia · Eit / τ)Σj exp(Eia · Ejt / τ) + log exp(Eit · Eia / τ)Σj exp(Eit · Eja / τ) ]

Reading it as code: the first log-term is the audio→text classification (for audio i, the right answer among N candidate captions is caption i); the second is the symmetric text→audio classification. Without the symmetric term the text tower receives only weak gradient; under symmetric training both encoders are updated by the same loss magnitude per pair. τ is a learnable scalar — both papers parameterize it in log-space to keep it positive, with initialization values that differ in a revealing way (covered just below). Projections are L2-normalized before the inner product is taken; without this, the dot product would conflate similarity with vector magnitude and the loss would just push everything toward larger norms.

Why is this the right loss? The mutual-information lower bound

The InfoNCE loss is not arbitrary; it is provably a lower bound on the mutual information between the two views (van den Oord et al., 2018). Specifically:

I(audio; text)  ≥  log N  −  ℒInfoNCE

Pushing the loss down pushes the bound up, so minimizing ℒ provably increases (the bound on) I(audio; text). A consequence with practical bite: the bound is capped by log N. Doubling the batch size raises the ceiling by log 2 ≈ 0.69 nats. This is the formal reason contrastive methods are notoriously batch-size hungry — and why CLAP scales the batch from 768 to 2,304 to 4,608 as more corpora are mixed in. Empirically, doubling N improves zero-shot accuracy by 1–2 points across the board.

Contrastive training in 2D embedding space

Each audio embedding (orange) and text embedding (blue) lives on the unit circle (the L2-normalization constraint). Pressing ▶ Train runs gradient steps on the symmetric InfoNCE loss: paired (ai, ti) get pulled together, all other pairs get pushed apart. Drag τ to see the temperature/sharpness trade-off, lr to see step size effects (push it past 0.3 and watch it overshoot), speed to watch single steps. Pause anytime to inspect the state.

Temperature τ shapes the softmax

τ → 0: softmax becomes argmax — all probability on the positive (or the wrong negative if the positive isn't already closest). τ → ∞: uniform — every candidate gets 1/N = 0.125. Current loss −log P(pos) = 0.190 · MI lower bound log N − L = 1.889 nats (max log N = 2.079).

Feature fusion: handling variable-length audio  LAION-CLAP only

LAION-CLAP’s training set includes clips that run for minutes, but the audio encoder still expects a fixed-length input. Its solution is the Attention Feature Fusion (AFF) module — an attention-pooled aggregator that preserves both broad temporal context and local detail. (MS-CLAP, for comparison, simply sidestepped the problem by training only on fixed 5-second clips — clean, but discards anything longer.) The AFF algorithm is more involved than a simple chunk-and-pool. For a clip longer than 10 seconds:

1. Downsample the full clip to a single 10s tensor → Xglobal
2. Sample three non-overlapping 10s windows from the front, middle, and back thirds of the original clip → three local tensors
3. Pass all 4 tensors through the audio encoder's first stage
4. Merge the three local features via a 2D-conv with temporal stride 3 → Xlocal
5. Fuse: Xfusion = α · Xglobal + (1 − α) · Xlocal, where α is produced by the AFF block (a small attention module learning the mixing ratio per token)

The intuition: the global view preserves broad temporal context (a 5-minute song's overall structure) while the three locals preserve fine-grained detail at full resolution; AFF lets the model adaptively weight the two depending on the content. Without fusion, the encoder must choose between coarse resolution (downsample everything) or losing context (random 10s crop). For clips shorter than 10 seconds, the input is simply repeated and padded; no fusion is applied.

Keyword-to-Caption augmentation  LAION-CLAP only

LAION-CLAP scales captioned-data availability by an order of magnitude over MS-CLAP — not by finding more captioned audio, but by inventing captions for the much larger label-only corpora. Much of the available audio data (AudioSet’s 1.9M clips in particular) ships with sparse tag-style labels (a comma-separated list like dog, barking, outdoor) rather than fluent captions. CLAP turns these into training pairs by prompting a pre-trained T5 with the keywords and the instruction generate a caption from these keywords, yielding outputs along the lines of A dog is barking outdoors. A small post-processing step replaces gendered terms (the words man, woman) with the neutral person to mitigate downstream gender bias amplification. The result is roughly 1.9M synthetic (audio, caption) pairs from AudioSet alone, which dwarfs the genuinely captioned pool.

Training data and hyperparameters

LAION-CLAP’s full training corpus reaches approximately 2.5M (audio, caption) pairs across three sources: LAION-Audio-630K (633,526 pairs, ~4,325 hours of in-the-wild web-scraped audio), AudioCaps + Clotho (~55K human-captioned pairs, the only genuinely high-quality captions in the mix), and AudioSet (1.9M label-to-caption pairs via the K2C augmentation above). Training runs for 45 epochs with Adam (β1=0.99, β2=0.9), learning rate 1e−4, warmup followed by cosine decay. Batch size is scaled with corpus size: 768 for the smallest mix, 2,304 when LAION is included, 4,608 at full scale — a direct reflection of the log N bound discussed above. MS-CLAP, by contrast, used roughly 20× less data and 40 epochs at lr 1e−3 with batches as small as 32 — an instructive baseline for what the contrastive recipe can do with clean captions before scale enters the picture.

What does CLAP actually let you do?

The reason all this engineering matters is the downstream interface it unlocks: once the encoders are trained, you can describe any sound in natural language and find it (or sounds like it) in any indexed library. No retraining per category.

CLAP-style retrieval (illustrative)

query "rhythmic percussion" → embedding
rhythmic
harmonic
bright
natural
speech
sustained
1
drum loop
rhythmic · percussion · beat · drums
0.88
2
bass riff
bass · low · rhythmic · music
0.58
3
bird chirp
bird · high · bright · natural
0.31
4
rain ambience
rain · nature · ambient · natural
0.22
5
jazz piano chord
music · harmonic · piano · jazz
0.07
6
violin note
violin · music · sustained · harmonic
0.03
Illustrative — not real CLAP. Real CLAP encodes audio and text into a learned 512-dim space (~150M parameters per encoder) trained on millions of pairs. Here we use a hand-designed 6-D semantic space so you can see the mechanism: the query gets embedded, every clip is already embedded, and cosine similarity ranks the clips. Same recipe, vastly simpler geometry. Notice how queries that name musical structure (chords, key, instrumentation) work well because the space has axes for them — but a query like "in the key of G minor" would fail here, exactly as it tends to fail in real CLAP, because the training distribution rarely captions that.

The downstream utility is broad and is the reason CLAP-style embeddings now appear in almost every recent audio generation system. Zero-shot classification: take the CLAP audio embedding, take the CLAP text embedding of each candidate class name (“dog barking,” “piano,” “rain”), pick the closest. Retrieval: build an index over a sound library and query it with a sentence. Conditioning: feed the CLAP text embedding to a diffusion model so that text prompts steer audio generation. None of these downstream uses require a fresh round of training; the representation does the work.

MERT: Learning Music From Itself

Li et al. (2024) take the position that aligning with text is the wrong starting point for music understanding, for two reasons. First, captions describe what humans choose to say about music, which is heavily biased toward genre, instrument, and mood, and almost never mentions key, harmonic function, or rhythmic structure; a representation aligned with that distribution will inherit its blind spots. Second, large-scale captioned music data is scarce compared to large-scale unlabeled music, and self-supervised approaches scale with raw audio hours rather than caption availability.

The architecture inherits from HuBERT in speech (Hsu et al., 2021). Raw waveform at 24 kHz is fed into a 7-layer convolutional feature extractor that downsamples to 75 Hz (one frame per ~13.3 ms, matching EnCodec’s tokenization rate exactly so the teachers and the encoder share a temporal grid). The frame sequence enters a Transformer encoder (12 layers for MERT-95M-public, 24 layers with Pre-LN for MERT-330M). During training, frames are masked HuBERT-style — the MERT paper inherits the masking hyperparameters from HuBERT rather than restating them, so the numbers here are HuBERT’s: roughly 8% of frames are sampled as starting indices and each is expanded into a 10-frame span, yielding approximately 50% of frames masked in expectation. Masked positions are replaced with a learned mask embedding, and the model must predict properties of the masked frames from the surrounding context. What MERT changes is the target of that prediction.

HuBERT-style masking on a frame strip

Each frame has probability p of being chosen as a starting index (purple diamond). From each start, the next 10 frames are masked together. Overlapping spans merge — that's why the total masked fraction is well below p × 10. MERT (and HuBERT) default to p ≈ 8%, which yields roughly 50% of frames masked in expectation. The model must reconstruct the orange frames using only the teal context.
Audio24 kHz waveformCNN feat.75 Hz framesmask ~50%Transformer Encoder12L (95M) / 24L (330M)Acoustic TeacherEnCodec RVQ-VAEpredict 8 codebook indicesMusical TeacherCQT spectrogramregress log-magnitude binsL = L_a + L_mmulti-task losstrained on ~160K hours of music (CC-licensed + Music4All)

The acoustic teacher: EnCodec RVQ-VAE

The acoustic teacher is a pre-trained EnCodec residual vector-quantized autoencoder (Défossez et al., 2022). EnCodec processes the original (unmasked) audio and emits at each frame a stack of K = 8 codebook indices, where each codebook has 1024 entries. This factorized representation can express 10248 ≈ 1024 distinct combinations per frame, more than enough to reconstruct the waveform on decoding. MERT trains a per-codebook classification head on top of the transformer encoder. For each masked frame t in the masked set M and each codebook k from 1 to 8, the encoder must predict the right index out of 1024:

ℒacoustic = − Σt ∈ M Σk=18 log pfk(zt,k  |  x′, t)

where x′ is the masked input sequence, zt,k is the ground-truth code index from running EnCodec on the unmasked audio at frame t in codebook k, and fk is the prediction head for codebook k. This is identical in form to HuBERT's loss but with codes drawn from EnCodec rather than k-means on MFCCs. The paper also explored a k-means alternative (300 centroids on log-mel + 200 centroids on chroma, joint cluster space = 60,000 classes); EnCodec proved more effective. Any feature in the encoder that helps minimize ℒacoustic must by construction preserve enough information to identify which of 1024 acoustic prototypes — spectral shape, transient pattern, broad timbre — the masked frame belongs to in each of 8 parallel quantizations.

EnCodec: 8 codebooks add up to one frame

EnCodec encodes each audio frame as 8 codebook indices. Codebook 1 picks the entry that best matches the raw frame; codebook 2 picks the entry that best matches the residual; codebook 3 corrects what's still left; and so on. Each level only has to cover what the previous levels missed, so codebooks deeper in the stack store progressively finer details. Drag the slider to stack codebooks one at a time and watch the residual shrink — when K = 8 the reconstruction nearly matches the target. This is what MERT's acoustic teacher asks the encoder to predict: not the raw spectrum, but which entry from each of the 8 codebooks was chosen.

The musical teacher: CQT regression

The musical teacher is the Constant-Q Transform of the original audio. The CQT differs from a mel-spectrogram in that its frequency bins are spaced logarithmically, with one bin per semitone (or a fraction thereof), which means harmonics of any pitch land at fixed, semantically meaningful positions independent of the fundamental. MERT trains a separate prediction head fcqt to regress the CQT magnitudes at masked positions under an L2 loss:

ℒmusical = Σt ∈ M ‖ zcqt,t − fcqt(x′)t ‖2

where zcqt,t is the CQT bin vector at frame t computed on the unmasked audio. This is regression, not classification: the head outputs a continuous vector and is trained to land near the target rather than choose among quantized categories. The choice matters — quantizing CQT would discard the magnitude information that distinguishes a forte from a piano, and would reintroduce the pitch-blurring that motivated using CQT in the first place.

Same chord, two representations

C4 + E4 + G4 — three fundamentals, each with their own harmonic stack. The colored dots in the right margin label each fundamental's harmonic stack — orange for the lowest fundamental, blue for the next, teal for the highest (in chord/octaves mode). The key contrast: in CQT, the colored stacks are translation-invariant — each fundamental's harmonics sit at the same relative semitone offsets (0, +12, +19, +24, ...), so you can read the stacks as identical patterns just shifted in pitch. In mel, the same harmonic stack changes shape depending on where you start: the spacing between harmonics 1→2 versus 2→3 looks different at C4 than at G4. That translation invariance is exactly what MERT exploits by using CQT as its musical teacher.

The two losses are combined with a scalar weight α (the paper sweeps and finds α = 1 optimal):

ℒtotal = α · ℒacoustic + ℒmusical

Scale and training

The two principal model sizes are:

MERT-95M-public: 12 transformer layers · 95M parameters · trained on 910 hours of Music4All (the released checkpoint; the paper's internal 95M used a ~1K-hour subset of the larger corpus)
MERT-330M: 24 transformer layers with Pre-LN · 330M parameters · trained on ~160K hours of mixed CC-licensed and internet-mined music

Batch sizes are expressed in audio-hours per step (a useful convention for music SSL): roughly 1.5 hours per batch for the 95M models, 5.5 hours per batch for the 330M. At 75 Hz, 5.5 hours corresponds to approximately 1.5 million frames per batch — large enough to make EnCodec teacher precomputation and on-disk caching non-trivial. Pre-LN was specifically introduced in the 330M variant because the original Post-LN HuBERT recipe diverged at this scale, a hard-won engineering lesson the paper documents in the appendix.

Evaluation: MARBLE and the probing protocol

After pretraining, the encoder is evaluated on the MARBLE benchmark (Yuan et al., 2023) plus separate evaluations covering genre classification, emotion recognition, key detection, beat tracking, source separation, and singer identification. The protocol is probing: the MERT weights are frozen and a small head is trained per task. The head is not always linear — the paper’s default probe is an MLP with one hidden layer of 512 units and 0.25 dropout, trained with batch size 64. Hyperparameter search is limited to a small learning-rate grid spanning 1e−4 through 1e−2. The 330M model achieves state-of-the-art across most tasks at the time of publication, including notably strong results on the pitch-sensitive tasks where prior masked-modeling work without a musical teacher had lagged.

What MERT lets you ask about a clip

Once the encoder is trained, the workflow is: feed a clip through MERT (frozen), grab the resulting frame-level features, and train a tiny task head on top. The same representation supports very different questions in parallel.

MERT probes: one encoder, many tasks

Pitch class probe top: C (32%)
C
C#
D
D#
E
F
F#
G
G#
A
A#
B
Instrument family probe top: Keys (78%)
Strings
5%
Keys
78%
Bass
8%
Percussion
4%
Ambient
5%
Genre probe top: Jazz (78%)
Jazz
78%
Rock
5%
Electronic
3%
Classical
12%
Ambient
2%
Illustrative — not real MERT outputs. Real MERT-330M produces a 1024-dim feature vector per frame; each downstream task trains its own MLP probe on top of those frozen features. The three probes here simulate that pipeline: pitch class shows where the harmonic content is concentrated, instrument family shows what's making the sound, and genre shows a higher-level musical category. Click a clip and notice that the same representation would feed all three probes — this is what "one encoder, many tasks" means in practice. Notice also where the probes get confused: drum loop has high entropy on pitch class (no clear tonal center); bird chirps and rain confuse genre because they're not music; jazz piano gets E and G in addition to C because those are in the Cmaj7 chord.

How They Connect

CLAP and MERT both seek a general-purpose audio representation, but they make almost-mirrored design decisions, and the resulting embeddings have correspondingly mirrored strengths.

CLAP familycross-modal contrastiveMS-CLAP (2022) + LAION-CLAP (2023)Signal:(audio, caption) pairsStrength:zero-shot + retrievalWeakness:caption distribution biasUsed by:AudioLDM, Stable Audio, SAM AudioMERTmasked acoustic modelingSignal:masked frames (audio only)Strength:pitch / harmony featuresWeakness:no language interfaceUsed by:MIR probes, music tagging, MARBLE

The most useful way to read the pair is to ask, for any given downstream task, which kind of supervisory signal would have been most informative during pretraining? If the task involves matching audio to natural language (“retrieve clips that sound joyful,” “label by genre using a free-text vocabulary”), CLAP’s training distribution maps directly. If the task involves musical structure that captioners rarely mention (chord recognition, key detection, beat tracking, instrument fingerprinting), MERT’s frame-level acoustic supervision captures it more faithfully. Several recent systems combine both, using CLAP for the conditioning interface and MERT for the encoder backbone; the two are complementary in production even though they compete in the literature.

It is also worth noting how this pair maps onto the parallel debate in vision. CLIP (contrastive cross-modal) and DINO / MAE (self-supervised single-modal) emerged at roughly the same time for the same reason, and the field has not so much resolved the debate as accepted that both representations have their place. CLAP and MERT are the audio-side echo. The next several years of work in audio representation learning will likely follow the vision template: hybridization (use both signals together), distillation (compress the bigger model into a smaller deployable one), and progressively more music-specific second modalities (lyric-aligned text, score-aligned MIDI, performance metadata).

Further Reading

CLAP and MERT are entry points into much larger families. If either clicked, here’s how to navigate the literature next.

Beyond CLAP: variants and the music-specific cousins

The contrastive audio-text recipe has been extended in several productive directions. The most important pointer for a music-AI audience is MuLan, which is essentially “CLAP, but music-specific and at 44M-clip scale” — it’s the audio encoder behind Google’s MusicLM and the most direct music-domain analog of what we covered today. MuQ-MuLan is its 2025 successor and currently the SOTA music-CLAP.

Beyond MERT: other paths to music SSL

MERT is one of several approaches to self-supervised music understanding. The most useful contrasts are with MusicFM (which argues you don’t need a learned tokenizer at all — random-projection quantization works fine) and JukeMIR (which argues the right move is to skip SSL entirely and reuse a large generative model’s hidden states as features). MAP-Music2Vec is MERT’s direct predecessor from the same group and shows the lineage. MULE is the strongest non-transformer non-masked baseline.

Papers & Resources