Beat LLM s at Their Own Game: Zero-Shot LLM -Generated Text Detection via Querying C hat GPT (2023)

Abstract: Large language models (LLMs), e.g., ChatGPT, have revolutionized the domain of natural language processing because of their excellent performance on various tasks. Despite their great potential, LLMs also incur serious concerns as they are likely to be misused. There are already reported cases of academic cheating by using LLMs. Thus, it is a pressing problem to identify LLM-generated texts. In this work, we design a zero-shot black-box method for detecting LLM-generated texts. The key idea is to revise the text to be detected using the ChatGPT model. Our method is based on the intuition that the ChatGPT model will make fewer revisions to LLM-generated texts than it does to human-written texts, because the texts generated by LLMs are more in accord with the generation logic and statistical patterns learned by LLMs like ChatGPT. Thus, if the text to be detected and its ChatGPT-revised version have a higher degree of similarity, the text is more likely to be LLM-generated. Extensive experiments on various datasets and tasks show that our method can effectively detect LLM-generated texts. Moreover, compared with other detection methods, our method has better generalization ability and is more stable across various datasets. The codes are publicly available at https://github.com/thunlp/LLM-generated-text-detection.

## introduction benefiting from the emergent ability, large language models (llms) have demonstrated excellent performance on a large number of natural language processing tasks @xcite . recently, llms (e.g., chatgpt) trained to follow instructions @xcite can generate high-quality responses when given specific instructions and input data by a user. the strong emergent abilities, however, also trigger social concerns for the misuse of llms. the academic cheating by using llms to write essays and homework has been repeatedly reported. the fabricated news generated by llms also causes a significant problem to our society. thus, it is an important problem to detect whether a piece of text is generated by the llm. following previous works @xcite , we formulate the problem of detecting llmgenerated texts as a binary classification task, i.e., classifying whether a piece of text is generated by the llm or written by human. previous methods for detecting llm-generated texts can be classified into two categories. the first category is the zero-shot detection method @xcite @xcite , which needs to access the model's output logits or losses for detection. however, many llm services provided by commercial companies do not expose the model's output logits or losses at the inference time. thus, these methods have to rely on local proxy models to access the output information. however, the inconsistency between the online model and the local proxy model may lead to poor detection performance. the second category is the supervised fine-tuning method @xcite , which trains a deep neural network (dnn)-based classifier with the labeled training data. it is prone to overfitting the training data and thus may have poor generalization ability. to address the abovementioned problems, we propose a zero-shot black-box detection method leveraging the chatgpt model. our method is based on the following finding. if we use the chat-gpt model to revise texts, it will make fewer revisions to llm-generated texts than it does to humanwritten texts. the underlying reason may be that the llm-generated texts conform to the generation logic and statistical patterns learned by the chatgpt model. the overall framework of our firstly, the text to be detected x i is revised by chat-gpt. then our method calculates the similarity score s i between the text x i and its corresponding revised text xi . if the similarity score s i is no smaller than the threshold ε, the text x i is likely to be generated by llm. we perform experiments on six datasets including question answering and summarization generation tasks. the experimental results prove that our method can effectively detect llm-generated texts. besides, we compare our method with other zeroshot detection methods and the supervised finetuning method. the experimental results show that our detection method is more universal across various datasets and has better generalization ability. moreover, our method is robust to dataset biases. llm-generated text detection. previous llm-generated text detection methods can generally be classified into two categories. the first category is the zero-shot detection method @xcite @xcite . however, these methods rely on the model's output logits or losses. if there is no access to the output logits or losses of the source model that generates the text to be detected, these methods can use a proxy model to get the proxy model's output logits or losses for detection. however, the difference between the source model and the proxy model may cause poor detection performance. thus, it is essential to design a detection method without accessing the model's output logits or losses. the second category is to train a dnnbased classifier using some labeled human-written and llm-generated samples @xcite . however, it is hard to collect sufficient labeled training samples to train a generalizable dnn-based classifier @xcite . moreover, training dnn-based classifiers are vulnerable to backdoor attacks @xcite and the dnn-based detector is lack of interpretability. thus, it is important to build an explainable detector without training dnn-based classifiers. jawahar et al. (2020) survey some automatic detection methods and identify some future directions for building useful detectors. he et al. (2023) develop a benchmark for evaluating existing detection methods and call for more robust detection methods. in this paper, we aim to design a robust and explainable black-box detection method without training dnn-based classifiers. ## method in this section, we illustrate our method step by step. we take the bartscore as an example. given a sequence-to-sequence pre-trained model like bart model @xcite which is parameterized by θ, the bartscore is calculated using the log probability of the target text x i given the revised text xi as the source text. the target text is tokenized into a sequence of tokens: the bartscore can measure the semantic coverage between the source text and the target text @xcite . for the calculation of bartscore in this paper, we use the bartscore-cnn, which uses a bart model that is fine-tuned on the cnndm dataset @xcite . for more details of other evaluated similarity metrics, please refer to appendix b. the llm-generated text and its revised text are more similar compared with the human-written text and its revised text. thus, a higher similarity score s i indicates that the text x i is more likely to be llm-generated. ## experiments in this section, we evaluate the detection performance of our method and compare our method with other detection methods. ## conclusion in this paper, we design a simple and effective baseline method for detecting llm-generated texts. our proposed method is based on the intuition that the chatgpt model revises less for llm-generated texts than it does for human-written texts. compared with previous methods, our method neither needs to train a dnn-based classifier nor requires access to the source model's output logits or losses. thus, our method has better generalization ability and is more practical. we perform experiments on six datasets of question answering and summarization generation tasks. the experimental results on various datasets show that our method can effectively detect llm-generated texts. moreover, our method is robust to dataset biases.