Abstract
Large Language Models (LLMs) often struggle with cross-task generalization, where target tasks fall outside their training distribution. We present a framework for Instance-Level Dynamic LoRAs Composition, which "hot-swaps" specialized Low-Rank Adapters (LoRAs) at the individual query level. By dynamically retrieving and weighting expert modules for every input, our method achieves superior performance on unseen tasks compared to traditional task-level composition and in-context learning. Evaluated on the Big-Bench Hard (BBH) benchmark, our approach yields an average accuracy of 35.6, outperforming the previous state-of-the-art task-level method.
Introduction
While LLMs excel at instruction following, generalizing to entirely new tasks remains a challenge. Current strategies like full fine-tuning are computationally prohibitive, while In-Context Learning (ICL) suffers from high token consumption and latency. Recent advancements in task-level composition, such as LoraHub, combine multiple LoRAs into a single task-specific module. However, these methods apply a uniform adapter configuration to every instance within a task, failing to account for the unique semantic nuances of individual questions. We propose that a "one-size-fits-all" approach is insufficient and advocate for instance-level adaptation.
Methodology
Our framework operates in three distinct stages to construct optimized "mini-models" on the fly:
- LoRA Library Construction: A library of specialized LoRAs is pre-trained on 97 diverse upstream tasks from the Flan-v2 dataset.
- Semantic Retrieval: Instead of random selection, we utilize Dense Passage Retrieval (DPR) to identify the top $N$ most relevant expert modules based on semantic similarity between the input and the LoRAs' training sets.
- Dynamic Weighting: For a small set of example instances, we employ gradient-free optimization to determine the optimal blend of the selected $N$ LoRAs. At inference, the system applies the weight configuration of the most similar example instance to the new query.
Experimental Results
We evaluated our method using Flan-T5-Large as the base model on the Big-Bench Hard (BBH) benchmark, comprising 27 reasoning-intensive tasks.
As shown in the results, our instance-level approach achieved an average accuracy of 35.6, surpassing LoraHub (34.0) and standard ICL (30.9). Notably, our method outperformed LoraHub on 16 out of 27 BBH tasks. In specific domains like "disambiguation qa," performance nearly doubled compared to task-level approaches, demonstrating the efficacy of tailoring adapter weights to specific question nuances. While the instance-level weighting introduces a slight increase in latency (3.7s vs 1.4s per batch compared to task-level methods), it remains significantly more token-efficient than ICL by avoiding long prompt prefixes.
Discussion and Conclusion
The primary insight of this work is that instance-level specificity is a critical driver for cross-task generalization. By moving from random task-level selection to semantic retrieval, we improve both performance and stability. While our method introduces some computational overhead during the initial weighting phase, it remains significantly more token-efficient than ICL. Future work will focus on scaling the LoRA library and refining retrieval mechanisms to further enhance the model's ability to "borrow" specialized knowledge across diverse domains.
Summary updated