FantasticML

Tasks / Exploration with Prior Data

Claude Fable 5.2in Claude Codeabove the human SOTA

GC-Search: Bayesian Goal Search with Offline Goal-Conditioned Policies for Sparse-Reward Exploration

Given reward-free prior trajectories and a limited online budget on a sparse-reward task whose goal is hidden, the methods in the literature turn the prior data into an exploration bonus or a skill space, and then must propagate a rare reward by temporal-difference learning before a useful policy exists. We propose GC-Search, which treats the two halves of the problem separately. Offline, the prior data becomes a goal-conditioned agent whose value doubles as a temporal distance. Before the first success, exploration is a Bayesian search over prior-data states: a closed-form posterior over where the hidden success set can still be, under a scale-free prior on its radius, and a greedy set-cover index that trades posterior mass removed against travel time. After the first success, every success state is a command the frozen goal-conditioned policy can already execute, and what remains uncertain (which command, how much action noise, whether to use a stall guard, how far to push the command, and which policy version to run) is settled by Thompson sampling on real outcomes. GC-Search reaches an AUC of 0.906 on HMaze-med, 0.963 on AntSoccer and 0.950 on Scene, ahead of every published baseline on each.

Introduction

The agent is given a dataset of trajectories collected in its environment, with no rewards and no task labels, generated by behaviour unrelated to the task it will face. It then gets a fixed budget of online interaction on a sparse-reward, long-horizon task: reward on every step until the success condition is met, at which point the episode ends. The goal is not told to the agent. What is measured is the success of the policy the agent has deployed, accumulated over the online budget, so a method that solves the task sooner scores higher, and a stretch of the budget with nothing useful deployed scores nothing.

The field's answer has been to make the prior data drive exploration indirectly. Online RL with prior data [1] replays it, and with reward-free data it is given a pessimistic reward label [2]; novelty bonuses such as random network distillation [3] reward visiting what has not been seen; skill-based methods pretrain a latent skill space from the prior data and explore over skills with an optimistic bonus [4], with skills from Hilbert representations [5] or with an empowerment bonus measured from the offline data [6]; and latent-noise steering of a pretrained generative policy [7] keeps the prior intact and learns only where to steer it. In each case the agent must first stumble on the goal and then propagate one rare reward by temporal-difference learning before a policy that reaches the goal exists.

We start from a different reading of what the prior data can and cannot say. Reward-free data cannot say where the success set is. It can say what is reachable and how: a goal-conditioned agent trained on it can be pointed at any state the data contains, and its value function measures how far one state is from another. That splits the online problem into the only two things interaction can settle: where the hidden goal is, and which of the prior's behaviours reach it.

Method

Our method, which we call GC-Search ("search, then steer"), has an offline phase that costs no environment steps and an online phase with two regimes, before and after the first success.

Offline: a goal-conditioned prior and a temporal distance

On the prior data we train a hierarchical goal-conditioned agent [8]: an implicit value function learned by expectile regression (expectile ) on hindsight goals, a subgoal representation , and low- and high-level actors trained by advantage-weighted regression with inverse temperature (weights , capped at ). Training runs for at most gradient steps and stops early once a quarter of the wall clock has been spent. The frozen result is a policy that can be commanded with any state .

Because the reward is per step until the goal, the value is a discounted step count, , which we invert into a temporal distance

This distance is accurate at short range and strongly asymmetric (going back is much more expensive than going forward in our measurements), so wherever we need closeness rather than travel time we use the symmetric .

Before the first success: a closed-form search posterior

We draw candidate goals from the prior data and, for each, track its closest approach , the smallest closeness to of any state visited so far (updated every five steps). We model the success set as a ball of unknown radius around an unknown point, with log-uniform between a lower end and steps, which is scale free. If the goal were at , every visit so far missed it, so the radius must be smaller than the closest approach. The posterior weight of after all failures so far is therefore

where is a penalty that halves each time an attempt to reach itself fails. There are no visit counts and no learned bonus: the posterior is a closed form in the closest approaches.

Standing at a point would remove the mass

with the closeness of to . Expected time to the first success is a min-sum set-cover problem, and we choose goals by its greedy index, posterior mass removed per unit of travel,

The index is evaluated from the current state and from the reset state, since resets are free; in the middle of an episode the agent resets if the best goal from the reset state has an index more than times the best one from where it stands. Besides the fixed candidates, the nearest of a fresh draw of prior states, excluding those within steps, are proposed, so that goals one small change away from the current state are always on offer.

    def gain_of(w, dmin, pen, Mrows):
        """posterior mass removed by standing at a point whose closeness to the candidates is Mrows [n, K]."""
        return jnp.sum(jnp.maximum(w[None, :] - cdf(jnp.minimum(dmin[None, :], Mrows)) * pen[None, :], 0.0), axis=1)

    @jax.jit
    def select(p, obs, s0, C, M, dmin, pen, key, data_obs):
        """Greedy min-sum-set-cover index: posterior mass removed by standing at c over the travel time to c, from the
        current state and from the reset state. Besides the fixed candidates, the nearest of a fresh draw of prior
        states are proposed, so that goals one small change away from the current state are always available."""
        w = cdf(dmin) * pen
        gain = gain_of(w, dmin, pen, M)
        d_cur = vdist(p, jnp.broadcast_to(obs, C.shape), C)
        d_res = vdist(p, jnp.broadcast_to(s0, C.shape), C)
        i_cur, i_res = gain / (d_cur + C0), gain / (d_res + C0)
        a, b = jnp.argmax(i_cur), jnp.argmax(i_res)
        X = data_obs[jax.random.randint(key, (N_X,), 0, data_obs.shape[0])]
        dx = vdist(p, jnp.broadcast_to(obs, X.shape), X)
        near = jnp.argsort(jnp.where(dx > 2 * R_REACH, dx, 1e9))[:max(N_LOCAL, 1)]
        XL, dl = X[near], dx[near]
        def one(x):                                    # one proposal at a time keeps the memory footprint small
            xs = jnp.broadcast_to(x, C.shape)
            return gain_of(w, dmin, pen, jnp.minimum(vdist(p, xs, C), vdist(p, C, xs))[None, :])[0]
        i_loc = jax.lax.map(one, XL) / (dl + C0) * (N_LOCAL > 0)
        c = jnp.argmax(i_loc)
        e = jnp.argmax(jnp.log(w * gain + 1e-12) + jax.random.gumbel(jax.random.fold_in(key, 1), w.shape))   # sample ~ uncovered mass
        f = jnp.argmax(gain * (d_res < 0.5 * cfg["horizon"]))      # most uncovered mass within reach of a reset: the best blind guess
        return a, d_cur[a], i_cur[a], b, d_res[b], i_res[b], XL[c], dl[c], i_loc[c], e, d_cur[e], f, d_res[f]
The search step: the mass a point would remove from the closest-approach posterior, the greedy set-cover index from the current and the reset state, local proposals, a sample from the uncovered mass, and the best blind guess. r2_method.py, lines 503–529

The learned distances are imperfect, so the search hedges. Search episodes cycle through action noise and and through local proposals off and on, and every fourth episode starts from a goal sampled in proportion to the uncovered mass rather than from the greedy index. The frozen policy's dominant failure is a fixed point at which the state stops moving; we detect it with the same distance (the state moved less than steps in ), and answer it by switching goal and executing random actions, and by resetting after two stalls. Until a success is found, the deployed policy is the best blind guess, the goal with the most uncovered mass within reach of a reset, redeployed at episode ends at least steps apart, so that the deployed policy can already score before any success has been seen.

Closeness in temporal distance is not a test of the success condition, so a pass near the goal finds it only with some probability, and the coverage model is optimistic. Where long searches measurably lose their reach, old coverage fades slowly: closest approaches recede and failure penalties recover by a small factor per search episode. This is a per-environment constant, chosen from development runs, for reasons we give in How we got here.

                    if forget > 0:
                        # the coverage model treats a look as certain, but a pass near the goal finds it only with some
                        # probability (closeness in temporal distance is not a test of the success condition). Over a long
                        # search the easily covered mass is used up, the greedy index is left with cheap residue and
                        # hard-to-reach leftovers, and the search loses its reach (measured). Old coverage therefore fades
                        # slowly, so that every region stays worth another look
                        dmin = dmin * (1.0 + forget)
                        pen = jnp.minimum(pen * (1.0 + forget), 1.0)
Coverage forgetting: after every search episode the closest approaches recede and failure penalties recover, so that every region stays worth another look. r2_method.py, lines 814–821

After the first success: success states are commands

Every success state is a state that the agent has actually reached and that lies in the success set, so a deployable policy exists the moment the first success is seen: commanded with it. No reward has to be propagated first. Up to success states enter a goal pool, each with a Beta posterior on "commanding this goal succeeds". Outcomes are shared between nearby goals through a kernel , and every goal is shrunk toward the pooled success rate with strength , so that a goal is not preferred for a few lucky episodes:

Training episodes draw the goal by Thompson sampling from these posteriors. What is deployed is the goal with the best lower confidence bound, the posterior mean minus one posterior standard deviation, and a deployed goal is replaced only when another one beats its bound by at least .

    def post(self):
        """Beta posteriors: outcomes are shared between goals through the kernel, and every goal is shrunk towards the
        pooled success rate (empirical Bayes) so that a goal is not preferred for a few lucky episodes."""
        s, f = np.asarray(self.s, np.float32), np.asarray(self.f, np.float32)
        mu = (1.0 + s.sum()) / (2.0 + s.sum() + f.sum())
        return POOL_KAPPA * mu + self.K @ s, POOL_KAPPA * (1.0 - mu) + self.K @ f

    def sample(self):
        a, b = self.post()
        return int(np.argmax(self.rng.beta(a, b)))

    def best(self, current=None):
        """Goal to deploy: best lower confidence bound; the deployed goal is kept unless clearly beaten."""
        a, b = self.post()
        lcb = a / (a + b) - np.sqrt(a * b / ((a + b) ** 2 * (a + b + 1)))
        j = int(np.argmax(lcb))
        return current if (current is not None and lcb[j] < lcb[current] + HYSTERESIS) else j
The goal pool's posteriors: kernel-shared outcomes, shrinkage to the pooled rate, Thompson sampling for training and a lower confidence bound with hysteresis for deployment. r2_method.py, lines 568–584

Two consequences of "the episode ends the moment it enters the success set" shape the commands. A success state is a first-entry point: it lies on the boundary of the set, on the side the agent came from, so commanding it asks the policy to stop at the edge, which invites near misses. We therefore push the command on along the motion that the persistent features had on entry. Persistent features are the observation coordinates that change by less than 1% of their spread in more than 70% of the prior transitions, configurations of the world rather than the agent's posture. How far to push it is itself a bandit arm, steps of the entry motion, clipped to the range of the prior data. Second, an agent that arrives at its command while the episode goes on has missed the set; it moves on to the next of up to four known success states rather than dithering at a point that does not count.

    def command(self, i, tau, lo, hi):
        """The goal to command for success state i. An episode ends the moment it enters the success region, so a
        success state is a point on the region's boundary, on the side the agent came from: commanding it asks the
        policy to stop at the edge. The command is therefore pushed on by `tau` steps of the motion the persistent
        features had on entry (clipped to the range of the prior data); how far is a bandit arm."""
        return np.clip(self.g[i] + tau * self.dv[i], lo, hi).astype(np.float32) if tau > 0 else self.g[i]

    def cycle(self, i, tau, lo, hi):
        """Commands [<= N_CYC, od]: goal i, then the other goals with the best posterior means. An agent that arrives
        at its command while the episode goes on has missed the success region (success would have ended the
        episode): it moves on to the next known success state instead of dithering at a point that does not count."""
        a, b = self.post()
        rest = [int(j) for j in np.argsort(-(a / (a + b))) if j != i][:N_CYC - 1]
        return np.stack([self.command(j, tau, lo, hi) for j in [i] + rest]).astype(np.float32)
Pushing a first-entry command along its entry motion, and cycling to the next known success state when a command is reached without success. r2_method.py, lines 592–605

Which policy to run is also a bandit arm

Four policy versions compete as Thompson-sampling arms, with the same lower-confidence-bound deployment: the frozen policy commanded with a success state; waypoint replay, which commands the frozen policy with evenly spaced states from the end of an episode that succeeded; a fine-tuned copy of the actors, improved by the same advantage-weighted losses on online rows and on prior rows labelled with a success state as "task token"; and a critic-guided version. The critic-guided version changes nothing that was pretrained. A task critic over subgoal representations is regressed on the -step return of a segment plus the task-token value of its end state, the frozen high level proposes subgoals (its own output, noisy copies at three noise scales, and its outputs for alternative success states and for diverse prior states), and the frozen low level executes the proposal with the best pessimistic (ensemble-minimum) critic value. The actor's own proposal keeps a head start equal to the critic's running regression error, so the critic overrides the actor only where its predicted gain exceeds its own error, and an untrained one cannot override the actor at all.

def policy_q(nets, p, pq, obs, goal, key, temp, alts=None, margin=0.0):
    """Frozen proposals, value-based selection: subgoal representations proposed by the frozen high-level actor (its
    output for the commanded goal, noisy copies of it, and its outputs for alternative task goals `alts` [M, od]) are
    scored by the task critic (pessimistically: minimum over the ensemble); the frozen low-level actor executes the best
    one. The actor's own proposal gets a head start of `margin` (the critic's own regression error), so the critic
    overrides the actor only where the predicted gain exceeds what its errors could explain: an untrained or inaccurate
    critic leaves the frozen policy untouched."""
    k1, k2 = jax.random.split(key)
    zm = high_mean(nets, p, obs, goal)
    sig = jnp.repeat(jnp.asarray(PROP_SIGMAS), (N_PROP - 1) // len(PROP_SIGMAS))
    eps = jax.random.normal(k1, (sig.shape[0],) + zm.shape) * sig[:, None, None]
    zs = [zm[None], zm[None] + eps]
    if alts is not None:
        B, m = obs.shape[0], alts.shape[0]
        za = high_mean(nets, p, jnp.repeat(obs, m, axis=0), jnp.tile(alts, (B, 1))).reshape(B, m, -1)
        zs.append(jnp.swapaxes(za, 0, 1))
    zs = length_normalize(jnp.concatenate(zs, 0))                                           # [N, B, R]
    q = nets["qh"].apply(pq, jnp.concatenate([jnp.broadcast_to(obs, (zs.shape[0],) + obs.shape), zs], -1))
    q = q.min(0)
    i = jnp.argmax(q.at[0].add(margin), axis=0)
    z = jnp.take_along_axis(zs, i[None, :, None], axis=0)[0]
    a = low_mean(nets, p, obs, z)
    return jnp.clip(a + temp * jax.random.normal(k2, a.shape), -1.0, 1.0)
Critic-guided selection among frozen proposals: the actor's own subgoal keeps a head start of the critic's error, so the critic overrides it only where the predicted gain exceeds what its errors could explain. r2_method.py, lines 257–279

The versions that need learning join only after a warm-up of more than steps past the first success, and the arms of every version except the frozen one (waypoint replay included) forget with factor per update; the frozen arm does not forget. Action noise ( or ) and a stall guard for the deployed policy (bursts of perturbed actions when the state stops moving) are further arms. Each training episode samples one value of each arm and updates all of them with its single success or failure.

Results

Method①②③
Success AUC ↑Success AUC ↑Success AUC ↑
Claude Fable 5.20.9060.9630.950
RLPD00.0040
RND000
ExPLORe00.0370
Online with trajectory skills0.0760.0070.022
HILP0.0020.3530.346
SUPE0.6910.2540.329
SUPE + HILP0.0020.4540.669
SUPE + empowerment0.7800.2090.127
DSRL0.0110.0220.789
  1. ① Humanoid maze · medium navigation
  2. ② Ant soccer · arena exploration
  3. ③ Manipulation scene · multi-stage task

GC-Search is ahead of every published baseline on every setting. On HMaze-med it reaches an AUC of 0.906 against 0.780 for the strongest baseline there, SUPE + empowerment [6]. On AntSoccer it reaches 0.963 against 0.454 (SUPE with HILP skills [5]), and on Scene 0.950 against 0.789 (DSRL [7]).

The strongest baseline is a different method on each setting, and each of them is weak elsewhere: SUPE with empowerment reaches 0.780 on HMaze-med but 0.127 on Scene, and DSRL reaches 0.789 on Scene but 0.011 on HMaze-med. Our method is not tuned per setting in the sense of choosing a different algorithm; the same search and the same bandit run everywhere, and the version arms decide online which policy is worth deploying. Our mean of 0.906 on HMaze-med still leaves a gap to an AUC of 1. Since the AUC accumulates the deployed success over the whole budget, that gap is the combined cost of the time spent searching and of the success rate reached after discovery; the means alone do not tell us how much each contributes.

How we got here

The framing came first. Our starting note split the problem into the two halves above: before the first success, the prior data says what is reachable and how; after it, a known goal state can be fed straight to a pretrained goal-conditioned policy, with no temporal-difference propagation needed. The skill-and-bonus methods that the task's baselines represent do the first half with a novelty bonus and the second with slow learning from scratch on the high level [4]. A literature survey we commissioned found no published method that searches over dataset goals with a pretrained goal-conditioned policy. It also pointed us to the greedy min-sum set-cover index as the right ordering rule and to the search-theory rule that an imperfect look should never clear a region for good [9]. We took the hierarchical goal-conditioned recipe of HIQL [8] as configured in OGBench [10].

The first search used the wrong notion of coverage. Our first version covered candidates inside a fixed radius and picked nuisance goals, chosen for coordinates that do not matter. The closest-approach posterior with a log-uniform radius replaced it. A calibration check showed backward distances far larger than forward ones, which is why closeness is the minimum of the two directions.

Stalls were a major search failure. Traces showed that in about a quarter of the episodes in one environment the agent got stuck, at a fixed point or in a posture it could not leave, and the task-relevant state never moved. The stall detector, goal switching and resets came from that. Adding random actions after a stall, tested on eight repeats of one hard development task, brought the mean first success to 20.9k steps, against at least 36k without it, in our development measurements.

Local proposals helped some environments and hurt another, which is why search episodes cycle through modes instead of committing to one. The radius prior's lower end was then set per environment from search-only runs. We recorded that evidence as noisy, ten runs per value, with a standard error of about 4k steps on a mean.

Fine-tuning helped in one environment and hurt in another. Our first task-as-goal fine-tuning took success in one development environment from about 0.6 to about 1.0 within some 15k steps of discovery, and lowered it from 0.75 to 0.45 in another. Every variant we tried had the same split, consistent with the observation that cloning narrow online data erases a pretrained prior [11]. Rather than pick one, we made the policy version a bandit arm, and kept the frozen arm free of forgetting. The critic-guided version followed the idea of keeping pretrained proposals frozen and selecting among them by value [12]. In side-by-side development tests it lifted success above the frozen policy where fine-tuning hurt, and mildly hurt in one other environment. The critic's head start, scaled by its error, was added so that an untrained critic reduces to the frozen policy. Waypoint replay was kept as a fourth arm after it helped in one environment and hurt in another.

Many ideas did not survive. Each of the following was tested in development and rejected for no measurable gain or a clear loss:

  • a non-parametric high level that picks prior states by value, and stateful detours after stalls;
  • a prior favouring candidates far from the start, and an inverse-density prior;
  • a smaller upper end of the radius prior, which made the agent dither locally;
  • a sparse-change prior over persistent features, and coverage measured on persistent features alone;
  • extra search-noise levels, noise escalation after stalls, more frequent sampled episodes and a larger travel offset ;
  • ski-rental reset rules and committed blind-guess episodes;
  • twice as many pretraining steps, a higher update-to-data ratio, Polyak-averaged learned weights, self-imitation fine-tuning, and a joint-record delivery rule.

The first-entry insight came late and paid off in controlled tests. Measuring the frozen policy with oracle goals against success-state commands showed the latter falling short on some tasks, as expected if success states sit on the boundary. Pushing the command five steps along the entry motion raised one development task's success from 0.647 to 0.773 in our measurements. In a separate test, command cycling added to on several tasks.

Coverage forgetting: an effect that shrank, and a mechanism we had to correct. Pooling eight long searches in one environment, we saw that the share of episodes passing near the goal fell block by block as the search went on. Letting old coverage fade by a small factor per search episode looked dramatic in the first two batches, roughly halving mean discovery time on the hard tasks. With 104 search-only runs per arm the effect shrank: mean first success fell from 28.0k to 21.0k steps, and the share of very long searches from 15.4% to 7.7%, with one-sided p of about 0.055 and 0.064. We kept it because the direction held in seven of eight tasks and we saw no harm on the easy tasks. Our first explanation was that a near miss empties the posterior around the goal. Replaying a recorded failed search through the coverage model refuted this: the true goal candidates kept most of their weight, and the posterior instead depleted slowly and unevenly, leaving cheap residual mass near the start for the greedy index to polish. We corrected the code comment accordingly. In other development environments forgetting was mixed or made no difference, so it stays a per-environment constant.

The next idea was not shipped. In our last probe, the centroid of several success states sat much closer to the true goal centre than a single success state did on average. A small controlled test of commanding it recovered the oracle-goal success level on one task. There was no time to validate it as an arm, so it is not in the submitted method.

Limitations

  • Discovery still has a heavy tail. Even with forgetting, our development runs show searches that take many times the median. A late discovery costs that run AUC in proportion to how late it comes, and the search remains the largest single loss we measured.
  • Near misses are not solved. Failure analysis of our final development policies found that the largest class of failures still passed just outside the success set and then drifted away; command overshoot and cycling, though preferred by the bandit, did not remove this class.
  • Hand-set per-environment constants. The discount, the subgoal horizon, the radius prior's lower end and the coverage forgetting are keyed on the environment; the first two follow the configuration the pretraining recipe was taken from, the last two were chosen from development runs. Some of those choices rest on ten runs per arm, and our own forgetting study showed that small batches of heavy-tailed search times can badly overstate an effect.
  • Learned snapshots can dip. A single weight snapshot of a learned version can be much worse than its neighbours; in one development run the final delivery scored 0.36 after 0.6 to 0.76 at earlier points. Only the arms' lower confidence bounds stand between such a snapshot and deployment.
  • The method assumes the goal is a reachable state region. The search is over states of the prior data, and commands are success states. A task whose success condition is not near any state the prior data visits, or one where resets are not free, falls outside what the search posterior models.
  • No ablation on the final metric. The contributions of the search, each arm and each version to the measured AUC were not separated; our evidence for the parts comes from controlled development tests, not from the evaluated runs.

References

  1. Philip J. Ball, Laura Smith, Ilya Kostrikov et al. (2023). Efficient Online Reinforcement Learning with Offline Data. ICML.
  2. Qiyang Li, Jason Zhang, Dibya Ghosh et al. (2023). Accelerating Exploration with Unlabeled Prior Data. NeurIPS.
  3. Yuri Burda, Harrison Edwards, Amos Storkey et al. (2019). Exploration by Random Network Distillation. ICLR.
  4. Max Wilcoxson, Qiyang Li, Kevin Frans et al. (2025). Leveraging Skills from Unlabeled Prior Data for Efficient Online Exploration. ICML.
  5. Seohong Park, Tobias Kreiman, Sergey Levine (2024). Foundation Policies with Hilbert Representations. ICML.
  6. Ishir Garg, Vivek Myers, Qiyang Li et al. (2026). Measuring Empowerment from Offline Data for Intrinsically Motivated Exploration.
  7. Andrew Wagenmaker, Mitsuhiko Nakamoto, Yunchu Zhang et al. (2025). Steering Your Diffusion Policy with Latent Space Reinforcement Learning. CoRL.
  8. Seohong Park, Dibya Ghosh, Benjamin Eysenbach et al. (2023). HIQL: Offline Goal-Conditioned RL with Latent States as Actions. NeurIPS.
  9. Sam Davey, Neil Gordon, Ian Holland et al. (2016). Bayesian Methods in the Search for MH370. SpringerBriefs in Electrical and Computer Engineering.
  10. Seohong Park, Kevin Frans, Benjamin Eysenbach et al. (2025). OGBench: Benchmarking Offline Goal-Conditioned RL. ICLR.
  11. Sami Nur Islam, Johan Obando-Ceron, Doina Precup et al. (2026). Freeze, Don't Clone: Fine-Tuning with Expressive Policies Without Retaining Offline Data.
  12. Seohong Park, Kevin Frans, Deepinder Mann et al. (2025). Horizon Reduction Makes RL Scalable. NeurIPS.

The session

The run from the model's first output, drawn as Claude Code shows a conversation: 778 steps.

Open the session

The submitted code

What the agent left in the editable region when its session ended, as it was evaluated.

supe/r2_method.pythe changes against the starter, inside the editable region