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

LLMs Are In-Context Bandit Reinforcement Learners

Giovanni Monea, Antoine Bosselut, Kianté Brantley, Yoav Artzi

TL;DR

This paper introduces In-Context Reinforcement Learning (ICRL) for Large Language Models (LLMs), enabling them to learn online from external rewards within their context window, similar to how humans learn from experience. They demonstrate that LLMs can effectively perform ICRL, achieving significant performance gains on classification tasks, but highlight the critical role of exploration and the challenge of learning from negative feedback.

What Problem Does This Paper Address?

Traditional in-context learning (ICL) relies on providing LLMs with pre-annotated examples to guide their responses. However, this approach is limited by the availability of labeled data and doesn't reflect how agents learn in dynamic, real-world environments where feedback is often sparse and delayed. The authors address the question of whether LLMs can learn online and interactively from external rewards, akin to reinforcement learning, without requiring parameter updates or fixed datasets. This is crucial for enabling LLMs to adapt and improve in deployment settings.

Methods

The core contribution is the formulation and empirical study of In-Context Reinforcement Learning (ICRL). The authors propose two main methods:

  • Naive ICRL: A straightforward implementation where the LLM's context is built from past (input, prediction, reward) triplets.
  • Naive+ ICRL: An improvement that filters out negative reward episodes, significantly boosting performance and stability.
  • Stochastic ICRL: This method introduces stochasticity in prompt composition by randomly sampling past episodes to include in the context. This enhances exploration and improves stability compared to Naive+, especially when dealing with negative feedback.

They also introduce Approximate ICRL to reduce computational costs by maintaining a limited set of contexts, which can be expanded over time.

Datasets

The experiments were conducted on several multi-label classification datasets:

  • Banking77: 77 labels, economic context.
  • CLINC150: 150 labels, intent classification.
  • NLU: 68 labels, human-robot interaction.
  • TREC: 6 labels, question classification.
  • TREC-fine: 50 labels, question classification.

These datasets were used in both their original semantic form and with abstract labels (e.g., "label5") to test the models' ability to learn without inherent semantic cues.

Key Insights and Ideas

  • LLMs possess innate ICRL capabilities: Off-the-shelf LLMs can learn in-context from their own predictions and rewards, demonstrating a form of online learning.
  • Exploration is paramount: Effective ICRL heavily relies on the model's ability to explore and generate diverse outputs, which is crucial for discovering positive reward signals.
  • Negative feedback is a major challenge: Naive ICRL struggles significantly with negative rewards, highlighting a limitation in LLMs' implicit reasoning about errors. Filtering these out (Naive+) dramatically improves performance.
  • Stochasticity aids learning and stability: Introducing randomness in context selection (Stochastic ICRL) helps LLMs explore more effectively and leads to more stable learning, even when negative feedback is present.
  • Model scale matters: Larger LLMs generally exhibit better ICRL performance and stability, suggesting that scaling up is a key factor for robust in-context learning.
  • Abstract labels are learnable, but harder: LLMs can learn tasks with abstract labels, but it requires more careful prompting and often benefits from initial exemplars.

Key Results

  • Significant performance gains: Naive+ and Stochastic ICRL improved zero-shot accuracies by 28.6–74.4% for Llama and 29.2–68.4% for Qwen on various tasks. For example, Qwen2.5-7B improved from 6.2% to 72.2% on Banking77 using Stochastic ICRL.
  • Scaling trends: Performance generally increased with model size, with smaller models plateauing earlier.
  • Stability improvements: Stochastic ICRL demonstrated more stable learning trends compared to Naive+, with fewer performance dips.
  • Computational efficiency: Approximate ICRL reduced token processing by two orders of magnitude compared to Stochastic, while maintaining competitive performance.

Limitations and Future Work

  • Learning from mistakes: The paper highlights that LLMs struggle to learn effectively from negative rewards without explicit reasoning mechanisms (like Chain-of-Thought). Future work could focus on developing methods to elicit or train LLMs to reason about and learn from negative feedback.
  • Complex RL scenarios: The current study focuses on contextual bandit settings with binary rewards and single-step interactions. Extending ICRL to more complex, multi-step RL problems with nuanced rewards (e.g., math or coding tasks) is a significant area for future research.
  • Computational resources: ICRL can be compute-intensive, especially as the context window fills. Further work on optimizing computational demands, such as through more efficient approximation strategies, is needed.
  • Hyperparameter tuning: While temperature and $P_{keep}$ were explored, further optimization of these parameters, particularly for Stochastic ICRL, could yield even better results.

Summary updated

BibTeX
@inproceedings{monea2025llms,
  author = {Giovanni Monea and Antoine Bosselut and Kianté Brantley and Yoav Artzi},
  title = {{LLMs Are In-Context Bandit Reinforcement Learners}},
  booktitle = {COLM},
  year = {2025},
  url = {https://openreview.net/forum?id=c0RsezY2D1},
}
Figure