In-Context Learning as Rate–Distortion Optimization

Jiayu Zhang, Changbang Li, Canran XiaoICML 2026

Large Language Models (LLMs) are remarkably adept at In-Context Learning (ICL)—adapting to new tasks simply by observing a few demonstrations in their prompt. However, strict context limits create a persistent "token crunch." Because every additional token increases both latency and computational cost, developers must carefully decide how to spend their scarce token budget.

Recent research reframes this challenge as a classical communication problem: how can we pack the maximum amount of task-relevant "signal" into a prompt without introducing "noise" like redundancy or contradictions? By treating prompts as finite-capacity messages—much like a telegram with a strict character limit—researchers have introduced RDCO (Rate-Distortion Context Optimizer), a training-free method that achieves state-of-the-art performance and token efficiency.

The Pitfalls of Standard Context Selection

When building prompts, current retrieval methods often fail to optimize for the token budget, typically falling into three traps:

  1. Redundancy: Selecting multiple examples that demonstrate the exact same pattern, wasting valuable context space.
  2. Conflict: Including examples that contradict one another or the specific query, which confuses the model and degrades performance.
  3. Token Blindness: Treating all examples as equal regardless of length, ignoring the fact that a short, punchy demonstration often provides better "value" than a long, rambling one.

Introducing RDCO

To address these inefficiencies, the authors propose RDCO, a deterministic, training-free optimizer that constructs prompts step-by-step using three core pillars:

  • Marginal Information Density: Instead of merely asking if an example is relevant, RDCO evaluates how much an example shifts the model's prediction for the current query per token. It prioritizes demonstrations that deliver the highest informational impact for the lowest token cost.
  • Redundancy and Conflict Penalties: RDCO utilizes cosine similarity to penalize candidate examples that are too similar to those already in the prompt. Furthermore, it applies a "conflict cost"—if the model finds a candidate highly unlikely given the already-selected examples, it is flagged as a contradiction and deprioritized.
  • Bounded-Divergence Compaction: Once the best examples are selected, RDCO compresses their text. Crucially, it only trims tokens if the model's predicted output distribution remains within a strict limit (measured via KL divergence). This ensures the prompt is compacted without losing its core predictive "gist."

Key Insights and Theoretical Grounding

RDCO is not just a heuristic; it is grounded in classical information theory. The authors provide a theoretical framework (Theorem 4.1) proving that ICL follows the laws of Rate-Distortion theory, bridging the gap between traditional signal processing and modern LLM prompting.

By visualizing the selection process, the researchers identified a "Bend then Flatten" trajectory. The first few tokens added to a prompt provide a massive spike in useful information. However, after a certain point, adding more tokens yields diminishing returns, mostly introducing redundancy and conflict. RDCO naturally identifies the "elbow" of this curve, stopping before the token budget is wasted.

Additionally, RDCO exhibits a "Firefighter" effect. It is highly effective at filtering out messy, noisy, or redundant candidate pools, saving the model from being misled by subpar retrieval systems.

Empirical Results

The researchers evaluated RDCO across a massive suite of benchmarks, including a 10-dataset multi-task suite (covering classification and structured generation), dynamic calibration benchmarks, and out-of-distribution/retrieval-augmented QA tasks.

RDCO consistently outperformed both unsupervised (BM25) and heavy-duty supervised (EPR, CEIL) baselines:

  • Performance Boost: On the 10-task benchmark, RDCO achieved 63.26 Accuracy on classification and 60.26 Exact Match on generation, beating the strongest baselines by 2.20 and 2.26 points, respectively.
  • Overall Average: Across all 10 tasks, RDCO improved the overall average by 4.94 points under the exact same token budget.
  • Efficiency Frontier: RDCO traces a superior Pareto frontier, meaning that for any given token cost or inference time, it provides higher accuracy than competing methods.

Limitations and Future Directions

While highly effective, RDCO does come with an inference overhead. Because it calculates marginal information, it requires multiple forward passes to score candidates before the final generation. While the authors demonstrate that this compute cost is justified by the accuracy gains, it may pose challenges for real-time applications with ultra-strict latency requirements.

Furthermore, RDCO is fundamentally a selector and compressor—it suffers from candidate pool dependence. If the initial pool of retrieved examples contains zero useful information, RDCO cannot hallucinate a good prompt out of thin air.

Looking ahead, the authors suggest extending this framework to long-context models. While these models have larger budgets, the risk of the "lost in the middle" phenomenon or conflicting signals is even higher, making principled rate-distortion optimization more relevant than ever.

Summary updated

BibTeX
@inproceedings{zhang2026context,
  author = {Jiayu Zhang and Changbang Li and Canran Xiao},
  title = {{In-Context Learning as Rate–Distortion Optimization}},
  booktitle = {International Conference on Machine Learning},
  year = {2026},
  url = {https://openreview.net/forum?id=jLgwk2e1aW},
}
Figure