TL;DR
This paper introduces SPICE, a novel In-Context Reinforcement Learning (ICRL) method that leverages Bayesian principles to adapt to new tasks without parameter updates. SPICE addresses key limitations of existing ICRL approaches, such as sensitivity to suboptimal training data and lack of uncertainty quantification, by learning a robust value prior and fusing it with context evidence for principled exploration.
What Problem Does This Paper Address?
In-Context Reinforcement Learning (ICRL) aims to enable agents to adapt to new tasks using only a history of past interactions, without requiring gradient-based updates. This is highly desirable for real-world applications where online learning is risky or expensive. However, current ICRL methods face several challenges:
- Behavior-Policy Bias: Methods trained with Maximum Likelihood Estimation (MLE) often inherit the limitations of the behavior policy, performing poorly if the training data is suboptimal. They can get stuck imitating the suboptimal behavior.
- Lack of Uncertainty Quantification: Effective adaptation and exploration require understanding the uncertainty in action value estimates. Most ICRL methods don't provide actionable posteriors for principled exploration strategies like Upper Confidence Bound (UCB).
- Unrealistic Data Requirements: Some methods demand near-optimal trajectories or full learning traces for training, which are often unavailable in practice.
SPICE aims to overcome these limitations by providing a Bayesian framework for ICRL that is robust to suboptimal training data and enables principled, gradient-free adaptation.
Methods
SPICE introduces a Bayesian approach to ICRL by combining a learned value prior with context-derived evidence. The core components are:
- Transformer Trunk: A causal transformer (similar to Decision Transformer) encodes the query state and the context (past interactions). This trunk is trained with a weighted loss that incorporates propensity correction, advantage weighting, and epistemic weighting. This shaping helps the trunk learn representations that are de-biased, reward-relevant, and uncertainty-aware, even from suboptimal data.
- Value Ensemble Prior: A K-head value ensemble is attached to the transformer trunk. This ensemble learns a prior over Q-values, providing not just a mean estimate but also a calibrated measure of uncertainty (variance). This prior is learned using TD(n) regression and Bayesian shrinkage, making it robust to noisy or sparse data.
- Bayesian Context Fusion: At test time, SPICE fuses the learned ensemble prior with evidence extracted from the test-time context. This evidence is weighted based on the similarity between the query state and context states, using a kernel function. The fusion is performed using a closed-form Bayesian update (precision additivity), resulting in per-action posterior distributions over Q-values.
- Posterior-UCB Controller: For online adaptation, SPICE uses a posterior-UCB rule. This rule leverages the posterior distribution to balance exploration (sampling actions with high uncertainty) and exploitation (choosing actions with high estimated value), enabling principled exploration and adaptation without parameter updates. For offline settings, it can act greedily based on the posterior mean.
Datasets
The paper evaluates SPICE on several benchmarks:
- Stochastic Bandits: Standard bandit tasks with Gaussian rewards.
- Darkroom Environment: A custom 10x10 gridworld navigation task with sparse rewards and distributional shift in goal locations. This environment is designed to be challenging, especially for methods relying on imitation learning from suboptimal data.
The pretraining data for these tasks is intentionally made suboptimal (e.g., using a uniform behavior policy and "weak-last" labels) to specifically test SPICE's robustness.
Key Insights and Ideas
- Bayesian Fusion for ICRL: The core idea of fusing a learned Bayesian prior with context-specific evidence is a powerful way to achieve robust adaptation in ICRL. It allows the model to leverage general knowledge from pretraining while quickly incorporating task-specific information.
- Calibrated Uncertainty is Key: The value ensemble's ability to provide calibrated uncertainty estimates is crucial. This uncertainty allows the posterior-UCB controller to explore effectively, even when the prior is miscalibrated or the context is sparse.
- Representation Shaping for Robustness: The weighted supervision on the transformer trunk is vital for overcoming behavior-policy bias. By upweighting important transitions (high advantage, high uncertainty), the trunk learns representations that are more useful for value estimation, even from suboptimal data.
- Theoretical Guarantees: SPICE achieves optimal logarithmic regret in bandit settings and optimal regret rates in finite-horizon MDPs, even when pre-trained on suboptimal data. This theoretical backing is a significant contribution, demonstrating the principled nature of the approach.
Key Results
- Bandit Performance: SPICE achieves near-optimal offline selection quality and the lowest cumulative regret among learned methods in online bandit settings, closely tracking classical UCB. It also shows strong robustness to reward noise shifts, unlike methods like DPT.
- Darkroom Performance: In the challenging Darkroom environment with weak supervision, SPICE adapts quickly and achieves high returns, demonstrating a significant improvement over DPT and other baselines that struggle with suboptimal data and distributional shift.
- Regret Bounds: SPICE theoretically achieves optimal regret bounds in both bandit and MDP settings, with any pretraining miscalibration contributing only a constant warm-start term, not affecting asymptotic performance.
- Ablation Studies: Weighting terms in the training objective (especially epistemic weighting) are shown to be crucial for SPICE's performance, particularly in sparse-reward environments.
Limitations and Future Work
- Kernel Choice: The performance of SPICE can depend on the choice of kernel for state similarity. In highly non-stationary or partially observable settings, poorly chosen kernels could lead to issues.
- Prior Calibration: While SPICE is designed to be robust to prior miscalibration, a systematically misspecified prior could still slow down early adaptation.
- Future Work: The authors suggest exploring extensions to continuous action spaces and investigating more sophisticated kernel selection methods. Further research into improving prior calibration and handling more complex partially observable environments is also suggested.
Summary updated