From Weak Data to Strong Policy: Q-Targets Enable Provable In-Context Reinforcement Learning

Yichen Lin, Xuyuan Xiong, Xue Wang, Xiangfu Meng, Mike Mingcheng Wei, Tao YaoNeurIPS 2026

TL;DR

Training a Transformer to make sequential decisions by simply copying past actions works great—until your training data is full of bad choices. Q-Target Pretrained Transformers (QTPT) swaps out blind imitation for value estimation, training sequence models to read past rewards and transitions to figure out what an action is actually worth. As a result, an agent can learn strong, adaptable policies for brand-new tasks even when pretrained on completely random, non-expert trajectories.

What Problem Does This Paper Address?

Transformers are famously good at in-context learning: hand them a prompt with a few examples, and they adapt on the fly without updating a single weight. Recently, researchers brought this magic to In-Context Reinforcement Learning (ICRL). Feed a Transformer a history of states, actions, and rewards, and it infers the hidden rules of an unseen environment to choose the next move.

Here is the catch: most ICRL methods rely on Supervised Pretraining (SPT)—essentially behavior cloning. You show the model logged trajectories and train it to predict the exact action taken in the dataset. If that offline dataset was recorded by an expert, life is good. If it was recorded by a clumsy, noisy, or random policy, supervised learning faithfully teaches the Transformer to make those exact same mistakes. How do we build sequence models that still infer tasks from context, without inheriting the bad habits of weak training data?

Overview comparing QTPT's Bellman value objective with SPT's action-imitation objective on expert vs. non-expert data.

Methods

The authors keep the standard causal Transformer architecture (a GPT-2-style decoder) and test-time setup, where the model adapts purely via its growing interaction history. What is new is replacing the supervised action-prediction loss with an end-to-end Bellman Q-learning objective, creating QTPT.

  • What stays standard: The input is still a chronological sequence of states, actions, and rewards, plus the current state. At test time, weights remain frozen as the context window grows.
  • What changes: Instead of outputting a probability distribution to mimic the logged action, the Transformer outputs Q-values—estimates of total future reward—for all possible actions. During pretraining, it minimizes the Temporal Difference (TD) error: matching its current value prediction to the immediate reward plus the best estimated value of the next state (stabilized practically using a target network and softmax-weighted backups). At deployment, the agent simply acts greedily, picking whichever action has the highest predicted Q-value.

Datasets

No new benchmarks are introduced; the authors evaluate across synthetic, robotic, and language benchmarks:

  • Stochastic Linear Bandits: Synthetic 10-arm problems ($d=5$, horizon $T=200$) using 100,000 trajectories collected via random policies, expert (LinUCB) policies, or mixtures of both.
  • Contextual MDPs: Standard ICRL grid/visual worlds—Darkroom, Dark Key-to-door, and Miniworld—where goal locations change per episode and must be inferred from context.
  • D4RL: Higher-dimensional continuous control tasks with sparse rewards (Kitchen-partial-v0, Kitchen-mixed-v0, and AntMaze-umaze-v2).
  • GSM8K: Grade-school math word problems used to test cross-domain adaptation to LLM reasoning.

Key Insights and Ideas

  • Bad imitation targets can be great exploration data: A random policy is terrible to copy, which is why supervised pretraining collapses on it. Yet random wandering stumbles across diverse states, actions, and rewards. Because QTPT learns values from transitions rather than copying choices, random data actually beat expert data in Darkroom—wider coverage gave Q-learning a richer map of the world!
  • Disentangling data limits from model limits: Theoretically, the authors split suboptimality into sample bias (how well the offline dataset covers optimal paths) and model bias (the Transformer's approximation and finite-sample limits), proving that Bellman pretraining extracts diminishing error from random bandit data where imitation stays stuck with linear regret.
  • Both context and bootstrapping do heavy lifting: Swapping bootstrapped TD targets for full Monte Carlo returns hurts performance, and stripping away interaction history destroys it completely—showing that in-context task inference and step-by-step valuestitching work hand-in-hand.

Key Results

Bandit performance showing QTPT maintaining low suboptimality across time steps and across varying fractions of expert data compared to SPT.

Figure 2: (a) Suboptimality gap over time for QTPT and SPT under random and LinUCB pretraining data, averaged over 1000 runs. (b) Mixture evaluation: mean gap and one standard deviation across five training seeds, evaluated on 1,000 task instances, versus the fraction of expert trajectories. Both are finite-horizon results at T = 200, not a verification of asymptotic rates.
  • Bandit Robustness: As the share of expert trajectories drops from 100% down to 0%, SPT’s cumulative suboptimality gap balloons from ~45 to over 220, while QTPT stays flat and low (~35–40) across the entire spectrum.
  • Contextual MDPs & Ablations: On Darkroom with random pretraining data, QTPT scores 13.15 average reward versus SPT's 0.65. In controlled Darkroom ablations (random data), removing TD bootstrapping for Monte Carlo returns drops reward by 35% (14.46 to 9.33), and removing context drops it by 97% (to 0.38). (Exception: on Dark Key-to-door with expert-only data, extremely sparse rewards make TD learning slightly trail SPT, 0.71 vs. 0.78).
  • D4RL & Math Reasoning: Under matched Transformer baselines, QTPT leads on AntMaze-umaze-v2 with a 35.94% success rate (vs. 26.96% for SPT and 20.00% for QDT) and tops Kitchen-mixed-v0 (14.62 vs. 13.25 SPT). Adapted to math reasoning on GSM8K, it beats behavior cloning by an average of 1.81%.

Limitations and Future Work

  • Coverage is still king: QTPT forgives suboptimal choices, not missing data. Both theory and practice require the offline dataset to actually visit the states and actions needed to piece together a good policy.
  • Residual value overestimation: Like classic offline Q-learning, QTPT can still overestimate the value of out-of-distribution (unsupported) actions. Target networks and softmax backups soften the blow, though tacking on a standard Conservative Q-Learning (CQL) penalty yielded no statistically reliable boost in diagnostics.
  • Not tuned for SOTA leaderboards: D4RL runs use fixed protocols to compare Transformer objectives apples-to-apples, exhibiting high seed variance rather than competing with specialized offline-RL pipelines. Future directions include scaling to larger D4RL suites and industrial datasets, testing multi-step Bellman backups, handling train–test distribution shifts, and expanding to broader NLP reasoning tasks.

Summary updated

Abstract

Existing in-context reinforcement learning methods mainly pretrain Transformers with supervised behavior-prediction objectives. While such objectives support task inference from context, they tie the learned policy to the quality of offline actions and can fail when trajectories are weak or suboptimal. We propose Q-Target Pretrained Transformers (QTPT), which preserves context-conditioned inference but replaces behavior cloning with a Bellman-style Q-target objective. QTPT learns to estimate action values from contextual rewards and transitions, rather than simply imitating the behavior policy. We analyze QTPT in stochastic linear bandits and finite-horizon MDPs, deriving suboptimality bounds that separate offline-data effects from Transformer approximation error. Empirically, QTPT is most beneficial under weak offline data across controlled RL benchmarks, and controlled ablations show that context conditioning is essential while Bellman/TD targets provide additional gains. We further include D4RL experiments as higher-dimensional stress tests under matched Transformer baselines.
BibTeX
@inproceedings{lin2026from,
  author = {Yichen Lin and Xuyuan Xiong and Xue Wang and Xiangfu Meng and Mike Mingcheng Wei and Tao Yao},
  title = {{From Weak Data to Strong Policy: Q-Targets Enable Provable In-Context Reinforcement Learning}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=UNtPiyXC2w},
}
Figure