Pack of LLMs: Model Fusion at Test-Time via Perplexity Optimization

Costas Mavromatis, Petros Karypis, George Karypis · DOI

Abstract

The rapid evolution of Large Language Models (LLMs) has led to a proliferation of models with diverse strengths. Fusing these models to leverage their collective intelligence typically requires expensive retraining or results in suboptimal static ensembles. We present Pack of LLMs (PackLLM), a modular, training-free framework that fuses an arbitrary set of LLMs at test-time. By using perplexity as a dynamic indicator of model expertise for a given prompt, PackLLM optimizes the combination of model outputs. Our results show that PackLLM significantly outperforms traditional ensembles and surpasses learning-based fusers by incorporating the latest high-performing models without additional training costs.

The Challenge of Model Fusion

The current AI ecosystem is characterized by a constant stream of new LLMs, each trained on different datasets with varying architectures. Combining these models—a process known as "fusion"—aims to create a system superior to any single component. However, existing fusion strategies face a critical trade-off between performance and modularity.

Comparison of traditional retraining-based fusion versus the modular PackLLM approach.

Learning-based fusers (e.g., FuseLLM) require training a secondary "meta-model" to learn how to combine others. While effective, this approach is non-modular; the release of a new, superior model necessitates a complete retraining cycle. Conversely, heuristic ensembles like uniform averaging are modular but "dumb," often allowing weaker models to degrade the performance of stronger ones. PackLLM addresses this by enabling test-time fusion, where models are combined on-the-fly based on their specific expertise for each input.

Methodology: Perplexity as Expertise

PackLLM is built on the intuition that a model's perplexity (PPL) on an input prompt serves as a reliable proxy for its expertise. A model that assigns high probability to the prompt tokens likely "understands" the context better.

Comparison of fusion strategies: Learn-to-Fuse (non-modular), Ensemble (uniform), and PackLLM (perplexity-based).

The framework offers two primary variants:

  • PackLLM_sim: Uses a softmax over negative log-perplexity scores to assign weights.
  • PackLLM_opt: Employs a greedy optimization algorithm to find the linear combination of model logits that minimizes perplexity over the input prompt.

To bridge the gap between models with different vocabularies, PackLLM uses a Minimum Edit Distance (MinED) strategy for tokenizer alignment, ensuring that logits from disparate architectures (e.g., Llama and Mistral) can be mathematically aggregated.

Experimental Evaluation

The authors evaluated PackLLM using over 100 LLMs across 25 benchmarks, including MMLU (STEM and Health), reasoning tasks (ARC, BoolQ), and domain-specific datasets like PubMedQA.

Key Results

  • Performance Gains: PackLLM outperformed uniform ensembles by approximately 1.72–1.89% in accuracy.
  • Outperforming State-of-the-Art: When allowed to include newer models released after the training of learning-based fusers, PackLLM outperformed methods like FuseLLM and FoE by 3.92–11.94%.
  • Efficiency and Scalability: PackLLM achieves these gains with significantly fewer parameters than learning-based alternatives. Unlike uniform ensembles, which can plateau as more models are added, PackLLM continues to scale effectively as more specialized "experts" join the pack.

Insights and Future Directions

A key finding is that the effectiveness of PackLLM increases with prompt length, as longer contexts provide a clearer perplexity signal. However, the approach does come with increased inference costs, as multiple models must run in parallel. Future work may focus on more sophisticated tokenizer alignment and reducing the computational overhead of multi-model inference.

Reference: Mavromatis, C., Karypis, P., & Karypis, G. (2024). Pack of LLMs: Model Fusion at Test-Time via Perplexity Optimization. arXiv:2404.11531v1 [cs.CL].

Summary updated

BibTeX
@inproceedings{mavromatis2024pack,
  author = {Costas Mavromatis and Petros Karypis and George Karypis},
  title = {{Pack of LLMs: Model Fusion at Test-Time via Perplexity Optimization}},
  booktitle = {COLM},
  year = {2024},
  url = {https://openreview.net/forum?id=5Nsl0nlStc},
}
Figure