Exploring Unbiased Deepfake Detection via Token-Level Shuffling and Mixing

TL;DR

Proposes a Token-level shuffling and mixing framework for unbiased deepfake detection, significantly improving cross-dataset generalization with state-of-the-art AUC scores.

cs.CV 🔴 Advanced 2025-01-08 55 citations 108 views
Xinghe Fu Zhiyuan Yan Taiping Yao Shen Chen Xi Li
Deepfake Detection Transformer Bias Mitigation Contrastive Learning Causal Inference

Key Findings

Methodology

This paper introduces an unbiased deepfake detection framework leveraging Transformer-based token shuffling and mixing strategies. The shuffling branch randomly permutes local patch tokens and their positional encodings in the latent space, disrupting position bias. The mixing branch randomly exchanges tokens between two images with the same label within a batch, reducing content bias. During training, contrastive loss aligns features from different branches, while divergence loss aligns logits, promoting unbiased feature representations. The approach incorporates low-rank adaptation (LoRA) for parameter-efficient tuning. Extensive experiments on five public datasets demonstrate that this method surpasses state-of-the-art techniques, especially in cross-dataset scenarios, by effectively mitigating biases and enhancing generalization.

Key Results

  • On cross-dataset evaluation, the model achieves a 86.9% AUC on the CDF dataset, outperforming previous methods by approximately 10%. On DFD and DFDC datasets, the AUC reaches 91.0% and 75.8%, respectively, showing robust generalization. Ablation studies confirm that the combination of shuffling and mixing significantly reduces reliance on biased cues. The model maintains high robustness under various perturbations such as Gaussian blur, JPEG compression, and contrast changes, indicating strong real-world applicability.
  • Compared to baseline models like ViT-B and previous SOTA methods such as LSDA and TALL++, the proposed approach consistently improves detection performance across multiple datasets. Notably, the cross-dataset AUC improvements highlight its potential for practical deployment. The feature space analysis reveals that the bias-intervened model exhibits higher feature similarity across different fake types, confirming the effectiveness of bias removal strategies.
  • The experiments also demonstrate that the proposed method effectively suppresses position and content biases, as evidenced by feature visualization and attention maps. The model's ability to detect unseen forgery techniques and adapt to diverse content scenarios underscores its robustness and practical value.

Significance

This work addresses a fundamental challenge in deepfake detection: poor generalization across datasets due to bias reliance. By explicitly intervening on position and content biases in the latent space, the proposed framework significantly enhances the model's robustness, making it more suitable for real-world applications where data distributions vary widely. The integration of causal inference principles provides a solid theoretical foundation, advancing the understanding of bias mitigation in deep learning models. The approach's simplicity, efficiency, and compatibility with existing Transformer architectures make it highly practical for industry deployment, potentially transforming digital media security and misinformation detection.

Technical Contribution

The paper's key technical contribution lies in the novel use of token-level shuffling and mixing within Transformer models to intervene on bias sources. The shuffling module randomly permutes local patch tokens and their positional encodings, disrupting position bias. The mixing module performs stochastic token exchanges between images, reducing content bias. These operations are integrated into a multi-branch training framework with contrastive and divergence losses, enabling the model to learn bias-invariant features. The use of LoRA allows efficient parameter tuning without retraining the entire backbone, facilitating scalable deployment. Theoretically, the causal graph analysis clarifies how these interventions block spurious backdoor paths, ensuring the model captures genuine forgery cues. Overall, this work bridges bias control, causal inference, and Transformer-based detection, opening new avenues for robust deepfake detection.

Novelty

This research is the first to systematically incorporate token-level shuffling and mixing operations within Transformer-based deepfake detectors to explicitly address position and content biases. Unlike prior works that focus solely on feature disentanglement or data augmentation, this method employs causal intervention principles to block spurious correlations at the latent space level. The combination of local token permutation and content exchange, guided by contrastive and divergence losses, provides a unified, scalable, and theoretically grounded solution for bias mitigation. Its compatibility with state-of-the-art models like CLIP further enhances its novelty and practical relevance.

Limitations

  • The current approach primarily targets position and content biases; other biases such as temporal inconsistencies or multimodal cues are not explicitly addressed. In scenarios with highly sophisticated or adaptive fake content, detection performance may degrade.
  • The token shuffling and mixing operations introduce additional computational overhead, which could impact real-time deployment, especially on resource-constrained devices. Optimization for efficiency remains an open challenge.
  • While the method demonstrates strong cross-dataset generalization, its robustness against emerging deepfake generation techniques, especially those that manipulate global semantic content, needs further validation. Future work should explore adaptive bias interventions and multi-modal fusion to address these limitations.

Future Work

Future directions include integrating multi-modal data (audio, text) to further improve robustness, developing adaptive bias intervention strategies that dynamically respond to new fake content types, and optimizing the computational efficiency for real-time deployment. Additionally, extending causal analysis to other bias sources and exploring explainability of the bias removal process will enhance the interpretability and trustworthiness of deepfake detectors. Investigating the combination of bias intervention with adversarial training and self-supervised learning could further strengthen detection capabilities against evolving threats.

AI Executive Summary

The rapid proliferation of deepfake technology has posed significant challenges to digital media integrity and trustworthiness. Existing detection methods, often based on learning subtle artifacts or frequency domain cues, tend to perform well within the datasets they are trained on but struggle to generalize across different data distributions. This limitation stems from models overfitting to dataset-specific cues, especially biases related to the position of manipulated regions or irrelevant content such as backgrounds and accessories. Such biases create spurious correlations that hinder the model’s ability to detect unseen or novel deepfake techniques in real-world scenarios.

Recognizing this critical issue, the authors propose a novel framework that explicitly intervenes on these biases within the Transformer architecture. The core idea is to perform token-level shuffling and mixing operations in the latent space, disrupting the model’s reliance on biased cues. The shuffling branch randomly permutes local patch tokens and their positional encodings, effectively breaking the positional bias. Meanwhile, the mixing branch exchanges tokens between two images with the same label, reducing content bias. These operations are integrated into a multi-branch training pipeline, where contrastive and divergence losses are employed to align features and logits across branches, encouraging the network to learn bias-invariant representations.

This approach is grounded in causal inference principles, where the interventions at the token level serve as a form of causal treatment, blocking backdoor paths that lead to spurious correlations. The authors leverage the low-rank adaptation (LoRA) technique to fine-tune the model efficiently, making the method scalable and practical. Extensive experiments on five public datasets, including FaceForensics++, Celeb-DF, DFDC, DFD, and DeepfakeDetection, demonstrate that the proposed method outperforms existing state-of-the-art techniques, especially in cross-dataset evaluations. For example, the cross-dataset AUC on the CDF dataset reaches 86.9%, a significant improvement over baselines.

Beyond quantitative metrics, the method shows strong robustness against various image perturbations such as Gaussian blur, JPEG compression, and contrast adjustments. Visualization analyses confirm that bias-related attention is suppressed, and the model focuses more on genuine forgery cues. These results highlight the potential of bias intervention strategies to enhance the generalization and reliability of deepfake detectors.

In practical terms, this work advances the field by providing a scalable, theoretically grounded, and highly effective solution to a long-standing problem. It opens new avenues for integrating causal inference with deep learning-based detection, with promising implications for digital security, misinformation control, and content verification. Future research may extend these ideas to multi-modal settings, dynamic bias modeling, and real-time deployment, further strengthening the defenses against increasingly sophisticated deepfake threats.

Deep Analysis

Background

Deepfake技术的快速发展极大地推动了虚假内容的生成与传播,尤其是在社交媒体、娱乐和新闻领域。早期的深度伪造检测方法多依赖于局部伪造痕迹、频域特征或伪造指纹,代表性工作包括Li和Lyu的伪造指纹检测、Yang等的频域分析等。这些方法在训练集上表现优异,但在跨数据集和实际应用中,常常面临泛化能力不足的问题。近年来,Transformer架构的引入为捕获全局关系提供了新途径,但也带来了对偏差敏感的问题。现有研究多关注于提取伪造特征,忽视了模型对位置偏差(position bias)和内容偏差(content bias)的依赖,导致在实际场景中易受偏差干扰,影响检测效果。为应对这一挑战,学界开始探索偏差消除和因果推断的方法,试图让模型学习到更稳健的伪造特征。

Core Problem

深度伪造检测的核心难点在于模型的泛化能力不足。现有方法多依赖于伪造特征的学习,容易受到位置偏差和内容偏差的影响。位置偏差表现为模型过度关注图像中心区域,即使没有伪造也倾向于依赖中心信息;内容偏差则表现为模型错误地利用背景、发型等无关内容作为判别依据。这些偏差导致模型在训练时学习到的特征具有较强的偏向性,难以在不同数据分布或新颖伪造技术中保持性能。解决这一问题的难点在于如何在模型训练中有效干预偏差,避免模型对无关信息的过度依赖,同时保持对伪造痕迹的敏感性。

Innovation

本文的创新点主要在于引入Token级别的偏差干预策略,结合Transformer潜在空间的洗牌与混合机制,系统性地减少模型对位置和内容偏差的依赖。具体创新包括:1)设计基于Token嵌入的洗牌操作,通过随机重排局部Token及其位置编码,扰乱位置偏差;2)提出基于Batch的Token混合操作,随机交换两张图片的Token内容,减少内容偏差;3)结合对比和散度损失,强化模型在特征和输出层的无偏表示;4)引入低秩参数调优(LoRA),提升训练效率和模型泛化能力。这些创新在深度伪造检测领域尚属首次,系统性地解决了偏差干扰问题,为Transformer模型的偏差控制提供了新思路。

Methodology

  • �� 输入:一张深度伪造或真实图片,经过预训练的Transformer(如ViT-B)提取Token特征。• 洗牌分支:在Token嵌入层,将局部区域的Token及其位置编码随机重排,形成扰乱位置偏差的Token集合。具体操作包括随机采样矩形区域、插值调整位置编码、块级随机置换Token。• 混合分支:在Batch中随机选择两张标签相同的图片,随机抽取一定比例的Token,从一张图片的Token中抽取内容,再与另一张图片的Token进行交换,形成内容混合的Token集合。• 训练目标:在不同分支输出的特征和Logits上,分别引入对比损失(如SimCLR)和散度损失,促使模型学习到无偏的特征表示和分类器。• 参数调优:采用LoRA技术,冻结主干参数,仅微调低秩参数,提升训练效率和模型泛化能力。• 损失函数:结合交叉熵、对比损失和散度损失,优化模型输出的判别能力。• 训练流程:多分支同时训练,利用对比和因果推断理论,确保模型在偏差干预后,能更专注于伪造相关的因果特征。

Experiments

  • �� 数据集:使用FaceForensics++、Celeb-DF、DFDC、DFD、DeepfakeDetection等五个公开数据集,训练集为FF++,测试在其他数据集上进行跨域验证。• 实验设置:采用ViT-B作为主干网络,预训练自CLIP,训练时采样8帧视频片段。• 超参数:洗牌块大小为2×2,混合比例r设为0.3,LoRA秩为4,损失参数τ、λ1、λ2均设为0.1。• Ablation:逐步加入洗牌和混合策略,验证偏差干预效果。• 评估指标:采用AUC(ROC曲线下面积)作为主要性能指标,分别评估帧级和视频级检测性能。• 其他:对模型的鲁棒性、抗干扰能力进行测试,包括高斯模糊、JPEG压缩、对比度变化等多种扰动。

Results

  • �� 跨数据集测试中,模型在CDF数据集AUC达86.9%,优于传统Transformer方法约10%;在DFDC、D-FAKE等数据集上,AUC分别提升至75.8%、91.0%,表现出强大泛化能力。• 消融实验显示,加入Token洗牌和混合后,模型对位置和内容偏差的依赖明显减弱,特征空间的相似性增强,检测未见伪造类型的能力显著提升。• 在抗干扰测试中,模型在高斯模糊、JPEG压缩等扰动下仍保持较高的检测性能,验证了偏差干预策略的鲁棒性。

Applications

  • �� 该方法可应用于社交媒体内容审核、新闻验证、数字取证等场景,提升平台对深度伪造内容的识别能力。• 需要在实际部署中结合多模态信息(如音频、文本)以增强鲁棒性,适应不同伪造技术的发展。• 还可扩展到实时检测系统,结合硬件加速技术,实现快速、准确的伪造内容识别,为数字媒体安全提供技术保障。

Limitations & Outlook

  • �� 当前方法主要针对位置偏差和内容偏差;在极端偏差场景(如伪造区域极其隐蔽或内容极度复杂)下,检测性能可能仍不足。• 训练引入的洗牌和混合操作增加了计算成本,影响实时性,需优化算法效率。• 模型在新兴伪造技术上的泛化能力仍需验证,尤其是在多模态、多源信息融合场景中,未来需结合多模态学习和因果推断技术进行改进。

Plain Language Accessible to non-experts

想象你在一家蛋糕工厂工作。每次做蛋糕时,你可以用不同的材料和方法,但有些工厂为了节省时间,可能只关注蛋糕的中心部分,忽略了其他部分。这样做的蛋糕虽然看起来不错,但其实并不代表所有工厂都这样。深度伪造检测就像是检查蛋糕的工艺,想找出真正的制作痕迹,而不是被工厂的偏好或习惯所迷惑。传统的方法就像只看蛋糕的中心,容易被误导。而这篇文章提出的方法,就像是随机打乱蛋糕的材料顺序,或者用不同的材料混合,确保检测系统不会只依赖某一部分或某一种材料。这样,检测系统变得更聪明、更可靠,不会被偏见所迷惑,也能更好地识别出真正的假蛋糕。这就像让工厂的蛋糕变得更加公平和真实,避免只看表面或某一部分的偏见。

ELI14 Explained like you're 14

你知道吗?在你用手机拍视频时,有些人可以用电脑做出假的视频,让人很难分辨真假。这就像有人用魔法变出一段看起来很真实的影片,但其实是假的。科学家们一直在想办法,让电脑变得更聪明,能一眼看出哪些视频是假的。但是,问题来了:如果电脑只学会了看某个特定的伪造方法,它就会在遇到新方法时变得无能为力。就像你只知道用一种魔法变东西,但别人用另一种魔法,你就认不出来了。为了解决这个问题,研究人员设计了一种新方法,就像是让电脑随机打乱视频中的内容,让它不要只依赖某一部分信息。这样,电脑就能更全面地理解视频,不会被偏见迷惑。通过这种方式,电脑变得更聪明、更可靠,可以发现各种不同的假视频。是不是很酷?这就像让电脑变成了一个超级侦探,能发现各种不同的伪造!

Abstract

The generalization problem is broadly recognized as a critical challenge in detecting deepfakes. Most previous work believes that the generalization gap is caused by the differences among various forgery methods. However, our investigation reveals that the generalization issue can still occur when forgery-irrelevant factors shift. In this work, we identify two biases that detectors may also be prone to overfitting: position bias and content bias, as depicted in Fig. 1. For the position bias, we observe that detectors are prone to lazily depending on the specific positions within an image (e.g., central regions even no forgery). As for content bias, we argue that detectors may potentially and mistakenly utilize forgery-unrelated information for detection (e.g., background, and hair). To intervene these biases, we propose two branches for shuffling and mixing with tokens in the latent space of transformers. For the shuffling branch, we rearrange the tokens and corresponding position embedding for each image while maintaining the local correlation. For the mixing branch, we randomly select and mix the tokens in the latent space between two images with the same label within the mini-batch to recombine the content information. During the learning process, we align the outputs of detectors from different branches in both feature space and logit space. Contrastive losses for features and divergence losses for logits are applied to obtain unbiased feature representation and classifiers. We demonstrate and verify the effectiveness of our method through extensive experiments on widely used evaluation datasets.

cs.CV

References (20)

The DeepFake Detection Challenge (DFDC) Dataset.

Brian Dolhansky, Joanna Bitton, Ben Pflaum et al.

2020 988 citations ⭐ Influential

Face X-Ray for More General Face Forgery Detection

Lingzhi Li, Jianmin Bao, Ting Zhang et al.

2019 1255 citations ⭐ Influential View Analysis →

Face Forensics in the Wild

Tianfei Zhou, Wenguan Wang, Zhiyuan Liang et al.

2021 189 citations ⭐ Influential View Analysis →

The Deepfake Detection Challenge (DFDC) Preview Dataset

Brian Dolhansky, Russ Howes, Ben Pflaum et al.

2019 672 citations ⭐ Influential View Analysis →

Celeb-DF: A New Dataset for DeepFake Forensics

Yuezun Li, Xin Yang, Pu Sun et al.

2019 214 citations ⭐ Influential

Exposing DeepFake Videos By Detecting Face Warping Artifacts

Yuezun Li, Siwei Lyu

2018 1229 citations View Analysis →

What makes fake images detectable? Understanding properties that generalize

Lucy Chai, David Bau, Ser-Nam Lim et al.

2020 468 citations View Analysis →

Grad-CAM++: Generalized Gradient-Based Visual Explanations for Deep Convolutional Networks

Aditya Chattopadhyay, Anirban Sarkar, Prantik Howlader et al.

2017 3366 citations View Analysis →

Grad-CAM: Visual Explanations from Deep Networks via Gradient-Based Localization

Ramprasaath R. Selvaraju, Abhishek Das, Ramakrishna Vedantam et al.

2016 28984 citations View Analysis →

Selecting Data Augmentation for Simulating Interventions

Maximilian Ilse, Jakub M. Tomczak, Patrick Forré

2021 62 citations

Visualizing Data using t-SNE

L. Maaten, Geoffrey E. Hinton

2008 50887 citations

Simple Statistical Gradient-Following Algorithms for Connectionist Reinforcement Learning

Ronald J. Williams

2004 10635 citations

Representation Learning with Contrastive Predictive Coding

Aäron van den Oord, Yazhe Li, O. Vinyals

2018 14288 citations View Analysis →

On the Detection of Digital Face Manipulation

J. Stehouwer, H. Dang, Feng Liu et al.

2019 773 citations View Analysis →

FaceShifter: Towards High Fidelity And Occlusion Aware Face Swapping

Lingzhi Li, Jianmin Bao, Hao Yang et al.

2019 468 citations View Analysis →

DeeperForensics-1.0: A Large-Scale Dataset for Real-World Face Forgery Detection

Liming Jiang, Wayne Wu, Ren-Cang Li et al.

2020 630 citations View Analysis →

A Simple Framework for Contrastive Learning of Visual Representations

Ting Chen, Simon Kornblith, Mohammad Norouzi et al.

2020 25873 citations View Analysis →

Self-Supervised Learning for Generalizable Out-of-Distribution Detection

Sina Mohseni, Mandar Pitale, Jbs Yadawa et al.

2020 233 citations

Thinking in Frequency: Face Forgery Detection by Mining Frequency-aware Clues

Yuyang Qian, Guojun Yin, Lu Sheng et al.

2020 1219 citations View Analysis →

Representation Learning via Invariant Causal Mechanisms

Jovana Mitrovic, B. McWilliams, Jacob Walker et al.

2020 290 citations View Analysis →

Cited By (20)

Low-rank Orthogonal Subspace Intervention for Generalizable Face Forgery Detection

2026 1 citations ⭐ Influential View Analysis →

Open-Unfairness Adversarial Mitigation for Generalized Deepfake Detection

2025 1 citations ⭐ Influential

LOGER: Local-Global Ensemble for Robust Deepfake Detection in the Wild

2026 1 citations ⭐ Influential View Analysis →

Towards generalizable and robust deepfake video detection via feature reconstruction and sequential temporal network

2026

Implementation of Robust Deepfake Detection via 3D Residual Attention Densenet with Pyramid Dilation Network

2025

Generalizing Deepfake Video Detection with Plug-and-Play: Video-Level Blending and Spatiotemporal Adapter Tuning

2024 75 citations View Analysis →

Unlocking the Capabilities of Large Vision-Language Models for Generalizable and Explainable Deepfake Detection

2025 29 citations View Analysis →

Orthogonal Subspace Decomposition for Generalizable AI-Generated Image Detection

2024 111 citations View Analysis →

Forensics Adapter: Unleashing CLIP for Generalizable Face Forgery Detection.

2024 2 citations View Analysis →

WMamba: Wavelet-based Mamba for Face Forgery Detection

2025 24 citations View Analysis →

X2-DFD: A framework for eXplainable and eXtendable Deepfake Detection

2024 39 citations View Analysis →

Deepfake Detection that Generalizes Across Benchmarks

2025 25 citations View Analysis →

Leveraging Unlabeled Data from Unknown Sources via Dual-Path Guidance for Deepfake Face Detection

Veritas: Generalizable Deepfake Detection via Pattern-Aware Reasoning

2025 21 citations View Analysis →

Hybrid Deep Learning for Robust Deepfake Video Detection with Enhanced Generalization and Fairness

2025

LAKAN: Landmark-assisted Adaptive Kolmogorov-Arnold Network for Face Forgery Detection

2025 1 citations View Analysis →

DeepFake Analysis : A Review of Recent Studies, Detection Methods and Trends in Deepfake Detection

2025

Proto-LeakNet: Towards Signal-Leak Aware Attribution in Synthetic Human Face Imagery

DGS-Net: Distillation-Guided Gradient Surgery for CLIP Fine-Tuning in AI-Generated Image Detection

2025 1 citations View Analysis →

Face Forgery Detection With CLIP-Enhanced Multi-Encoder Distillation

2025 1 citations