Dynamic Uncertainty Ranking: Enhancing Retrieval-Augmented In-Context Learning for Long-Tail Knowledge in LLMs

Shuyang Yu, Runxue Bao, Parminder Bhatia, Taha A. Kass-Hout, Jiayu Zhou, Cao Xiao

Abstract

Large Language Models (LLMs) often struggle with "long-tail" knowledge—specialized or rare information underrepresented in training data. While Retrieval-Augmented In-Context Learning (RA-ICL) aims to mitigate this by providing relevant examples, performance is often unstable and sensitive to the specific examples retrieved. We present Dynamic Uncertainty Ranking (DUR), a reinforcement learning-based framework that trains a retriever to prioritize samples that stabilize correct predictions. By incorporating a dynamic budget controller to filter misleading examples, DUR improves accuracy on difficult long-tail questions by nearly 6% while reducing computational overhead.

Introduction: The Long-Tail Challenge in RA-ICL

LLMs serve as vast knowledge bases but face significant limitations when queried about niche domains like medicine or specialized history. RA-ICL addresses this by prepending retrieved examples to the user's prompt. However, RA-ICL is notoriously brittle; adding seemingly relevant examples can sometimes introduce noise, causing "prediction shifts" where a previously correct model becomes confused. Standard retrievers like BM25 do not account for this uncertainty, failing to distinguish between informative and misleading context.

Methodology: Dynamic Uncertainty Ranking (DUR)

The DUR framework treats example retrieval as a reinforcement learning problem, optimizing for both prediction accuracy and stability.

Retriever Architecture and RL Loop

The system utilizes a BERT-based retriever augmented with a fine-tuned linear layer to calculate ranking scores. Training follows a policy gradient approach (REINFORCE):

  1. The retriever selects a sequence of examples.
  2. The LLM generates predictions based on varying "shot" counts.
  3. A binary reward (positive for correct, negative for incorrect) is issued. The retriever learns to prioritize "informative and stable" samples—those that consistently lead to correct answers across different prompt configurations.
Overview of the DUR retriever training process, illustrating the RL loop between the retriever and the LLM.

Dynamic Budget Controller

To optimize efficiency, DUR introduces a learnable threshold ($\sigma$). If a retrieved sample's score falls below this threshold, it is discarded. This "budget controller" automatically adjusts to negative prediction shifts, preventing the inclusion of misleading data and significantly reducing the number of tokens processed by the LLM.

Experimental Evaluation

DUR was evaluated across five diverse datasets: Pubmedqa (biomedical), ethos-national (hate speech), eval-climate (climate change), T-REx (Wikipedia extraction), and NatQA (general knowledge). These datasets were chosen to test the model's ability to generalize across specialized domains.

Key Results and Insights

The experimental results demonstrate that DUR consistently outperforms traditional retrieval baselines, particularly on "hard" samples where the LLM fails in a zero-shot setting.

Performance comparison of DUR against baselines on Easy and Hard samples across five datasets.
  • Accuracy Gains: DUR achieved a 2.76% average accuracy boost over the best baseline (Rerank) and a significant 5.96% improvement on hard, long-tail questions.
  • Efficiency: On the Pubmedqa dataset, DUR maintained superior performance while using only 33.8% of the examples required by competitive baselines like PromptPG.
  • Cross-Domain Transferability: Retrievers trained on one domain showed robust performance when transferred to others, indicating that DUR learns fundamental characteristics of "helpful" examples rather than domain-specific patterns.

Conclusion

Dynamic Uncertainty Ranking addresses the inherent instability of RA-ICL for long-tail knowledge. By explicitly modeling prediction uncertainty and employing a dynamic budget controller, DUR provides a more reliable and efficient way to augment LLMs with specialized information. Future work will explore the impact of example ordering and extending the framework to more complex generative tasks.

Summary updated

BibTeX
@inproceedings{yu2025dynamic,
  author = {Shuyang Yu and Runxue Bao and Parminder Bhatia and Taha A. Kass-Hout and Jiayu Zhou and Cao Xiao},
  title = {{Dynamic Uncertainty Ranking: Enhancing Retrieval-Augmented In-Context Learning for Long-Tail Knowledge in LLMs}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2025},
  doi = {10.18653/v1/2025.naacl-long.453},
}
Figure