#  Quest: Quality-Aware Metropolis-Hastings Sampling for Machine Translation

Gonçalo R. A. Faria1, Sweta Agrawal1, António Farinhas1,2,
Ricardo Rei3, José G. C. de Souza3, André F.T. Martins1,2,3,4
1Instituto de Telecomunicações, 2Instituto Superior Técnico, Universidade de
Lisboa
3Unbabel, 4ELLIS Unit Lisbon
<EMAIL_ADDRESS>
###### Abstract

An important challenge in machine translation is to generate high-quality and
diverse translations. Prior work has shown that the estimated likelihood from
the MT model correlates poorly with translation quality. In contrast, quality
evaluation metrics (such as COMET or BLEURT) exhibit high correlations with
human judgments, which has motivated their use as rerankers (such as quality-
aware and minimum Bayes risk decoding). However, relying on a single
translation with high estimated quality increases the chances of “gaming the
metric”. In this paper, we address the problem of sampling a set of high-
quality and diverse translations. We provide a simple and effective way to
avoid over-reliance on noisy quality estimates by using them as the energy
function of a Gibbs distribution. Instead of looking for a mode in the
distribution, we generate multiple samples from high-density areas through the
Metropolis-Hastings algorithm, a simple Markov chain Monte Carlo approach. The
results show that our proposed method leads to high-quality and diverse
outputs across multiple language pairs (English$\leftrightarrow${German,
Russian}) with two strong decoder-only LLMs (Alma-7b, Tower-7b).

##  1 Introduction

Machine translation (MT) is becoming increasingly more accurate and powerful,
as it benefits from the many capabilities and acquired knowledge of large
language models (LLMs) (Freitag et al., 2023b; Hendy et al., 2023). However,
for many domains and languages the quality of translation is still not
satisfactory—for example, hallucinations or critical errors are a serious
issue when translating high-risk content, as in medical and legal domains
(Khoong et al., 2019; Taira et al., 2021; Shen et al., 2023; Guerreiro et al.,
2023b; Sanz-Valdivieso and López-Arroyo, 2023; Grimm et al., 2024). Developing
procedures for sampling higher-quality translations is therefore in high
demand.

It is known that the output quality of the translations generated by
maximizing the model likelihood is limited because of the inadequacy of the
mode—models tend to produce distributions over outputs that are highly peaked,
favoring a single hypothesis (Eikema and Aziz, 2020; Peters and Martins, 2021;
Eikema, 2024); and improving search often makes things worse (Koehn and
Knowles, 2017; Stahlberg and Byrne, 2019). In general, maximizing model
likelihood tends to overlook hypotheses that could be equally valid and more
appropriate in certain contexts. To address this limitation, a string of work
has been initiated towards “quality-aware decoding”, which leverages powerful
quality estimation (QE) and evaluation metrics, such as COMET (Rei et al.,
2022) or BLEURT (Yan et al., 2023), to explore and rerank a broader range of
candidate hypotheses generated via sampling from the model’s distribution,
selecting the best-1 (Freitag et al., 2022a; Fernandes et al., 2022b; Farinhas
et al., 2023) or the best-$k$ (Jinnai et al., 2024; Singhal et al., 2023)
according to these learned metrics.

Despite the benefits, reranking-based methods have their own drawbacks. There
is a risk of these approaches overfitting to the metrics used, potentially
leading to illusory gains in quality, as the translations obtained via
optimizing these metrics may not always be preferred by humans when compared
to other alternatives (Fernandes et al., 2022b). Secondly, their effectiveness
is limited by the quality of the initial candidate set. For instance, Vernikos
and Popescu-Belis (2024) show that many high-quality translations, generated
by combining translation hypotheses, are less likely to be sampled from the
model’s distribution even with a very large pool size.

One potential way to remedy these issues, which we explore in this paper, is
to use these automatic metric proxies as the energy function of a Gibbs
distribution. However, sampling hypotheses from this distribution presents a
difficult challenge: unlike likelihood-based sampling, “quality-based
sampling” from a Gibbs distribution cannot be performed autoregressively, and
it is intractable to enumerate and score all possible hypotheses. We address
this challenge by proposing a simple and effective Markov chain Monte Carlo
approach (MCMC) method, combining the Metropolis-Hastings algorithm with a
suitable proposal distribution. Our method, Quality-Aware Metropolis-Hastings
(Quest) Sampling, uses a novel proposal distribution that is compatible with
sentence-level evaluation metrics, common in text generation tasks like MT. We
further note that while we focus on MT, where automatic QE metrics are more
developed and robust, our proposed method is general and can be applied to
other natural language processing (NLP) tasks. Furthermore, as our method is
agnostic to the specific quality metric used in the Gibbs distribution, it can
directly benefit from any future improvements in the metrics.

We show that Quest sampling results in high-quality and diverse samples on
multiple test beds (WMT23 English $\leftrightarrow$ {German, Russian}) and
with multiple decoder-only LLMs (Tower-7b, Alma-7b). Our method generates many
novel hypotheses from the high-density regions unlikely to be generated via
ancestral sampling. Furthermore, with increasing chain size, average quality
as measured by automatic metrics continues to improve, unlike ancestral
sampling, where the candidate set quality remains unchanged even with a larger
pool size.111We release the code to replicate our experiments at
https://github.com/deep-spin/quest-decoding.

##  2 Background

###  2.1 Large Language Models for Machine Translation

Generating translations from autoregressive LLMs (either encoder-decoder or
decoder-only) involves conditioning the language model on a prompt $x$, which
is a sequence of tokens $(x_{1},x_{2},\ldots,x_{L})\in\mathcal{X}$ encoding
the text to be translated coupled with a translation instruction (Raffel et
al., 2020; Hendy et al., 2023). Let $\mathcal{V}$ be a fixed vocabulary and
$\mathcal{Y}=\mathcal{V}^{*}$ its Kleene closure. The joint distribution over
the output translations, $y\in\mathcal{Y}$, given the prompt $x$, can be
factorized as the product of conditional probabilities over individual tokens
$(y_{1},y_{2},\ldots,y_{N})$, where each $y_{i}\in\mathcal{V}$. The
probability of a particular translation $y$ for a given input $x$ can be
written as

$\displaystyle
p_{\text{LM}}(y|x)=\prod_{i=1}^{N}p_{\text{LM}}(y_{i}|y_{<i},x).$ (1)

Here, $y_{<i}:=(y_{1},y_{2},\ldots,y_{i-1})$. During inference, a translation
is generated by sampling one token at a time from the distribution
$p_{\text{LM}}(y_{i}|y_{<i},x)$, adjusted by a temperature, $\tau$. The
(adjusted) probability of generating a particular token $y_{i}$, given the
preceding tokens $y_{<i}$ and the input $x$, is defined as:

$p_{\text{LM},\tau}(y_{i}=v|y_{<i},x)=\frac{p_{\text{LM}}(y_{i}=v|y_{<i},x)^{1/\tau}}{\sum_{v^{\prime}\in\mathcal{V}}p_{\text{LM}}(y_{i}=v^{\prime}|y_{<i},x)^{1/\tau}}.$
(2)

Lower temperature values $\tau$ make the distribution more deterministic,
favoring the most probable tokens, whereas higher values make the distribution
flatter, approximating a uniform distribution.

However, multiple works have scrutinized the reliability of model likelihood
as a measure for translation quality (Ott et al., 2018; Stahlberg and Byrne,
2019; Eikema and Aziz, 2020; Freitag et al., 2022a; Eikema, 2024). Instead of
solely relying on the likelihood, these works advocate using an automatic
translation quality metric as a utility function for minimum Bayes risk (MBR)
decoding or reranking based on QE metrics. This shift not only improves the
selection of translations but also facilitates the exploration of the
underlying distribution learned by the models. However, it is crucial to
acknowledge that the overall translation quality is still contingent on the
quality of the candidate pool. We next discuss common automatic metrics used
for assessing translation quality.

###  2.2 Automatic Metrics for Machine Translation

Automatic quality assessment of machine-generated translations has received
considerable attention recently, resulting in metrics that attain high
correlations with human judgment of translation quality (Freitag et al.,
2022b, 2023b). These automatic metrics are meant to assess the quality of a
translation across multiple dimensions (e.g. fluency, adequacy) and can
provide reliable feedback when human judgments are unavailable. Among these
metrics, neural learned metrics that are trained on human translation quality
assessment scores or error span annotations have gained significant traction
(Rei et al., 2022; Yan et al., 2023; Guerreiro et al., 2023a; Perrella et al.,
2022).

For aligning automatically generated translations with human quality
preferences, many works have proposed to use automatic metrics as an
alternative to human feedback during MT training (Shen et al., 2016; Wieting
et al., 2019; He et al., 2024; Xu et al., 2024b) or decoding Shen et al.
(2004); Fernandes et al. (2022b); Freitag et al. (2022a, 2023a). Freitag et
al. (2022a) show the efficacy of using reference-based neural metrics as
utility functions for MBR decoding over lexical alternatives. Further,
Fernandes et al. (2022a) use QE metrics like Comet-QE to select 1-best or
N-best translations from a pool of candidate hypotheses. Their analysis shows
that while these automatic metrics can be useful, they might not always
reflect human preferences accurately. Additionally, extra care has to be taken
when optimizing systems for these metrics, as the improvements might be
attributable to overfitting or “gaming the metric”, rather than being genuine
improvements in translation quality. Nevertheless, these metrics encode useful
information about the quality of translations and can still be useful to
obtain high-quality translations.

##  3 An MCMC-based Decoding Approach for Text Generation

Given that we have access to an automatic metric that quantifies how desirable
a particular translation is, we aim to address the following questions:

Can we sample directly in proportion to their corresponding quality values?
Can we use automatic metrics that already give us a reliable estimate of
human-perceived quality to achieve that? Finally, can we use this process to
obtain diverse high-quality samples?

To answer these questions and to address the limitations of quality-aware
decoders, we propose to take an alternative approach, quality-aware sampling,
which ensures high quality and diversity. Recognizing that naturally occurring
texts can have numerous valid translations (Nida, 1964; Dreyer and Marcu,
2012; Ott et al., 2018; Mayhew et al., 2020), the ability to generate diverse
translation hypotheses is paramount.

To this end, we first present background on Metropolis-Hastings in Section
3.1. Section 3.2 discusses our proposal distribution. Finally, we connect our
approach to reinforcement learning with human feedback (RLHF) in Section 3.3.

###  3.1 Metropolis-Hastings

The problem of sampling translation hypotheses in proportion to a metric,
$r(x,y)$, can be framed as sampling from the following Gibbs distribution:

$\pi_{\beta}(y|x)=\frac{1}{Z_{\beta}(x)}\exp\left(\frac{r\left(y,x\right)}{\beta}\right),$
(3)

where $Z_{\beta}(x)=\sum_{y}\exp\left(\frac{r\left(y,x\right)}{\beta}\right)$
and $\beta$ is the temperature of the Gibbs distribution. We denote the
corresponding unnormalized density by $\tilde{\pi}_{\beta}(y|x)$, which unlike
$Z_{\beta}(x)$ can be evaluated for any $(x,y)$.

While several algorithms have been proposed to sample approximately from such
intractable distributions (Miao et al., 2018; Berglund et al., 2015; Amini et
al., 2023), we resort to Metropolis-Hastings (Metropolis et al., 1953, MH) due
to its simplicity and flexibility in handling a wide range of proposal
distributions. The MH algorithm generates a sequence of samples from a target
distribution, here $\pi_{\beta}(y|x)$, by constructing a Markov chain
$(y^{0},y^{1},\ldots,y^{T})$ that has $\pi_{\beta}(y|x)$ as its equilibrium
distribution. It starts from an arbitrary hypothesis $y^{0}$. In the
$t\textsuperscript{th}$ iteration, it draws a new hypothesis $y$ from a
proposal distribution $q(y|y^{t},x)$. This hypothesis is accepted with an
acceptance probability $\alpha_{\beta}(y,y^{t})\in[0,1]$ given by:

$\alpha_{\beta}(y,y^{t})=\min\left\\{1,\,\,\frac{{\pi}_{\beta}\left(y|x\right)q\left(y^{t}|y,x\right)}{{\pi}_{\beta}\left(y^{t}|x\right)q\left(y|y^{t},x\right)}\right\\}.$
(4)

If the candidate $y$ is accepted, the next state in the chain becomes
$y^{t+1}=y$; if rejected, the chain stays at $y^{t+1}=y^{t}$. The process
repeats for some number of steps $T$ and in the end it returns the hypothesis
$y^{T}$. Note that, while computing the likelihood $\pi_{\beta}(y|x)$ of a
particular hypothesis $y$ under the Gibbs distribution is intractable (due to
the intractable partition function $Z_{\beta}(x)$), evaluating the acceptance
criterion $\alpha_{\beta}(y,y^{t})$ is easy, because it depends only on the
likelihood ratio, in which the normalization constants cancel out, i.e.:

$\frac{{\pi}_{\beta}(y|x)}{{\pi}_{\beta}(y^{t}|x)}=\frac{\tilde{\pi}_{\beta}(y|x)}{\tilde{\pi}_{\beta}(y^{t}|x)}=\exp\left(\frac{r\left(y,x\right)-r\left(y^{t},x\right)}{\beta}\right).$
(5)

MH converges to the unique stationary distribution $\pi_{\beta}(y|x)$,
regardless of the initial distribution we start with, if the transition
distribution of the Markov chain, i.e.,
$p(y^{t}|y^{t-1},x)=q(y^{t}|y^{t-1},x)\alpha(y^{t},y^{t-1})$ satisfies the
Markov chain ergodic theorem (Neal, 2011).

This requires a suitable proposal distribution $q(y|y^{t},x)$ which must be
irreducible and aperiodic. To ensure irreducibility, the proposal distribution
should have sufficient support, such that it is possible to transition from
any state to any other state with a nonzero probability in a finite number of
steps. Aperiodicity ensures that the Markov chain does not get stuck in a
cyclic behavior, where it keeps returning to the same states in a fixed
pattern. Additionally, due to the acceptance criterion defined in Eq. 4, the
transition distribution satisfies the detailed balance condition:

${\pi}_{\beta}\left(y|x\right)p\left(y^{t}|y,x\right)={{\pi}_{\beta}\left(y^{t}|x\right)p\left(y|y^{t},x\right)}.$
(6)

It is trivial to show that the chain has the target distribution,
$\pi_{\beta}(y|x)$ as its stationary distribution:

$\pi_{\beta}(y|x)=\sum_{y^{\prime}\in\mathcal{Y}}p(y|y^{\prime},x)\pi_{\beta}(y^{\prime}|x).$
(7)

Note that MH can work with almost any proposal distribution. However, if the
detailed balance conditions are far from holding, the acceptance probability
will be low for transitions, making the convergence to the target distribution
very slow and the approach impractical. Hence, choosing a suitable proposal
distribution for the task is essential. We next describe our proposal
distribution, $q(y|y^{t},x)$, which overcomes these limitations and satisfies
the required constraints.

###  3.2 Proposal distribution

Previous works (Berglund et al., 2015; Miao et al., 2018; Su et al., 2018) use
proposal distributions that generate hypotheses with one-word or token-level
modifications. The different formulations in their most basic form propose a
Markov chain in which the state comprises the sentence $y^{t}\in\mathcal{Y}$
and an index variable $i^{t}\in\\{0,\ldots,|y^{t-1}|\\}$. At every step, an
index is sampled that determines the token to be changed, and a new token is
then sampled based on the following full conditional distribution:

$q(y_{i}|y_{<i},y_{>i})=\frac{\tilde{\pi}(y_{<i},y_{i},y_{>i})}{\sum_{{y_{i}^{\prime}}\in\mathcal{V}}\tilde{\pi}(y_{<i},{y_{i}^{\prime}},y_{>i})},$
(8)

where $\mathcal{V}$ is created by considering the $k$ most likely tokens ($k$
is generally large) under $p_{\text{LM}}(y_{i}|y_{<i})$.

This procedure, however, has several limitations: first, it makes it difficult
to handle more general combinatorial constraints, in our case more
sophisticated metrics. As we only explore adjacent positions in the sentence
space due to small local changes, the Markov chain risks becoming trapped in
infeasible states, necessitating a very large number of steps $T$ to converge.
Second, relying solely on token-level modifications makes it exceedingly
difficult to generate plausible text, making it impractical to align
generations with QE metrics or general reward models. We show that this is
indeed the case in Section 5.2.

We instead propose a simple and effective procedure that only requires
generating a single hypothesis from the model $p_{\text{LM}}$ and a single
evaluation from the metric, $r(y,x)$, and still allows the Markov chain to
converge to the target distribution. We characterize the proposal by the
following procedure:

  1. 1.

Given an instance $y^{t}$ with length $n^{t}:=|y^{t}|$, sample an index $i$,
$i\sim q(i|n^{t})$.

  2. 2.

Generate a completion $y_{\geq i}$ from $p_{\text{LM}}(y_{\geq
i}|y^{t}_{<i},x)$.

Note that, due to the nature of our proposal distribution, $y^{t}$ and $y$
share a common substructure (prefix) before the index $i$, i.e.,
$y^{t}_{<i}=y_{<i}$, which implies that

$q(y|y^{t},x,i)=p_{\text{LM}}(y_{\geq
i}|y^{t}_{<i},x)\prod_{j<i}\delta(y_{j},y^{t}_{j}),$ (9)

where $\delta(y_{j},y^{t}_{j})$ is the Kronecker delta function, which assigns
zero probability to prefix tokens which are different from $y^{t}_{<i}$ and
probability one to tokens matching the prefix.

The complete proposal when we include the index distribution $q({i}|n^{t})$,
which depends on the previous sentence lengths $n^{t}:=|y^{t}|$, is given as

$q(y,{i}|y^{t},x)=q(i|n^{t})p_{\text{LM}}(y_{i\geq}|y^{t}_{<i},x)\prod_{j<i}\delta(y_{j},y^{t}_{j}).$
(10)

Algorithm 1 QUality-Aware mEtropolis-HaSTings (Quest) Sampling

1:Input: $x$, $p_{\text{LM}}$, $r$, $T$

2:Hyperparameters: $\tau$, $t_{\text{burning}}$, $\beta$

3:Sample initial response $y_{0}\sim p_{\text{LM}}(\cdot\mid x)$

4:$t\leftarrow 1$

5:for $1\text{ to }T$ do

6: Sample index $i\sim q(i|n^{t-1})$

7: Sample ${y}_{\geq i}\sim p_{\text{LM}}(\cdot|y_{<i}^{t-1},x)$

8: $y\leftarrow(y_{<i}^{t-1},{y}_{\geq i})$

9: Compute $\alpha_{\beta}(y,y^{t-1})$ through Eq. 4

10: Sample $\alpha$ uniformly in $[0,1]$

11: if $\alpha\leq\alpha_{\beta}(y,y^{t-1})$ then

12: $y^{t}\leftarrow y$

13: $t\leftarrow t+1$

14: end if

15:end for

16:return $y^{t_{\text{burning}}},\ldots,y^{t}$

We will use the uniform distribution as the index distribution, i.e.,
$q(i|n^{t})={1}/{n^{t}}$ for each $i\in[n^{t}]$, unless otherwise stated.
Algorithm 1 describes the complete sampling process.

This proposal is both irreducible and aperiodic as there is a non-zero
probability of going from a particular sentence to any other sentence and
back. When $i=0$, we can generate any text from the language model, which,
when using ancestral sampling, implies that we can sample any possible
sequence. As our approach only requires access to the token-level log
probabilities and the ability to generate good continuations given a prefix,
it can also be used with closed LLMs through an API as long as the it provides
access to the sample likelihoods. However, we limit our experiments to open-
source models due to the incurred cost and lack of training details about
these black-box models.

###  3.3 Connections to Reinforcement Learning with Human Feedback

Reinforcement Learning with Human Feedback (RLHF) leverages human feedback to
guide the learning process of complex NLP tasks (Stiennon et al., 2022;
Fernandes et al., 2023; Kaufmann et al., 2023). The process is as follows.
Given a language model, one generates hypotheses $y\in\mathcal{Y}$ given an
input prompt $x$ and gathers human feedback about which outputs are
preferable. This preference data is then used to train a proxy reward model
$r_{\phi}(y,x)$. Finally, reinforcement learning (RL) methods are used to
optimize the original LM with respect to the reward model, following

$\max_{\pi}\mathbb{E}_{x\sim\mathcal{D},y\sim\pi(y|x)}\left[\frac{r_{\phi}(x,y)}{\beta}\right]-D_{\text{KL}}\left[\pi(y|x)\parallel
p_{\text{LM}}(y|x)\right].$ (11)

Many works show that the optimal solution to the KL-constrained reward
maximization objective takes the form (Peters and Schaal, 2007; Peng et al.,
2019; Korbak et al., 2022b, a; Go et al., 2023):

$\pi(y|x)=\frac{1}{Z_{\beta}(x)}p_{\text{LM}}(y|x)\exp\Bigg{(}\frac{r(y,x)}{\beta}\Bigg{)},$
(12)

where
$Z_{\beta}(x)=\sum_{y\in\mathcal{Y}}p_{\text{LM}}(y|x)\exp\left(\frac{r\left(x,y\right)}{\beta}\right)$.
While we cannot sample autoregressively from this distribution, this density
can be represented as a Gibbs distribution with the corresponding reward
function $\tilde{r}(x,y)=\log p_{\text{LM}}(y|x)+\frac{r(x,y)}{\beta}$.

Instead of the target distribution expressed in Eq. 3, we could define the
above distribution as our target when using Quest to sample from it, avoiding
optimizing the objective in Eq. 11 directly. If we formulate the acceptance
criterion using this target density and our proposal distribution introduced
in Eq. 10, we obtain the following:

$\alpha_{\beta}(y,y^{t})=\max\left\\{1,\exp\left(\frac{r\left(y,x\right)-r\left(y^{t},x\right)}{\beta}\right)\frac{q(i|n)}{q(i|n^{t})}\right\\}.$
(13)

The full derivation is in Appendix A. Using this approach, we can align
language model generations without access to the model weights, log
probabilities, or RL. We provide a preliminary experimental comparison using
the two target distributions (Eq. 3 and Eq. 12) using Quest in Appendix D.

##  4 Experimental Settings

#### Data and Evaluation

We test our approach on the WMT23 test sets (Kocmi et al., 2023) covering four
language pairs, English $\leftrightarrow$ {German, Russian}.

We evaluate the quality and the diversity of the generated texts as follows.
Suppose $\bar{\mathcal{Y}}$ is the set of hypotheses generated for the source
text $x$ with reference hypothesis $y^{\star}$ and
$\mathcal{D}=\\{(x,y^{\star},\bar{\mathcal{Y}})\\}$ represents the evaluation
set. We compute the mean quality over each set of hypotheses using xComet-XL
(Guerreiro et al., 2023a) as
$\frac{1}{|\mathcal{D}|}\sum_{(x,y^{\star},\bar{\mathcal{Y}})\in\mathcal{D}}\frac{1}{|\bar{\mathcal{Y}}|}\sum_{y\in\bar{\mathcal{Y}}}\text{{xComet-
XL}}(x,y,y^{\star})$. Similarly, we measure the mean diversity using the
average pairwise BLEU (Papineni et al., 2002; Shen et al., 2019) as
$1-\frac{1}{|\mathcal{D}|}\sum_{(x,y^{\star},\bar{\mathcal{Y}})\in
D}\frac{1}{|\bar{\mathcal{Y}}|(|\bar{\mathcal{Y}}|-1)}\sum_{(y,y^{\prime})\in\bar{\mathcal{Y}}^{2}\,\,\text{s.t.}\,\,y\neq
y^{\prime}}\text{{BLEU}}(y,y^{\prime})$.222https://github.com/mjpost/sacrebleu/tree/master

#### Models

We use Tower-7b (Alves et al., 2024, Unbabel/TowerInstruct-7B-v0.2) and
Alma-7b (Xu et al., 2024a, haoranxu/ALMA-7B), two strong decoder-only MT
models based on Llama2-7b (Touvron et al., 2023) as these models achieve
competitive translation quality with GPT-4 and productized models like Google
Translate. Unlike Alma-7b, Tower-7b uses bilingual MT data as well as datasets
from MT-related tasks during training. Prompts are shown in Appendix B.

#### Automatic Metrics for Quest

We use CometKiwi-XL (Rei et al., 2023), a reference-free QE model built on top
of XLM-R XL (Goyal et al., 2021) and trained to predict human-rated direct
assessments (Graham et al., 2013). This metric showed the highest correlations
with human judgments on the QE Shared Task organized by the eighth conference
on Machine Translation (WMT 2023) Blain et al. (2023). We transform the
normalized scores from the QE model into $z$-scores using a logit
transformation with clamping applied to mitigate overflow.

#### Decoding Configurations

For ancestral sampling, we consider temperature values $\tau$ between $0.2$
and $1.0$, with an equally spaced interval of $0.1$. For generations with
Quest, we sample from the proposal distribution using $\tau=0.8$ and vary the
parameter $\beta$ of the target Gibbs distribution from the following range of
values $\\{0.01,0.02,0.05,0.1,0.2,0.5,1.0\\}$. The number of ancestral samples
and decoding steps are both set to 128. We use VLLM (Kwon et al., 2023), a
high-throughput and memory-efficient inference engine for generating outputs.

#### Compute Comparison: Ancestral Vs Quest

We use the number of output tokens as a metric to compare the different
approaches. For the sake of simplicity, let us assume that the output sentence
has a fixed size of $N$. On average, Quest in $T$ steps generates
$\big{(}\frac{T-1}{2}+1\big{)}N=\frac{(T+1)N}{2}$ tokens, $N$ tokens for the
initial hypothesis, and then on average $\frac{N}{2}$ tokens for the remaining
$T-1$ steps in the chain. If we contrast against sampling $T$ sentences using
ancestral sampling, we decode $T\times N$ tokens. This suggests that for an
equal number of samples generated using ancestral sampling and Quest, the
latter results in about $\frac{2T}{(T+1)}\approx 2$ times as many tokens, on
average. Note, however, that the computational cost of Quest is higher than
ancestral sampling, as the hypotheses are generated sequentially and evaluated
at every step. We run our experiments on NVIDIA RTX A6000 GPUs. Each ancestral
sampling and Quest for run with $T=128$ takes, on average, 1 hour and 6 hours,
respectively, for 2000 unique source texts on a single GPU. The compute
bottleneck for Quest also arises from using a large QE metric, potentially
distilling this metric into smaller models could help reduce the compute time.
We leave this to future work.

##  5 Results

###  5.1 Main Findings

The main results of our experiments are presented in Figure 1.

Figure 1: Average quality vs. diversity on WMT23 datasets. Different points
represent different hyperparameter values. Quest outperforms ancestral
sampling in six out of eight settings.

Quest results in better translation quality-diversity trade-offs. Across
language directions and models, the samples generated by Quest tend to have
better or similar quality than ancestral sampling as measured by xComet-XL. As
Quest does not directly use the reference metric, xComet-XL, we reduce the
chance of overfitting to the metric and thus the gains represent the ability
of Quest to improve translation quality more realistically. The benefits of
the proposed approach are more noticeable when translating from English (en
$\rightarrow$ {de, ru}). Specifically, for En $\leftrightarrow$ Ru, our model
improves xComet-XL by up to 2 points for both language models, showing the
efficacy of Quest over ancestral sampling.

Although ancestral exhibits better quality than Quest for De-En, further
analysis suggests that this discrepancy may stem from the constraints of the
QE metric used to model the translation preferences. Notably, Quest
demonstrates significantly higher CometKiwi-XL scores across the board (see
Appendix Figure 4), suggesting that better and more robust QE models can
result in improved translation quality.333Kocmi et al. (2024) report that a
difference of $2.7$ CometKiwi-XL on average is statistically significant with
a 98.9% accuracy. Quest improvements are always greater than this value across
the board. Furthermore, WMT23 De-En includes short passages that might require
additional steps to reach the high-density regions. Based on a length analysis
(See Appendix C.3), we observe that the quality of Quest lags behind ancestral
sampling, specifically for longer sentences. We leave the exploration of
finding optimal steps for convergence and adapting the proposal distribution
for document-level MT to future work.

###  5.2 Ablation Analysis

We present further analysis on some properties of our proposed approach using
WMT23 En$\rightarrow$Ru datasets with translations generated using Alma-7b.

(a) Sample Overlap between ancestral and Quest.

(b) Average quality over MCMC steps and number of ancestral samples $t$.

(c) Distribution of # of accepted samples: high $\beta$ results in higher
acceptance rates.

(d) Reward differences between an initial hypothesis and proposal hypotheses
given the initial hypothesis.

####  Quest generates less-likely high-quality samples.

We compute the set overlap for Quest and ancestral samples ($T=128$) with an
independent draw of 512 ancestral samples to investigate whether our approach
results in hypotheses from unexplored regions (Fig. 2(a)). Compared to
ancestral, Quest results in hypotheses that are not found in the larger pool
(4$\times$) of ancestral samples as illustrated by a higher mass at the
overlap value of 0. This demonstrates that Quest effectively gets to regions
of the output manifold that would be less likely sampled by the LM and still
attain, on average, better quality and diversity.

#### Average reward improves over decoding steps.

Figure 2(b) shows the average reward with increasing decoding steps and the
sample size for Quest and ancestral respectively. As ancestral results in
independent samples, the mean reward estimate remains unchanged for different
sample sizes. However, for Quest, hypotheses are gradually sampled in the
direction of higher-quality regions, closer to the target density, resulting
in increased average reward with more steps. We can also observe that the
standard deviation of the reward over all samples decreases with the
increasing number of steps, suggesting that the model eventually reaches a
better target distribution.

#### High $\beta$ value results in higher acceptance rates.

Figure 2(c) shows the distribution of accepted samples when varying $\beta$,
considering all (blue) versus unique (red) accepted samples. As expected, on
average, the number of accepted samples is smaller than the number of steps
$T$ depending upon the rejection rate—low $\beta$ values lead to higher
rejection rates. Furthermore, within the accepted samples, we also observe
many repeats. This can be attributed to the observation that the language
model has a low entropy distribution for continuations when the sample indices
lie at the end of sentences. Moreover, for probable sentences, only a few have
a high reward, which could result in the Markov chain getting stuck in a
particular state. Increasing the temperature of the LM or adjusting the index
distribution to have less density in the last few tokens could potentially
reduce the number of repeats. We leave this exploration to future work.

#### Our sentence-level proposal generates better candidates.

For a random example sampled from the WMT23 dataset, we generate $25$k
hypotheses using three proposal distributions: a) token-level modification
with uniform probability b) token-level modification with full posterior
presented in Eq. 8, and c) our sentence-level proposal (Eq. 10) and calculate
the reward differences between the original ($y$) and the generated hypothesis
($y^{\prime}$): $r(y^{\prime},x)-r(y,x)$. Figure 2(d) shows its distribution:
for proposals (a) and (b), the reward for the generated hypotheses is almost
always lower than the initial translation. On the other hand, our proposal
results in assigning half of the probability mass to hypotheses that improve
over $y$, leading to faster convergence over token-level alternatives.

##  6 Related Work

#### Sampling from Intractable Gibbs distributions.

Several methods have been proposed to sample approximately from Gibbs
distributions in text generation using autoregressive and masked-language
models. Prior works (Miao et al., 2018; Zhang et al., 2020) use MH with a
proposal distribution that makes token-level modifications for constrained
generation tasks. Since masked language models (MLM) do not have a
straightforward mechanism for sampling text, MCMC has been widely explored
using variations of Gibbs sampling (Berglund et al., 2015; Su et al., 2018;
Wang and Cho, 2019; Yamakoshi et al., 2022). However, Goyal et al. (2022)
shows that the masked conditional distributions from MLMs result in invalid
Gibbs samplers and, therefore, proposes to use MH on the masked conditionals,
resulting in higher-quality text. Mireshghallah et al. (2022); Forristal et
al. (2023) build on this work and use MLMs for sampling from Gibbs
distributions. Some works (Kumar et al., 2022; Qin et al., 2022; Amini et al.,
2023; Du et al., 2023) also adapt the Hamiltonian MCMC algorithms originally
designed for high-dimensional continuous distributions for the discrete
scenario (Duane et al., 1987; Neal, 2011). Furthermore, Hu et al. (2024) apply
GFlowNets (Bengio et al., 2021) to fine-tune language models for solving
posterior inference problems, which can be considered as sampling in
proportion to an intractable Gibbs distribution. In our work, we instead aim
to use MCMC for MT to sample translations in proportion to a sentence-level
evaluation metric.

#### Diverse Decoding for Machine Translation.

Variants of beam search (Cho, 2016; Vijayakumar et al., 2017; Kulikov et al.,
2019; Tam, 2020) have been proposed to produce a diverse set of translations
using diversity-promoting objectives. However, the increased computation cost
with the model size and beam width makes it infeasible and impractical to use
with LLMs and it fails to yield consistent improvement over ancestral with an
increase in beam width (Stahlberg and Byrne, 2019; Eikema and Aziz, 2020; Pang
et al., 2024). Quality-aware decoding approaches on the other hand are almost
always used to generate a single best hypothesis. Concurrently, Jinnai et al.
(2024) add diversity promoting objective to MBR decoding to generate a set of
high-quality diverse candidates. However, their approach only allows for the
selection of hypotheses from a predefined set. We further note that we do not
directly promote diversity—rather, diverse translations are a side product of
efficiently exploring multiple high-quality regions from the model’s
distribution.

##  7 Conclusion

We propose a new decoding approach for MT, QUality-Aware mEtropolis-HaSTings
(Quest) sampling based on MCMC that enables the generation of hypotheses in
proportion to an automatic QE metric. We present a simple and novel proposal
distribution that satisfies the constraints imposed by the Metropolis-Hastings
algorithm. Our experiments on four language directions and two strong decoder-
only language models show the efficacy of our approach over baselines. We
further show that our approach results in samples from underexplored high-
density regions and that the average quality continues to improve as the
Markov chain size increases.

##  8 Limitations and Broad Impact

Quest requires generating many samples to reach high-density regions
sequentially from an LLM for each input prompt, which can be computationally
expensive for time-critical applications. Additionally, the required number of
steps may vary depending on the input and the quality of the initial
hypothesis. Furthermore, our proposal distribution only modifies the sentence
suffix, which becomes restrictive once the chain reaches a high-quality
region. As at this point, only minor changes to the hypothesis are accepted,
slowing the mixing process. Addressing these limitations and extending this
approach to other NLP tasks are avenues for future work.

Furthermore, we leverage recent advances in QE methods for MT and integrate
them directly in the generation process of LLMs, which can potentially reduce
the errors generated by these systems. However, despite the high correlations
of evaluation metrics with human judgments, they are sometimes hard to
interpret and occasionally fail to detect simple mistakes such as incorrect
translations of numbers or entities (Amrhein and Sennrich, 2022). In such
cases, sampling from the Gibbs distributions induced by these metrics might
increase the chances of sampling those erroneous translations. We believe
these risks will be mitigated as better metrics are constantly being
developed—our method, being agnostic to the specific quality metric, will
directly benefit from it. In addition, since Quest supports any Gibbs
distribution, it can also incorporate multiple QE models or additional checks
which can rule out problematic samples by assigning them a very low QE score.

## Acknowledgments

We thank Ben Peters, Marcos Treviso, and Sergey Troshin for their helpful and
constructive feedback on the initial versions of the paper. Part of this work
was supported by the EU’s Horizon Europe Research and Innovation Actions
(UTTER, contract 101070631), by the project DECOLLAGE (ERC-2022-CoG
101088763), by the Portuguese Recovery and Resilience Plan through project
C645008882- 00000055 (Center for Responsible AI), and by Fundação para a
Ciência e Tecnologia through contract UIDB/50008/2020.

## References

  * Alves et al. (2024) Duarte M. Alves, José Pombal, Nuno M. Guerreiro, Pedro H. Martins, João Alves, Amin Farajian, Ben Peters, Ricardo Rei, Patrick Fernandes, Sweta Agrawal, Pierre Colombo, José G. C. de Souza, and André F. T. Martins. 2024.  Tower: An open multilingual large language model for translation-related tasks.
  * Amini et al. (2023) Afra Amini, Li Du, and Ryan Cotterell. 2023.  Structured voronoi sampling.
  * Amrhein and Sennrich (2022) Chantal Amrhein and Rico Sennrich. 2022.  Identifying weaknesses in machine translation metrics through minimum Bayes risk decoding: A case study for COMET.  In _Proceedings of the 2nd Conference of the Asia-Pacific Chapter of the Association for Computational Linguistics and the 12th International Joint Conference on Natural Language Processing (Volume 1: Long Papers)_ , pages 1125–1141, Online only. Association for Computational Linguistics.
  * Bengio et al. (2021) Emmanuel Bengio, Moksh Jain, Maksym Korablyov, Doina Precup, and Yoshua Bengio. 2021.  Flow network based generative models for non-iterative diverse candidate generation.
  * Berglund et al. (2015) Mathias Berglund, Tapani Raiko, Mikko Honkala, Leo Kärkkäinen, Akos Vetek, and Juha Karhunen. 2015.  Bidirectional recurrent neural networks as generative models - reconstructing gaps in time series.
  * Blain et al. (2023) Frederic Blain, Chrysoula Zerva, Ricardo Rei, Nuno M. Guerreiro, Diptesh Kanojia, José G. C. de Souza, Beatriz Silva, Tânia Vaz, Yan Jingxuan, Fatemeh Azadi, Constantin Orasan, and André Martins. 2023.  Findings of the WMT 2023 shared task on quality estimation.  In _Proceedings of the Eighth Conference on Machine Translation_ , pages 629–653, Singapore. Association for Computational Linguistics.
  * Cho (2016) Kyunghyun Cho. 2016.  Noisy parallel approximate decoding for conditional recurrent language model.  _arXiv preprint arXiv:1605.03835_.
  * Dreyer and Marcu (2012) Markus Dreyer and Daniel Marcu. 2012.  Hyter: Meaning-equivalent semantics for translation evaluation.  In _Proceedings of the 2012 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies_ , pages 162–171.
  * Du et al. (2023) Li Du, Afra Amini, Lucas Torroba Hennigen, Xinyan Velocity Yu, Jason Eisner, Holden Lee, and Ryan Cotterell. 2023.  Principled gradient-based markov chain monte carlo for text generation.
  * Duane et al. (1987) Simon Duane, A.D. Kennedy, Brian J. Pendleton, and Duncan Roweth. 1987.  Hybrid monte carlo.  _Physics Letters B_ , 195(2):216–222.
  * Eikema (2024) Bryan Eikema. 2024.  The effect of generalisation on the inadequacy of the mode.  In _Proceedings of the 1st Workshop on Uncertainty-Aware NLP (UncertaiNLP 2024)_ , pages 87–92, St Julians, Malta. Association for Computational Linguistics.
  * Eikema and Aziz (2020) Bryan Eikema and Wilker Aziz. 2020.  Is MAP decoding all you need? the inadequacy of the mode in neural machine translation.  In _Proceedings of the 28th International Conference on Computational Linguistics_ , pages 4506–4520, Barcelona, Spain (Online). International Committee on Computational Linguistics.
  * Farinhas et al. (2023) António Farinhas, José de Souza, and Andre Martins. 2023.  An empirical study of translation hypothesis ensembling with large language models.  In _Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing_ , pages 11956–11970, Singapore. Association for Computational Linguistics.
  * Fernandes et al. (2022a) Patrick Fernandes, António Farinhas, Ricardo Rei, José G. C. de Souza, Perez Ogayo, Graham Neubig, and Andre Martins. 2022a.  Quality-aware decoding for neural machine translation.  In _Proceedings of the 2022 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies_ , pages 1396–1412, Seattle, United States. Association for Computational Linguistics.
  * Fernandes et al. (2022b) Patrick Fernandes, António Farinhas, Ricardo Rei, José G. C. de Souza, Perez Ogayo, Graham Neubig, and André F. T. Martins. 2022b.  Quality-aware decoding for neural machine translation.
  * Fernandes et al. (2023) Patrick Fernandes, Aman Madaan, Emmy Liu, António Farinhas, Pedro Henrique Martins, Amanda Bertsch, José G. C. de Souza, Shuyan Zhou, Tongshuang Wu, Graham Neubig, and André F. T. Martins. 2023.  Bridging the Gap: A Survey on Integrating (Human) Feedback for Natural Language Generation.  _Transactions of the Association for Computational Linguistics_ , 11:1643–1668.
  * Forristal et al. (2023) Jarad Forristal, Niloofar Mireshghallah, Greg Durrett, and Taylor Berg-Kirkpatrick. 2023.  A block metropolis-hastings sampler for controllable energy-based text generation.
  * Freitag et al. (2023a) Markus Freitag, Behrooz Ghorbani, and Patrick Fernandes. 2023a.  Epsilon sampling rocks: Investigating sampling strategies for minimum Bayes risk decoding for machine translation.  In _Findings of the Association for Computational Linguistics: EMNLP 2023_ , pages 9198–9209, Singapore. Association for Computational Linguistics.
  * Freitag et al. (2022a) Markus Freitag, David Grangier, Qijun Tan, and Bowen Liang. 2022a.  High quality rather than high model probability: Minimum Bayes risk decoding with neural metrics.  _Transactions of the Association for Computational Linguistics_ , 10:811–825.
  * Freitag et al. (2023b) Markus Freitag, Nitika Mathur, Chi-kiu Lo, Eleftherios Avramidis, Ricardo Rei, Brian Thompson, Tom Kocmi, Frederic Blain, Daniel Deutsch, Craig Stewart, Chrysoula Zerva, Sheila Castilho, Alon Lavie, and George Foster. 2023b.  Results of WMT23 metrics shared task: Metrics might be guilty but references are not innocent.  In _Proceedings of the Eighth Conference on Machine Translation_ , pages 578–628, Singapore. Association for Computational Linguistics.
  * Freitag et al. (2022b) Markus Freitag, Ricardo Rei, Nitika Mathur, Chi-kiu Lo, Craig Stewart, Eleftherios Avramidis, Tom Kocmi, George Foster, Alon Lavie, and André F. T. Martins. 2022b.  Results of WMT22 metrics shared task: Stop using BLEU – neural metrics are better and more robust.  In _Proceedings of the Seventh Conference on Machine Translation (WMT)_ , pages 46–68, Abu Dhabi, United Arab Emirates (Hybrid). Association for Computational Linguistics.
  * Go et al. (2023) Dongyoung Go, Tomasz Korbak, Germán Kruszewski, Jos Rozen, Nahyeon Ryu, and Marc Dymetman. 2023.  Aligning language models with preferences through f-divergence minimization.
  * Goyal et al. (2022) Kartik Goyal, Chris Dyer, and Taylor Berg-Kirkpatrick. 2022.  Exposing the implicit energy networks behind masked language models via metropolis–hastings.
  * Goyal et al. (2021) Naman Goyal, Jingfei Du, Myle Ott, Giri Anantharaman, and Alexis Conneau. 2021.  Larger-scale transformers for multilingual masked language modeling.  In _Proceedings of the 6th Workshop on Representation Learning for NLP (RepL4NLP-2021)_ , pages 29–33, Online. Association for Computational Linguistics.
  * Graham et al. (2013) Yvette Graham, Timothy Baldwin, Alistair Moffat, and Justin Zobel. 2013.  Continuous measurement scales in human evaluation of machine translation.  In _Proceedings of the 7th Linguistic Annotation Workshop and Interoperability with Discourse_ , pages 33–41, Sofia, Bulgaria. Association for Computational Linguistics.
  * Grimm et al. (2024) David R Grimm, Yu-Jin Lee, Katherine Hu, Longsha Liu, Omar Garcia, Karthik Balakrishnan, and Noel F Ayoub. 2024.  The utility of chatgpt as a generative medical translator.  _European Archives of Oto-Rhino-Laryngology_ , pages 1–5.
  * Guerreiro et al. (2023a) Nuno M. Guerreiro, Ricardo Rei, Daan van Stigt, Luisa Coheur, Pierre Colombo, and André F. T. Martins. 2023a.  xcomet: Transparent machine translation evaluation through fine-grained error detection.
  * Guerreiro et al. (2023b) Nuno Miguel Guerreiro, Duarte M Alves, Jonas Waldendorf, Barry Haddow, Alexandra Birch, Pierre Colombo, and André FT Martins. 2023b.  Hallucinations in large multilingual translation models.  _Transactions of the Association for Computational Linguistics_ , 11.
  * He et al. (2024) Zhiwei He, Xing Wang, Wenxiang Jiao, Zhuosheng Zhang, Rui Wang, Shuming Shi, and Zhaopeng Tu. 2024.  Improving machine translation with human feedback: An exploration of quality estimation as a reward model.  _arXiv preprint arXiv:2401.12873_.
  * Hendy et al. (2023) Amr Hendy, Mohamed Abdelrehim, Amr Sharaf, Vikas Raunak, Mohamed Gabr, Hitokazu Matsushita, Young Jin Kim, Mohamed Afify, and Hany Hassan Awadalla. 2023.  How good are gpt models at machine translation? a comprehensive evaluation.  _arXiv preprint arXiv:2302.09210_.
  * Hu et al. (2024) Edward J. Hu, Moksh Jain, Eric Elmoznino, Younesse Kaddar, Guillaume Lajoie, Yoshua Bengio, and Nikolay Malkin. 2024.  Amortizing intractable inference in large language models.
  * Jinnai et al. (2024) Yuu Jinnai, Ukyo Honda, Tetsuro Morimura, and Peinan Zhang. 2024.  Generating diverse and high-quality texts by minimum bayes risk decoding.  _arXiv preprint arXiv:2401.05054_.
  * Kaufmann et al. (2023) Timo Kaufmann, Paul Weng, Viktor Bengs, and Eyke Hüllermeier. 2023.  A survey of reinforcement learning from human feedback.  _arXiv preprint arXiv:2312.14925_.
  * Khoong et al. (2019) Elaine C Khoong, Eric Steinbrook, Cortlyn Brown, and Alicia Fernandez. 2019.  Assessing the use of google translate for spanish and chinese translations of emergency department discharge instructions.  _JAMA internal medicine_ , 179(4):580–582.
  * Kocmi et al. (2023) Tom Kocmi, Eleftherios Avramidis, Rachel Bawden, Ondřej Bojar, Anton Dvorkovich, Christian Federmann, Mark Fishel, Markus Freitag, Thamme Gowda, Roman Grundkiewicz, Barry Haddow, Philipp Koehn, Benjamin Marie, Christof Monz, Makoto Morishita, Kenton Murray, Makoto Nagata, Toshiaki Nakazawa, Martin Popel, Maja Popović, and Mariya Shmatova. 2023.  Findings of the 2023 conference on machine translation (WMT23): LLMs are here but not quite there yet.  In _Proceedings of the Eighth Conference on Machine Translation_ , pages 1–42, Singapore. Association for Computational Linguistics.
  * Kocmi et al. (2024) Tom Kocmi, Vilém Zouhar, Christian Federmann, and Matt Post. 2024.  Navigating the metrics maze: Reconciling score magnitudes and accuracies.  _arXiv preprint arXiv:2401.06760_.
  * Koehn and Knowles (2017) Philipp Koehn and Rebecca Knowles. 2017.  Six challenges for neural machine translation.  In _Proceedings of the First Workshop on Neural Machine Translation_ , pages 28–39, Vancouver. Association for Computational Linguistics.
  * Korbak et al. (2022a) Tomasz Korbak, Hady Elsahar, Germán Kruszewski, and Marc Dymetman. 2022a.  On reinforcement learning and distribution matching for fine-tuning language models with no catastrophic forgetting.
  * Korbak et al. (2022b) Tomasz Korbak, Ethan Perez, and Christopher L Buckley. 2022b.  Rl with kl penalties is better viewed as bayesian inference.
  * Kulikov et al. (2019) Ilia Kulikov, Alexander Miller, Kyunghyun Cho, and Jason Weston. 2019.  Importance of search and evaluation strategies in neural dialogue modeling.  In _Proceedings of the 12th International Conference on Natural Language Generation_ , pages 76–87, Tokyo, Japan. Association for Computational Linguistics.
  * Kumar et al. (2022) Sachin Kumar, Biswajit Paria, and Yulia Tsvetkov. 2022.  Gradient-based constrained sampling from language models.
  * Kwon et al. (2023) Woosuk Kwon, Zhuohan Li, Siyuan Zhuang, Ying Sheng, Lianmin Zheng, Cody Hao Yu, Joseph E. Gonzalez, Hao Zhang, and Ion Stoica. 2023.  Efficient memory management for large language model serving with pagedattention.  In _Proceedings of the ACM SIGOPS 29th Symposium on Operating Systems Principles_.
  * Mayhew et al. (2020) Stephen Mayhew, Klinton Bicknell, Chris Brust, Bill McDowell, Will Monroe, and Burr Settles. 2020.  Simultaneous translation and paraphrase for language education.  In _Proceedings of the Fourth Workshop on Neural Generation and Translation_ , pages 232–243, Online. Association for Computational Linguistics.
  * Metropolis et al. (1953) Nicholas C. Metropolis, Arianna W. Rosenbluth, Marshall N. Rosenbluth, and A. H. Teller. 1953.  Equation of state calculations by fast computing machines.  _Journal of Chemical Physics_ , 21:1087–1092.
  * Miao et al. (2018) Ning Miao, Hao Zhou, Lili Mou, Rui Yan, and Lei Li. 2018.  CGMH: constrained sentence generation by metropolis-hastings sampling.  _CoRR_ , abs/1811.10996.
  * Mireshghallah et al. (2022) Fatemehsadat Mireshghallah, Kartik Goyal, and Taylor Berg-Kirkpatrick. 2022.  Mix and match: Learning-free controllable text generationusing energy language models.  In _Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)_ , pages 401–415, Dublin, Ireland. Association for Computational Linguistics.
  * Neal (2011) Radford M. Neal. 2011.  Probabilistic inference using markov chain monte carlo methods.
  * Nida (1964) Eugene Albert Nida. 1964.  _Toward a science of translating: with special reference to principles and procedures involved in Bible translating_.  Brill Archive.
  * Ott et al. (2018) Myle Ott, Michael Auli, David Grangier, and Marc’Aurelio Ranzato. 2018.  Analyzing uncertainty in neural machine translation.  In _International Conference on Machine Learning_ , pages 3956–3965. PMLR.
  * Pang et al. (2024) Jianhui Pang, Fanghua Ye, Longyue Wang, Dian Yu, Derek F Wong, Shuming Shi, and Zhaopeng Tu. 2024.  Salute the classic: Revisiting challenges of machine translation in the age of large language models.  _arXiv preprint arXiv:2401.08350_.
  * Papineni et al. (2002) Kishore Papineni, Salim Roukos, Todd Ward, and Wei-Jing Zhu. 2002.  Bleu: a method for automatic evaluation of machine translation.  In _Proceedings of the 40th Annual Meeting of the Association for Computational Linguistics_ , pages 311–318, Philadelphia, Pennsylvania, USA. Association for Computational Linguistics.
  * Peng et al. (2019) Xue Bin Peng, Aviral Kumar, Grace Zhang, and Sergey Levine. 2019.  Advantage-weighted regression: Simple and scalable off-policy reinforcement learning.
  * Perrella et al. (2022) Stefano Perrella, Lorenzo Proietti, Alessandro Scirè, Niccolò Campolungo, and Roberto Navigli. 2022.  MaTESe: Machine translation evaluation as a sequence tagging problem.  In _Proceedings of the Seventh Conference on Machine Translation (WMT)_ , pages 569–577, Abu Dhabi, United Arab Emirates (Hybrid). Association for Computational Linguistics.
  * Peters and Martins (2021) Ben Peters and André F. T. Martins. 2021.  Smoothing and shrinking the sparse Seq2Seq search space.  In _Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies_ , pages 2642–2654, Online. Association for Computational Linguistics.
  * Peters and Schaal (2007) Jan Peters and Stefan Schaal. 2007.  Reinforcement learning by reward-weighted regression for operational space control.  In _Proceedings of the 24th International Conference on Machine Learning_ , ICML ’07, page 745–750, New York, NY, USA. Association for Computing Machinery.
  * Qin et al. (2022) Lianhui Qin, Sean Welleck, Daniel Khashabi, and Yejin Choi. 2022.  Cold decoding: Energy-based constrained text generation with langevin dynamics.
  * Radford et al. (2019) Alec Radford, Jeff Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever. 2019.  Language models are unsupervised multitask learners.
  * Raffel et al. (2020) Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J Liu. 2020.  Exploring the limits of transfer learning with a unified text-to-text transformer.  _Journal of Machine Learning Research_ , 21:1–67.
  * Rei et al. (2022) Ricardo Rei, José G. C. de Souza, Duarte Alves, Chrysoula Zerva, Ana C Farinha, Taisiya Glushkova, Alon Lavie, Luisa Coheur, and André F. T. Martins. 2022.  COMET-22: Unbabel-IST 2022 submission for the metrics shared task.  In _Proceedings of the Seventh Conference on Machine Translation (WMT)_ , pages 578–585, Abu Dhabi, United Arab Emirates (Hybrid). Association for Computational Linguistics.
  * Rei et al. (2023) Ricardo Rei, Nuno M. Guerreiro, JosÃ© Pombal, Daan van Stigt, Marcos Treviso, Luisa Coheur, José G. C. de Souza, and André Martins. 2023.  Scaling up CometKiwi: Unbabel-IST 2023 submission for the quality estimation shared task.  In _Proceedings of the Eighth Conference on Machine Translation_ , pages 841–848, Singapore. Association for Computational Linguistics.
  * Sanz-Valdivieso and López-Arroyo (2023) Lucía Sanz-Valdivieso and Belén López-Arroyo. 2023.  Google translate vs. chatgpt: Can non-language professionals trust them for specialized translation?  In _International Conference Human-informed Translation and Interpreting Technology (HiT-IT 2023)_ , pages 97–107.
  * Shen et al. (2004) Libin Shen, Anoop Sarkar, and Franz Josef Och. 2004.  Discriminative reranking for machine translation.  In _Proceedings of the Human Language Technology Conference of the North American Chapter of the Association for Computational Linguistics: HLT-NAACL 2004_ , pages 177–184, Boston, Massachusetts, USA. Association for Computational Linguistics.
  * Shen et al. (2016) Shiqi Shen, Yong Cheng, Zhongjun He, Wei He, Hua Wu, Maosong Sun, and Yang Liu. 2016.  Minimum risk training for neural machine translation.  In _Proceedings of the 54th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)_ , pages 1683–1692, Berlin, Germany. Association for Computational Linguistics.
  * Shen et al. (2019) Tianxiao Shen, Myle Ott, Michael Auli, and Marc’Aurelio Ranzato. 2019.  Mixture models for diverse machine translation: Tricks of the trade.  In _International conference on machine learning_ , pages 5719–5728. PMLR.
  * Shen et al. (2023) Yiqiu Shen, Laura Heacock, Jonathan Elias, Keith D Hentel, Beatriu Reig, George Shih, and Linda Moy. 2023.  Chatgpt and other large language models are double-edged swords.
  * Singhal et al. (2023) Prasann Singhal, Jiacheng Xu, Xi Ye, and Greg Durrett. 2023.  Eel: Efficiently encoding lattices for reranking.
  * Stahlberg and Byrne (2019) Felix Stahlberg and Bill Byrne. 2019.  On NMT search errors and model errors: Cat got your tongue? In _Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP)_ , pages 3356–3362, Hong Kong, China. Association for Computational Linguistics.
  * Stiennon et al. (2020) Nisan Stiennon, Long Ouyang, Jeff Wu, Daniel M. Ziegler, Ryan Lowe, Chelsea Voss, Alec Radford, Dario Amodei, and Paul Christiano. 2020.  Learning to summarize from human feedback.  In _NeurIPS_.
  * Stiennon et al. (2022) Nisan Stiennon, Long Ouyang, Jeff Wu, Daniel M. Ziegler, Ryan Lowe, Chelsea Voss, Alec Radford, Dario Amodei, and Paul Christiano. 2022.  Learning to summarize from human feedback.
  * Su et al. (2018) Jinyue Su, Jiacheng Xu, Xipeng Qiu, and Xuanjing Huang. 2018.  Incorporating discriminator in sentence generation: a gibbs sampling method.
  * Taira et al. (2021) Breena R Taira, Vanessa Kreger, Aristides Orue, and Lisa C Diamond. 2021.  A pragmatic assessment of google translate for emergency department instructions.  _Journal of General Internal Medicine_ , 36(11):3361–3365.
  * Tam (2020) Yik-Cheung Tam. 2020.  Cluster-based beam search for pointer-generator chatbot grounded by knowledge.  _Computer Speech & Language_, 64:101094.
  * Touvron et al. (2023) Hugo Touvron, Louis Martin, Kevin Stone, Peter Albert, Amjad Almahairi, Yasmine Babaei, Nikolay Bashlykov, Soumya Batra, Prajjwal Bhargava, Shruti Bhosale, Dan Bikel, Lukas Blecher, Cristian Canton Ferrer, Moya Chen, Guillem Cucurull, David Esiobu, Jude Fernandes, Jeremy Fu, Wenyin Fu, Brian Fuller, Cynthia Gao, Vedanuj Goswami, Naman Goyal, Anthony Hartshorn, Saghar Hosseini, Rui Hou, Hakan Inan, Marcin Kardas, Viktor Kerkez, Madian Khabsa, Isabel Kloumann, Artem Korenev, Punit Singh Koura, Marie-Anne Lachaux, Thibaut Lavril, Jenya Lee, Diana Liskovich, Yinghai Lu, Yuning Mao, Xavier Martinet, Todor Mihaylov, Pushkar Mishra, Igor Molybog, Yixin Nie, Andrew Poulton, Jeremy Reizenstein, Rashi Rungta, Kalyan Saladi, Alan Schelten, Ruan Silva, Eric Michael Smith, Ranjan Subramanian, Xiaoqing Ellen Tan, Binh Tang, Ross Taylor, Adina Williams, Jian Xiang Kuan, Puxin Xu, Zheng Yan, Iliyan Zarov, Yuchen Zhang, Angela Fan, Melanie Kambadur, Sharan Narang, Aurelien Rodriguez, Robert Stojnic, Sergey Edunov, and Thomas Scialom. 2023.  Llama 2: Open foundation and fine-tuned chat models.
  * Vernikos and Popescu-Belis (2024) Giorgos Vernikos and Andrei Popescu-Belis. 2024.  Don’t rank, combine! combining machine translation hypotheses using quality estimation.  _arXiv preprint arXiv:2401.06688_.
  * Vijayakumar et al. (2017) Ashwin K Vijayakumar, Michael Cogswell, Ramprasaath R. Selvaraju, Qing Sun, Stefan Lee, David Crandall, and Dhruv Batra. 2017.  Diverse beam search: Decoding diverse solutions from neural sequence models.
  * Wang and Cho (2019) Alex Wang and Kyunghyun Cho. 2019.  BERT has a mouth, and it must speak: BERT as a markov random field language model.  _CoRR_ , abs/1902.04094.
  * Wieting et al. (2019) John Wieting, Taylor Berg-Kirkpatrick, Kevin Gimpel, and Graham Neubig. 2019.  Beyond BLEU:training neural machine translation with semantic similarity.  In _Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics_ , pages 4344–4355, Florence, Italy. Association for Computational Linguistics.
  * Xu et al. (2024a) Haoran Xu, Young Jin Kim, Amr Sharaf, and Hany Hassan Awadalla. 2024a.  A paradigm shift in machine translation: Boosting translation performance of large language models.
  * Xu et al. (2024b) Haoran Xu, Amr Sharaf, Yunmo Chen, Weiting Tan, Lingfeng Shen, Benjamin Van Durme, Kenton Murray, and Young Jin Kim. 2024b.  Contrastive preference optimization: Pushing the boundaries of llm performance in machine translation.  _arXiv preprint arXiv:2401.08417_.
  * Yamakoshi et al. (2022) Takateru Yamakoshi, Thomas Griffiths, and Robert Hawkins. 2022.  Probing BERT’s priors with serial reproduction chains.  In _Findings of the Association for Computational Linguistics: ACL 2022_ , pages 3977–3992, Dublin, Ireland. Association for Computational Linguistics.
  * Yan et al. (2023) Yiming Yan, Tao Wang, Chengqi Zhao, Shujian Huang, Jiajun Chen, and Mingxuan Wang. 2023.  BLEURT has universal translations: An analysis of automatic metrics by minimum risk training.  In _Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)_ , pages 5428–5443, Toronto, Canada. Association for Computational Linguistics.
  * Zhang et al. (2020) Maosen Zhang, Nan Jiang, Lei Li, and Yexiang Xue. 2020.  Language generation via combinatorial constraint satisfaction: A tree search enhanced Monte-Carlo approach.  In _Findings of the Association for Computational Linguistics: EMNLP 2020_ , pages 1286–1298, Online. Association for Computational Linguistics.

##  Appendix A Connection to RLHF derivation

If we take the target distribution to have the following form:

$\pi(y|x)=\frac{1}{Z(x)}p_{LM}(y|x)\exp\Bigg{(}\frac{r(x,y)}{\beta}\Bigg{)},$
(14)

then the likelihood ratio becomes :

$\frac{\pi(y|x)}{\pi(y^{t}|x)}=\exp\Big{(}\frac{r(x,y)-r(x,y^{t})}{\beta}\Big{)}\frac{p_{LM}(y_{\geq
i}|y^{t}_{<i},x)}{p_{LM}(y^{t}_{\geq i}|y^{t}_{<i},x)}.$ (15)

Note that the target log ratio contains the inverse of the probability of
returning, i.e.:

$\frac{q(y^{t}|y,x,i)}{q(y|y^{t},x,i)}=\frac{p_{LM}(y^{t}_{\geq
i}|y^{t}_{<i},x)}{p_{LM}(y_{\geq i}|y^{t}_{<i},x)},$ (16)

this allows simplifying the criterion as follows:

$\alpha_{\beta}(y,y^{t})=\max\left\\{1,\exp\left(\frac{r\left(x,y\right)-r\left(x,y^{t}\right)}{\beta}\right)\frac{q(i|n)}{q(i|n^{t})}\right\\}.$
(17)

##  Appendix B Prompts used for MT

For both the ALMA-7B and Tower-7B we adhere to the prompt format recommended
for translation in the original papers as shown below:

> Alma-7b:
>
>
>     Translate this sentence from {source language} to {target language}.
>     {source language} Source: {source sentence}.
>     {target language} Translation:
>
>
> Tower-7b
>
>
>     <|im_start|>user
>     Translate the following {source_language} source text to
> {target_language}:
>     {source_language}: {source_sentence}
>     {target_language}: <|im_end|>
>     <|im_start|>assistant
>

##  Appendix C Additional Results

(a) Distribution of rewards for sampled hypotheses for the toy summarization
problem.

###  C.1 Toy problem: Validating the Approach

To validate that our approach works, we test Quest on a controlled setting, a
toy summarization problem, where the ground truth reward is known. We consider
the following reward function:

$r(x,y):=\text{logit}\left(\text{clamp}\left(\mathcal{N}\left(|y|;\mu=7.5,\sigma^{2}=3.75^{2}\right)\right)\right),$
(18)

where $\text{clamp}(x)=\max({10}^{-2},\min(x,1-{10}^{-2}))$.

We use GPT2 (Radford et al., 2019) fine-tuned on the Reddit dataset Stiennon
et al. (2020) to generate summaries for 128 examples randomly sampled from the
test split. We compare the distribution of rewards obtained by different
sampling techniques (Ancestral, Quest and Truncated-Gibbs) to the ground truth
reward in Figure 3(a). For Truncated-Gibbs sampling, we estimate the partition
function using the ancestral samples and resample them based on the
probability distribution induced by the rewards. Unlike ancestral sampling
which results in samples that are far from the high-reward regions, our
sampling strategy, Quest, results in the best approximation of the ground
truth distribution. This simplified reward task serves as an useful example to
show the efficacy of our approach over alternatives.

###  C.2 QE Results

We report the quality as measured by the metric optimized for, i.e.,
CometKiwi-XL in Figure 4. Quest results in higher quality across the board
compared to ancestral sampling.

Figure 4: Average quality (CometKiwi-XL) vs. diversity (Pairwise-BLEU) on
WMT23 datasets. Different points represent different hyperparameter values.

(a) xComet-XL by source length.

(b) Distribution over Accepted indices.

###  C.3 MCMC results in better outputs for shorter segments.

We show the xComet-XL scores on WMT23 English-German pairs bucketed by the
length of the source text. In general, the quality of samples degrades with
increased source length when decoding via MCMC as shown in Figure 5(a). One
possible factor could be the uniform index-selection exploration strategy
where the proposal might require more steps as the sentence length increases.
Another factor could be the limitations of the reward function itself for
selecting high-quality translations for longer sequences. As these quality
estimation metrics have not been trained on longer sequences, due to a
distribution shift, they might not be representative of true quality for these
output lengths. We believe the latter option could be the more significant
factor as the reward optimized still improves regardless of the sentence
length (see Figure 4).

###  C.4 Accepted proposals are skewed towards the end of the sentence.

Figure 5(b) illustrates how the distribution of accepted indices changes with
decreasing $\beta$: lower $\beta$ values tighten acceptance criteria, favoring
states with higher rewards and a greater likelihood of returning to the
previous state. Consequently, transitions tend to yield minor alterations,
typically at the end of the sentence. Altering the beginning necessitates
sampling small indices values, risking a complete sentence change. This plot
highlights the current limitations of our proposal, especially the downstream
implications on the diversity of prefixes we get for a particular motivating
the use of parallel chains and potential avenues for improvement for future
work.

##  Appendix D Comparing RLHF-QUEST vs QUEST

We compare Quest with the alternative discussed in Section 3.3 where the
target distribution in Eq. 3 is replaced with Eq. 12, referred to as “RLHF-
Quest”. We compare sampling using the two target distributions in Figure 6.
Our results indicate that both approaches result in comparable translation
quality, with Quest resulting in slightly higher diversity on average than
RLHF-Quest. We leave the detailed exploration of these two methods to future
work.

Figure 6: Average Quality by xComet-XL (left) and CometKiwi-XL on English-
Russian dataset using Tower-7b