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

Fusing knowledge from multiple Large Language Models (LLMs) can combine their diverse strengths to achieve improved performance on a given task. However, current fusion approaches either rely on learning-based fusers that do not generalize to new LLMs, or do not take into account how well each LLM understands the input. In this work, we study LLM fusion at test-time, which enables leveraging knowledge from arbitrary user-specified LLMs during inference. We introduce Pack of LLMs (PackLLM), an effective method for test-time fusion that leverages each LLM's expertise, given an input prompt. PackLLM performs model fusion by solving an optimization problem for determining each LLM's importance, so that perplexity over the input prompt is minimized. First, our simple PackLLM-sim variant validates that perplexity is a good indicator for measuring each LLM's expertise. Second, our PackLLM-opt variant approximately solves the perplexity minimization problem via a greedy algorithm. The derived importance weights are used to combine the LLMs during inference. We conduct experiments with over 100 total LLMs on a diverse set of tasks. Experimental results show that (i) perplexity is a reliable measure for LLM fusion, (ii) PackLLM outperforms test-time fusion baselines by 1.89% accuracy points, and (iii) PackLLM can leverage new LLMs to improve performance over learning-based fusion approaches by 3.92-11.94% accuracy points.

Paper

References (43)

Scroll for more · 31 remaining

Similar papers

Reviewer ymUA7/10 · confidence 3/52024-04-18

Summary

This paper provides an alternative method for combining the responses from multiple LLMs. Weights were introduced to be used to re-weight the output logits. To determine the criterion for obtaining the optimal weights, the authors first discovered that the perplexity on the given prompts can be already served as a good approach to fuse the outputs of models. Next, the authors propose an greedy optimization-based algorithm that effectively fuses the outputs from different models. Experimental results show that the proposed algorithm can merge the outputs from models better than baseline methods such as ensemble and using only the model with lowest perplexity.

Rating

7

Confidence

3

Ethics flag

1

Reasons to accept

- The motivation is clearly described and the topic is interesting. - The empirical performance seems to be strong. - The techniques introduced in this paper are technically sound.

Reasons to reject

- I think the authors may also want to compare with always picking the responses from the largest model, because selecting the model with the lowest perplexity does not mean that model can generalize well. Selecting always the largest model may yield better performance. - I would also like to see how this model compared with model merging. I understand it is not always possible to merge models, especially when the number of parameters and the structures are diverse across models. However, I think the authors can at least find several publicly available models fine-tuned from llama-7b on different datasets and see if the proposed algorithm can outperform model merging.

Reviewer MKGz5/10 · confidence 4/52024-05-07

Summary

This paper presents a test-time LLM fusion method to leverage knowledge from the user-specified LLMs during inference. Specifically, the authors optimize the perplexity over the input prompt to perform model fusion. The experimental results demonstrate the effectiveness of the proposed method.

Rating

5

Confidence

4

Ethics flag

1

Reasons to accept

This work presents a simple but effective test-time LLM fusing method and provides valuable insights. The paper is well-written and clear. The authors conducted experiments on multiple datasets, illustrating that this method generalizes well to different domains.

Reasons to reject

In the main experimental results reported in Table 1, the proposed method outperforms the baseline models. However, it is important to note that the experiments involving some test-time fusion methods, such as cBTM and DExperts, are not fully reported. This lack of complete data undermines the reliability of these results. This issue is similar to the one observed in Table 2, where the comparison with learning-based fusion models becomes less convincing due to incomplete experimental data.

Questions to authors

- Is it possible to complete the results of the test-time baseline experiment? - It is advised to provide some case studies to show that the proposed ppl-based fusion method is superior to other methods.

Reviewer 7QCH7/10 · confidence 3/52024-05-11

Summary

This paper proposes PackLLMs, which utilizes the findings that perplexity of input tokens is a good indicator of LLM's performance in domains. The authors propose PackLLM-simp that utilize the heuristics above and PackLLM-Opt, which approximates an optimization objective with a greedy search algorithm. Experiments show improvement over baselines such as cBTM, DExperts. The approach is further modular and easy to use compared to other fusion methods that requires training LLMs.

Rating

7

Confidence

3

Ethics flag

1

Reasons to accept

- The proposed approach is simple and effective, and is broadly applicable to any combinations of LLMs with either same or different architectures. - The choice of baselines are recent and comprehensive. The results also show clear improvements of LLM. - The analysis of coefficients obtained (\lambda), and relationships between perplexity and prompt length in Section 6 are quite helpful. - The writing is quite clear.

Reasons to reject

- The authors should include discussions about the computational overhead of the approach. How much overhead is introduced by the grid search part, given the high dimensionality of logits (sequence length * vocab size for a single instance)? Is this overhead significant compared to a forward pass of the LM? I also encourage the authors to add a limitations sections to discuss potential limitations of the approach.

Questions to authors

I think the paper is quite solid and has addressed my initial questions in their later sections. A minor comment is that the second paragraph of the related works is repetitive given the second paragraph in introduction.

Reviewer Gnd47/10 · confidence 3/52024-05-16

Summary

This paper introduces a new method, PackLLM, to fuse LLMs at test-time as weighted ensemble, where the importance weights for seed LLMs are determined by minimizing the perplexity of the input prompt. There are two variants of PackLLM, one that directly uses normalized perplexity scores of individual LLMs as weights, and the other that performs an efficient greedy algorithm to search the optimal scores that minimize the prompt perplexity of the ensemble. The paper conducts extensive experiments to validate the performance of PackLLM. On pretraining perplexity, both variants of PackLLM outperform existing test-time model ensemble baselines like cBTM and DExperts, especially when the number of seed LLMs increases. On downstream tasks, PackLLM also outperforms simple baselines like uniform ensemble. While it trails other learning-based fusion methods like FuseLLM and FoE with the same set of seed LLMs, the learning-free nature allows PackLLM to achieve better performance by swapping in stronger seed LLMs. The paper also includes some analysis of the weight values, the impact of prompt length, and the time complexity of the two variants.

Rating

7

Confidence

3

Ethics flag

1

Reasons to accept

- Proposes a simple yet effective test-time fusion method for LLMs - Comprehensive empirical study by comparing PackLLM with different baselines across various settings - Well-written, clearly articulated motivation

Reasons to reject

I don’t have major concerns. I do have some questions listed below.

Questions to authors

- I’m curious to know the impact of aligning different tokenizers. Have you done any analysis comparing the performance when fusing similar-sized models with the same vs. different vocabularies? - In experimental results, I’d like to also see a comparison with the best seed LLM performance on each task, especially for Table 4, where most of the baseline results are not available. - While not an exhaustive search, the greedy search algorithm still seems a very expensive operation that needs to be done for every test-time input. Can we situate the time complexity analysis in Table 3 by comparing the additional time cost from greedy search with the actual inference time of LLMs? This would be important to help understand the real-world applicability of the proposed method.

Authorsrebuttal2024-06-02

Dear Reviewer Gnd4, thank you for **updating your review** in a timely manner. Please discard our previous message (we are unable to delete it). We reply to your questions below. **Q1) Impact of aligning different tokenizers**. Thank you for your insightful question. We do not have any experimental analysis evaluating the impact of the vocabulary size, but we agree that it would be easier to fuse knowledge from models with similar-sized vocabularies (e.g., LLama + Mistral) than models with different vocabularies (e.g., LLama + Gemma). Disentangling the effects of combining models with different vocabularies, e.g. LLama + Mistral vs. LLama + Gemma, is challenging as different models (Mistral vs. Gemma) perform differently on the underlying tasks. **Q2) Evaluating best LLM**. Thank you for your suggestion. We experiment with the best LLM (as evaluated on test data) on STEM and Commonsense tasks. We find that the best LLM works better when having few LLMs with different vocabularies, but when we have a large number of LLMs with the same vocabulary, PackLLM outperforms the best LLM. We hope with better tokenization mapping methods, PackLLM becomes more effective in the first scenario. To further verify our conclusions, we experiment on the C4 and S2ORC language modeling tasks, where we have a large number of expert OPT models sharing the same vocabulary. In this case, PackLLM also outperforms the Best LLM (selected as the top1 expert). We provide the results in the following tables. Setup: 5 MMLU-STEM tasks and 4 Commonsense tasks. Best LLM: LLaMA2-7B (Fuse LLMs), Platypus-7B (FoE LLMs) | |Fuse LLMs (3 seed LLMs, different vocab) | FoE LLMs (15 seed LLMs, same vocab) | |-|-|-| | | STEM / Com. | STEM / Com. | PackLLM | 31.2 / 54.9 | **40.3** / **67.1** | Best LLM (using test data) | **33.0** / **56.3** | 34.8 / 59.1 | Setup: 9 OPT models (30B OPT + 8* 1.3 OPT experts) on C4 and S2ORC language modeling tasks. Best LLM: Top1 model selection. | Fusion | Perplexity (the lower the better) | |-|-| | | C4 / S2ORC | | Largest (30B) | 12.71 / 11.46 | | Select Best (Top1 model) | 12.53 / 11.46 | |PackLLM | **11.03** / **11.05** | **Q3) Timing of PackLLM**. Thank you for your clarifying question. PackLLM can be applied in real-world scenarios as it does not incur significant additional costs. PackLLM computes the output logits by each LLM once (as in the Ensemble baseline), which are then used for determining the importance weights as shown in Lines 10-15 of Algorithm 1 in Appendix A. No additional LLM forward passes are required. We also provide the following time measurements for K=5 LLMs per input on a A100 GPU: | | Time| |-|-| |Single forward pass | 0.06 secs | | K=5 forward passes (Ensemble) | 0.30 secs | | PackLLM (K=5) | 0.32 secs | As evaluated, PackLLM does not incur significant time costs.

Reviewer Gnd42024-06-05

Thank you for the detailed response. It addressed most of my concerns.

Reviewer MKGz2024-06-03

Thanks for the authors' responses. However, it is still unconvincing to me. For example, what's the point of including cBTM and DExperts in Table 1 without reproducing the full experiments on all compared domain datasets? If all the experts and LLMs are known to cBTM and DExperts methods, do the proposed methods still outperform them? For Table 2, the last "Best Overall" column is misleading; the results are not comparable among the methods. I am still concerned about this.

Authorsrebuttal2024-06-04

**Comparison with cBTM & DExperts**. Thank you for your follow-up questions. cBTM’s LLMs are fine-tuned on top of the OPT model family, which are not relatively powerful models. For example, if we use cBTM’s LLMs, they perform ~25% at accuracy on MMLU, which is close to random answer selection. Generalizing cBTM to other model families for producing full results in Table 1 requires (i) proper data selection, and (ii) further model fine-tuning, which is limiting regarding compute resources. If all experts are known, PackLLM outperforms cBTM (Misc in Table 1) and DExperts (Medicine in Table 1). Following, we highlight the key difference between cBTM, DExperts, and PackLLM (ours) regarding how they compute the importance weights: - *cBTM*: Importance weights are **data-dependent** (Eq. 8; using tf-idf embeddings); the weights would be similar for LLaMA-7B and LLaMA-70B as the two models have similar pretraining data. - *DExperts*: Importance weights are **fixed** (Eq. 9). - *PackLLM*: Importance weights are **model-dependent** (perplexity-based), capturing how well each model understands the prompt; LLaMA-70B would be assigned a higher weight than LLaMA-7B. Figure 3 verifies the benefit of model-dependent weights (PackLLM vs. cBTM / DExperts). **Table 2**. Thank you for pointing this out. We will remove the “Overall” column to improve the readability of Table 2.

Reviewer ymUA2024-06-05

I have read the authors' responses and my concern has been addressed.

Program Chairsdecision2024-07-10

Decision

Accept

© 2026 NYSGPT2525 LLC