Science News & Breakthroughs Featured May 21, 2026

How Deepfake AI Works

A technical look at how deepfakes are generated, from autoencoders and GANs to diffusion models, and why detectors trained on one method often fail on the next.

SC
ScienceTrace Science Desk
•
 8 min read
•
 1,488 words

The word "deepfake" entered common use around 2017, when face-swapped videos began circulating on public forums, and it has since come to cover almost any synthetic image, video or audio clip that imitates a real person. For researchers the interesting question is not whether such media can be made, but which technical choices make them convincing, which choices leave measurable traces, and why the tools built to catch them tend to age quickly. This article walks through the main generative families, the signal-level reasons detection is hard, and what the evaluation literature actually shows.

Autoencoders: the original face swap

The earliest widely used face-swap tools were not adversarial at all. They relied on a shared-encoder, two-decoder autoencoder. A single encoder is trained to compress aligned face crops from two people, A and B, into a low-dimensional latent code. Two separate decoders are trained, one to reconstruct faces of A and one to reconstruct faces of B. Because the encoder is shared, it is pushed toward capturing identity-independent attributes such as pose, expression, gaze direction and lighting. At swap time a frame of A is encoded and then passed through B's decoder, producing B's face wearing A's expression.

The practical implications are worth noting. The decoder has to learn the target's appearance from many examples, so these systems typically need a large collection of frames of the target, often drawn from interviews or public footage. Output resolution is limited by the crop size, and a separate blending step (landmark alignment, colour matching, a soft mask) pastes the result back into the frame. Many visible flaws, such as flicker around the jawline or a mismatch in skin tone, come from that compositing stage rather than from the neural network itself.

Adversarial training and what it optimises

The generative adversarial network, introduced by Goodfellow and colleagues in 2014, frames generation as a two-player game. A generator maps random noise to an image; a discriminator estimates whether an image is real or generated. Training alternates between the two, and in theory the generator converges toward the data distribution. In practice GAN training is delicate: it can oscillate, and it can suffer mode collapse, where the generator produces a narrow range of outputs that happen to fool the current discriminator. Later architectures made face synthesis far more stable and sharper, and many face-manipulation systems, including those that edit attributes or reenact expressions, use an adversarial loss as one component alongside reconstruction and perceptual losses.

A point that matters for detection: a discriminator trained inside the generator's own pipeline is a detector for that pipeline's artifacts. Once the generator has satisfied it, those artifacts are, by construction, no longer easy to find with a similar model.

Diffusion models and why they changed the picture

Denoising diffusion models, popularised for images by Ho, Jain and Abbeel in 2020, take a different route. A forward process gradually adds Gaussian noise to a real image over many steps; a neural network is trained to predict and remove that noise. Generation runs the learned reverse process, starting from pure noise and denoising step by step, optionally guided by a text prompt or a reference image. Latent diffusion, described by Rombach and colleagues in 2022, performs this denoising in a compressed latent space, which made high-resolution synthesis affordable on consumer hardware.

For manipulation, diffusion offers inpainting (regenerating a masked region, such as a face, consistent with its surroundings) and fine-tuning on a small set of reference images of a person. Compared with older face-swap pipelines, this reduces the data and expertise required. It also changes the artifact profile: classifiers tuned to the upsampling traces typical of GAN generators do not automatically transfer to images produced by diffusion models.

Synthetic voice

Voice cloning typically has two parts: an acoustic model that turns text (or another speaker's speech) into a mel-spectrogram conditioned on a speaker embedding, and a neural vocoder that converts the spectrogram into a waveform. Speaker embeddings learned from large multi-speaker corpora allow a model to approximate an unseen voice from a short sample. Published systems vary widely in how much audio they need and how closely they match a target, and quality from a very short clip is generally lower than from minutes of clean speech; claims that a few seconds always suffice should be treated with caution. The ASVspoof challenge series, which supplies datasets of synthesised, converted and replayed speech, is the standard benchmark for countermeasures in this area.

Why detection is hard: signal and evaluation

Detection research has produced several families of cues. Early work looked at physiological regularities, for example the lower blink rate in early deepfakes (Li, Chang and Lyu, 2018), which disappeared once training data included closed-eye faces. Others examine geometric consistency of facial landmarks and head pose, colour and lighting inconsistencies between swapped region and background, frequency-domain fingerprints of upsampling layers, and blood-flow signals recovered from subtle colour variation in skin (remote photoplethysmography). Each cue is a statement about the current generation of tools, and each can be learned away by a generator trained against it.

A second problem is generalisation. The standard dataset in the field, FaceForensics++ (Rössler et al., 2019), contains videos manipulated by a small number of methods and offers several compression levels. Detectors reach high accuracy when train and test use the same manipulation method and the same compression, and perform noticeably worse when either changes. Celeb-DF (Li et al., 2020) was built with a better blending pipeline precisely because detectors that did well on earlier sets struggled on it. The Deepfake Detection Challenge organised by Facebook (Dolhansky et al., 2020) added the most realistic test of all: entrants were evaluated on a hidden set containing material unlike the public data, and the winning model scored considerably lower there than on the public leaderboard. Wang and colleagues (2020) showed that a classifier trained on one GAN family's output could generalise to others when trained with appropriate augmentation, a more encouraging result, though this was demonstrated on specific generators and not on every future one.

Compression compounds the difficulty. Re-encoding by a messaging app or social platform removes high-frequency content in which many forensic traces live. When reading a paper's headline number, check what compression was applied, whether identities overlap between train and test, and which metric is reported: area under the ROC curve hides how many real videos are wrongly flagged at an operating threshold, and that false-positive rate is what matters if a tool is ever used to judge real people.

Provenance as a complement to detection

Because passive detection is an arms race, a second strategy asks the capture device or editing tool to sign what it produces. The C2PA specification, developed by the Coalition for Content Provenance and Authenticity, defines cryptographically signed metadata that records origin and editing history. Provenance can show that a file is unmodified since signing; it cannot show that an unsigned file is fake, and the metadata can be stripped. It is best seen as a way to make authentic material verifiable, not to condemn the rest.

Limitations and open questions

  • Benchmark realism. Public datasets lag behind current generators. A detector's reported accuracy is a statement about the dataset, not about media circulating today.
  • Calibration. Most detectors output a score, not a probability that a clip is fake, and the base rate of fakes in the wild is unknown and context dependent.
  • Audio-visual consistency. Mismatch between lip movement and speech is a promising cue, but how robust it is against joint audio-video generators is still being studied.
  • Human performance. Studies of human detection often use cherry-picked or low-quality fakes, so conclusions about how well people can spot them depend heavily on the stimuli.

Questions worth testing

  • How does a detector's error rate change when the same clips are re-encoded through two successive platforms?
  • Does performance hold when evaluation data comes from a generator released after the detector was trained?
  • Can detection be reported with a fixed false-positive budget (for example, at a threshold where one in a thousand real clips is flagged) instead of a single accuracy figure?
  • What is the effect of provenance signing on user behaviour, given that most legitimate content will remain unsigned for years?

References and further reading

  1. Goodfellow I. et al. Generative Adversarial Nets. Advances in Neural Information Processing Systems (NeurIPS), 2014.
  2. Ho J., Jain A., Abbeel P. Denoising Diffusion Probabilistic Models. NeurIPS, 2020.
  3. Rombach R. et al. High-Resolution Image Synthesis with Latent Diffusion Models. CVPR, 2022.
  4. Rössler A. et al. FaceForensics++: Learning to Detect Manipulated Facial Images. ICCV, 2019.
  5. Li Y. et al. Celeb-DF: A Large-scale Challenging Dataset for DeepFake Forensics. CVPR, 2020.
  6. Dolhansky B. et al. The DeepFake Detection Challenge (DFDC) Dataset. arXiv, 2020.
  7. Li Y., Chang M.-C., Lyu S. In Ictu Oculi: Exposing AI Created Fake Videos by Detecting Eye Blinking. IEEE WIFS, 2018.
  8. Wang S.-Y., Wang O., Zhang R., Owens A., Efros A. CNN-generated images are surprisingly easy to spot... for now. CVPR, 2020.
  9. Coalition for Content Provenance and Authenticity (C2PA). Technical Specification.
#deepfake #AI #machine learning #GAN #generative AI #synthetic media #detection
All Scientific Breakthroughs