Efficient Detection of LLM -generated Texts with a B ayesian Surrogate Model (2024)

Abstract: The detection of machine-generated text, especially from large language models (LLMs), is crucial in preventing serious social problems resulting from their misuse. Some methods train dedicated detectors on specific datasets but fall short in generalizing to unseen test data, while other zero-shot ones often yield suboptimal performance. Although the recent DetectGPT has shown promising detection performance, it suffers from significant inefficiency issues, as detecting a single candidate requires querying the source LLM with hundreds of its perturbations. This paper aims to bridge this gap. Concretely, we propose to incorporate a Bayesian surrogate model, which allows us to select typical samples based on Bayesian uncertainty and interpolate scores from typical samples to other samples, to improve query efficiency. Empirical results demonstrate that our method significantly outperforms existing approaches under a low query budget. Notably, when detecting the text generated by LLaMA family models, our method with just 2 or 3 queries can outperform DetectGPT with 200 queries.

## introduction large language models (llms) @xcite @xcite have the impressive ability to replicate human language patterns, producing text that appears coherent, well-written, and persuasive, although the generated text may contain factual errors and unsupported quotations. as llms are increasingly used to simplify writing and presentation tasks, some individuals regrettably have misused llms for nefarious purposes, such as creating convincing fake news articles or engaging in cheating, which can have significant social consequences. mitigating these negative impacts has become a pressing issue for the community. the llm-generated texts are highly articulate, posing a significant challenge for humans in identifying them @xcite . fortunately, it is shown that machine learning tools can be leveraged to recognize the watermarks underlying the texts. some methods (e.g., openai, 2023b) involve training supervised classifiers, which, yet, suffer from overfitting to the training data and ineffectiveness to generalize to new test data. zero-shot llm-generated text detection approaches bypass these issues by leveraging the source llm to detect its samples @xcite @xcite . they usually proceed by inspecting the average per-token log probability of the candidate text, but the practical detection performance can be unsatisfactory. detectgpt @xcite is a recent method that achieves improved zero-shot detection efficacy by exploring the probability curvature of llms. it generates multiple perturbations of the candidate text and scores them using the source llm to define detection statistics. it can detect texts generated by @xcite and gpt-neox-20b @xcite . yet, detectgpt relies on hundreds of queries to the source llm to estimate the local probability curvature surrounding one single candidate passage. this level of computational expense is impractical for handling large lms like llama @xcite , @xcite , and @xcite . this paper aims to improve the query efficiency of probability curvature-based detectors. we highlight that the inefficiency issues of the current approach stem from the use of purely random perturbations for curvature estimation. intuitively, due to the constraint on locality, the perturbed samples are highly correlated, sharing most words and having similar semantics. as a result, characterizing the local probability curvature can be essentially optimized as (i) identifying a set of typical samples and evaluating the source llm on them and (ii) interpolating the results to other samples. a surrogate model that maps samples to llm probability is necessary for interpolation, and it would be beneficial if the model could also identify typical samples. given these, we opt for the gaussian process (gp) model due to its non-parametric flexibility, resistance to overfitting in low-data regimes, and ease of use in solving regression problems. more importantly, the bayesian uncertainty provided by gp can effectively indicate sample typicality, as demonstrated in active learning @xcite . technically, we perform sample selection and gp fitting sequentially. at each step, we select the sample that the current gp model is most uncertain about, score it using the source llm, and update the gp accordingly. early stops can be in-voked adaptively. after fitting, we utilize the gp, rather than the source llm, to score a set of randomly perturbed samples to compute detection statistics. this way, we create a zero-shot llm-generated text detector with significantly improved query efficiency. to showcase the effectiveness and efficiency of our method, we conduct comprehensive empirical studies on diverse datasets using gpt-2 @xcite , llama2 @xcite , and vicuna @xcite . the results show that our method outperforms detectgpt with substantial margins under the low query budget. when detecting texts generated by llama, our method with just 2 or 3 queries can significantly outperform detectgpt with 200 queries. this is one significant step toward practical use. when detecting texts generated by gpt-2, it can achieve similar performance with up to 2 times fewer queries than de-tectgpt and achieve 3.7% higher auroc at a query number of 5. we also show that our approach remains effective even when detecting texts generated by blackbox models with huge parameter sizes like chatgpt and conduct ablation studies to offer insights into the behavior of our method. ## methodology this section first reviews detectgpt @xcite and highlights its query inefficiency to justify the need for a surrogate model. we then emphasize the importance of being bayesian and provide a comprehensive discussion on the specification of the surrogate model. we also discuss the strategy for selecting typical samples with bayesian uncertainty. the method overview is in fig. 1 . ## experiments we conduct extensive experiments to evaluate the efficiency and efficacy of our method for zero-shot llmgenerated text detection. we mainly compare our method to detectgpt @xcite because (i) both works adopt the same detection measure, and (ii) detectgpt has proven to defeat prior zero-shot and supervised methods consistently. we are primarily concerned with detecting under a low query budget and admit that our method would perform similarly to de-tectgpt if queries to the source model can be numerous. we also consider a black-box variant of the task where only a proxy of the source llm is available for detection. we have also verified the effectiveness of our method in detecting large-parameter models, such as chatgpt. we further qualitatively analyze the behavioral difference between our method and detectgpt and showcase the limitations of our method. datasets. following detectgpt @xcite , we primarily experiment on three datasets, covering news articles sourced from the xsum dataset @xcite , which represents the problem of identifying fake news, paragraphs from wikipedia drawn from the squad contexts @xcite , which simulates the detection of machinegenerated academic essays and prompted stories from reddit writingprompts dataset @xcite , which indicates the recognition of llm-created creative writing submissions. these datasets are representative of a variety of common domains and use cases for llm. we let the llms expand the first 30 tokens of the real text to construct generations. refer to @xcite for more details. ## conclusion this paper tackles the issue that the existing probability curvature-based method for detecting llm-generated text relies on a vast number of queries to the source llm when detecting a candidate text passage. we introduce a bayesian surrogate model to identify typical samples and then interpolate their scores to others. we use a gaussian process regressor to instantiate the surrogate model and perform an online selection of typical samples based on bayesian uncertainty. extensive empirical studies on various datasets, using gpt-2, llama2, and vicuna, validate our method's superior effectiveness and efficiency over detectgpt. our optimization approach serves as a foundational method, which can be applied to other unsupervised detection techniques such as binoculars @xcite and gpt-who @xcite , offering a means to enhance overall detection performance. xianjun yang, wei cheng, linda petzold, william yang wang, and haifeng chen. 2023. dna-gpt: divergent n-gram analysis for training-free detection of gptgenerated text. arxiv preprint arxiv:2305.17359. susan zhang, stephen roller, naman goyal, mikel artetxe, moya chen, shuohui chen, christopher dewan, mona diab, xian @xcite . opt: open pre-trained transformer language models. arxiv preprint arxiv:2205.01068. tianyi zhang, varsha kishore, felix wu, kilian q weinberger, and yoav artzi. 2019. bertscore: evaluating text generation with bert. arxiv preprint arxiv:1904.09675.