Lunar Boom Learning

4.4 · Overfitting and Memorisation

Section 4.4 of 4.6

Overfitting and Memorisation

Learning musical patterns without reproducing training examples

Learn how to distinguish useful generalisation from overfitting, split leakage, duplicate exposure, memorisation, and exact or approximate reproduction in generated music.

About 16 minutes

Guiding question

Why can lower training loss be misleading?

By the end, you’ll be able to
  • Distinguish underfitting, generalisation, overfitting, memorisation, and data replication.
  • Interpret training, validation, and test curves without treating one curve shape as conclusive proof.
  • Explain how duplicated and near-duplicated examples can distort both training and evaluation.
  • Identify validation failures caused by leakage, distribution mismatch, preprocessing errors, or unstable estimates.
  • Compare exact token matching, symbolic similarity, acoustic similarity, and embedding-based nearest-neighbour analysis.
  • Explain why memorisation tests require thresholds, controls, and human review.
  • Select practical responses such as deduplication, regularisation, early stopping, data expansion, and reduced model capacity.
  • Design an evaluation that measures both target-domain quality and reproduction risk.

Section 3 designed a small melody experiment with separate training, validation, and test data. Those divisions matter because a model can become extremely good at the examples it has already seen without learning behaviour that transfers to new music.

This section separates several problems that are often grouped together:

    1. Overfitting: performance on training data improves more than performance on relevant unseen data.
    2. Leakage: held-out information enters training or model selection.
    3. Duplication: the same or nearly the same material appears multiple times.
    4. Memorisation: the trained model retains information specific to individual training examples.
    5. Replication: generated output reproduces a training example or part of one under a chosen similarity criterion.

These problems interact, but they are not interchangeable.

Five different failure modes

Swipe sideways to view the full comparison

ProblemWhat it changesTypical evidence
UnderfittingThe model fails to learn enough from training dataTraining and validation performance are both weak
OverfittingTraining performance improves without comparable held-out improvementA widening train-validation gap or worsening validation result
Data leakageHeld-out information affects training or model selectionSuspiciously strong validation or test scores that fall after correcting the pipeline
MemorisationThe model retains example-specific informationExtraction, membership, or exact continuation evidence
ReplicationA generated sample resembles a training sample beyond a defined thresholdExact or approximate match confirmed through calibrated retrieval and review

Reading training and validation curves

Training loss is calculated on examples used for optimisation. Validation loss is calculated on held-out examples without parameter updates.

A common overfitting pattern is:

  1. Training and validation loss both fall.
  2. Validation improvement slows.
  3. Training loss continues falling.
  4. Validation loss stops improving or begins rising.

The checkpoint near the best validation result may generalise better than the final checkpoint. The curve is evidence, not a complete diagnosis. Its interpretation depends on the loss calculation, data distributions, model mode, and uncertainty in the validation estimate.

Common curve patterns

Swipe sideways to view the full comparison

PatternPossible interpretationNext check
Both losses remain highUnderfitting, optimisation failure, or unsuitable representationInspect baseline, learning rate, capacity, targets, and tokenisation
Both losses fall and remain closeHealthy learning under the current validation designInspect generated samples and the untouched test set
Training falls while validation risesPossible overfittingSelect an earlier checkpoint and audit leakage or distribution mismatch
Validation is lower than trainingCan occur with dropout, augmentation, harder training batches, or loss-mode differencesRecalculate both under comparable evaluation conditions
Validation jumps sharplySmall validation set, unstable examples, numerical issue, or pipeline changeInspect per-example losses and repeat the evaluation
Validation is implausibly strongPossible duplicate or preprocessing leakageAudit grouping, overlap, and feature preparation

Validation can fail before the model does

A validation score is trustworthy only when the validation process represents the intended use.

Common failures include:

    1. Overlapping windows from one song across splits
    2. Alternate performances or arrangements of one composition across splits
    3. Duplicate files across partitions
    4. Normalisation statistics calculated using all data
    5. Validation prompts taken from training captions
    6. A validation set that is too small or unrepresentative
    7. Different preprocessing or masking in training and validation
    8. Repeated tuning against the validation set until it becomes indirectly overfit

A rising validation loss may indicate model overfitting, but a broken validation design can create the same appearance.

Duplicates change how often the model sees an example

If one melody appears once and another appears fifty times through copies, excerpts, transpositions, remasters, or metadata variants, the second receives far more optimisation exposure.

Exact duplicates are the simplest case. Near duplicates can include:

    1. The same audio under different filenames
    2. A remastered or compressed version
    3. A shortened excerpt
    4. A MIDI transposition
    5. Alternate performances of the same composition
    6. A loop copied into several commercial packs
    7. Several captions pointing to the same audio

Research in language modelling has shown a strong relationship between repeated exposure and regeneration of memorised sequences. Audio research has also found substantial duplication inside a commonly used training dataset and observed partial replication in trained diffusion models. These findings support duplicate auditing, but modality-specific measurements remain necessary.

Real-world example: MusicGen's memorisation experiment

The MusicGen researchers tested whether the model could continue extracts from its own training set. They sampled 20,000 training examples, supplied increasing lengths of original EnCodec-token prompts, and generated five seconds using greedy decoding.

They measured:

    1. Exact matches: every generated token in the tested coarse codebook matched the source continuation.
    2. Partial matches: at least 80 percent of the generated tokens matched the source continuation.

This is a strong targeted test of continuation from known training prefixes. It does not measure every possible form of musical similarity, and it examines one coarse codec stream rather than every detail in the waveform.

Examples in practice

Real-world example: audio diffusion replication

The ICASSP study Generation or Replication trained and analysed text-to-audio latent diffusion models on AudioCaps. It investigated memorisation as training-set size changed, found many duplicated clips in the dataset, and reported mel-spectrogram similarity as more robust than the tested learned embeddings for detecting matches in that setup.

Real-world example: MiRA

The ISMIR Music Replication Assessment work compared several raw-audio music-similarity metrics in controlled replication experiments. It proposed a model-independent retrieval workflow and showed why replication assessment should use calibrated metrics rather than one unexamined embedding distance.

Music can match in several different ways

Two tracks can share one property while differing in others. A generated track might reproduce a melody but change its instrumentation, or preserve production texture while changing harmony.

Possible comparison levels include:

    1. Exact token sequence
    2. Pitch sequence
    3. Transposition-invariant intervals
    4. Rhythm and onset pattern
    5. Chord progression
    6. Melodic contour
    7. Chroma or tonal content
    8. Spectrogram texture
    9. Audio fingerprint
    10. Learned semantic embedding
    11. Production-style embedding

No single metric captures every musically or legally relevant form of similarity.

Selecting a similarity test

Swipe sideways to view the full comparison

MethodSensitive toCan miss
Exact symbolic tokensLiteral event-sequence reproductionTransposition, timing shifts, ornamentation, and alternative tokenisations
Interval or contour matchingMelodic shape despite transpositionTimbre, harmony, rhythm, and production
Audio fingerprintHighly similar recordings or excerptsReperformed or transformed musical content
Mel-spectrogram similarityLocal acoustic and time-frequency resemblanceSome musically related but acoustically transformed versions
Chroma similarityPitch-class and harmonic resemblanceRhythm, timbre, octave, and production
Learned audio embeddingBroad semantic or acoustic similarity represented by the encoderFine copying that the embedding discards
Human listening reviewMusically meaningful resemblance across several propertiesScalability and precise reproducibility without a protocol
Factors that can raise memorisation risk

Swipe sideways to view the full comparison

FactorWhy it mattersAudit response
Exact or near duplicatesSelected material receives repeated optimisation exposureCanonicalise, cluster, count, and reweight or deduplicate
Small datasetEach example represents a larger share of the learning signalUse conservative capacity and stronger held-out testing
Large model capacityThe model can represent more example-specific informationCompare smaller models and inspect retrieval risk
Many epochsThe same examples are revisited repeatedlyTrack exposure counts and checkpoint-level replication
Rare or distinctive exampleUnique features may become strongly associated with a prompt or prefixCreate targeted prompts and nearest-neighbour tests
Detailed identifying captionThe condition can act as a retrieval keyAudit specific captions and condition variants
Train-test overlapEvaluation may reward recognition rather than transferRebuild splits using grouped and duplicate-aware rules

Reducing overfitting

No single intervention prevents every kind of overfitting or memorisation. Useful options include:

    1. More representative and less duplicated data
    2. Smaller model or adapter capacity
    3. Fewer training steps
    4. Earlier checkpoint selection
    5. Weight decay
    6. Dropout
    7. Data augmentation that preserves the task
    8. Mixing broader rehearsal data during narrow fine-tuning
    9. Freezing more pretrained parameters
    10. Label smoothing for suitable classification objectives
    11. Explicit replication tests during evaluation

Every intervention changes the learning problem. For example, aggressive pitch transposition may be suitable for key-invariant melody learning but unsuitable when absolute register is important.

Mitigation strategies and trade-offs

Swipe sideways to view the full comparison

StrategyPotential benefitPossible cost
Deduplicate dataReduces repeated exposure and leakageCan remove legitimate variants if similarity rules are crude
Add representative dataImproves coverage and reduces reliance on individual examplesRequires rights, cleaning, storage, and compute
Reduce capacityLimits the model's ability to fit small detailsMay increase underfitting
Use dropout or weight decayDiscourages brittle parameter fittingCan slow optimisation or weaken useful detail
Stop earlierSelects a checkpoint before held-out performance declinesRequires stable validation and may leave capacity unused
Freeze more parametersPreserves pretrained behaviour during small-data adaptationMay prevent sufficient domain learning
Augment dataCreates task-preserving variationBad augmentations can change labels or musical meaning
Filter generationsCatches suspicious nearest neighbours before releaseAdds retrieval cost and cannot fix all hidden memorisation

A practical overfitting and memorisation audit

  1. Validate the splits

    Check work, source, performer, arrangement, and duplicate groups before interpreting any curve.

  2. Plot comparable losses

    Use consistent masking, reduction, preprocessing, and evaluation mode.

  3. Select several checkpoints

    Compare early, best-validation, and final checkpoints rather than only the last one.

  4. Generate controlled samples

    Use held-out prompts, training prompts, random prompts, prefixes, and repeated seeds.

  5. Run exact symbolic checks

    Compare token sequences, n-grams, intervals, rhythm, and transposition-normalised melodies where applicable.

  6. Run audio retrieval

    Use fingerprints, spectrogram metrics, chroma, and learned embeddings against the indexed training set.

  7. Calibrate thresholds

    Use known copied, transformed, and independent pairs to measure false positives and false negatives.

  8. Review flagged candidates

    Listen, inspect alignments, record evidence, and avoid relying on one metric.

  9. Compare mitigation variants

    Test deduplication, earlier stopping, smaller capacity, or stronger regularisation under the same evaluation.

  10. Preserve the audit record

    Store dataset version, hashes, model checkpoint, prompts, seeds, metrics, thresholds, neighbours, and review decisions.

Interactive lesson

Spot Overfitting and Memorisation

Try it: Begin with the healthy scenario and scrub through checkpoints. Compare underfitting, ordinary overfitting, split leakage, duplicate-heavy training, and targeted memorisation. Change model capacity, duplicate count, regularisation, and stopping point, then inspect both held-out quality and replication risk.

Overfitting is a gap between training and held-out behaviour. Memorisation is retention of example-specific information. Diagnose them with trustworthy splits, comparable loss curves, duplicate audits, checkpoint comparisons, calibrated similarity metrics, nearest-neighbour retrieval, and human review.

From statistical risk to physical cost

Reducing overfitting may require more data, more model comparisons, several checkpoints, repeated seeds, and large nearest-neighbour indexes. Those safeguards consume storage, memory, compute, and engineering time.

The next section, Compute and Infrastructure, explains the hardware and systems required to train, evaluate, checkpoint, and reproduce music models at different scales.

Check your understanding

Ready for a quick check?

Test whether you can distinguish generalisation, overfitting, leakage, duplication, memorisation, and replication, then select a defensible audit and response.

Ready to continue?

Save this section to your account and continue from any device.

Checking your account…
Sources for this lesson (12)
  1. Validation Curves: Plotting Scores to Evaluate Models — scikit-learn contributors
  2. Common Pitfalls and Recommended Practices — scikit-learn contributors
  3. Cross-Validation: Evaluating Estimator Performance — scikit-learn contributors
  4. Underfitting Versus Overfitting — scikit-learn contributors
  5. torch.nn.Dropout — PyTorch contributors
  6. Dropout: A Simple Way to Prevent Neural Networks from Overfitting — Nitish Srivastava, Geoffrey Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdinov (2014)
  7. Simple and Controllable Music Generation — Jade Copet et al. (2023)
  8. Generation or Replication: Auscultating Audio Latent Diffusion Models — Dimitrios Bralios et al. (2024)
  9. Towards Assessing Data Replication in Music Generation with Music Similarity Metrics on Raw Audio — Roser Batlle-Roca, Wei-Hsiang Liao, Xavier Serra, Yuki Mitsufuji, and Emilia Gómez (2024)
  10. Deduplicating Training Data Mitigates Privacy Risks in Language Models — Nikhil Kandpal, Eric Wallace, and Colin Raffel (2022)
  11. Deduplicating Training Data Makes Language Models Better — Katherine Lee et al. (2022)
  12. Extracting Training Data from Diffusion Models — Nicholas Carlini et al. (2023)
Browse all contextual sources →