<div align="center">
<h1>Deepfake Text Detection in the Wild</h1>
<!-- **Authors:** -->

_**Yafu Li<sup>†</sup><sup>‡</sup>, Qintong Li<sup>§</sup>, Leyang Cui<sup>¶</sup>, Wei Bi<sup>¶</sup>,<br>**_
  
_**Longyue Wang<sup>¶</sup>, Linyi Yang<sup>‡</sup>, Shuming Shi<sup>¶</sup>, Yue Zhang<sup>‡</sup><br>**_

<!-- **Affiliations:** -->

_<sup>†</sup> Zhejiang University,
<sup>‡</sup> Westlake University,
<sup>§</sup> The University of Hong Kong,
<sup>¶</sup> Tencent AI Lab_

Presenting a comprehensive benchmark dataset designed to assess the proficiency of deepfake detectors amidst real-world scenarios.
</div>

## 📌 Table of Contents
- [Introduction](#🚀-introduction)
- [Dataset](#📝-dataset)
- [Try Detection](#🖥%EF%B8%8F-try-detection)
- [Citation](#📚-citation)

## 🚀 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 comprehensive 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 
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 testbed**s with increasing wildness and detection difficulty.
- **2 wilder test sets**: (1) texts collected from new datasets and generated by GPT-4; (2) paraphrased texts.

### 📥 How to Get the Data
#### 1. Huggingface
You can access the full dataset, which includes the Cross-domains & Cross-models testbed and two additional wilder test sets, through the Huggingface API:
```python
from datasets import load_dataset
dataset = load_dataset("yaful/DeepfakeTextDetect")
```
which includes traditional splits (train.csv, valid.csv and test.csv) and two wilder test sets (test_ood_set_gpt.csv and test_ood_set_gpt_para.csv).
The csv files have three columns: text, label (0 for machine-generated and 
1 for human-written) and text source information (e.g., ''cmv_human'' denotes the text is written by humans, 
whereas ''roct_machine_continuation_flan_t5_large'' denotes the text is generated by ''flan_t5_large'' using continuation prompt).

To obtain the 6 testbeds mentioned in our paper, simply apply the provided script:
```shell
python3 deployment/prepare_testbeds.py DATA_PATH
```
Replace ''DATA_PATH'' with the output data directory where you want to save the 6 testbeds.

#### 2. Cloud Drive
Alternatively, you can access the 6 testbeds by downloading them directly through [Google Drive](https://drive.google.com/drive/folders/1p09vDiEvoA-ZPmpqkB2WApcwMQWiiMRl?usp=sharing)
or [Tencent Weiyun](https://share.weiyun.com/JUWQxF4H)：

The folder contains 4 packages:
- 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.
- source.zip: Source texts of human-written texts and corresponding texts generated by LLMs, without filtering.
- 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. 




## 🖥️ Try Detection

### Model Access
Our Longformer detector, which has been trained on the entire dataset, is now accessible through [Huggingface](https://huggingface.co/nealcly/detection-longformer). Additionally, you can try detection directly using our [online demo](https://huggingface.co/spaces/yaful/DeepfakeTextDetect).

### Deployment
We have refined the decision boundary based on out-of-distribution settings. To ensure optimal performance, we recommend preprocessing texts before sending them to the detector. 
See 🏃 [Deepfake Text Detection in the Wild](https://github.com/yafuly/DeepfakeTextDetect) for the complete detection pipeline:
```python
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)
```


## 📚 Citation

If you use this dataset in your research, please cite it as follows:
```bibtex
@misc{li2023deepfake,
      title={Deepfake Text Detection in the Wild}, 
      author={Yafu Li and Qintong Li and Leyang Cui and Wei Bi and Longyue Wang and Linyi Yang and Shuming Shi and Yue Zhang},
      year={2023},
      eprint={2305.13242},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
}
```
We welcome contributions to improve this dataset! If you have any questions or feedback, please feel free to reach out at yafuly@gmail.com.


<!-- # 🤝 Contributing -->
license:apache-2.0 arxiv:2305.13242 region:us
{"license": "apache-2.0"}
TAGS
#license-apache-2.0 #arxiv-2305.13242 #region-us 

<div align="center">
<h1>Deepfake Text Detection in the Wild</h1>


_Yafu Li<sup>†</sup><sup>‡</sup>, Qintong Li<sup>§</sup>, Leyang Cui<sup>¶</sup>, Wei Bi<sup>¶</sup>,<br>_
  
_Longyue Wang<sup>¶</sup>, Linyi Yang<sup>‡</sup>, Shuming Shi<sup>¶</sup>, Yue Zhang<sup>‡</sup><br>_



_<sup>†</sup> Zhejiang University,
<sup>‡</sup> Westlake University,
<sup>§</sup> The University of Hong Kong,
<sup>¶</sup> Tencent AI Lab_

Presenting a comprehensive benchmark dataset designed to assess the proficiency of deepfake detectors amidst real-world scenarios.
</div>

##  Table of Contents
- Introduction
- Dataset
- Try Detection
- Citation

##  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 comprehensive 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 URL We invite you to test your own detection methods on our testbed and encourage you to star our Github repo at URL


##  Dataset 
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.

###  How to Get the Data
#### 1. Huggingface
You can access the full dataset, which includes the Cross-domains & Cross-models testbed and two additional wilder test sets, through the Huggingface API:

which includes traditional splits (URL, URL and URL) and two wilder test sets (test_ood_set_gpt.csv and test_ood_set_gpt_para.csv).
The csv files have three columns: text, label (0 for machine-generated and 
1 for human-written) and text source information (e.g., ''cmv_human'' denotes the text is written by humans, 
whereas ''roct_machine_continuation_flan_t5_large'' denotes the text is generated by ''flan_t5_large'' using continuation prompt).

To obtain the 6 testbeds mentioned in our paper, simply apply the provided script:

Replace ''DATA_PATH'' with the output data directory where you want to save the 6 testbeds.

#### 2. Cloud Drive
Alternatively, you can access the 6 testbeds by downloading them directly through Google Drive
or Tencent Weiyun：

The folder contains 4 packages:
- 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.
- URL: Source texts of human-written texts and corresponding texts generated by LLMs, without filtering.
- URL: 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.URL" 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. 




## ️ 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 decision boundary based on out-of-distribution settings. To ensure optimal performance, we recommend preprocessing texts before sending them to the detector. 
See  Deepfake Text Detection in the Wild for the complete detection pipeline:



##  Citation

If you use this dataset in your research, please cite it as follows:

We welcome contributions to improve this dataset! If you have any questions or feedback, please feel free to reach out at yafuly@URL.



##  Table of Contents
- Introduction
- Dataset
- Try Detection
- Citation ##  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 comprehensive 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 URL We invite you to test your own detection methods on our testbed and encourage you to star our Github repo at URL ##  Dataset 
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. ###  How to Get the Data #### 1. Huggingface
You can access the full dataset, which includes the Cross-domains & Cross-models testbed and two additional wilder test sets, through the Huggingface API:

which includes traditional splits (URL, URL and URL) and two wilder test sets (test_ood_set_gpt.csv and test_ood_set_gpt_para.csv).
The csv files have three columns: text, label (0 for machine-generated and 
1 for human-written) and text source information (e.g., ''cmv_human'' denotes the text is written by humans, 
whereas ''roct_machine_continuation_flan_t5_large'' denotes the text is generated by ''flan_t5_large'' using continuation prompt).

To obtain the 6 testbeds mentioned in our paper, simply apply the provided script:

Replace ''DATA_PATH'' with the output data directory where you want to save the 6 testbeds. #### 2. Cloud Drive
Alternatively, you can access the 6 testbeds by downloading them directly through Google Drive
or Tencent Weiyun：

The folder contains 4 packages:
- 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.
- URL: Source texts of human-written texts and corresponding texts generated by LLMs, without filtering.
- URL: 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.URL" 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. ## ️ 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 decision boundary based on out-of-distribution settings. To ensure optimal performance, we recommend preprocessing texts before sending them to the detector. 
See  Deepfake Text Detection in the Wild for the complete detection pipeline: ##  Citation

If you use this dataset in your research, please cite it as follows:

We welcome contributions to improve this dataset! If you have any questions or feedback, please feel free to reach out at yafuly@URL.
TAGS
#license-apache-2.0 #arxiv-2305.13242 #region-us 
 ##  Table of Contents
- Introduction
- Dataset
- Try Detection
- Citation ##  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 comprehensive 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 URL We invite you to test your own detection methods on our testbed and encourage you to star our Github repo at URL ##  Dataset 
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. ###  How to Get the Data #### 1. Huggingface
You can access the full dataset, which includes the Cross-domains & Cross-models testbed and two additional wilder test sets, through the Huggingface API:

which includes traditional splits (URL, URL and URL) and two wilder test sets (test_ood_set_gpt.csv and test_ood_set_gpt_para.csv).
The csv files have three columns: text, label (0 for machine-generated and 
1 for human-written) and text source information (e.g., ''cmv_human'' denotes the text is written by humans, 
whereas ''roct_machine_continuation_flan_t5_large'' denotes the text is generated by ''flan_t5_large'' using continuation prompt).

To obtain the 6 testbeds mentioned in our paper, simply apply the provided script:

Replace ''DATA_PATH'' with the output data directory where you want to save the 6 testbeds. #### 2. Cloud Drive
Alternatively, you can access the 6 testbeds by downloading them directly through Google Drive
or Tencent Weiyun：

The folder contains 4 packages:
- 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.
- URL: Source texts of human-written texts and corresponding texts generated by LLMs, without filtering.
- URL: 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.URL" 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. ## ️ 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 decision boundary based on out-of-distribution settings. To ensure optimal performance, we recommend preprocessing texts before sending them to the detector. 
See  Deepfake Text Detection in the Wild for the complete detection pipeline: ##  Citation

If you use this dataset in your research, please cite it as follows:

We welcome contributions to improve this dataset! If you have any questions or feedback, please feel free to reach out at yafuly@URL.
passage: TAGS
#license-apache-2.0 #arxiv-2305.13242 #region-us 
##  Table of Contents
- Introduction
- Dataset
- Try Detection
- Citation##  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 comprehensive 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 URL We invite you to test your own detection methods on our testbed and encourage you to star our Github repo at URL##  Dataset 
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.###  How to Get the Data