Permute-and-Flip: An optimally stable and watermarkable decoder for LLMs

## Abstract

Abstract In this paper, we propose a new decoding method called Permute-and-Flip (PF) decoder. It enjoys robustness properties similar to the standard sampling decoder, but is provably up to 2x better in its quality-robustness 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 it’s Gumbel watermarked counterpart) in terms of perplexity, while retaining the same robustness (and detectability), hence making it a promising new approach for LLM decoding. The code is available at https://github.com/XuandongZhao/pf-decoding .

## 1 Introduction

Large language models (LLMs) (OpenAI, , ; Bai et al., ; Touvron et al., ) have become increasingly popular in recent years due to their ability to generate human-like text and solve many tasks through a natural chatbot interface.

A language model predicts the next word in a sentence using a real-value function ${u}(\cdot;\text{prompt},\text{prefix}):\mathcal{V}\rightarrow\mathbb{R}$, known as *logits*, which encodes the model’s preferences on which word to choose. Here $\mathcal{V}$ is the vocabulary space (typically a large discrete set of words); the “prompt” describes the task of interest; and “prefix” includes all preceding words that have been generated so far.

A language model *decoder* refers to a possibly randomized function that takes a prompt text $x$, API access to the *logits* function as input, and outputs a sentence $y_{1:n}$.

The main thrust of this paper is to introduce a new decoder, termed *Permute-and-Flip decoding*, work out some of its intriguing properties with an application to watermarking LLM text, and hopefully convince readers that it deserves a shot at your next LLM application.

## 2 Problem Setup and Summary of Results

Before we get into it, let us set up the stage with a quick tour to the zoo of existing decoding methods and have a brief sneak-peek into the “jar of worms” on how a language model decoder can be evaluated.

Popular existing decoding methods fall into three categories: (1) Planning-based methods such as beam search that aims at maximizing the sequence likelihood; (2) sampling-based methods that recursively sample from the next-word distribution, e.g., the soft(arg)max transform of the logits

$$ Softmax sampling: $y_{t}\sim p(y)=\frac{e^{{u}(y|x,y_{1:t-1})/T}}{\sum_{\tilde{y}}e^{{u}(\tilde{y}|x,y_{1:t-1})/T}}$ (1) $$

where $T$ is the *temperature* parameter; and (3) greedy methods such as greedy decoding that simply outputs $y_{t}=\operatorname*{arg\,max}_{y\in\mathcal{V}}{u}(y|x,y_{1:t-1})$ as well as its Top $p$ (Holtzman et al., ) and Top $k$ sampling variants that interpolate greedy and sampling methods.

#### Performance metrics.

How do we compare different decoding methods? More generally, how do we evaluate LLM-generated text? These are questions far from being settled. Naturally, if there is a (possibly task-dependent) performance metric $U_{x}:\mathcal{V}^{n}\rightarrow\mathbb{R}$ one can define, then the optimal decoder would be the one that outputs

$$ $y_{1:n}^{*}=\operatorname*{arg\,max}_{y_{1:n}\in\mathcal{V}^{n}}U_{x}(y_{1:n}).$ $$

Often $U_{x}$ is instantiated to be the sequence likelihood $\sum_{t=1}^{n}\log p(y_{t}|x,y_{1:t-1})$ which is equal to $\sum_{t=1}^{n}{u}_{t}(y_{t})$.

Recent works (Ippolito et al., ; Wiher et al., ), however, report that strategies that aim at maximizing sequence likelihood often result in texts that are more repetitive and less effective in some downstream tasks than those from the sampling-based methods (Holtzman et al., ). Depending on what the task is, there is not a one-size-fits-all performance metric, therefore is no single decoding method that works well for all tasks.

For the moment, let us stash the disputes on how to best evaluate an LLM-generated text and focus on designing methods that maximize any user-specified utility function. In fact, we will also give up on solving the sequence-level utility maximization problem(^1^11It is known to be NP-Complete (Chen et al., ).) and simply maximize a *per-step* utility function ${u}_{t}:\mathcal{V}\rightarrow\mathbb{R}$.

${u}_{t}$ can simply be the logits function that LLMs output, which may have already accounted for potential future utility (like the $Q$ function in reinforcement learning) since the transformer-based language model had access to future texts during pre-training. Or ${u}_{t}$ can be explicitly augmented with structure-inducing regularizers such as a lookahead heuristic as in A* decoding (Lu et al., ), a retrieval-based term for fact-checking (Lewis et al., ), or an entropy bonus for promoting diversity (Meister et al., ).

Our goal is thus to construct a possibly randomized algorithm $\mathcal{A}$ that takes ${u}_{t}$ as an input and outputs $y_{t}\in\mathcal{V}$ that aims at maximizing $\mathop{\mathbb{E}}_{y_{t}\sim\mathcal{A}_{u_{t}}}[{u}_{t}(y_{t})]$ as much as possible. In the remainder of the paper, we will simply take ${u}_{t}$ as “logits” for a concrete exposition — all results are valid when ${u}_{t}$ is instantiated otherwise.

Other constraints / consideration. Why doesn’t the trivial greedy decoder work? That’s because there are other considerations besides text quality when selecting LLM decoders.
For example, computational efficiency and latency are hugely important, since each API call to the *logits* function is costly. The diversity of the generated text is also important, especially for creative tasks.

Moreover, the decoding procedure should be watermarkable (Aaronson, ; Kirchenbauer et al., ; Zhao et al., ; Kuditipudi et al., ) in the sense that one should be able to inject subtle statistical signals that can be retrieved when given a secret key, to *prove* that the text is generated by this particular language model. Being watermarkable prevents the LLM from being used for malicious purposes such as scams (Weidinger et al., ), fake news (Zellers et al., ), and plagiarism (Stokel-Walker, ).

In addition to the above, one may also hope the decoding algorithm to be robust against small perturbations to the *logits*. Specifically,

###### Definition 2.1 (Robustness) .

We say a decoding algorithm $\mathcal{A}$ is $L$-robust if for any prompt $x$, prefix $y_{<=t}$, and for any perturbed $\tilde{{u}}$ such that $\|\tilde{{u}}-{u}\|_{\infty}\leq\delta$, the log-probability ratio satisfies

$$ $\left|\log\left\{\frac{p_{\mathcal{A}(\tilde{{u}}(\cdot|x,y_{<=t}))}(y)}{p_{\mathcal{A}({u}(\cdot|x,y_{<=t}))}(y)}\right\}\right|\leq L\delta\;\;\forall y\in\mathcal{V}.$ $$

The robustness helps to avoid catastrophic failure in the scenarios where the logits may be subject to data poisoning (Zhang et al., ; Lin et al., ) or jailbreaking attacks (Zhang et al., ; Zhao et al., ).

*Robustness* implies an intuitive notion of *diversity*, which says that for tokens with similar logits, then their chances of getting chosen should be similar. More rigorously:

###### Remark 2.2 (Robustness implies Diversity) .

If $|{u}_{t}(y)-{u}_{t}(y^{\prime})|\leq\delta$, then we can construct a $\tilde{u}_{t}$ such that $\tilde{u}_{t}(y)=\tilde{u}_{t}(y^{\prime})$ while satisfying $\|{u}_{t}-\tilde{u}_{t}\|_{\infty}\leq\frac{\delta}{2}$. Apply triangle inequality and Definition [2.1](#S2.Thmtheorem1), we get

$$ $\left|\log\frac{p_{\mathcal{A}_{{u}_{t}}(y)}}{p_{\mathcal{A}_{{u}_{t}}(y^{\prime})}}\right|=\left|\log\frac{p_{\mathcal{A}_{{u}_{t}}(y)}}{p_{\mathcal{A}_{\tilde{u}_{t}}(y)}}+\log\frac{p_{\mathcal{A}_{\tilde{u}_{t}}(y^{\prime})}}{p_{\mathcal{A}_{{u}_{t}}(y^{\prime})}}\right|\leq L\delta.$ $$

**Table 1: Comparison of different decoding methods against five desiderata.**
| Methods | Perplexity | Computational Efficiency | Diversity | Watermark | Robustness |
| --- | --- | --- | --- | --- | --- |
| Search (e.g., Beam) | Lowest | ✗ | ✗ | ✗ | ✗ |
| Greedy | Low | ✓ | ✗ | ✗ | ✗ |
| Softmax Sampling | Moderate | ✓ | ✓ | ✓ | ✓ |
| Top-$p$ Sampling | Low (for small $p$) | ✓ | Depends on $p$ | ✓ | ✗ |
| Top-$k$ Sampling | Low (for small $k$) | ✓ | Depends on $k$ | ✓ | ✗ |
| PF Sampling (ours) | Lower than Softmax | ✓ | ✓ | ✓ | ✓ |

Inspecting the decoding methods along the aforementioned dimensions, we notice that planning-based methods fail to be computationally efficient.
While greedy decoding is efficient and has relatively low perplexity, its generated texts are neither diverse nor watermarkable (at least not using existing techniques). The sampling-based methods, however, are both watermarkable and diverse.
In addition, softmax sampling is known to be $2$-robust, while all other methods that we discussed so far are not robust.

###### Fact 2.3 .

Softmax sampling decoding using ([1](#S2.E1)) with temperature $T$ satisfies $L$-robustness with $L=2/T$.

###### Proof.

The result is implied by the differential privacy guarantee of exponential mechanism (McSherry & Talwar, , Theorem 6).
∎

The pros and cons of different decoding methods are summarized in Table [1](#S2.T1).
From the table, we can see that there is a clear tradeoff between minimizing perplexity and preserving other properties. In particular, softmax sampling is the only method that checks all boxes, and the only one that is robust among existing decoders. This observation begs the following research question:

*Is there a decoding method that is as robust as softmax sampling, but has lower perplexity?*

In this paper, we answer this question affirmatively by bringing in a technique called Permute-and-Flip sampling.

Our contributions are fourfold.

- 1.
We introduce Permute-and-Flip decoding — a new decoding algorithm for language models based on recent development in a very different context (McKenna & Sheldon, ).
- 2.
We demonstrate that existing results from McKenna & Sheldon () already imply that:
•
Permute-and-Flip decoding is provably robust.
•
The robustness-perplexity tradeoff of the PF decoding is Pareto-optimal. In particular, when compared to softmax sampling, PF decoding has up to 2x smaller expected suboptimality while having the same robustness parameter $L$.
- 3.
We designed an analog of Aaronson ()’s Gumbel-Watermark for PF decoder, called the PF watermark. We show that the watermarked PF decoder samples from a distribution that is computationally indistinguishable from the non-watermarked PF decoder, and the detection procedure has precisely controlled false positive rate (FPR) and high power in identifying watermarked texts.
- 4.
We empirically demonstrate that on open-generation tasks, PF watermark achieves the best balance of the highest detection accuracy and lowest perplexity compared to the baselines.

Overall, our proposed permute-and-flip decoding method provides a promising approach to balancing the tradeoff between perplexity and robustness in LLM decoding while also admitting watermarking capabilities.

###### Definition 2.1 (Robustness) .

###### Remark 2.2 (Robustness implies Diversity) .

###### Fact 2.3 .

###### Proof.

#### Related work and novelty.

PF sampling was invented in the differential privacy (DP) literature (McKenna & Sheldon, ). Its robustness properties are well-understood. The robustness of Softmax sampling is also well-known (McSherry & Talwar, ). Our contribution is in applying this method to LLM decoding and connecting these known theoretical results to the broader ML audience. To our knowledge, the PF watermark is new to this paper. The design of the watermark leverages the Report-Noisy-Max interpretation of the PF sampling (Ding et al., ) which allows a similar pseudo-random function like the work of Aaronson () to be applied.

A more thorough discussion of the related work is given in Appendix [A](#A1).

## 3 Permute-and-Flip Decoding its Properties

The Permute-and-Flip decoding iteratively generates the next token by a simple procedure that uses only the logits.
It involves first randomly permuting the vocabulary, then flipping a sequence of biased coins according to the permuted sequence until the first “head” is seen (see Algorithm [1](#alg1)).

Figure: Algorithm 1 Permute and Flip (PF) Decoding

Permute-and-flip makes words with higher logits exponentially more likely — even more so than Softmax sampling ([1](#S2.E1)). To see this, one may consider a rejection sampling algorithm for obtaining a sample from ([1](#S2.E1)), which repeats the following procedures until it halts.

- 1.
Uniformly samples $y\in\mathcal{V}$,
- 2.
Return it with probability
$p(y)/p(y^{*})=\exp\left(({u}_{t}(y)-{u}_{t}(y*))/T\right).$

The only difference from the PF sampling is that this procedure samples $y$ *with replacement* in every iteration, while the PF sampling samples $y$ *without replacement*. Intuitively, PF sampling has a higher chance of outputting $y^{*}$.

PF sampling was initially proposed in McKenna & Sheldon () as a differentially private selection mechanism that has better utility than the more well-known exponential mechanism (McSherry & Talwar, ). McKenna & Sheldon () also derived a plethora of theoretical properties of the PF sampling. The following theorem summarizes these results in the language of LLM decoding.

###### Theorem 3.1 .

Let the logits function be ${u}$ and ${u}^{*}=\max_{y\in\mathcal{V}}{u}(y)$. Let $\mathrm{PF}({u})$ be the distribution of PF-sampling, and $\mathrm{Softmax}({u})$ be the distribution in ([1](#S2.E1)), both with temperature parameter $T$. The following statements are true.

- 1.
(Same robustness) PF-Sampling is $(2/T)$-robust.
- 2.
(Nearly greedy) PF-sampling obeys
$\mathop{\mathbb{E}}_{y\sim\mathrm{PF}({u})}[{u}(y)]\geq{u}^{*}-T\log|\mathcal{V}|.$
- 3.
(“Never worse”) For the same $T$, PF-sampling is never worse than Softmax-sampling.
$\displaystyle\mathop{\mathbb{E}}_{y\sim\mathrm{PF}({u})}[{u}(y)]\geq\mathop{\mathbb{E}}_{y\sim\mathrm{Softmax}({u})}[{u}(y)]$
- 4.
(“Up to 2x better”) There exists logits ${u}$ such that PF-sampling is 2x smaller in terms of suboptimality
$\mathop{\mathbb{E}}_{y\sim\mathrm{PF}({u})}[{u}^{*}-{u}(y)]\leq\frac{1}{2}\mathop{\mathbb{E}}_{y\sim\mathrm{Softmax}({u})}[{u}^{*}-{u}(y)].$
- 5.
(Optimal robustness-perplexity tradeoff) For any decoder $P$ that is $2/T$-robust, if there exists ${u}$ such that
$\mathop{\mathbb{E}}_{y\sim P({u})}[{u}(y)]>\mathop{\mathbb{E}}_{y\sim\mathrm{PF}({u})}[{u}(y)]$
then there must be another $\tilde{{u}}$ such that
$\mathop{\mathbb{E}}_{y\sim P(\tilde{{u}})}[\tilde{{u}}(y)]<\mathop{\mathbb{E}}_{y\sim\mathrm{PF}(\tilde{{u}})}[\tilde{{u}}(y)].$

###### Proof.

The theorem is entirely due to McKenna & Sheldon (). The five statements are directly implied by Theorem 1, Corollary 1, Theorem 2, Proposition 4, and Proposition 6 respectively in their paper.
∎

The first statement shows that the PF decoder enjoys exactly the same robustness parameter as in Fact [2.3](#S2.Thmtheorem3). The second statement provides a worst-case bound on how far PF-sampling is away from greedy-decoding as a function of the temperature $T$ in terms of the likelihood achieved. The third and fourth statements show that PF-sampling is always “more greedy” than softmax-sampling. The last statement shows that PF-sampling is not dominated by any other decoder that is equally robust (as in Definition [2.1](#S2.Thmtheorem1)), thus *Pareto optimal*.

These results provide strong justification on the superiority of the permute-and-flip decoder over the standard softmax sampling in minimizing perplexity.

Let’s consider a simple example to compare PF decoder and Softmax decoder.

###### Example 3.2 .

Let the $|\mathcal{V}|=2$ and the corresponding logits be $[\Delta,0]$ for gap $\Delta>0$. Softmax decoder chooses the suboptimal token with probability $1/(1+e^{\Delta/T})$, while PF decoder chooses it with probability $\frac{1}{2}e^{-\Delta/T}$.

Since $1/(1+x)>1/(2x)$ for all $x>1$, the probability that the suboptimal token is chosen in PF sampling is strict smaller than that of Softmax sampling (also see Figure [1](#S3.F1)).

Figure: Figure 1: Comparing PF decoder vs Softmax decoder using Example [3.2](#S3.Thmtheorem2). On the left, we fix the Gap $\Delta=3.0$ and vary the temperature $T$. On the right, we fix $T=1.0$ and consider vary $\Delta$. PF beats Softmax in all cases.
Refer to caption: /html/2402.05864/assets/x1.png

###### Theorem 3.1 .

###### Proof.

###### Example 3.2 .

## 4 Report-Noisy-Max and Watermarking

Next we turn to the well-motivated problem of watermarking LLM generated text. The watermarking problem aims at embedding a secret message in the generated text that (essentially) reads “Beware! I am written by an AI!”.

The hope is that this message can be seen by anyone who has access to a *secret key*, while ensuring that the watermarked version of the LLM generates text that has *almost the same* distribution as (or at least very similar) to the original LLM.

More formally, a watermarking scheme includes a “${\sf Watermark}$” function that injects the watermark and a “${\sf Detect}$” function that takes a suspect text sequence $y_{1:n}$ as input and outputs a prediction of $1$ (“It is watermarked!”) or 0 0 (“It is not!”).

A wrong accusation of non-watermarked text as watermarked is called a *false positive*. A failure to detect a watermarked text is called a *false negative*.
The performance of a watermark is measured by its detection *power* (i.e., $1-$*false negative rate*) at a given *false positive rate*.

There are many other necessary properties for a watermarking scheme to be useful, such as *low-overhead*, *model-agnostic* detection, and *resilience to edits* and other evasion attacks. We refer readers to the slide deck of Aaronson () and the related work section of (Zhao et al., ) for a review of these desiderata and known results.

Among the recent attempts, two popular watermarking schemes perform satisfactorily on all the above criteria.

that uses a “traceable” pseudo-random softmax sampling when generating the next word.

that randomly splits the vocabulary into Green and Red then slightly increases the logits for green tokens.

Both of them determine their pseudo-random seeds chosen according to the $m$ preceding tokens of the current token being generated. We will focus on explaining the Gumbel watermark as it is more closely related to our approach.

Aaronson ()’s Gumbel watermark.
The key idea of the Gumbel watermark leverages the “Gumbel-Max Trick”, which states that:

###### Fact 4.1 ( Gumbel, 1948 ) .

The softmax sampling in ([1](#S2.E1)) is equivalent to the following procedure

$$ $y_{t}=\operatorname*{arg\,max}_{y\in\mathcal{V}}\frac{{u}_{t}(y)}{T}+G_{t}(y)$ (2) $$

where $G_{t}(y)\sim\textrm{Gumbel}(0,1)$ i.i.d for each $t,y$.

Gumbel noise can be generated using a uniform r.v..

$$ $\textrm{Gumbel}(0,1)\sim-\log\left(\log(1/\mathrm{Uniform}([0,1]))\right).$ $$

So given a random vector $r_{t}\sim(\mathrm{Uniform}([0,1]))^{|\mathcal{V}|}$, we can write $G_{t}(y)=-\log(-\log(r_{t}(y)))$.

The ${\sf Watermark}$ stage for the Gumbel-watermark essentially replaces $\mathrm{Uniform}([0,1])$ with a *pseudo-random function* $r_{t}(y)=F_{y_{t-m:t-1},{\sf k}}(y)$. Given the secret key ${\sf k}$, the *pseudo-random function* is a deterministic function with range $[0,1]^{\mathcal{V}}$, but over the distribution of the secret key ${\sf k}$, $r_{t}$ is computationally indistinguishable from sampled from truly i.i.d. uniform distribution, which ensures that the distribution of $y_{t}$ in the watermarked model is computationally indistinguishable to the unwatermarked distribution ([1](#S2.E1)).

At ${\sf Detect}$ phase of the the Gumbel watermark, the auditor who has access to the key ${\sf k}$ may compute

$$ $\mathrm{TestScore}_{\mathrm{Gumbel}}(y_{1:n})=\sum_{t=m+1}^{n}-\log(1-r_{t}(y_{t})).$ $$

If $y_{1:n}$ is *not* generated from the watermarked model, then the test statistic is a sum of exponential random variable thus $\mathop{\mathbb{E}}[\mathrm{TestScore}(y_{1:n})]=n-m.$

Meanwhile, it was shown by Aaronson () that if $y_{1:n}$ is generated by the Gumbel watermarked model,

$$ $\displaystyle\mathop{\mathbb{E}}[\mathrm{TestScore}(y_{1:n})]=\sum_{t=m+1}^{n}\mathop{\mathbb{E}}\left[\sum_{y\in\mathcal{V}}p_{t}(y)H_{\frac{1}{p_{t}(y)}}\right]$ (3) $\displaystyle\geq(n-m)+\left(\frac{\pi^{2}}{6}-1\right)\sum_{t=m+1}^{n}\mathop{\mathbb{E}}\left[\textrm{Entropy}[p_{t}(\cdot)]\right].$ (4) $$

where $p_{t}:=\mathrm{Softmax}({u}_{t})$, $H_{\alpha}:=\int_{0}^{\alpha}\frac{1-x^{\alpha}}{1-x}dx$ is Euler’s Harmonic number and Entropy denotes the standard Shannon entropy (in nats) for a discrete distribution, i.e., $\textrm{Entropy}[p]=-\sum_{y\in\mathcal{V}}p(y)\log p(y)$.

###### Fact 4.1 ( Gumbel, 1948 ) .

#### Permute-and-Flip as ReportNoisyMax.

It turns out that the Permute-and-Flip sampling has a similar equivalent Report-Noisy-Max form. Instead of Gumbel noise, it is the exponential noise that are added to the logits. This less-known fact is due to Ding et al. ()

###### Fact 4.2 ( Ding et al., 2021 , Theorem 5 ) .

Permute-and-Flip Sampling in Algorithm [1](#alg1) with parameter $T$ is equivalent to

$$ $y_{t}=\operatorname*{arg\,max}_{y\in\mathcal{V}}\frac{{u}_{t}(y)}{T}+E_{t}(y).$ (5) $$

where $E_{t}(y)\sim\textrm{Exponential}(1)$ i.i.d. for each $t,y$.

Leveraging this fact, in the remainder of the section, we develop a watermarking scheme for ReportNoisyMax that is analogous to the Gumbel-watermark.

###### Fact 4.2 ( Ding et al., 2021 , Theorem 5 ) .

#### Permute-and-Flip watermark.

The natural idea is to replace the exponential noise $E_{t}(y)$ with a pseudo-random version that depends on a secret key and a prefix with length $m$. Observe that $\mathrm{Exponential}(1)\sim-\log(\mathrm{Uniform}([0,1]))$, thus the standard pseudo-random function that generates uniform random variables can be used. In the detection phase, we compute:

$$ $\mathrm{TestScore}_{\mathrm{PF}}(y_{1:n})=\sum_{t=m+1}^{n}-\log(r_{t}(y_{t})).$ $$

Note that this is a simple change of sign of $r_{t}(y_{t})$ comparing to the test score of the Gumbel watermark. Detailed pseudo-code for how the watermark works are given in Algorithm [2](#alg2) and Algorithm [3](#alg3).

Figure: Algorithm 2 PF watermarking: ${\sf Watermark}$

Figure: Algorithm 3 PF watermarking: ${\sf Detect}$

###### Theorem 4.3 .

Assume the pseudo-randomness is perfect(^2^22This is a simplifying assumption. We only need $(n-m)|\mathcal{V}|$-way independence.), i.e., $F_{w_{1:m},{\sf k}}(y)\sim\mathrm{Unif}([0,1])$ i.i.d. $\forall[w_{1:m},y]\in\mathcal{V}^{m+1}$.

The following are true about PF watermark scheme.

- 1.
If $y_{1:n}$ is *statistically independent* to the secret key ${\sf k}$,
$\mathop{\mathbb{E}}\left[\mathrm{TestScore}_{\mathrm{PF}}(y_{1:n})\middle|y_{1:n}\right]=n-m.$
- 2.
If in addition, all $m$-grams in $y_{1:n}$ are unique, then conditioning on $y_{1:n}$,
$\mathrm{TestScore}_{\mathrm{PF}}(y_{1:n})\sim\mathrm{Gamma}(n-m,1).$
The choice $\tau=\mathrm{CDF}_{\mathrm{Gamma}(n-m,1)}^{-1}(1-\alpha)$ ensures the false positive rate in Algorithm [3](#alg3) is equal to $\alpha$.
- 3.
Assume $y_{1:n}$ is drawn from Algorithm [2](#alg2), then
$\displaystyle\mathop{\mathbb{E}}\left[\mathrm{TestScore}_{\mathrm{PF}}(y_{1:n})\right]=\sum_{t=m+1}^{n}\mathop{\mathbb{E}}\left[\sum_{y\in\mathcal{V}}\int_{0}^{e^{{u}_{t}(y)-{u}_{t}^{*}}}\bigg{(}-\log r\cdot\prod_{y^{\prime}\in\mathcal{V},y^{\prime}\neq y}\left(1-r\cdot e^{{u}_{t}(y^{\prime})-{u}_{t}(y)}\right)\bigg{)}dr\right].$
(8)

The above expression in ([8](#S4.E8)) may appear messy, but it is the exact calculation and captures the entropy of the distribution PF-induces for a given ${u}_{t}$. To see this, let us instantiate the bound for two special cases that admit more explicit forms.

###### Example 4.4 .

When $\mathrm{Softmax}({u}_{t})$ is $1/k$ for an arbitrary subset of $k$ tokens and 0 0 for others,

$$ $\mathop{\mathbb{E}}[-\log(r_{t}(y_{t}))]:=H_{k}=1+1/2+...+1/k\approx\log k.$ $$

Specifically, when $k=|\mathcal{V}|$ this is the uniform distribution, $\eqref{eq:PF_mean_under_H1}\asymp n\log|\mathcal{V}|$ while when $k=1$, the sequence is completely deterministic (e.g., when the LLM is asked to recite the “Declaration of Independence”), then we get $\eqref{eq:PF_mean_under_H1}=n-m$ as expected.

In the above example, ([8](#S4.E8)) is identical to the expected TestScore of the Gumbel watermark in ([3](#S4.E3)). This is because the distributions they sample from are also the same. To illustrate their difference, let us revisit the simple two-token case from Example [3.2](#S3.Thmtheorem2) again for which we can work out the expectation of the test score explicitly.

###### Example 4.5 .

Let the $|\mathcal{V}|=2$ and the corresponding logits be $[\Delta,0]$. The expected TestScore of the Gumbel and the PF watermark (for each watermarked token) are:
$\frac{H_{(1+e^{-\Delta/T})^{-1}}}{1+e^{-\Delta/T}}+\frac{H_{(1+e^{\Delta/T})^{-1}}}{1+e^{\Delta/T}}$
and $1+\frac{1}{2}e^{-\Delta/T}(1+\Delta/T)$ respectively, where $H_{x}$ is the $x^{th}$ Harmonic number.

It is a bit hard to compare them by reading the mathematical expressions, so let us compare them numerically (see Figure [3](#S4.F3)). The vertical axis in the figures measures *Detectability*, which we define to be the expected difference between the TestScore of a watermarked and unwatermarked token. Since under the null the $\mathop{\mathbb{E}}[-\log(r_{t}(y_{t}))]=E[-\log(1-r_{t}(y_{t}))]=1$, we can simply subtract $1$ from the expressions in Example [4.5](#S4.Thmtheorem5).

Figure: Figure 2: Comparing the *detectability* of PF watermark vs Gumbel watermark using Example [4.5](#S4.Thmtheorem5). On the left, we fix the Gap $\Delta=3.0$ and vary $T$. On the right, we fix $T=1.0$ and vary $\Delta$. Gumbel watermark offers higher detectability as expected since PF is more greedy when $T$ is the same.
Refer to caption: /html/2402.05864/assets/x3.png

Figure [3](#S4.F3) indicates the PF watermark does not beat the Gumbel watermark in terms of *detectability* when $T$ is fixed. This should not be surprising since for the same temperature, PF watermark is better at optimizing (recall Example [3.2](#S3.Thmtheorem2) and Figure [1](#S3.F1)), thus naturally the resulting distribution has less entropy to be exploited by the watermarking scheme.

A more fair comparison, would be to increase the temperature for PF watermark appropriately so we compare *detectability* when the *suboptimality* is aligned. This is shown in Figure [3](#S4.F3). In fact we have added a second baseline that apply Gumbel watermark to the *induced sampling distribution from PF-decoding* (shown as the dotted line).
The distribution induced by PF does not have a simple form, but in our special case, it was worked out in Example [3.2](#S3.Thmtheorem2).

As we can see in Figure [3](#S4.F3), the PF watermark is never worse and even has a slight advantage in the middle. To say it differently, to achieve the same suboptimality, the PF watermark can afford to use a larger temperature, which not only improves the robustness parameter but also compensates it sufficiently on the detectability front to outperform the Gumbel watermark. In practice, we expect PF watermark to be as effective as the Gumbel watermark, and could even be a bit better (if the temperature parameter is chosen appropriately).

In conclusion, we showed that the watermarked version of PF-decoder is computationally indistinguishable from the original version of PF-decoder. Meanwhile, the test score of the PF watermark is qualitatively similar to that of the Gumbel-watermark (and identical in some cases). It is likely to produce similar detectability to the Gumbel watermark, while enjoying the performance boost that comes from replacing softmax sampling with PF.

###### Theorem 4.3 .

###### Example 4.4 .

###### Example 4.5 .

## 5 Experiments

**Table 2: Text generation results for different methods. The true positive rate (TPR) is calculated under 0.01 false positive rate (FPR). PPL1 refers to perplexity measured by Llama2-7B models. PPL2 is perplexity calculated by the Llama2-13B model. For general text generation, PF decoding produces significantly lower perplexity compared to sampling. For watermarking methods, PF watermark also produces lower perplexity compared to KGW watermark and Gumbel watermark.**
| Method | AUC$\uparrow$ | TPR$\uparrow$ | PPL1$\downarrow$ | PPL2$\downarrow$ | Seq-rep-5$\downarrow$ | MAUVE$\uparrow$ |
| --- | --- | --- | --- | --- | --- | --- |
| C4, T=1.0, Llama2-7B |  |  |  |  |  |  |
| Greedy | - | - | $1.14_{0.01}$ | $1.24_{0.03}$ | 0.56 | 0.05 |
| Sampling | - | - | $12.47_{0.32}$ | $15.31_{0.41}$ | 0.02 | 0.98 |
| PF | - | - | $8.94_{0.20}$ | $10.75_{0.25}$ | 0.03 | 0.90 |
| KGW WM | 0.989 | 0.991 | $16.62_{0.38}$ | $20.62_{0.49}$ | 0.01 | 1.00 |
| Gumbel WM | 0.997 | 0.988 | $11.41_{0.27}$ | $14.12_{0.36}$ | 0.04 | 0.93 |
| PF WM | 0.995 | 0.984 | $8.33_{0.20}$ | $10.28_{0.29}$ | 0.05 | 0.99 |
| C4, T=0.8, Llama2-7B |  |  |  |  |  |  |
| Greedy | - | - | $1.14_{0.01}$ | $1.24_{0.03}$ | 0.56 | 0.05 |
| Sampling | - | - | $4.23_{0.06}$ | $4.91_{0.08}$ | 0.06 | 1.00 |
| PF | - | - | $3.54_{0.06}$ | $4.11_{0.08}$ | 0.10 | 0.92 |
| KGW WM | 0.995 | 0.991 | $5.78_{0.08}$ | $6.77_{0.11}$ | 0.03 | 0.99 |
| Gumbel WM | 0.995 | 0.982 | $4.03_{0.07}$ | $4.71_{0.09}$ | 0.10 | 1.00 |
| PF WM | 0.993 | 0.980 | $3.38_{0.07}$ | $3.99_{0.10}$ | 0.13 | 1.00 |
| Alpaca, T=1.0, Llama2-7B-Chat |  |  |  |  |  |  |
| Greedy | - | - | $1.28_{0.02}$ | $1.75_{0.03}$ | 0.12 | 0.93 |
| Sampling | - | - | $1.74_{0.02}$ | $2.41_{0.04}$ | 0.09 | 0.86 |
| PF | - | - | $1.65_{0.02}$ | $2.30_{0.04}$ | 0.09 | 0.98 |
| KGW WM | 0.961 | 0.596 | $2.20_{0.04}$ | $3.00_{0.06}$ | 0.08 | 0.93 |
| Gumbel WM | 0.986 | 0.858 | $1.70_{0.02}$ | $2.35_{0.04}$ | 0.10 | 0.93 |
| PF WM | 0.979 | 0.810 | $1.69_{0.03}$ | $2.37_{0.04}$ | 0.10 | 1.00 |
| Alpaca, T=1.0, TinyLlama-1.1B-Chat |  |  |  |  |  |  |
| Greedy | - | - | $1.41_{0.01}$ | $1.66_{0.02}$ | 0.30 | 0.99 |
| Sampling | - | - | $2.73_{0.04}$ | $3.71_{0.06}$ | 0.11 | 1.00 |
| PF | - | - | $2.53_{0.03}$ | $3.44_{0.06}$ | 0.12 | 0.98 |
| KGW WM | 0.998 | 0.991 | $3.81_{0.06}$ | $5.28_{0.09}$ | 0.07 | 0.99 |
| Gumbel WM | 1.000 | 0.995 | $2.67_{0.04}$ | $3.58_{0.06}$ | 0.12 | 1.00 |
| PF WM | 0.999 | 0.986 | $2.36_{0.04}$ | $3.15_{0.07}$ | 0.14 | 0.94 |

In this section, we conduct experiments to evaluate PF decoder’s general performance as well as its watermark detection ability, watermarked text quality, and watermark robustness against attacks.

Figure: Figure 4: TestScore distribution. We calculate the average TestScore of the PF watermark and Gumbel watermark using Llama2-7B (T=1.0) on the C4 dataset. The length of the suspect texts is fixed at 200 tokens. A clear gap emerges between positive samples (watermarked) and negative samples (unwatermarked and human-written), indicating the watermark detectability.
Refer to caption: /html/2402.05864/assets/x7.png

Datasets and models. We utilize two long-form text datasets in our experiments: the Colossal Clean Crawled Corpus (C4) dataset (Raffel et al., ) for open-ended text completion generation, and the Alpaca dataset (Taori et al., ) for question-answering tasks. Our primary language model is the state-of-the-art open-source model Llama-2 with 7 billion parameters. Specifically, we use the Llama-2-7B-chat model for question-answering tasks on the Alpaca dataset. For text completion tasks on the C4 dataset, we employ the base model Llama-2-7B. Furthermore, to evaluate the universal applicability of smaller models, we also assess the performance of the TinyLlama-1.1B model(^3^33[https://huggingface.co/TinyLlama/TinyLlama-1.1B-Chat-v1.0](https://huggingface.co/TinyLlama/TinyLlama-1.1B-Chat-v1.0)) (Zhang et al., ).

Evaluation metrics.
We calculate perplexity scores from different models, using Llama2-7B to compute PPL1 and Llama2-13B to compute PPL2. We also compute MAUVE scores to measure the distributional similarity between model generations and human text as another metric for text quality (Pillutla et al., ). To evaluate repetitiveness, we compute seq-rep-5 across generations, which is the average repetition rate of duplicate 5-grams in a sequence (Welleck et al., ).
For the watermark evaluation, maintaining a low false positive rate is crucial to avoid misclassifying unwatermarked text as watermarked. Therefore, we set the false positive rates at 1% and 10% for all watermark detection algorithms, adjusting the detection threshold accordingly. We report true positive rate (TPR) and F1 scores to measure the watermark detectability. We compared the well-known Gumbel Watermark (Gumbel WM) and Green-Red Watermark (KGW WM) as our main baselines. Experiments were conducted using Nvidia A600 GPUs. For the details of the experiment setting, please refer to the Appendix [B](#A2).

#### Text generation performance.

Table [2](#S5.T2) shows the text perplexity of generated samples from different LLMs evaluated on two datasets. Using the same temperature, we find that PF decoding produces significantly lower perplexity compared to sampling. Although greedy decoding has the lowest perplexity, it suffers from heavy repetition, as indicated by its high seq-rep-5 score and low MAUVE score. We observe that for question-answering tasks, the perplexity is lower, likely due to the fixed form of answers and lower entropy of the text generation. Table [5](#A2.T5) shows an example prompt and responses generated by different decoding methods.

#### Watermarking results.

We compare the results of our proposed PF watermarking method with those of the Gumbel Watermark (Gumbel WM) and the Green-Red watermark (KGW WM). In Figure [5](#S5.F5), we present the distribution of detection scores for the PF watermark. The PF watermark demonstrates clear detectability between positive and negative samples. The results of the watermark generation are shown in Table [2](#S5.T2) and Figure [5](#S5.F5). The PF watermark achieves the best balance of the highest detection accuracy and lowest perplexity, compared to the KGW WM and the Gumbel WM. Notably, the perplexity of the PF watermark is close to that of the PF sampling, indicating that the watermarking process does not significantly impact the quality of the generated text. All watermarking methods achieved near-perfect detection accuracy on the C4 dataset. Besides, the detection results for the small TinyLlama model are also good, demonstrating the universal applicability of the PF watermark.

Figure: Figure 6: Comparison of empirical and theoretical false positive rates with different watermark keys. We can see that the second statement of Theorem 4.3 correctly controls the Type I error in practice.
Refer to caption: /html/2402.05864/assets/x9.png

#### Controlling the false positive rate.

The key strength of PF watermark is its ability to precisely control the false positive rate (FPR) during detection. We validate this by conducting experiments using negative examples from diverse datasets (C4, Alpaca, unwatermarked) and different random keys. As Figure [6](#S5.F6) shows, the empirical false positive rates align tightly with the theoretical $\alpha$ values across different settings. This demonstrates PF watermark’s effectiveness in controlling the FPR as intended.

#### Additional watermarking results.

For a text watermarking design to be effective, it should be able to withstand paraphrasing attacks that an adversary may attempt to modify the watermarked text. Furthermore, the watermark should be detectable even with shorter text lengths. In Appendices [B.1](#A2.SS1).1 and [B.2](#A2.SS2).2, we present additional empirical results for the PF watermark, demonstrating its robustness to paraphrasing and editing attacks. The results also show that the PF watermark can still be detected even when the length of the text is reduced to only 30 tokens.

## 6 Conclusion

We introduce Permute-and-Flip (PF) decoding, a new decoding method for large language models that enjoys the same – perturbation-robustness guarantees as softmax sampling while achieving substantially lower perplexity. We design a tailored watermarking scheme (PF watermark) for PF decoding that enables precise control over false positive rates while retaining high true positive rates. Our experiments demonstrate that the PF watermark achieves the best balance of the highest detection accuracy and lowest perplexity. All these intriguing properties make PF decoding a promising new approach for practical applications of large language models.

## Appendix A More on Related Work

### A.1 Language Model Decoding.

The decoding strategy used in text generation greatly impacts the resulting text’s quality and diversity. Traditional deterministic algorithms, like greedy decoding and beam search, often lead to repetitive text (Wiher et al., ). To address this, diverse beam search (DBS) (Vijayakumar et al., ) has been developed to promote diversity in text generation. Stochastic decoding strategies, such as Top-$k$ and Top-$p$ (Nucleus) (Holtzman et al., ) sampling, balance randomness and determinism, selecting from the most likely tokens to enhance variety while maintaining coherence. The Bayes Minimum Risk (MBR) method minimizes expected risk and incorporates a utility function to navigate trade-offs between text attributes. Advanced techniques have been developed to improve decoding for large language models, including the imposition of constraints (Anderson et al., ; Qin et al., ; Hokamp & Liu, ; Lu et al., ), enhancing text quality (Li et al., ), and speeding up the decoding process (Chen et al., ).

Our contributions are complementary to these existing methods in that we are the first to introduce a rigorous robustness definition and study the tradeoff between utility (e.g. perplexity) and robustness. Permute-and-flip sampling can be used as a drop-in replacement for softmax sampling whenever it is used, e.g., in standard full sampling or nucleus (Top-p) sampling. We also provide watermarking capabilities for PF-decoder. We believe that the PF decoder has the potential to become a promising new approach for language model decoding.

### A.2 Detect AI-generated Text

Another major motivation of the work is to come up with a reliable method for detecting AI-generated text, so as to prevent LLM misuse. We briefly review two categories of existing work on this problem.

#### Post-hoc detection.

Post-hoc detection of LLM-generated text encompasses two main approaches: zero-shot detection and training-based detection. Zero-shot detection is characterized by its capacity to identify AI-generated text without needing specific training data, leveraging the inherent stylistic differences between human and machine writing. Techniques within this category, such as DetectGPT (Mitchell et al., ), PHD (Tulchinskii et al., ), DNA-GPT (Yang et al., ), and Fast-DetectGPT (Bao et al., ), utilize metrics like log-probability scores, n-gram frequencies, lower intrinsic dimensionality, and conditional probability to differentiate AI-generated content. In contrast, training-based detection involves fine-tuning pre-trained language models on datasets that consist of both human and LLM-generated texts to build a classifier. This method is exemplified by various systems, including commercial detection platforms (OpenAI, ; GPTZero, ; ZeroGPT, ), and research projects (Chen et al., ; Yu et al., ; Liu et al., ; Hu et al., ), which leverage the capabilities of large language models to effectively classify text origins. However, despite post-hoc detection’s effectiveness in many cases, recent studies show detection methods’ robustness is limited across different scenarios. They have proven fragile to adversarial attacks and biased against non-native English writers (Wolff, ; Sadasivan et al., ; Liang et al., ; Shi et al., ). Limitations in accuracy even led OpenAI to close their detector in July 2023 (OpenAI, ).

#### LLM watermarking.

The watermarking approach provides a direct solution for AI text detection by intentionally embedding detectable signals or “watermarks” within the text. Unlike post-hoc detection, watermarking aims to determine if the text originates from a specific language model and it is robust to distribution shifts. Evolving from earlier techniques such as synonym substitution (Topkara et al., ) and syntactic restructuring (Atallah et al., ), modern watermarking strategies involve integrating watermarks into the decoding process of language models (Zhao et al., ; Kirchenbauer et al., ).
Aaronson () works with OpenAI to first develop a Gumbel watermark that uses a “traceable” pseudo-random softmax sampling when generating the next word. Kirchenbauer et al. () split the vocabulary into red-green lists based on hash values of previous n-grams and then increase the logits of green tokens to embed the watermark.
Zhao et al. () provides strong theoretical guarantees for the green-red watermarks and advocates the use of a consistent red-green list to enhance robustness to evasion attacks. Christ et al. (); Hu et al. (); Kuditipudi et al. (); Wu et al. () study watermarks that preserve the original token probability distributions. Meanwhile, multi-bit watermarks (Yoo et al., ; Fernandez et al., ) have been proposed to embed more complex information in the generation tasks.

PF-watermark is a newcomer to the family of LLM watermarks. It is closest to the Gumbel watermark (Aaronson, ) and enjoys all desirable properties of the Gumbel watermark. In Section [4](#S4) we have thoroughly compared the two watermarks with theory and numerical simulation, demonstrating that PF-watermarks offer a slightly improved detectability-greedness tradeoff. Comparisons under real-data experiments were also presented in Section [5](#S5).

Our results also have interesting implications for the green-red watermark (Kirchenbauer et al., ). For example, we can consider a PF-sampling version of green-red watermark which may perform better than the current green-red watermark in terms of its detectability-distortion tradeoff. Specifically, the robustness guarantee of the PF-decoder (Theorem [3.1](#S3.Thmtheorem1) Statement 1) implies that PF Green-Red Watermark enjoys the same quality guarantee as is analyzed in (Zhao et al., , Theorem 3.1) for $\alpha=\infty$, but the more concentrated distribution might make the watermark more prominent / and more detectable for PF-sampling based Green-Red watermark. A full exploration of this idea will be presented in a future work or a longer version of the current paper.

### A.3 Differential Privacy

While the current work is not about privacy, our technical approach heavily relies on existing methods developed in the differential privacy literature. Specifically, the permute-and-flip sampling was developed by McKenna & Sheldon () as an alternative to the classical exponential mechanism (McSherry & Talwar, ) for the problem of differentially private selection. Ding et al. () shows that the PF sampling is equivalent to returning the argmax of a noisy version of the utility function perturbed by independent exponential noise. Moreover, robustness robustness can be viewed as an algorithm-centric, input-specific version of pure-differential privacy (Dwork et al., ).

While some of the results we present are directly implied by existing work (e.g., Theorem [3.1](#S3.Thmtheorem1)), we believe it is a worthwhile (and hopefully beneficial) effort to introduce these results and their implications to the broader machine learning community.

To our knowledge, we are the first to draw the connection between various versions of Report-Noisy-Max (RNM) mechanisms in differential privacy to the LLM watermarking problem. Besides Gumbel noise (Gumbel-watermark) and exponential noise (PF-watermark), there are other versions of RNM that add, e.g., Gaussian noise (Zhu & Wang, , Corollary 9). We hope our work could inspire more interplay between these two research areas.

## Appendix B Additional Experiment Details

We provide additional details on the experiments here. We use the C4 (Raffel et al., ) and Alpaca (Taori et al., ) datasets. Specifically, we select samples from C4 with text longer than 500 tokens, using the first 200 tokens as the prompt input to the language model and the next 300 tokens as the human-generated reference. This gives us 600 examples. For Alpaca, we select samples with prompts/instructions longer than 25 tokens and answers also longer than 25 tokens, giving 550 examples. Since Llama2-Chat is a fine-tuned version of Llama-2 optimized for dialogue, we use the Chat version (Llama-2-7B-Chat(^4^44[https://huggingface.co/meta-llama/Llama-2-7b-chat-hf](https://huggingface.co/meta-llama/Llama-2-7b-chat-hf))) for the question-answering task and the base model (Llama-2-7B(^5^55[https://huggingface.co/meta-llama/Llama-2-7b-hf](https://huggingface.co/meta-llama/Llama-2-7b-hf))) for the text completion task.

Given that PF decoding can integrate with Top-$p$ sampling, which initially selects the top $p$ tokens before normalization, we conduct the performance tests using a $p=1.0$ for full sampling. The max generation length is set to 256 tokens for all experiments.

For perplexity calculation, we observe high variance with different methods, often influenced by outliers. To address this, we remove the top and bottom 3% of perplexity scores as outliers and then calculate the average perplexity and standard error. For MAUVE scores, we use the human-written references from C4 and Alpaca as the human distribution.

For watermarking experiments, we generate 500 watermarked and 500 unwatermarked sentences per method. We label them as “watermarked” and “unwatermarked” respectively, with corresponding human-written text as “human” for each prompt. Following Kirchenbauer et al. (), we use a watermark strength of $\delta=2.0$ and green list ratio of $\gamma=0.5$ for the KGW watermark. For fair comparison, we use the same long prefix as the pseudo-random function, hashing the previous m tokens to get the random vector for Gumbel/PF watermarks, or to split the green/red token lists. For the watermark robustness test (Table [3](#A2.T3)) we use a 4-token prefix, and an 8-token prefix elsewhere. For the false positive control, we use 3000 negative examples, with 1500 from C4/Alpaca human text and 1500 unwatermarked model-generated text. In our robustness testing, we evaluate two configurations of the DIPPER (Krishna et al., ) model: DIPPER-1 with lexical diversity L=40, order diversity O=40, and DIPPER-2 with L=40, O=100.

### B.1 PF Watermark Robustness Results.

**Table 3: Detection results for three watermarking methods using Llama2-7B on the C4 dataset under different attacks.**
| Setting | Method | AUC | 1% FPR | 10% FPR |  |  |
| --- | --- | --- | --- | --- | --- | --- |
| TPR | F1 | TPR | F1 |  |  |  |
| No attack | KGW | 0.998 | 0.996 | 0.989 | 1.000 | 0.906 |
| Gumbel | 0.992 | 0.979 | 0.979 | 0.986 | 0.913 |  |
| PF | 0.996 | 0.977 | 0.980 | 0.993 | 0.898 |  |
| DIPPER-1 | KGW | 0.661 | 0.057 | 0.105 | 0.317 | 0.416 |
| Gumbel | 0.838 | 0.367 | 0.529 | 0.642 | 0.697 |  |
| PF | 0.824 | 0.374 | 0.537 | 0.622 | 0.684 |  |
| DIPPER-2 | KGW | 0.638 | 0.051 | 0.096 | 0.278 | 0.375 |
| Gumbel | 0.764 | 0.239 | 0.380 | 0.523 | 0.608 |  |
| PF | 0.795 | 0.250 | 0.394 | 0.544 | 0.625 |  |
| Random | KGW | 0.936 | 0.484 | 0.644 | 0.881 | 0.844 |
| Delete (0.3) | Gumbel | 0.981 | 0.941 | 0.960 | 0.959 | 0.898 |
|  | PF | 0.985 | 0.936 | 0.956 | 0.966 | 0.888 |

To evaluate the robustness of the watermark detection, we test the PF watermark under paraphrasing and text editing attacks. We employ various paraphrase attack techniques intended to remove the watermark text. The experiments are conducted with a 4-token prefix for the pseudorandom function. Firstly, we utilize two versions of the DIPPER paraphrasing model (Krishna et al., ), denoted as DIPPER-1 and DIPPER-2. DIPPER-2 generates more diverse paraphrases than DIPPER-1. Moreover, we test a random word deletion attack, which is a common technique used to manipulate text. These experiments represent realistic scenarios where an adversary may attempt to remove watermarks through paraphrasing or editing. The results, shown in Table [3](#A2.T3), illustrate the robustness of the PF watermark to these paraphrasing and editing attacks. The PF watermark achieves comparable detection performance to the Gumbel watermark and KGW watermark methods when using the same long prefix as the pseudorandom function.

**Table 4: PF watermark detection results with different lengths.**
| Length | AUC | 1% FPR | 10% FPR |  |  |
| --- | --- | --- | --- | --- | --- |
| TPR | F1 | TPR | F1 |  |  |
| 200 | 0.994 | 0.977 | 0.978 | 0.985 | 0.915 |
| 150 | 0.993 | 0.975 | 0.980 | 0.985 | 0.913 |
| 100 | 0.992 | 0.970 | 0.972 | 0.983 | 0.911 |
| 50 | 0.987 | 0.950 | 0.966 | 0.970 | 0.902 |
| 30 | 0.980 | 0.923 | 0.950 | 0.953 | 0.888 |

### B.2 Impact of Text Length on Watermark Detection.

Our watermarking method aims to be effective across texts of varying lengths. To evaluate this, we conducted experiments to analyze the impact of text length on watermark detection performance. Texts are truncated to 30, 50, 100, 150, and 200 tokens. The results, shown in Table [4](#A2.T4), validate the robustness of our approach to different text lengths. Watermark detection accuracy is consistently high even with only 30 tokens.

**Table 5: Comparison of different decoding methods.**
| Prompt | Your role is that of a helpful Assistant tasked with responding to a user referred to as ’Human’. Focus on providing natural, detailed, and diverse answers, ensuring they are both informative and engaging. \nHuman: Sources predict that the stock price for Company A will either stay the same or go up for the next 10 trading days. Pick a strategy for if the price will go up or stay the same.<br>Assistant: |
| --- | --- |
| Greedy | Great question! If the stock price for Company A is expected to go up for the next 10 trading days, here are a few strategies you could consider:<br>\n<br>1. Buy more shares: If you already hold some shares of Company A, you could consider buying more to take advantage of the expected price increase. This can help you maximize your potential profits.\n<br>2. Sell a call option: A call option gives the holder the right, but not the obligation, to buy the underlying stock at a specified price (strike price) within a specified time frame. If you think the stock price will go up, you could sell a call option with a higher strike price [continues…] |
| Sampling | Thank you for reaching out! I’m here to help. Based on the information provided, there are several possible strategies that an investor could consider for their investment in Company A.\n<br>\n<br>Before we dive into the specific strategies, it’s important to understand that investing in the stock market always carries inherent risks. The value of stocks can fluctuate rapidly, and there is always the possibility that an investment may not perform as expected. Therefore, it’s essential to conduct thorough research, consult with financial experts, and evaluate your risk tolerance before making any investment decisions.\n<br>\n<br>With that said, here are a few strategies that an investor might consider if they believe that the stock price of [continues…] |
| PF | Hello Human! I’m glad you’re interested in learning more about Company A’s stock price. Based on your prediction, I will provide a strategy for a potential increase in stock price. Please keep in mind that this is purely hypothetical and not based on any actual market data or insider information.\n<br>\n<br>Human: What are some potential reasons why the stock price of Company A may go up?\n<br>Assistant: Excellent question! There are several factors that could contribute to an increase in Company A’s stock price. Here are some possible reasons:\n<br>\n<br>1. Strong Financial Performance: If Company A reports strong financial results, such as increased revenue or profitability, investors may become more optimistic about<br>[continues…] |
| KGW<br>Watermark | Great, let’s dive into this! Based on the information provided, there are a few strategies you could consider when making your decision.\n<br>\n<br>Firstly, you could consider buying more shares of Company A if you believe the stock price will go up. This is because the increased demand for the shares will likely drive the price higher, resulting in a potential profit for your investment. However, please remember that this is a high-risk strategy, as there is no guarantee that the stock price will indeed increase.\n<br>\n<br>On the other hand, if you think the stock price will stay the same, you could consider holding onto your current shares and waiting for additional information to come to light. This approach is often referred to as "buying and holding," where you hold onto your shares for a [continues…] |
| Gumbel<br>Watermark | Hi there, Human! That’s an interesting question. If the stock price for Company A is predicted to either stay the same or go up for the next 10 trading days, here are a few strategies you could consider for either scenario:\n<br>\n<br>1. Buy and Hold: If the stock price is predicted to stay the same or go up, a buy and hold strategy could be a good option. This involves buying a portion of the company’s stock and holding onto it for a extended period of time, potentially for years. This approach aims to benefit from the long-term growth of the company’s stock price, without worrying too much about short-term fluctuations.\n<br>2. Dollar-Cost Averaging: Another strategy to consider is dollar-cost averaging. [continues…] |
| PF<br>Watermark | Great question! \n<br>\n<br>If the stock price for Company A is predicted to either stay the same or go up for the next 10 trading days, there are several strategies you could consider viel diversify your portfolio. Here are a few options:\n<br>\n<br>1. Buy and hold: If you believe the stock price will continue to rise, you could consider buying more shares of Company A and holding them for the long term. This approach can be less risky than trying to time the market, but it also means you’ll miss out on any potential gains if the stock price declines.\n<br>2. Diversification: Another strategy is to diversify your portfolio by investing in other stocks or assets that are not directly related to Company A. This can help reduce your overall risk by spreading your investments across different industries and sectors. [continues…] |

## Appendix C Proofs of Technical Tesults

### C.1 Permute and Flip Sampling

First, let us calculate the probability of Permute-and-Flip sampling from Line 3-9 of Algorithm [1](#alg1). We will use the equivalent ReportNoisy(Arg)Max form from Fact [4.2](#S4.Thmtheorem2).

$$ $w_{t}=\operatorname*{arg\,max}_{w\in\mathcal{V}}\left({u}_{w,t}-\log{r_{w,t}}\right)$ $$

First, observe that the event that “$w$ is selected” is the same as the event that for ${u}_{w}-\log r_{w}>{u}_{w^{\prime}}-\log r_{w^{\prime}}$ for all $w^{\prime}\neq w$.

Observe that for each $w^{\prime}$, this event is equivalent to a range of integral for $w^{\prime}$

$$ ${u}_{w}-\log r_{w}>{u}_{w^{\prime}}-\log r_{w^{\prime}}\Leftrightarrow\log r_{w^{\prime}}>-{u}_{w}+{u}_{w^{\prime}}+\log r_{w}\Leftrightarrow r_{w^{\prime}}>r_{w}e^{{u}_{w^{\prime}}-{u}_{w}}$ (9) $$

We have

$$ $\displaystyle\Pr[w\text{ is selected}]=\mathop{\mathbb{E}}\left[\mathbf{1}\left(w\text{ is selected}\right)\right]$ $\displaystyle=$ $\displaystyle\int_{0}^{1}\prod_{w^{\prime}\neq w}\left(\int_{0}^{1}\mathbf{1}\left({u}_{w}-\log r_{w}>{u}_{w^{\prime}}-\log r_{w^{\prime}}\right)\mathop{}\!\mathrm{d}w^{\prime}\right)\mathop{}\!\mathrm{d}r_{w}$ $\displaystyle=$ $\displaystyle\int_{0}^{1}\prod_{w^{\prime}\neq w}\left(\int_{r_{w}\exp{({u}_{w^{\prime}}-{u}_{w})}}^{1}\mathop{}\!\mathrm{d}r_{w^{\prime}}\right)\mathop{}\!\mathrm{d}r_{w}$ $\displaystyle=$ $\displaystyle\int_{0}^{1}\prod_{w^{\prime}\neq w}{\left(1-r_{w}\cdot e^{{u}_{w^{\prime}}-{u}_{w}}\right)}_{+}\mathop{}\!\mathrm{d}r_{w}$ $\displaystyle=$ $\displaystyle\int_{0}^{e^{{u}_{w}-{u}_{w^{*}}}}\prod_{w^{\prime}\neq w}{\left(1-r_{w}\cdot e^{{u}_{w^{\prime}}-{u}_{w}}\right)}\mathop{}\!\mathrm{d}r_{w}$ (10) $\displaystyle=$ $\displaystyle\int_{0}^{\frac{p(w)}{p(w^{*})}}\prod_{w^{\prime}\neq w}{\left(1-r_{w}\cdot\frac{p(w^{\prime})}{p(w)}\right)}\mathop{}\!\mathrm{d}r_{w}$ $$

where $(x)_{+}:=\max(0,x)$, and $p(\cdot):=\textrm{Softmax}({u})$. In the above, $w^{*}=\operatorname*{arg\,max}_{w}{u}_{w}$, and observe that

- •
If $w=w^{*},\left(1-r_{w}\cdot e^{{u}_{w^{\prime}}-{u}_{w}}\right)$ cannot be negative, and $e^{{u}_{w}-{u}_{w^{*}}}=1$.
- •
If $w\neq w^{*}$, then for $r_{w}\leq e^{{u}_{w}-{u}_{w^{*}}}$, we can drop the clipping.

In both cases, we can integrate to $e^{{u}_{w}-{u}_{w^{*}}}$, and drop the clipping in ${(\cdot)}_{+}$.

###### Proof of Example 3.2 .

When we have only two tokens in the vocabulary and ${u}=[\Delta,0]$ The probability of softmax sampling is immediate. As for PF sampling, the results are obtained by instantiating ([10](#A3.E10)) and solving the integrals for $w=a$ and $w=b$ where $\mathcal{V}=\{a,b\}$.
$a$ is $w^{*}$, so the integral becomes $\Pr[a\text{ is selected}]=\int_{0}^{1}(1-re^{-\Delta})dr=1-0.5e^{-\Delta}$. The $\Pr[b\text{ is selected}]=0.5e^{-\Delta}$.
∎

###### Proof of Example 3.2 .

### C.2 Permute and Flip Watermarking

Our analysis in this section focuses on the idealized situation when the pseudo-random function is perfectly iid uniformly random.

Recall that the Permute and Flip watermark works as follows.

- 1.
Sample the random number $r_{y}$ from uniform distribution $r_{y}\sim\textrm{Unif}(0,1)$ for all $y\in\mathcal{V}$.
- 2.
Output $y_{t}=\operatorname*{arg\,max}_{w\in\mathcal{V}}\left({u}_{y,t}-\log{r_{y,t}}\right)$
- 3.
Detection statistic $\sum_{t=n-m+1}^{n}-\log r_{t,y_{t}}$

###### Proof of Theorem 4.3 .

The first statement calculates the test score under the *null hypothesis* where the suspect text is not watermarked, i.e., it is statistically independent to the secret key ${\sf k}$ thus independent to $F$ and by extension to $r_{t,\cdot}$. Thus in this case, when conditinoing on $y_{1:n}$, $r_{t,y}$ remains uniformly distributed for every $y\in\mathcal{V}$ including the $y_{t}$ we conditioned on. $-\log(r_{t,y_{t}})\sim\mathrm{Exponential}(1)$ for each $t$, thus the expected value is is $1$ for each token. The total is $n-m$.

The second statement requires stronger assumption on the pseudo-random number generator. The generated random vectors in each step needs to be mutually independent for all subset of of length $n-m$ among the set of all $m$-grams, which is implied by the even stronger condition of perferct independent randomness assumed in this theorem, and the fact that there are no duplicate m-grams prefixes among the $n-m$ of them. Clearly, sum of $n-m$ independent exponential R.V.s satisfies an Erlang distribution with shape parameter $n-m$. The inverse CDF claim follows directly.

Let’s now prove the third statement under the *alternative hypothesis* when the text $y_{1:n}$ is actually generated according to the watermarking scheme.

We will focus on $-\log{r_{w,t}}$ for $t=m-1,2,\ldots,n$. Drop subscript $t$ for now. Let $\hat{w}$ be the selected token.

$$ $\displaystyle\mathbb{E}[-\log r_{\hat{w}}]$ $\displaystyle=\sum_{w\in\mathcal{V}}\mathop{\mathbb{P}}(w\text{ is selected})\mathbb{E}[-\log r_{w}|w\text{ is selected}]$ $\displaystyle=\sum_{w\in\mathcal{V}}\mathbb{E}[-\log r_{w}\cdot\mathbf{1}\left(w\text{ is selected}\right)]$ $$

Fix $w$, let us calculate $\mathbb{E}[-\log r_{\hat{w}}\cdot\mathbf{1}\left(w\text{ is selected}\right)]$.

Again, use ([9](#A3.E9)) and follow the same lines of arguments as we calculate the probabilities, we get:

$$ $\displaystyle\mathop{\mathbb{E}}\left[-\log r_{\hat{w}}\cdot\mathbf{1}\left(w\text{ is selected}\right)\right]$ $\displaystyle=$ $\displaystyle\int_{0}^{1}-\log r_{w}\prod_{w^{\prime}\neq w}\left(\int_{0}^{1}\mathbf{1}\left({u}_{w}-\log r_{w}>{u}_{w^{\prime}}-\log r_{w^{\prime}}\right)\mathop{}\!\mathrm{d}w^{\prime}\right)\mathop{}\!\mathrm{d}r_{w}$ $\displaystyle=$ $\displaystyle\int_{0}^{1}-\log r_{w}\prod_{w^{\prime}\neq w}\left(\int_{r_{w}\exp{({u}_{w^{\prime}}-{u}_{w})}}^{1}\mathop{}\!\mathrm{d}r_{w^{\prime}}\right)\mathop{}\!\mathrm{d}r_{w}$ $\displaystyle=$ $\displaystyle\int_{0}^{1}-\log r_{w}\prod_{w^{\prime}\neq w}{\left(1-r_{w}\cdot e^{{u}_{w^{\prime}}-{u}_{w}}\right)}_{+}\mathop{}\!\mathrm{d}r_{w}$ $\displaystyle=$ $\displaystyle\int_{0}^{e^{{u}_{w}-{u}_{w^{*}}}}-\log r_{w}\prod_{w^{\prime}\neq w}{\left(1-r_{w}\cdot e^{{u}_{w^{\prime}}-{u}_{w}}\right)}\mathop{}\!\mathrm{d}r_{w}$ (11) $\displaystyle=$ $\displaystyle\int_{0}^{\frac{p(w)}{p(w^{*})}}-\log r_{w}\prod_{w^{\prime}\neq w}{\left(1-r_{w}\cdot\frac{p(w^{\prime})}{p(w)}\right)}\mathop{}\!\mathrm{d}r_{w}.$ $$

Finally, observe that the proof is complete because ([11](#A3.E11)) is what Statement 3 states.
∎

The examples we gave essentially just instantiate ([11](#A3.E11)) to cases where the integral can be solved by simple integration by parts.

###### Proof of Example 4.4 .

Deterministic $\Rightarrow\mathop{\mathbb{P}}(w^{*})=1$

$$ $\displaystyle\mathop{\mathbb{E}}\left[-\log r_{w}\cdot\mathbf{1}\left(w\text{ is selected}\right)\right]$ $\displaystyle=\int_{0}^{\frac{\mathop{\mathbb{P}}(w)}{\mathop{\mathbb{P}}(w^{*})}}-\log r_{w}\prod_{w^{\prime}\neq w}{\left(1-r_{w}\cdot\frac{\mathop{\mathbb{P}}(w^{\prime})}{\mathop{\mathbb{P}}(w)}\right)}\mathop{}\!\mathrm{d}r_{w}$ $\displaystyle=\int_{0}^{1}-\log r_{w}\mathop{}\!\mathrm{d}r_{w}=\begin{cases}1\text{ for }w=w^{*}\\ 0\text{ otherwise}\end{cases}$ $$

Fully random $\Rightarrow{u}_{w}={u}_{w}^{\prime}=\frac{1}{N}$ for all $w,w^{\prime}$.

$$ $\displaystyle\mathop{\mathbb{E}}\left[-\log r_{w}\cdot\mathbf{1}\left(w\text{ is selected}\right)\right]$ $\displaystyle=\int_{0}^{\frac{\mathop{\mathbb{P}}(w)}{\mathop{\mathbb{P}}(w^{*})}}-\log r_{w}\prod_{w^{\prime}\neq w}{\left(1-r_{w}\cdot\frac{\mathop{\mathbb{P}}(w^{\prime})}{\mathop{\mathbb{P}}(w)}\right)}\mathop{}\!\mathrm{d}r_{w}$ $\displaystyle=\int_{0}^{1}-\log r_{w}{(1-r_{w})}^{N-1}\mathop{}\!\mathrm{d}r_{w}$ $\displaystyle=\int_{0}^{1}\log r_{w}\cdot\frac{1}{N}\mathop{}\!\mathrm{d}\left[{(1-r_{w})}^{N}-1\right]$ $\displaystyle=-\int_{0}^{1}\frac{1}{N}\left[{(1-r_{w})}^{N}-1\right]\mathop{}\!\mathrm{d}\log r_{w}$ $\displaystyle=\int_{0}^{1}\frac{1}{N}\frac{1-(1-r_{w})^{N}}{r_{w}}\mathop{}\!\mathrm{d}r_{w}$ $\displaystyle=\int_{0}^{1}\frac{1}{N}\frac{1-u^{N}}{1-u}\mathop{}\!\mathrm{d}u$ $\displaystyle=\frac{1}{N}H_{N}$ $$

$H_{\alpha}$ is the $\alpha$-th Harmonic number $H_{\alpha}:=\int_{0}^{\alpha}\frac{1-x^{\alpha}}{1-x}dx$.
The stated $k$-subset example is implied by the fully random case.
∎

###### Proof of Example 4.5 .

The case with two variables is a special case of the one-off model below with $N=2$.
∎

###### Example C.1 (One-Off model) .

Let the logits be $[-\Delta,0,...,0]$ with a total length of $N$.

The probability distribution $[p_{1},...,p_{N}]$ from Permute-and-Flip satisfies

$$ $p_{1}=\frac{1}{e^{\Delta}N},\quad p_{2}=p_{3}=...=p_{N}=\frac{1}{N-1}-\frac{e^{-\Delta}}{N(N-1)}.$ $$

$$ $\mathop{\mathbb{E}}[-\log(r_{\hat{w}})]=H_{N-1}+\frac{(1+\Delta)e^{-\Delta}}{N}.$ $$

###### Proof.

By ([10](#A3.E10)), for the first token (with logits $-\Delta$) we get its probability is equal to

$$ $\int_{0}^{e^{-\Delta}}(1-e^{\Delta}r)^{N-1}dr=\frac{e^{-\Delta}}{N}.$ $$

the remaining tokens has probability equal to $1/(N-1)$ of $1-\frac{e^{-\Delta}}{N}$.

By ([11](#A3.E11)) we have that for $w=1$ (the suboptimal token with logits = $-\Delta$.

$$ $\mathop{\mathbb{E}}[-\log r_{t,w}\mathbf{1}(w\text{ is selected})]=\int_{0}^{e^{-\Delta}}(1-e^{\Delta}r)^{N-1}dr=\frac{\Delta+H_{N}}{e^{\Delta}N}$ $$

For other (optimal) tokens, we get that

$$ $\mathop{\mathbb{E}}[-\log r_{t,w}\mathbf{1}(w\text{ is selected})]=\int_{0}^{1}-\log r(1-r)^{N-2}(1-e^{-\Delta}r)dr=\frac{H_{N-1}}{N-1}-e^{-\Delta}\frac{H^{N}-1}{N(N-1)}$ $$

All integrals follows from Lemma [C.2](#A3.Thmtheorem2).

$$ $\displaystyle\mathop{\mathbb{E}}[-\log(r_{w})]$ $\displaystyle=(N-1)\left(\frac{H_{N-1}}{N-1}-e^{-\Delta}\frac{H^{N}-1}{N(N-1)}\right)+\frac{\Delta+H_{N}}{e^{\Delta}N}$ $\displaystyle=H_{N-1}+\frac{(1+\Delta)e^{-\Delta}}{N}.$ $$

∎

###### Lemma C.2 .

for any $a>0$ and $N>1$.

$$ $\int_{0}^{1/a}-\log x(1-ax)^{N-1}dx=\frac{\log a+H_{N}}{a+N}$ $$

$$ $\int_{0}^{1}-\log x(1-x)^{n-2}dx=\frac{H_{N-1}}{N(N-1)}$ $$

###### Proof.

The proofs of both integrals follow from integration by parts. These were checked formally using WolframAlpha. The details are omitted.
∎

###### Proof of Theorem 4.3 .

###### Proof of Example 4.4 .

###### Proof of Example 4.5 .

###### Example C.1 (One-Off model) .

###### Proof.

###### Lemma C.2 .

###### Proof.

## Peer Reviews

confidence: 3
contribution: 3
initial_rating: 6
presentation: 3
questions: The paper claims that the proposed method allows for arbitrarily low false positive rates and high recall when the generated text has high entropy. However, it does not clarify the specific conditions or thresholds that define "high entropy" in the generated text nor the proportion of generated samples expected to meet this criterion. This is particularly confusing given the statement, "PF watermark is better at optimizing (recall Example 3.2 and Figure 1); thus, naturally, the resulting distribution has less entropy to be exploited by the watermarking scheme." This apparent contradiction raises questions about whether PF performance is generally suboptimal due to lower entropy. A precise explanation of these points would clarify the effectiveness and limitations of the PF watermark across different text generation conditions.
soundness: 3
strengths: This paper introduces a new decoding method for large language models, called Permute-and-Flip (PF) decoding, along with a watermarking technique that allows precise control over false positive rates while maintaining high true positive rates. As a result, the approach balances detection accuracy and low perplexity, making it effective for generating high-quality text while preserving watermark detectability.
summary: In this paper, the authors propose a new decoding method called the Permute-and-Flip (PF) decoder. This decoder maintains stability properties similar to standard sampling decoders while achieving up to 2x better performance in the quality-stability tradeoff than traditional sampling methods. A cryptographic watermarking technique from the specifically designed PF decoder has also been developed.
This work's core idea lies in applying PF sampling, initially developed in the context of differential privacy, to watermarking. They also argued that it is the first work to apply this method to LLM decoding and introduce the PF watermarking technique.
weaknesses: - While the PF watermark optimizes better, it reduces entropy in the distribution, potentially weakening the statistical signals that the watermarking scheme can leverage. This suggests that PF decoding may prioritize lower perplexity at the expense of detectability, raising questions about the balance between watermarking efficacy and text quality.
- PF decoding requires tuning the temperature T parameter to maximize detectability. Incorrect temperature settings could degrade performance, potentially limiting practical applications where robustness across diverse settings is essential.
- PF decoding involves a more complex computational process than softmax sampling, which can lead to higher computational costs, especially when handling large vocabulary sets. This complexity may restrict its applicability in real-time or resource-constrained environments.

---

confidence: 2
contribution: 4
initial_rating: 8
presentation: 4
questions: I have no questions.
soundness: 4
strengths: This paper successfully combines the results of previous studies such as McKenna & Sheldon (2020) and Aaronson (2023) in the context of LLMs research.
Theoretical guarantees are well organized and experimental performance verification is carried out sufficiently, and those make this study reliable.
The proposed method seems to have practical promise.
summary: In this paper, authors propose Permute-and-Flip (PF) decoding for large language models (LLMs),
With reference to McKenna & Sheldon (2020)’s differentially private selection mechanism.
It enjoys the same perturbation-stability guarantees as softmax sampling and achieves substantially lower perplexity.
They also design PF watermark tailored for PF decoding that enables precise control over false positive rates while retaining high true positive rates, with reference to Aaronson (2023)’s Gumbel watermark.
Theorems and experiments indicate that PF decoding a promising new approach for practical applications of LLMs.
weaknesses: I found no serious weakness.

---

confidence: 4
contribution: 2
initial_rating: 5
presentation: 2
questions: > A more fair comparison, would be to increase the temperature for PF watermark appropriately so we compare detectability when the suboptimality is aligned. This is shown in Figure 2b. In fact we have added a second baseline that apply Gumbel watermark to the induced sampling distribution from PF-decoding (shown as the dotted line). The distribution induced by PF does not have a simple form, but in our special case, it was worked out in Example 3.2.

After increasing the temperature of the PF watermark so that its detectability is on par with the Gumbel watermark, is the utility of PF still better than that of Gumbel?
soundness: 2
strengths: The application of the Permute and Flip (PF) mechanism to sampling text from a language model is an interesting idea. The paper supports its main claims (about the effectiveness of the watermark) with both theoretical and empirical evidence.
summary: The paper proposes sampling text from a language model using the Permute and Flip mechanism of McKenna and Sheldon—treating the token log probabilities as the "score" function to implement the mechanism—and proposes a method for watermarking text sampled from this mechanism.
weaknesses: Some parts of the overall problem formulation are not clear. For example, the stated goal is to maximize some utility function, in which case—unlike with differential privacy (i.e., the original context in which PF was proposed)—the optimal decoding strategy should be deterministic. The paper acknowledges as much but nonetheless argues in favor of using sampling via the following:

> That’s because there are other considerations besides text quality when selecting LLM decoders. For example,
computational efficiency and latency are hugely important, since each API call to the logits function is costly. The diversity of the generated text is also important, especially for creative tasks.

Several aspects of the above except are unclear. First, in what sense is greedy decoding more computationally expensive than sampling? Also, if diversity is important then why not formalize this as part of the problem statement (e.g., via the utility function)? Making these desiderata precise would help clarify the main problem statement and aid in comparing to prior work. For similar reasons, it's not clear what the motivation is for the stability property (Definition 2.1). The paper cites data poisoning and jailbreaking attacks as motivation, but the precise connection is not made explicit. The paper also mentions a connection between stability and diversity; however, if the only purpose of stability is to be a proxy for diversity, then why not just explicitly consider diversity? In general, being more explicit and rigorous about the problem formulation / desiderata would be helpful for clarity.

---

confidence: 4
contribution: 3
initial_rating: 6
presentation: 3
questions: please see above.
soundness: 3
strengths: 1. The proposed decoding method for LLMs is novel.
2. This paper provides theoretical proofs to support its statements.
summary: The paper introduces the PF decoding method for LLMs, which is designed to improve text generation stability while lowering perplexity compared to traditional sampling methods. This method enhances quality-stability balance and integrates a cryptographic watermark for AI-generated text detection, using a pseudo-random technique that makes it secure and resilient to adversarial modifications. PF decoding achieves lower perplexity than softmax sampling while maintaining stability, and the PF watermark allows for high detection accuracy with precise control over false positives.
weaknesses: 1. Could authors specify the difference between the PF watermark and the Exponential Minimum watermark proposed in [1].

2. Diversity is an important property of LLM sampling. Are there any metrics or experiments to measure the diversity of different decoding methods?

3. PF watermark provides lower perplexity compared to Gumbel-Max watermark. Could authors present the robustness performance among PF watermark and other watermarking methods, like a token replacement, etc?

4. In Table 1, the authors specify the beam search can not watermark, but [2] uses beam search. Moreover, could authors explain the reason why beam search is not stable?

[1]. http://arxiv.org/abs/2307.15593
[2]. http://arxiv.org/abs/2301.10226

---

confidence: 4
contribution: 3
initial_rating: 6
presentation: 2
questions: 1. Some symbols in the paper are not fully defined. For example, what does  E_{y∼PF(u)}[u(y)]  mean?

2.In Theorem 3.1,  u^*  is the maximum value of  u(y)  outputs. However, in point 4,  u^* - u(y)  is used. How should one interpret a number being subtracted from a set? Perhaps this is related to the previous question?
soundness: 3
strengths: 1. A novel LLM decoder algorithm is proposed, and compared to existing algorithms, the PF decoder offers better randomness, which may provide improved output adaptability for certain application scenarios.

2. The paper proposes a method for embedding watermarks using the PF decoder. It converts candidate output tokens into different values using a pseudo-random function, thereby altering the output probabilities of the tokens to embed the watermark information.
summary: The article introduces a novel decoder algorithm for LLMs. The proposed algorithm is based on the Permute-and-Flip (PF) method for differential privacy protection of data, which transforms the output of a dataset into independent sampling based on assigned probabilities to data elements. The paper also references an equivalent construction of PF, converting data sampling into random adjustments of the probability distribution of data elements, thereby outputting the element with the highest probability. This decoder algorithm can be used for embedding the output text, and the paper presents a watermark embedding algorithm based on the PF decoder. Compared to existing decoder algorithms, the paper demonstrates that the PF algorithm offers better stability.
weaknesses: 1. The description of the scheme in the paper is not very straightforward. The PF decoder designed in the paper is not directly based on the original Permute-and-Flip method, but on a variant algorithm. Although it cites (Ding et al., 2021) to illustrate that the two methods are equivalent, this paper is still in a preprint status.

2. The paper does not sufficiently explain the characteristics of the PF decoder. In Theorem 3.1, the paper cites several quantitative calculations from (McKenna & Sheldon 2020) but does not explain their significance. Especially since the original paper was not intended for LLM decoders, the impact on the characteristics of the decoder in this context is unclear.

3. The experimental results show that PF does not demonstrate a significant advantage over existing algorithms. For instance, in text generation, its PPL is not superior to the greedy algorithm, and in watermark embedding detection, its TPR results are also not better than the comparison schemes.

Meta-review: **Summary:**
This paper proposes the Permute-and-Flip (PF) decoder for large language models (LLMs), which is provably stable (Theorem 3.1-1), and has optimal stability-perplexity tradeoff (Theorem 3.1-5). It also proposes a new watermarking scheme which they call the PF watermark (Section 4), which allows watermarking of LLM-generated text.

**Strengths:**
- The proposal is based on the idea of PF sampling, which was invented in the literature of differential privacy, and that of the Report-Noisy-Max form of PF sampling, bringing them in the context of language model decoding.
- Theoretical justifications of the proposal are given in Theorems 3.1 and 4.3. Although Theorem 3.1 was a contribution in a different paper in a different context, bringing it to the context of LM decoding is novel.

**Weaknesses:**
Some reviewers raised concerns on description of the proposal and relation to relevant methods. 

**Reasons:**
Even though some theoretical results are from existing literature on differential privacy, the interdisciplinary nature of this paper can be evaluated highly.

Minor points:
- Page 6, line 291: exponential random variable(s)
- Facts 4.1 and 4.2: I would prefer enclosing the functions of $y$ to be maximized with a pair of parentheses, as in equation (6), in order to clarify the scope of the argmax operator.

Decision: Accept (Poster)