The run.py script is the primary entrypoint for executing the machine-generated text detection experiments described in the DetectGPT paper. You can configure the base model, the mask-filling model, perturbation settings, and dataset selection using command-line arguments.
Common CLI Arguments
| Argument | Description |
|---|
--output_name | A string identifier for the output results (e.g., main, main_top_p). |
--base_model_name | The name/path of the LLM used for detection (e.g., gpt2-xl, EleutherAI/gpt-j-6B). |
--mask_filling_model_name | The name/path of the model used for mask filling (e.g., t5-3b). |
--n_perturbation_list | A comma-separated list of integers specifying the number of perturbations to use (e.g., 1,10,100). |
--n_samples | The number of text samples to process. |
--pct_words_masked | The fraction of words to mask during perturbation (e.g., 0.3). |
--span_length | The length of the spans to be masked. |
--batch_size | The number of samples to process in a single batch. |
--dataset | The name of the dataset to use (e.g., squad, writing). |
--dataset_key | The specific key within the dataset to use (e.g., context for squad). |
--do_top_p | Flag to enable top-p sampling for perturbations. |
--do_top_k | Flag to enable top-k sampling for perturbations. |
python run.py --output_name main --base_model_name gpt2-xl --mask_filling_model_name t5-3b --n_perturbation_list 1,10,100 --n_samples 500 --pct_words_masked 0.3 --span_length 2