On-Device Collaborative Language Modeling via a Mixture of Generalists and Specialists

Dongyang Fan, Bettina Messmer, Nikita Doikov, Martin Jaggi

Introduction

Deploying Large Language Models (LLMs) directly on edge devices, such as smartphones and tablets, is a growing trend driven by the need for user privacy and low-latency interactions. However, training and fine-tuning these models collaboratively across many devices—typically done via Federated Learning (FL)—faces significant hurdles.

To address these challenges, researchers have introduced CoMiGS (Collaborative learning with a Mixture of Generalists and Specialists). CoMiGS is a novel federated learning framework that enables personalized on-device LLM fine-tuning by combining shared "generalist" experts with local "specialist" experts through a bi-level optimization strategy.

The Challenge of On-Device LLMs

Two massive roadblocks stand in the way of effective on-device collaborative learning:

  1. Data Heterogeneity: Users have vastly different typing habits and interests. One person might frequently write about skiing, while another discusses coding. A model needs to be personalized for these specific interests while remaining "universal" enough to recall factual truths (e.g., knowing the current US president).
  2. Resource Heterogeneity: Devices vary wildly in computational power. A high-end flagship phone can handle a much larger model than a budget device. Standard Federated Learning usually requires all participants to use the exact same model architecture, which leaves performance on the table for powerful devices and overburdens weaker ones.

The CoMiGS Framework

To solve these dual challenges, CoMiGS utilizes a Mixture-of-Experts (MoE) architecture where each "expert" is a lightweight Low-Rank Adaptation (LoRA) module.

The CoMiGS architecture showing shared generalists and local specialists/routers.

The core architecture decouples the model into three distinct components:

  • Generalist Experts: These modules are shared and aggregated across all users via a central server, capturing universal linguistic knowledge and broad facts.
  • Specialist Experts: These remain strictly local to each device, allowing the model to adapt to a user's specific niche, technical jargon, or personal slang.
  • Learned Routers: A local router decides, on a token-by-token basis, which combination of experts to use for the next word.

The technical innovation enabling this is a bi-level optimization formulation. Instead of training all components simultaneously on the same data, the router is optimized using a separate, small validation set to ensure it aligns with the target distribution. Meanwhile, the experts are trained on the main local training data. This objective is solved using an alternating minimization algorithm, which the authors prove converges at a linear rate.

Experimental Setup

The researchers evaluated CoMiGS across several diverse datasets to simulate real-world usage, including Multilingual Wikipedia (to test language variation), SlimPajama (to test topic-specific personalization across domains like StackExchange and GitHub), and AG News. They tested both In-Distribution (training and testing on the same topics) and Out-of-Distribution (training on one topic, testing on a mixture) scenarios.

Key Insights & Results

CoMiGS consistently outperformed state-of-the-art baselines like FedAvg, PCL, and pFedMoE in terms of test perplexity (a measure of how well the model predicts the next word, where lower is better).

  • Performance: On the SlimPajama dataset using a GPT2-124M base model, CoMiGS achieved a perplexity of 21.79, significantly beating standard FedAvg (23.27) and local-only training (26.95).
  • Token-Level Routing: Unlike previous methods that assign a single weight to a collaborator's model, CoMiGS makes decisions for every single word. Function words (like "the" or "and") are typically routed to generalists, while domain-specific terms are routed to specialists.
  • Generalists as Regularizers: A surprising finding was that shared generalists actually prevent local specialists from overfitting. Even when a user has very little data, the generalist provides a stable foundation that keeps the model from "hallucinating" based on a tiny local sample.
  • Resource Efficiency: CoMiGS allows users with powerful hardware to host more specialist experts without forcing that same burden on weaker devices. Furthermore, because only the generalist weights are sent to the server, communication costs are reduced by 50% compared to standard FedAvg.
Comparison of expert scores over time between CoMiGS and pFedMoE.

As shown in the routing score visualizations above, the CoMiGS router successfully learns to balance its reliance on generalists and specialists over time, whereas competing methods often fail to adapt as effectively to out-of-distribution tasks.

Limitations and Future Work

While CoMiGS represents a major step forward for decentralized LLM training, the authors note a few areas for future improvement. First, the current framework does not explicitly guarantee resilience against adversarial attackers who might try to poison the shared generalist weights. Second, while user data stays on-device, the shared weights could theoretically leak information; integrating Differential Privacy (DP) could further harden the system. Finally, the "regularizing" effect of generalists is less pronounced on very simple tasks where local models are inherently less prone to overfitting.

Summary updated

BibTeX
@inproceedings{fan2025device,
  author = {Dongyang Fan and Bettina Messmer and Nikita Doikov and Martin Jaggi},
  title = {{On-Device Collaborative Language Modeling via a Mixture of Generalists and Specialists}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=Eog0kXX7hW},
}
Figure