NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

The Wisdom of Hindsight Makes Language Models Better Instruction Followers

Tianjun Zhang, Fangchen Liu, Justin Wong, Pieter Abbeel, Joseph E. Gonzalez

Aligning Large Language Models (LLMs) with human instructions is the "secret sauce" behind the success of models like ChatGPT. Typically, this is achieved via Reinforcement Learning from Human Feedback (RLHF). While effective, RLHF is notoriously finicky: it requires training separate reward and value networks, is highly sensitive to hyperparameters, and often discards "failed" attempts that don't match the target instruction.

In their paper, "The Wisdom of Hindsight Makes Language Models Better Instruction Followers," researchers from UC Berkeley propose a simpler, more data-efficient alternative: Hindsight Instruction Relabeling (HIR).

Executive Summary

HIR treats instruction following as a goal-reaching problem, applying the concept of "hindsight" to let models learn from their mistakes. Instead of discarding incorrect outputs, HIR relabels them with the instructions they actually fulfilled. This allows the model to improve via standard supervised fine-tuning, bypassing the complexity and instability of traditional RLHF.

The Problem with Current Alignment Methods

The current gold standard for alignment, RLHF (specifically using Proximal Policy Optimization or PPO), is complex. It essentially treats the LLM as an agent in a game where the "reward" is human preference. However, RL algorithms are difficult to scale, require additional parameters (reward/value models), and are often unstable.

Furthermore, existing methods are highly data-inefficient. If you ask a model to "Sort these words alphabetically" and it returns them sorted by length instead, a standard trainer marks that as a "fail" and moves on. The model learns nothing from the computation it just performed. The authors argue that this "failed" data contains valuable information if we simply change the context of the goal.

Methods: Hindsight Instruction Relabeling

The core innovation of the paper is Hindsight Instruction Relabeling (HIR), a technique inspired by Hindsight Experience Replay (HER) in robotics.

The Hindsight Instruction Relabeling (HIR) pipeline, showing the alternating phases of online sampling and offline training with relabeled instructions.

The algorithm operates in two alternating phases:

  1. Online Sampling: The model generates various outputs (trajectories) for a set of instructions. To encourage exploration and diverse responses, the researchers use a high sampling temperature.
  2. Offline Relabeling & Training: For every instruction-output pair, if the output is incorrect for the original instruction, the algorithm uses a "relabeling function" to find an instruction that does match the output. For example, if the model was asked to "Give a correct answer" but gave a "wrong answer," HIR relabels the prompt to "Give a wrong answer" and pairs it with that output. The model is then trained on these relabeled pairs using standard Supervised Fine-Tuning (SFT).

To make the training more robust, the authors also introduce a Contrastive Instruction Loss, which encourages the model to distinguish between instructions that lead to the same output, and Sub-output Relabeling, which provides denser feedback by relabeling intermediate reasoning steps.

Datasets and Evaluation

The authors evaluated HIR on 12 challenging tasks from BigBench, a benchmark designed to test the limits of LLMs. These tasks were specifically chosen for their reasoning requirements, including:

  • Logical Deduction: Deducing the order of objects.
  • Tracking Shuffled Objects: Identifying the final position of an item after multiple swaps.
  • Date Understanding: Calculating dates based on relative descriptions.
  • Direct Generation: Object counting and word sorting.

They used FLAN-T5 (Large and Base) as their backbone models.

Key Insights

  • Failure is a Matter of Perspective: A "wrong" answer is often just a "right" answer to a different question. By relabeling, HIR turns every failure into a successful training example.
  • No Extra Parameters: Unlike RLHF, which requires auxiliary reward and value models, HIR uses only the original LLM. This makes it much easier to integrate into existing pre-training pipelines.
  • Reasoning as Goal-Reaching: By framing text generation as a sequence of actions toward a goal (the instruction), the authors successfully bridge the gap between classical Reinforcement Learning and Natural Language Processing.

Key Results

HIR demonstrated significant performance gains over both RL baselines and standard fine-tuning.

Average performance on 12 BigBench tasks. HIR significantly outperforms PPO and FARL baselines, and even surpasses standard supervised finetuning.
  • Outperforming PPO: On the "Tracking Shuffled Objects (7 objects)" task, HIR achieved 42.6% accuracy, while the PPO baseline struggled at a mere 6.3%.
  • Massive Average Gains: Across the 12 BigBench tasks, HIR achieved an average accuracy of 67.3%, outperforming the "Final-Answer RL" (FARL) baseline by 11.2% and the PPO baseline by 32.6%.
  • Model Agnostic: The benefits held true across different model sizes. HIR improved the performance of the smaller FLAN-T5-Base by over 40% in several categories.
  • Surpassing SFT: Remarkably, HIR performed as well as or better than Supervised Fine-Tuning (which averaged ~64%), despite SFT having access to ground-truth labels that HIR has to "discover" through sampling.

Limitations and Future Work

  • Scripted Feedback: Currently, HIR relies on scripted functions to determine if an answer is "right" or "wrong" to perform relabeling. This works well for math and logic but is harder to apply to open-ended creative writing (e.g., "Write a poem about a frog").
  • Feedback Granularity: For very long-horizon tasks, binary feedback (correct/incorrect) might be too sparse. Moving toward more granular, "human-in-the-loop" relabeling could be a promising next step.
  • Base Model Strength: HIR still requires a base model capable of generating some variety of outputs to bootstrap the learning process. If a model is too weak to ever stumble upon a "relatable" answer, HIR has nothing to work with.

Summary updated

BibTeX
@inproceedings{zhang2023wisdom,
  author = {Tianjun Zhang and Fangchen Liu and Justin Wong and Pieter Abbeel and Joseph E. Gonzalez},
  title = {{The Wisdom of Hindsight Makes Language Models Better Instruction Followers}},
  booktitle = {International Conference on Machine Learning},
  year = {2023},
  url = {https://openreview.net/forum?id=rWG8gvquU2},
}
Figure