Introduction
Deploying Large Language Models (LLMs) on mobile devices requires a delicate balance between versatility and resource constraints. While base models like Llama-3.2-1B are powerful, they often require specialized Low-Rank Adapters (LoRAs) to excel at specific tasks, such as multi-lingual summarization or grammar correction. However, as the number of tasks grows, the storage requirements for these adapters become prohibitive. For instance, storing 40 distinct LoRAs could consume over 1GB of storage, which is a significant burden for mobile hardware.
Furthermore, in real-world scenarios, these task capabilities often arrive incrementally. This paper introduces K-Merge, a framework for online continual merging, which allows for the integration of new adapters into a fixed number of storage "slots" on-the-fly, without requiring access to original training data.
The K-Merge Framework
K-Merge and its variant, K-Merge++, manage a limited storage budget of $K$ slots by intelligently clustering and merging incoming adapters based on weight similarity.
The process follows a three-step pipeline:
- Similarity-Based Clustering: Upon the arrival of a new LoRA, the system calculates the cosine similarity between its flattened weight matrices and those of the adapters currently stored on the device.
- Decision Logic:
- K-Merge: If an empty slot is available, the new adapter occupies it. If all $K$ slots are full, the new adapter is merged into the most similar existing one.
- K-Merge++: This version introduces a similarity threshold. If the new adapter is not sufficiently similar to any existing slot, the system attempts to preserve a new slot for it, maintaining diversity for future tasks.
- History-Aware Merging: To prevent newer tasks from overshadowing older ones, K-Merge uses a running average formula. This ensures that each task within a merged slot maintains a balanced influence, regardless of its arrival order.
Experimental Evaluation
The framework was evaluated using a benchmark of 40 tasks across five problem types (Smart Reply, Summarization, Tone Adjustment, QA, and Grammar Correction) and eight languages.
Key Insights
- Task-Centric Clustering: A significant finding is that LoRAs cluster more naturally by task type than by language. For example, summarization adapters across different languages share more weight similarity than different task adapters within the same language.
- Efficiency: The merging process is extremely fast, taking between 0.04s and 0.18s, as it operates solely on model weights without processing text data.
Performance Analysis
K-Merge consistently outperforms standard merging techniques such as Linear averaging, TIES, and DARE, particularly under tight storage constraints.
As shown in the results, with a budget of only 8 slots to cover 40 tasks, K-Merge++ recovers 80-90% of the performance of dedicated, task-specific adapters. The system also demonstrates high robustness to the order of task arrival, thanks to the running average mechanism and similarity thresholds.
Conclusion and Future Work
K-Merge provides a scalable solution for enhancing on-device LLM capabilities within strict storage limits. While currently focused on text-based models and LoRA adapters, future research will explore extending this framework to multimodal models and other adapter architectures.
Summary updated