You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We propose a new decoding method called Permute-and-Flip (PF) decoder. It enjoys stability properties similar to the standard sampling decoder, but is provably up to 2x better in its quality-stability tradeoff than sampling and never worse than any other decoder. We also design a cryptographic watermarking scheme analogous to Aaronson (2023)'s Gumbel watermark, but naturally tailored for PF decoder. The watermarking scheme does not change the distribution to sample, while allowing arbitrarily low false positive rate and high recall whenever the generated text has high entropy. Our experiments show that the PF decoder (and its watermarked counterpart) significantly outperform(s) naive sampling (and its Gumbel watermarked counterpart) in terms of perplexity, while retaining the same stability (and detectability), hence making it a promising new approach for LLM decoding.
Algorithm
The PF decoder is a simple and efficient algorithm that can be used to decode any LLM. It is based on the idea of sampling from the distribution of the LLM, but with a twist. The algorithm is as follows:
Watermarking
We also propose a watermarking scheme for the PF decoder. The watermarking scheme is as follows:
Code
The code is written in Python and uses PyTorch. You can run the code using the following command:
If you find this work useful, please consider citing our paper:
@inproceedings{zhao2025permute,
title={Permute-and-Flip: An optimally stable and watermarkable decoder for LLMs},
author={Zhao, Xuandong and Li, Lei and Wang, Yu-Xiang},
booktitle={The Thirteenth International Conference on Learning Representations},
year={2025}
}
About
[ICLR 2025] Permute-and-Flip: An optimally robust and watermarkable decoder for LLMs