Spaces:
Runtime error
title: DeepfakeTextDetect
emoji: 💻
colorFrom: yellow
colorTo: blue
sdk: gradio
sdk_version: 3.35.2
app_file: app.py
pinned: false
license: mit
Deepfake Text Detection in the Wild
Yafu Li†‡, Qintong Li§, Leyang Cui¶, Wei Bi¶,
Longyue Wang¶, Linyi Yang‡, Shuming Shi¶, Yue Zhang‡
† Zhejiang University, ‡ Westlake University, § The University of Hong Kong, ¶ Tencent AI Lab
Presenting a comprehensive benchmark dataset designed to assess the proficiency of deepfake detectors amidst real-world scenarios.
🚀 Introduction
Recent advances in large language models have enabled them to reach a level of text generation comparable to that of humans. These models show powerful capabilities across a wide range of content, including news article writing, story generation, and scientific writing. Such capability further narrows the gap between human-authored and machine-generated texts, highlighting the importance of deepfake text detection to avoid potential risks such as fake news propagation and plagiarism. In practical scenarios, the detector faces texts from various domains or LLMs without knowing their sources.
To this end, we build a wild testbed for deepfake text detection, by gathering texts from various human writings and deepfake texts generated by different LLMs. The data in this repository is used to evaluate the effectiveness of deepfake detection methods, as described in our paper titled "Deepfake Text Detection in the Wild" (available at https://arxiv.org/abs/2305.13242). We invite you to test your own detection methods on our testbed and encourage you to star our Github repo at https://github.com/yafuly/DeepfakeTextDetect.
📝 Dataset Description
The dataset consists of 447,674 human-written and machine-generated texts from a wide range of sources in the wild:
- Human-written texts from 10 datasets covering a wide range of writing tasks, e.g., news article writing, story generation, scientific writing, etc.
- Machine-generated texts generated by 27 mainstream LLMs from 7 sources, e.g., OpenAI, LLaMA, and EleutherAI, etc.
- 6 systematic testbeds with increasing wildness and detection difficulty.
- 2 wilder test sets: (1) texts collected from new datasets and generated by GPT-4; (2) paraphrased texts.
🖥️ Try Detection
Model Access
Our Longformer detector, which has been trained on the entire dataset, is now accessible through Huggingface. Additionally, you can try detection directly using our online demo.
Deployment
We have refined the threshold based on out-of-distribution settings. To ensure optimal performance, we recommend preprocessing texts before sending them to the detector.
import torch
import os
from transformers import AutoModelForSequenceClassification,AutoTokenizer
from deployment import preprocess, detect
# init
device = 'cpu' # use 'cuda:0' if GPU is available
model_dir = "nealcly/detection-longformer"
tokenizer = AutoTokenizer.from_pretrained(model_dir)
model = AutoModelForSequenceClassification.from_pretrained(model_dir).to(device)
# preprocess
text = preprocess(text)
# detection
result = detect(text,tokenizer,model,device)
Detection Performance
In-distribution Detection
Testbed | HumanRec | MachineRec | AvgRec | AUROC |
---|---|---|---|---|
Domain-specific & Model-specific | 97.30% | 95.91% | 96.60% | 0.99 |
Cross-domains & Model–specific | 95.25% | 96.94% | 96.10% | 0.99 |
Domain-specific & Cross-models | 89.78% | 97.24% | 93.51% | 0.99 |
Cross-domains & Cross-models | 82.80% | 98.27% | 90.53% | 0.99 |
Out-of-distribution Detection
Testbed | HumanRec | MachineRec | AvgRec | AUROC |
---|---|---|---|---|
Unseen Model Sets | 86.09% | 89.15% | 87.62% | 0.95 |
Unseen Domains | 82.88% | 80.50% | 81.78% | 0.93 |
Wilder Testsets
Testbed | HumanRec | MachineRec | AvgRec | AUROC |
---|---|---|---|---|
Unseen Domains & Unseen Model | 88.78% | 84.12% | 86.54% | 0.94 |
Paraphrase | 88.78% | 37.05% | 62.92% | 0.75 |
📥 How to Get the Data
Download
The dataset is available for download at:
The folder contains 4 packages:
- source.zip: Source texts of human-written texts and corresponding texts generated by LLMs.
- processed.zip: This is a refined version of the "source" that filters out low-quality texts and specifies sources as CSV file names. For example, the "cmv_machine_specified_gpt-3.5-trubo.csv" file contains texts from the CMV domain generated by the "gpt-3.5-trubo" model using specific prompts, while "cmv_human" includes human-written CMV texts. We suggest trying this version to test your detection methods.
- testbeds_processed.zip: 6 testbeds based on the ''processed'' version, which can be directly used for detecting in-distribution and out-of-distribution detection performance.
- wilder_testsets.zip: 2 wilder test sets with texts processed, aiming for (1) detecting deepfake text generated by GPT-4, and (2) detecting deepfake text in paraphrased versions.