Abstract
As Large Language Models (LLMs) scale, the computational cost of fine-tuning for specific tasks and the risk of catastrophic forgetting have become significant barriers to efficiency. This paper proposes a framework for creating modular LLMs by managing a library of specialized Low-Rank Adaptation (LoRA) modules. We introduce two key innovations: Model-Based Clustering (MBC) for consolidating task-specific knowledge into expert adapters, and Arrow, a zero-shot routing mechanism that utilizes the internal geometry of LoRA weights to select optimal experts for new inputs. Our experiments on Phi-2 and Mistral 7B demonstrate that this modular approach not only manages the complexity of large adapter libraries but also outperforms traditional full fine-tuning and existing Mixture-of-Experts (MoE) baselines.
Introduction
Fine-tuning a massive LLM for every specific application is computationally prohibitive. While Parameter-Efficient Fine-Tuning (PEFT) methods like LoRA allow for the creation of small, task-specific modules, they introduce a new challenge: the management and reuse of a growing "galaxy" of independent adapters. Existing Mixture-of-Experts (MoE) approaches typically require joint training of experts and routers, which is impractical in decentralized environments where adapters are developed independently.
This research addresses two fundamental questions in the pursuit of modularity:
- Building: How can we consolidate hundreds of task-specific adapters into a manageable library of specialized skills?
- Reusing: How can we automatically route new, unseen prompts to the most relevant adapters without requiring additional training data for a router?
Methodology
Model-Based Clustering (MBC)
The authors propose that the similarity between the parameters of LoRA adapters serves as a high-fidelity proxy for task relatedness. To build the library, "private" LoRAs are first trained for individual tasks. These tasks are then clustered based on the cosine similarity of their flattened LoRA weights. Finally, a single "expert" LoRA is trained for each cluster. This process reduces the total number of adapters while maximizing positive transfer between similar tasks, effectively distilling a large number of tasks into a set of core competencies.
Arrow Routing (↗)
Arrow is a novel, zero-shot routing mechanism designed to select the best experts for a given input without any task-specific training. Unlike traditional routers that learn to map inputs to experts, Arrow analyzes the LoRA weights themselves:
- Weight Prototypes: Arrow performs a Singular Value Decomposition (SVD) on the LoRA weight matrices ($AB^T$). It identifies the direction of maximum variance—the "specialty" of the adapter—and uses it as a prototype.
- Dynamic Inference: At runtime, Arrow computes the alignment between the input's hidden states and these weight-derived prototypes. It selects the top-$k$ adapters per token and per layer. Because it relies on the geometric properties of the weights, it requires zero training data and no access to original task labels.
Experimental Setup
The framework was evaluated using the following configurations:
- Training Data: A library of 256 tasks from the Flan-v2 collection.
- Models: Experiments were conducted primarily on Phi-2 (2.8B) and Mistral (7B).
- Evaluation Benchmarks:
- Zero-Shot: 10 diverse tasks including WinoGrande, HellaSwag, PIQA (reasoning), HumanEval, MBPP (coding), and ARC (QA).
- Supervised: 12 held-out tasks from SuperNatural Instructions (SNI).
Key Results and Insights
Performance Gains
The modular approach proved highly effective. On the Phi-2 model, the Private-Arrow configuration (routing to independently trained adapters) achieved an average accuracy of 66.6% across 10 tasks. This outperformed both the base model (63.8%) and a version of the model that underwent full multi-task fine-tuning (65.6%). For Mistral 7B, Arrow routing provided a 2.5% absolute increase in performance over uniform averaging of adapters, highlighting the necessity of intelligent routing as libraries scale.
Weights as Task Embeddings
A significant finding of this study is that LoRA weight vectors are more effective "task embeddings" than traditional text-based embeddings. Clustering tasks by their learned weights consistently outperformed clustering by text similarity, suggesting that the model's learned parameters capture functional task relationships that text alone does not.
Granular Routing
Unlike standard task predictors that select a single expert for an entire prompt, Arrow operates with layer-wise and token-wise granularity. This allows the model to dynamically blend skills—for instance, utilizing a coding expert for logic-heavy tokens and a linguistic expert for natural language structure within the same sentence.
Conclusion and Future Work
This framework demonstrates that powerful LLMs can be built asynchronously by combining specialized modules from different contributors. While the current work focuses on LoRA, it opens new avenues for decentralized model development. Future research is required to determine if these geometric routing properties extend to other adapter types (e.g., prefix tuning) and how Arrow scales to "heterogeneous universes" containing thousands of specialized modules, such as those found on public model hubs.
Summary updated