Abstract
In-Context Learning (ICL) has emerged as a transformative technique for adapting Large Language Models (LLMs) to specialized domains without extensive fine-tuning. In the biomedical field, where high-quality annotated data is scarce due to privacy regulations and the rarity of clinical conditions, ICL is particularly valuable. However, conventional demonstration selection strategies often rely solely on semantic similarity, which can lead to redundant and uninformative prompts. We introduce Dual-Div, a two-stage framework that employs submodular optimization to select demonstrations that are both relevant and diverse. By integrating coverage and diversity metrics, Dual-Div improves performance by up to 5% in macro-F1 scores across various biomedical NLP tasks, demonstrating that semantic diversity is crucial for effective few-shot learning.
Introduction
The efficacy of In-Context Learning (ICL) depends heavily on the quality and composition of the demonstrations provided in the prompt. In the biomedical domain, the challenge is twofold: data is difficult to acquire, and the semantic space is complex. Most existing retrieval methods focus on finding examples most similar to the test query. While intuitive, this approach often results in a set of demonstrations that are highly similar to each other, failing to cover the broader context necessary for the LLM to generalize effectively. This redundancy leaves the model "blind" to the varied scenarios typical of clinical text.
To address this, we propose a shift from simple similarity-based retrieval to a diversity-enhanced perspective. We frame demonstration selection as a submodular optimization problem, aiming to maximize a utility function that balances representativeness with semantic variety.
Methodology: The Dual-Div Framework
Dual-Div operates through a two-stage process designed to optimize the demonstration set for both global representativeness and local relevance.
Stage 1: Diversity-Enhanced Retrieval
The first stage focuses on constructing a high-quality candidate pool from a large, unlabeled corpus. We utilize submodular functions to ensure the pool provides broad Coverage (using a facility location function) and high Diversity (using Determinantal Point Processes, or DPPs). The DPP approach treats examples as vectors and seeks to maximize the "volume" of the space they span, effectively selecting "orthogonal" examples that minimize redundancy.
Stage 2: Diversity-Enhanced Ranking
Once the candidate pool is established, the system ranks these candidates against the specific test query. Instead of a static ranking, we look for the "marginal gain"—identifying which examples add the most novel information relative to the query and the examples already selected. To maintain computational efficiency, we employ a "lazy greedy" algorithm, which provides near-optimal selection with significantly reduced overhead.
Experimental Setup
We evaluated Dual-Div using state-of-the-art LLMs, including LLaMA 3.1 (8B) and Qwen 2.5 (7B). The framework was tested across three distinct biomedical NLP tasks:
- ChemProt: Identification of chemical-protein interactions in scientific literature.
- DDI (Drug-Drug Interaction): Extraction of relations between drugs (e.g., mechanism, effect).
- HealthAdvice: Classification of health-related advice to detect misinformation.
Results and Discussion
Dual-Div consistently outperformed standard similarity-based baselines, yielding improvements of up to 5% in macro-F1 scores.
The Impact of Diversity
A major finding is that introducing diversity during the initial retrieval stage (Stage 1) is more impactful than doing so during the final ranking. This suggests that a diverse "foundation" in the candidate pool is essential for the subsequent selection of high-utility demonstrations. Furthermore, Dual-Div proved particularly effective at handling class imbalance. In the DDI dataset, where target relations are rare, the diversity-first approach allowed the model to identify infrequent classes that similarity-based methods often overlooked.
Visualization of Semantic Coverage
The effectiveness of Dual-Div is visually evident in UMAP projections of the selected examples. As shown in Figure 2, traditional methods tend to select tight, redundant clusters of points. In contrast, Dual-Div selects candidates that are distributed across the entire semantic map, providing the LLM with a much richer context.
Robustness and Efficiency
The framework also demonstrated increased robustness to the order of examples in the prompt, a common sensitivity in LLMs. Performance remained stable regardless of permutation. Additionally, we observed a "sweet spot" of 3–5 examples; exceeding this number often introduced noise that degraded performance.
Conclusion and Future Work
Dual-Div demonstrates that submodular optimization is a powerful tool for enhancing In-Context Learning in data-constrained environments. By prioritizing diversity, we can significantly improve the reasoning capabilities of LLMs on complex biomedical tasks. Future research will focus on dynamically tuning the trade-off parameter between coverage and diversity and scaling the framework to handle multi-billion document corpora through distributed algorithms.
Summary updated