Jan 22, 2024: 🔥 We release FuseLLM-7B, which is the fusion of three open-source foundation LLMs with distinct architectures, including Llama-2-7B, OpenLLaMA-7B, and MPT-7B.
In this study, we explore the realm of knowledge fusion for LLMs to create a unified model that combines the capabilities and distinctive strengths of multiple structurally diverse LLMs. To achieve this, we introduce FuseLLM, which first leverages the generative distributions of these source LLMs to externalize both their collective knowledge and individual strengths, and subsequently transfer them to the target LLM through lightweight continual training.
Unlike model ensemble approaches that require the parallel deployment of multiple LLMs, or weight merging techniques that are typically limited to LLMs with identical architectures, FuseLLM is designed to support the fusion of multiple LLMs with diverse architectures into a more potent LLM. By explicitly transferring their knowledge and capabilities to a single target LLM, FuseLLM offers a powerful and flexible solution for the knowledge fusion of LLMs.
Model Release
We release the FuseLLM-7B on 🤗 Huggingface Models, which is the fusion of three popular open-source LLMs that possess distinct architectures and functionalities: Llama-2-7B, OpenLLaMA-7B, and MPT-7B.
Here are the evaluation results of FuseLLM.
General Reasoning & Commonsense Reasoning
We first show the performance of FuseLLM on Big-Bench Hard and CommonSense benchmarks, which evaluate the general reasoning and commonsense reasoning abilities respectively.
Code Generation & Text Generation
We then evaluate FuseLLM on MultiPL-E, which is a multilingual programming benchmark to assess the code generation performance. We also conduct experiments on several text generation benchmarks, including TrivialQA (question-answering), DROP (reading comprehension), LAMBADA (content analysis), IWSLT2017 (machine translation), and SCIBench (theorem application).
Instruction Following
FuseLLM is also applicable to the fusion of instruction-tuned LLMs. We further evaluate the Vicuna Benchmark, which assesses the instruction following ability.
FuseLLM vs. Knowledge Distillation
As knowledge distillation is also a method for enhancing the performance of LLMs by utilizing representations, we compare FuseLLM with Llama-2 KD, which is distilled from Llama-2 13B.
FuseLLM vs. Model Ensemble & Weight Merging
To compare FuseLLM with existing fusion methods (such as model ensemble and weight merging), we simulate scenarios to ensure model fusion with an identical structure where multiple source LLMs are derived from the same base model but are continually trained on different corpus. We then test the perplexity of these fusion methods on different benchmarks.
Quick Start
Setup
We use python 3.9 in this project.
Then, we have to install all the libraries listed in requirements.txt.
1# We split the dataset into 8 splits, then process each split on a GPU.2# Please run this script for llama_2_7b, open_llama_7b_v2, and mpt_7b.3foriin{0..7};do4exportCUDA_VISIBLE_DEVICES=${i}5python ./src/utils/forward_for_logits.py \6 --model_name_or_path "<path_to_each_model>"\7 --dataset "<path_to_minipile_split>"\8 --dataset_save_dir "${i}_8_<path_to_minipile_split_each_model_representation>"\9 --dataset_split_num 8\10 --dataset_index ${i}\11 --cache_dir "<path_to_cache_dir>"\12 --model_max_length 2048\13 --training_mode full \14 --load_in_half bf16 \15 --batch_size 8\16 --preprocessing_num_workers 80\17 --top_k_logits 10\18 --save_per_token_metric 2>&1>"${i}_8_<path_to_log_file>"2>&1&19unset CUDA_VISIBLE_DEVICES
20sleep3021done2223wait
If you find this work is relevant with your research or applications, please feel free to cite our work!
@inproceedings{wan2024knowledge,
title={Knowledge Fusion of Large Language Models},
author={Fanqi Wan and Xinting Huang and Deng Cai and Xiaojun Quan and Wei Bi and Shuming Shi},
booktitle={The Twelfth International Conference on Learning Representations},
year={2024},
url={https://openreview.net/pdf?id=jiDsk12qcz}
}