[ICLR 2026] Learn-to-Distance: Distance Learning for Detecting LLM-Generated Text
5
stars
63
commits
Python
primary language
Apr 3, 2026
updated
This repository contains the official implementation of Learn-to-Distance: Distance Learning for Detecting LLM-Generated Text (accepted at ICLR 2026).
L2D provides a geometric projection viewpoint on the effectiveness of rewrite-based detectors (Figure 1 🧠)
and strengthens this paradigm via distance learning (Figure 2 🧭). Under experimental settings, it achieves state-of-the-art performance across a wide range of LLMs and datasets (Figure 3 🏆).
Figure 1. 🧠 Projection intuition behind rewrite-based detection. (Click to expand the full explanation 👇)
Figure 2. 🧭 Workflow of the proposal: our method adaptively learns a distance metric to measure the discrepancy between human and LLM-generated texts for detection.
Figure 3. 🏆 AUC scores across datasets, models, and tasks; best method highlighted in blue, second best in orange.
./setup.sh
Recommended for off-the-shelf usage.
python scripts/detect_l2d.py --from_pretrained mamba413/L2D --eval_dataset example/demo --output_file example/demo --eval_only
Pretrained checkpoint details
google/gemma-2-9b-itmamba413/L2DIf you want better / cheaper rewriting
Qwen/Qwen3-4B, or bring your own rewrite model / dataset.Recommended when you want to:
Provide a .json file named xxx.raw_data.json with the following structure:
{
"original": ["human-text-1", "human-text-2", "..."],
"sampled": ["machine-text-1", "machine-text-2", "..."]
}
original: human-written textssampled: machine-generated texts (from one or more LLMs)python scripts/detect_l2d.py --train_dataset "./exp_prompt/data/squad_claude-3-5-haiku" --save_trained
By default, checkpoints are saved to ./scripts/AdaDist/ckpt/
python scripts/detect_l2d.py --eval_only --eval_dataset your_data --output_file your_result --from_pretrained ./scripts/AdaDist/ckpt/
The scripts/ directory contains implementations of various LLM detection methods from the literature. These implementations are modified from their official versions or from L2D to provide:
| Method | Script File | Paper/Website |
|---|---|---|
| AdaDetectGPT | detect_gpt_ada.py | arXiv:2510.01268 |
| BARTScore | detect_bartscore.py | EMNLP-main.463 |
| Binoculars | detect_binoculars.py | arXiv:2401.12070 |
| Fast-DetectGPT | detect_gpt_fast.py | arXiv:2310.05130 |
| GLTR | detect_gltr.py | arXiv:1906.04043 |
| IDE | detect_ide.py | arXiv:2306.04723 |
| ImBD | detect_ImBD.py | arXiv:2412.10432 |
| Likelihood | detect_likelihood.py | arXiv:2306.05540 |
| LRR | detect_lrr.py | arXiv:2306.05540 |
| RADAR | detect_radar.py | arXiv:2307.03838 |
| RADIAR | detect_radiar.py | arXiv:2401.12970 |
| RoBERTa OpenAI Detector | detect_roberta.py | arXiv:1908.09203 |
Additional baselines can be found in a comprehensive github repo: AdaDetectGPT.
exp_diverse.sh: generate Table 1 and Tables B1–B4exp_prompt.sh: generate Table 2After running the above code, use:
python script/report_results.py
You can call either report_black_prompt_results or report_diverse_results to render the tables/figures. To speedup the reproducibility, we include the rewritten texts for Table 2 in the directory exp_prompt.
exp_attack.sh: reproduce Figure 4 (use fig4.py to produce Figure 4 in the main text)If you find this work useful, please consider citing our paper:
@inproceedings{zhou2026learn,
title={Learn-to-Distance: Distance Learning for Detecting LLM-Generated Text},
author={Hongyi Zhou and Jin Zhu and Kai Ye and Ying Yang and Erhan Xu and Chengchun Shi},
booktitle={The Fourteenth International Conference on Learning Representations},
abbr={ICLR},
year={2026},
}
If you have any questions, please feel free to open an issue.
63 commits
Python
91.6%
Shell
8.4%
[ICLR 2026] Learn-to-Distance: Distance Learning for Detecting LLM-Generated Text
5
stars
63
commits
Python
primary language
Apr 3, 2026
updated
This repository contains the official implementation of Learn-to-Distance: Distance Learning for Detecting LLM-Generated Text (accepted at ICLR 2026).
L2D provides a geometric projection viewpoint on the effectiveness of rewrite-based detectors (Figure 1 🧠)
and strengthens this paradigm via distance learning (Figure 2 🧭). Under experimental settings, it achieves state-of-the-art performance across a wide range of LLMs and datasets (Figure 3 🏆).
Figure 1. 🧠 Projection intuition behind rewrite-based detection. (Click to expand the full explanation 👇)
Figure 2. 🧭 Workflow of the proposal: our method adaptively learns a distance metric to measure the discrepancy between human and LLM-generated texts for detection.
Figure 3. 🏆 AUC scores across datasets, models, and tasks; best method highlighted in blue, second best in orange.
./setup.sh
Recommended for off-the-shelf usage.
python scripts/detect_l2d.py --from_pretrained mamba413/L2D --eval_dataset example/demo --output_file example/demo --eval_only
Pretrained checkpoint details
google/gemma-2-9b-itmamba413/L2DIf you want better / cheaper rewriting
Qwen/Qwen3-4B, or bring your own rewrite model / dataset.Recommended when you want to:
Provide a .json file named xxx.raw_data.json with the following structure:
{
"original": ["human-text-1", "human-text-2", "..."],
"sampled": ["machine-text-1", "machine-text-2", "..."]
}
original: human-written textssampled: machine-generated texts (from one or more LLMs)python scripts/detect_l2d.py --train_dataset "./exp_prompt/data/squad_claude-3-5-haiku" --save_trained
By default, checkpoints are saved to ./scripts/AdaDist/ckpt/
python scripts/detect_l2d.py --eval_only --eval_dataset your_data --output_file your_result --from_pretrained ./scripts/AdaDist/ckpt/
The scripts/ directory contains implementations of various LLM detection methods from the literature. These implementations are modified from their official versions or from L2D to provide:
| Method | Script File | Paper/Website |
|---|---|---|
| AdaDetectGPT | detect_gpt_ada.py | arXiv:2510.01268 |
| BARTScore | detect_bartscore.py | EMNLP-main.463 |
| Binoculars | detect_binoculars.py | arXiv:2401.12070 |
| Fast-DetectGPT | detect_gpt_fast.py | arXiv:2310.05130 |
| GLTR | detect_gltr.py | arXiv:1906.04043 |
| IDE | detect_ide.py | arXiv:2306.04723 |
| ImBD | detect_ImBD.py | arXiv:2412.10432 |
| Likelihood | detect_likelihood.py | arXiv:2306.05540 |
| LRR | detect_lrr.py | arXiv:2306.05540 |
| RADAR | detect_radar.py | arXiv:2307.03838 |
| RADIAR | detect_radiar.py | arXiv:2401.12970 |
| RoBERTa OpenAI Detector | detect_roberta.py | arXiv:1908.09203 |
Additional baselines can be found in a comprehensive github repo: AdaDetectGPT.
exp_diverse.sh: generate Table 1 and Tables B1–B4exp_prompt.sh: generate Table 2After running the above code, use:
python script/report_results.py
You can call either report_black_prompt_results or report_diverse_results to render the tables/figures. To speedup the reproducibility, we include the rewritten texts for Table 2 in the directory exp_prompt.
exp_attack.sh: reproduce Figure 4 (use fig4.py to produce Figure 4 in the main text)If you find this work useful, please consider citing our paper:
@inproceedings{zhou2026learn,
title={Learn-to-Distance: Distance Learning for Detecting LLM-Generated Text},
author={Hongyi Zhou and Jin Zhu and Kai Ye and Ying Yang and Erhan Xu and Chengchun Shi},
booktitle={The Fourteenth International Conference on Learning Representations},
abbr={ICLR},
year={2026},
}
If you have any questions, please feel free to open an issue.
63 commits
Python
91.6%
Shell
8.4%