Certified Termination for Offline Goal-Reaching with Zero-Cost Steps

Many learning problems are "get to the goal as cheaply as possible" problems, where the agent decides for itself how long an episode lasts. A robot that drives to a charging dock and a translation model that writes tokens until it emits an end-of-sentence marker are both examples. The theory for learning such behavior from a fixed, pre-collected dataset, with no chance to explore, rests on one assumption: every step must cost at least some positive amount. That assumption is what makes endless wandering look expensive. Remove it, so that some steps are free, and a learner trained on a small dataset can no longer tell a policy that idles forever in a well-documented free loop from one that actually reaches the goal.

We propose to replace the positive-cost assumption with a termination certificate estimated from the data. Alongside the usual cautious estimate of cost, the learner keeps a cautious upper bound on how many steps each policy needs to reach the goal. It then optimizes cost only over policies whose bound fits within a budget the data can support. This gives a guarantee that never divides by the minimum step cost. We test the algorithm on synthetic goal-reaching problems built to contain zero-cost traps. We then run a deliberately falsifiable transfer test on domain-adapted machine translation, where in-domain parallel text is scarce and generation loops are a known failure mode.

Core Claim

The setting is the stochastic shortest path (SSP) problem: a Markov decision process with an absorbing goal state $g$, in which the episode ends when $g$ is reached. A policy is proper if it reaches $g$ with probability one and improper otherwise. The offline version, learning only from a static dataset $\mathcal{D}$ of $n$ transitions, was formalized by Yin et al. in Offline Stochastic Shortest Path: Learning, Evaluation and Towards Optimality. Their PVI-SSP algorithm (pessimistic value iteration) adds a Bernstein-style penalty to the costs of poorly covered state-action pairs. They prove a near-minimax rate $\tilde O(B_*\sqrt{SC^*/n})$, where $B_*$ is the optimal expected cost, $S$ the number of states and $C^*$ a coverage coefficient. However, they require every non-goal cost to satisfy $c(s,a)\ge c_{\min}>0$, and they name relaxing this requirement as an open problem.

The obstacle is specific. Pessimism penalizes what the data has not covered. A zero-cost self-loop that the logging policy visited thousands of times is perfectly covered, so pessimism treats it as cheap and safe. The penalty therefore cannot rule out improper policies. Our claim is that a second pessimistic quantity closes this hole. Let $T^\pi(s)$ be the expected number of steps for policy $\pi$ to reach $g$ from state $s$. This is itself the value of an auxiliary SSP with unit cost per step, so its minimum cost is 1 and PVI-SSP-style machinery applies to it unchanged. Write $\bar T^\pi$ for its pessimistic upper estimate from $\mathcal{D}$. The learner then solves

$$ \hat\pi=\arg\min_{\pi}\ \bar J^\pi(s_0)\quad\text{subject to}\quad \bar T^\pi(s_0)\le\tau , $$

where $\bar J^\pi$ is the pessimistic cost estimate for the original costs, which may be zero, and $\tau$ is a hitting-time budget. The target guarantee bounds the gap between $\hat\pi$ and the best policy whose true hitting time is at most $\tau$. The bound should scale with $B_*$, with $\tau$, and with the coverage of that comparator, but contain no $1/c_{\min}$ term. In addition, $\hat\pi$ should be proper with high probability.

Restricting the comparator to policies with bounded hitting time is forced by known results, not chosen for convenience. Tirinzoni et al. (Tirinzoni et al.) show that once zero-cost actions are allowed, the sample complexity of identifying an optimal policy can be unbounded. Some comparator restriction is therefore unavoidable. We make that restriction explicit, set it from the data, and pay for it only through $\tau$.

The constraint has a Lagrangian form, and it is worth stating plainly. Its dual adds a constant $\lambda$ to every step cost. That is exactly the small cost perturbation already used online by Rosenberg et al. in Near-optimal Regret Bounds for Stochastic Shortest Path and by Di et al. in Nearly Minimax Optimal Regret for Learning Linear Mixture Stochastic Shortest Path. The contribution is therefore not "perturb the costs." It has two parts. First, the perturbation size is chosen by a constraint that certifies termination from data, not fixed in advance. Second, the analysis tracks hitting time directly, so the error terms never pass through $c_{\min}$. Whether this beats a well-tuned fixed perturbation is the central empirical question, and we treat it as such below.

Research Program

The theory work proceeds in three steps. The first is tabular offline evaluation. We extend the VI-OPE estimator of Offline Stochastic Shortest Path: Learning, Evaluation and Towards Optimality to zero costs. That estimator injects a small $1/(n+1)$ jump to the goal so that the empirical Bellman operator contracts. We pair it with the unit-cost hitting-time evaluation and show that the evaluation error for $J^\pi$ is controlled by $\bar T^\pi$ rather than by $B_*/c_{\min}$.

The second step is tabular offline optimization. We solve the constrained problem by a primal-dual iteration over $\lambda$, which reuses PVI-SSP as the inner solver. The proof will adapt the variance-summation argument of Near-optimal Regret Bounds for Stochastic Shortest Path. That argument bounds the total variance of the cost-to-go over an episode by $B_*^2$ and is what removed $c_{\min}$ in the online setting. We will check whether the offline analogue needs the extra $\tau$ factor, or whether $\tau$ enters only inside logarithms.

The third step is linear function approximation. Here we follow the variance-weighted regression of LEVIS++ from Nearly Minimax Optimal Regret for Learning Linear Mixture Stochastic Shortest Path. In the offline setting, the hitting-time bound $\tau$ may replace their recursive high-order moment levels, whose count grows like $\log(B/c_{\min})$. If it does, it would also remove their need to know $B_*$ or $T_*$ in advance. These are two of the open limitations listed for that work.

The budget $\tau$ itself is chosen from data. We use the smallest value for which the constraint is feasible with margin, or a quantile of the episode lengths observed in $\mathcal{D}$. When no policy satisfies the constraint at the target state, the algorithm abstains and returns the logging policy restricted to covered actions. This mirrors the safe fallback policy in UC-SSP from No-Regret Exploration in Goal-Oriented Reinforcement Learning, with one difference: UC-SSP needs a known safe policy and online interaction, whereas our fallback is built entirely from the dataset.

The translation transfer test is secondary, and we frame it as something that could fail. Autoregressive translation ends when the model emits the end-of-sequence token, which plays the role of the goal $g$. Most token steps carry no intrinsic cost, so $c_{\min}=0$ in the SSP sense. Under domain shift with little in-domain bitext, models are known to loop or wander instead of terminating. We would train a remaining-length head on the in-domain bitext, with pessimistic upper bounds taken from an ensemble, and use it as $\bar T$ during beam search. A hypothesis is pruned when its current length plus its pessimistic remaining length exceeds the certified budget. When the certificate fails for every hypothesis, decoding falls back to the general-domain model. This differs from future-cost decoding in Modeling Future Cost for Neural Machine Translation, which estimates translation cost-to-go as a scoring heuristic but makes no claim about termination. It also differs from Minimum Risk Training for Neural Machine Translation, which minimizes expected sequence loss over sampled candidates and does not address stopping time at all.

Baselines

On the synthetic goal-reaching problems, the naive reference is behavior cloning of the logging policy, together with plain empirical value iteration with no pessimism. The strongest existing competitor is PVI-SSP with a fixed cost perturbation $\epsilon$ added to every step. We grid-search $\epsilon$ over five orders of magnitude and, to be generous, report the best value selected on the true environment. This oracle tuning favors the baseline. It is the strongest competitor because it is exactly what a practitioner would do with Yin et al.'s algorithm when faced with zero costs, and because it is the dual of our method at a single fixed multiplier. Both methods use the same datasets, the same Bernstein penalty constants and the same number of value-iteration sweeps.

The ablation that isolates the key ingredient keeps our primal-dual solver but replaces the pessimistic hitting-time bound $\bar T^\pi$ with its empirical, non-pessimistic estimate. If this ablation matches the full method, then the termination certificate is not doing the work. No reported numerical result found on Lacuna for any offline SSP method on a concrete environment; the file reports only rates. All synthetic baseline numbers will therefore come from our own runs. We count it as beating the fixed-$\epsilon$ baseline if our method achieves lower suboptimality and a lower rate of improper output policies, at matched $n$, than the oracle-tuned $\epsilon$, without access to the true environment.

On translation, the naive reference is the general-domain model decoded with a standard maximum-length cutoff relative to source length. The strongest pipelines in the file are the iterative transfer schedule of UCAM Biomedical Translation at WMT19: Transfer Learning Multi-domain Ensembles, which reports 41.3 BLEU on the Bio validation set for Health→All-biomed→Bio against 36.1 BLEU for Bio-only training, and the Dropout plus MAP-L2 regularized fine-tuning of Regularization techniques for fine-tuning in neural machine translation, which reports 31.48 BLEU on IWSLT English→German and 19.10 on English→Russian. Our certificate is a decoding-time addition, so we apply it on top of these exact fine-tuned models rather than competing with them. We also include a length-ratio cutoff tuned on the validation set and a standard repetition penalty, each given the same validation budget as our budget selection.

A translation win requires two things. The certificate must lower the rate of non-terminating or looping outputs below that of the tuned length-ratio cutoff. It must also do so without losing BLEU relative to those reported pipelines.

Why not just…?

Why not just add a small constant cost to every step and run PVI-SSP? This is the real threat, because it is the dual of our method at one fixed multiplier. The difficulty is that a single $\epsilon$ faces a two-sided trade-off. Small $\epsilon$ makes the time-to-goal bounds in the analysis scale like $B/\epsilon$. Large $\epsilon$ adds a bias of about $\epsilon T_*$, which matters exactly when the cheapest route is long and free. The synthetic families described below are built so that no single $\epsilon$ works across dataset sizes. The oracle-tuned grid baseline will show directly whether that trade-off bites in practice. If oracle-$\epsilon$ matches us everywhere, our practical claim reduces to choosing the perturbation from data without an oracle, and we will report that smaller claim.

Why not just truncate episodes at a fixed horizon or discount the future? Pardo (Time Limits in Reinforcement Learning) argues that imposing time limits or discount factors on goal-directed tasks distorts the learned behavior. Truncation also hides improper policies instead of excluding them. A policy that loops until the cutoff looks just as finished as one that reaches the goal. We include fixed-horizon value iteration as a baseline and measure its improper-policy rate when the horizon is removed at evaluation time.

Why not just cap decoding length by the source length and use regularized fine-tuning? For translation this simple fix may genuinely be enough. Length-ratio cutoffs are cheap and often effective. MAP-L2 regularization already stabilizes fine-tuning, though only for gains of +0.28 and +0.43 BLEU in Regularization techniques for fine-tuning in neural machine translation. The translation experiment is therefore designed so that this baseline can win. If a validation-tuned length-ratio cutoff matches the certificate on loop rate and BLEU across all in-domain data sizes, we drop the translation claim. The contribution then stands on the offline SSP theory and the synthetic results alone.

Proposed Experiments

The synthetic suite contains three tabular families. The first is a covered zero-cost self-loop next to a zero-cost but long path to the goal. The second is a gridworld in which goal-reaching corridors have zero cost and detours have positive cost. The third offers a choice between a short costly route and a long free route, with $T_*$ varied from 10 to $10^4$. Datasets come from logging policies with controlled coverage $C^*$, with $n$ swept over three orders of magnitude.

For linear approximation, we adapt the two-state hypercube-action linear-mixture SSP of Nearly Minimax Optimal Regret for Learning Linear Mixture Stochastic Shortest Path to the offline setting, with zero cost on a subset of actions. The metrics are suboptimality $J^{\hat\pi}(s_0)-J^*$, the fraction of seeds whose output policy is improper, the ratio of certified $\bar T$ to true $T^{\hat\pi}$, and how suboptimality scales with $n$. If the analysis is right, that scaling should follow the $1/\sqrt{n}$ form inherited from the Bernstein penalty and stay flat as $c_{\min}\to0$. The decisive check is a plot of suboptimality against $c_{\min}$ from 1 down to 0 at fixed $n$. Fixed-$\epsilon$ PVI-SSP should degrade or require retuning, and our method should not.

For translation, we use WMT19 Biomedical English↔Spanish with the Scielo, UFAL, Pubmed, Medline, IBECS and EMEA corpora, Khresmoi for validation and the WMT18/19 test sets, and the IWSLT English→German and English→Russian adaptation sets. In-domain bitext is subsampled to 1%, 10% and 100% to probe the low-data end of the logarithmic adaptation law. We report BLEU, the share of outputs that hit the hard maximum length or contain n-gram repetition loops, and the length-ratio deviation from references. The fine-tuned models follow the schedules of UCAM Biomedical Translation at WMT19: Transfer Learning Multi-domain Ensembles and Neural Machine Translation Training in a Multi-Domain Scenario.

The decisive translation check is the 1% data condition. Generation pathologies should be most frequent there, so if the certificate does not beat the tuned length-ratio cutoff at 1%, it will not beat it anywhere.