A diffusion model builds a picture by taking noise away, one small step at a time.
They also memorize. Trained long enough, a diffusion model will hand back pictures it was trained on instead of making a new one.
Below, a diffusion model learns 300 photographs from a single film set, and you can see when the learning turns into copying.
Drag the slider, or just scroll. This is the exact schedule the model trained with.
This is one training step, slowed down. A photograph is pulled from the dataset. A number between 0 and 1,000 is drawn at random, and that much noise is added to it. The model looks at the result and guesses what was added. The guess is compared against the real answer and the gap is a single number, called error.
That number is used to nudge the model's weights a little in the direction that would have been less wrong. Then the whole thing repeats. Sixty thousand times.
The error values are the real ones from the run and the curve in panel four is drawn from them as the counter climbs. The guess in panel three is a stand in. Saving the model's output at every one of sixty thousand steps was not worth the disk.
Scored on squared error, the best possible answer to a noisy image is the average of every clean photograph that could have produced it, weighted by how plausible each one is. There is a formula for it. The panel below applies that formula across all 300 photographs.
Real output, saved at 47 points during training. The starting noise never changes, so what moves is only the model.
Left, an image generated from random noise. Right, the photograph from the training set it landed on. Nothing was aligned, cropped or matched by hand.
These are not copies of any one photograph. They are parts of several, put together.
Some of the pieces are recognizable on their own. One holds the cinematographer's camera rig with the operator missing. Another is only light and shadow, though the logo survived intact. In several, the photograph named as the nearest match does not look much like the picture at all.
There is no moment where the model stops inventing and starts copying. The change is gradual, and the cutoff is subjective.
This is a membership inference attack. Add a known amount of noise to a photograph, ask the model to take it back off, and measure how close it gets. A model does that job better on photographs it was trained on than on photographs it has never seen, so the error alone separates members of the training set from everything else. The gap opens long before the model produces anything that looks like a copy.
One way to reduce the leak is to stop training sooner.
Stopping early works, but with caveats. At five thousand steps the attack falls from certain back to barely better than guessing. It costs picture quality: 241 on the quality score against 172 at the end of the run, about forty percent worse.
Early stopping is only the option this run happens to show, and it is not the best one. Differential privacy, using augmentation, removing duplicate images, increasing image variability and complexity, and training on enough data that no single photograph can be memorized are all better answers. None of them were measured here.
Eight photographs. Four were in the training set and four were never shown to the model. One clue: How hard the model found each one. Lower means more familiar.
That was a membership inference attack, run with a slider.
A real one automates the same comparison across millions of candidates and does not need to be right often to do harm. The three rounds are not equally winnable, and that spread is what the attack looks like partway through training.
These were photographs from a film set, taken by me over a decade ago. Nobody is harmed by a model that has memorized a clapperboard.
The model has no idea what it is looking at. It runs the same arithmetic on any set of pictures. This one was set up to memorize: A small training set, no augmentation, training carried on until the loss stopped moving. Larger models are harder to push this far, but researchers at Google and DeepMind have pulled training images back out of production models anyway.
Put medical scans in that training set instead, or the work of an artist who never agreed to be in it, and nothing about the method changes. The model learns them the same way, and gives them back the same way.