/ Модель

Характеристики

Контекст
2 048 токенов
Параметры
6,6 млрд
Размер весов
27 ГБ
Лицензия
Apache 2.0
Архитектура
llama · dense
Библиотека
transformers
Опубликована
21 янв 2024

FuseLLM-7B

Генерация текстаТекст → текст13 профессий

FuseLLM-7B — англоязычная LLM, объединяющая знания трёх моделей для генерации текста, рассуждений, ответов на вопросы и кода.

88скачиваний за 30 дней22лайкавеса обновлены1 апр 2024

Бенчмарки

Как модель справилась с задачами пользователей ailist и что о ней публикуют открытые лидерборды

Тесты пользователейпока нет

Никто ещё не опубликовал тест этой модели. Соберите бенчмарк из своих задач — результат появится здесь.

  1. Добавьте модель в бенчмарк

    Вместе с другими моделями категории «Текст» — сравнение идёт внутри одной категории.

  2. Опишите свои задачи

    Напишите запросы, при необходимости приложите файлы и эталонные ответы.

  3. Запустите и опубликуйте

    Модели ответят на каждую задачу, судья оценит ответы. Опубликованный результат появится на этой странице.

Публичные оценки

Из открытых лидербордов. Сравнивайте результаты одного теста при одинаковых условиях — отсутствие оценки не значит, что модель хуже.

В подключённых источниках результатов для этой модели пока нет.

Что умеет модель

Описание составлено по карточке модели и метаданным Hugging Face

FuseLLM-7B — языковая модель, разработанная исследователями Sun Yat-sen University и Tencent AI Lab. Это плотная авторегрессионная модель семейства Llama с 6,6 млрд параметров, созданная методом слияния знаний трёх открытых моделей разных архитектур: Llama-2-7B, OpenLLaMA-7B и MPT-7B. Авторы извлекали их генеративные распределения и переносили общие знания и сильные стороны в целевую модель посредством дополнительного обучения.

Модель предназначена для генерации текста и может применяться для рассуждений, ответов на вопросы, понимания прочитанного, генерации кода и машинного перевода. README приводит оценки на бенчмарках общих знаний, здравого смысла, кода и генерации текста. Модель принимает текст и генерирует текст; заявленный родной контекст — 2048 токенов, язык карточки — английский. Весы доступны в форматах PyTorch и Safetensors.

FuseLLM-7B выпущена под лицензией Apache-2.0. Результаты бенчмарков не гарантируют качество в конкретном приложении; модель имеет относительно короткое окно контекста и не описана как instruction-tuned релиз.

Сценарии применения

  • генерация и продолжение англоязычного текста
  • ответы на вопросы по заданному тексту
  • решение задач на общие знания и здравый смысл
  • генерация кода по описанию задачи
  • машинный перевод текстов

Ограничения

Контекст модели ограничен 2048 токенами. README описывает оценку на бенчмарках, но это не гарантирует качество в прикладных сценариях; выпуск не заявлен как instruction-tuned модель.

Для каких профессий подходит13

Разделы каталога профессий, в задачах которых используется эта модель

Все профессии

Также подходит для

Карточка модели

README от автора на Hugging Face, как он его опубликовал

Открыть на Hugging Face

Fanqi Wan†, Xinting Huang‡, Deng Cai‡, Xiaojun Quan†, Wei Bi‡, Shuming Shi‡

† Sun Yat-sen University, ‡ Tencent AI Lab

ModelBBHARC-easyARC-challengeBoolQHellaSwagOpenBookQA
OpenLLaMA-7B33.8769.7041.3872.2974.5341.00
MPT-7B33.3870.1242.1574.7476.2542.40
Llama-2-7B39.7074.5846.3377.7176.0044.20
Llama-2-CLM-7B40.4474.5446.5076.8876.5744.80
🤗 FuseLLM-7B41.7575.0447.4478.1376.7845.40
ModelMultiPL-ETrivialQADROPLAMBADAIWSLT2017SciBench
OpenLLaMA-7B18.1139.9622.3170.315.510.68
MPT-7B17.2628.8923.5470.085.490.88
Llama-2-7B14.6352.4627.2573.286.480.14
Llama-2-CLM-7B14.8353.1428.5173.456.910.94
🤗 FuseLLM-7B15.5654.4928.9773.726.751.65

News

WIP

Source LLMsTarget LLM
Mixtral-8x7B-v0.1, SOLAR-10.7B-v1.0, Mistral-7B-v0.1Mistral-7B-v0.1
Mixtral-8x7B-v0.1, SOLAR-10.7B-v1.0, Mistral-7B-v0.1SOLAR-10.7B-v1.0
Mixtral-8x7B-v0.1, SOLAR-10.7B-v1.0, Mistral-7B-v0.1Mixtral-8x7B-v0.1

Contents

Overview

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.

pip install -r requirements.txt

Usage

from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("Wanfq/FuseLLM-7B", use_fast=False)
model = AutoModelForCausalLM.from_pretrained("Wanfq/FuseLLM-7B", torch_dtype="auto")
model.cuda()
inputs = tokenizer("<your text here>", return_tensors="pt").to(model.device)
tokens = model.generate(
  **inputs,
  max_new_tokens=512,
  temperature=0.6,
  top_p=0.9,
  do_sample=True,
)
print(tokenizer.decode(tokens[0], skip_special_tokens=True))

We also find Exllama v2 Quantizations version on FuseLLM-7B-exl2, it uses ExLlamaV2 v0.0.11 for quantization.

Data Construction

We use the MiniPile dataset for continual training.

Here we show the scripts to obtain representations from multiple LLMs for model fusion.

  1. Split long text
python ./src/utils/split_long_text.py \
  --base_model_name_or_path "<path_to_llama_2_7b>" \
  --blending_model_name_or_path "<path_to_open_llama_7b_v2>" \
  --another_blending_model_name_or_path "<path_to_mpt_7b>" \
  --dataset "<path_to_minipile>" \
  --dataset_save_dir "<path_to_minipile_split>" \
  --cache_dir "<path_to_cache_dir>" \
  --block_size 2048 \
  --preprocessing_num_workers 80
  1. Get representations for each LLM
# We split the dataset into 8 splits, then process each split on a GPU.
# Please run this script for llama_2_7b, open_llama_7b_v2, and mpt_7b.
for i in {0..7}; do
export CUDA_VISIBLE_DEVICES=${i}
python ./src/utils/forward_for_logits.py \
  --model_name_or_path "<path_to_each_model>" \
  --dataset "<path_to_minipile_split>" \
  --dataset_save_dir "${i}_8_<path_to_minipile_split_each_model_representation>" \
  --dataset_split_num 8 \
  --dataset_index ${i} \
  --cache_dir "<path_to_cache_dir>" \
  --model_max_length 2048 \
  --training_mode full \
  --load_in_half bf16 \
  --batch_size 8 \
  --preprocessing_num_workers 80 \
  --top_k_logits 10 \
  --save_per_token_metric 2>&1 > "${i}_8_<path_to_log_file>" 2>&1 &
unset CUDA_VISIBLE_DEVICES
sleep 30
done

wait
  1. Align representations from different LLMs
# Get vocab mapping from different LLMs.

# llama_2_7b <-> open_llama_7b_v2
python ./src/utils/vocab_mapping.py \
  --base_model_name_or_path "<path_to_llama_2_7b>" \
  --blending_model_name_or_path "<path_to_open_llama_7b_v2>" \
  --dataset_dir "<path_to_minipile_split>" \
  --vocab_mapping_save_dir "<path_to_llama_2_7b_open_llama_7b_v2_vocab_mapping>" \
  --cache_dir "<path_to_cache_dir>" \
  --model_max_length 2048 \
  --vocab_mapping_type "default" \
  --num_process 1

# llama_2_7b <-> mpt_7b
python ./src/utils/vocab_mapping.py \
  --base_model_name_or_path "<path_to_llama_2_7b>" \
  --blending_model_name_or_path "<path_to_mpt_7b>" \
  --dataset_dir "<path_to_minipile_split>" \
  --vocab_mapping_save_dir "<path_to_llama_2_7b_mpt_7b_vocab_mapping>" \
  --cache_dir "<path_to_cache_dir>" \
  --model_max_length 2048 \
  --vocab_mapping_type "default" \
  --num_process 1
# Align representations from different LLMs.

# llama_2_7b <-> open_llama_7b_v2
for i in {0..7}; do
python ./src/utils/token_alignment.py \
  --base_model_name_or_path "<path_to_llama_2_7b>" \
  --blending_model_name_or_path "<path_to_open_llama_7b_v2>" \
  --base_dataset_dir "${i}_8_<path_to_minipile_split_llama_2_7b_representation>" \
  --blending_dataset_dir "${i}_8_<path_to_minipile_split_open_llama_7b_v2_representation>" \
  --dataset_save_dir "${i}_8_<path_to_minipile_split_llama_2_7b_open_llama_7b_v2_aligned_representation>" \
  --cache_dir "<path_to_cache_dir>" \
  --model_max_length 2048 \
  --preprocessing_num_workers 80 \
  --batch_size 100 \
  --blending_model_index 0 \
  --vocab_align_type "soft" \
  --vocab_mapping_save_dir "<path_to_llama_2_7b_open_llama_7b_v2_vocab_mapping>" \
  --metric_level "sequence"
done 

# llama_2_7b <-> mpt_7b
for i in {0..7}; do
python ./src/utils/token_alignment.py \
  --base_model_name_or_path "<path_to_llama_2_7b>" \
  --blending_model_name_or_path "<path_to_mpt_7b>" \
  --base_dataset_dir "${i}_8_<path_to_minipile_split_llama_2_7b_open_llama_7b_v2_aligned_representation>" \
  --blending_dataset_dir "${i}_8_<path_to_minipile_split_mpt_7b_representation>" \
  --dataset_save_dir "${i}_8_<path_to_minipile_split_llama_2_7b_open_llama_7b_v2_mpt_7b_aligned_representation>" \
  --cache_dir "<path_to_cache_dir>" \
  --model_max_length 2048 \
  --preprocessing_num_workers 80 \
  --batch_size 100 \
  --blending_model_index 1 \
  --vocab_align_type "soft" \
  --vocab_mapping_save_dir "<path_to_llama_2_7b_mpt_7b_vocab_mapping>" \
  --metric_level "sequence"
done
  1. Packing all features to speed up training.
for i in {0..7}; do
python3 ./src/utils/packing.py \
  --dataset_dir "${i}_8_<path_to_minipile_split_llama_2_7b_open_llama_7b_v2_mpt_7b_aligned_representation>" \
  --dataset_save_dir "${i}_8_<path_to_miniplie_fusellm_processed>" \
  --cache_dir "<path_to_cache_dir>" \
  --model_max_length 2048 \
  --preprocessing_num_workers 80 \
  --batch_size 1000 \
  --metric_level "sequence"

The final processed data is at ${i}_8_<path_to_miniplie_fusellm_processed>, where i in {0..7}.

Training

Here, we show the script for FuseLLM training.

export CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7

deepspeed --master_port=20001 ./src/train.py \
  --training_mode full \
  --deepspeed ./config/zero_stage2_config.json \
  --model_name_or_path "<path_to_llama_2_7b>" \
  --output_dir "<path_to_save_fusellm_7b>" \
  --model_max_length 2048 \
  --logging_steps 1 \
  --save_strategy steps \
  --save_steps 500 \
  --save_total_limit 1 \
  --evaluation_strategy steps \
  --per_device_eval_batch_size 1 \
  --logging_strategy steps \
  --do_train \
  --do_eval \
  --bf16 True \
  --tf32 True \
  --warmup_ratio 0.008 \
  --lr_scheduler_type cosine \
  --dataset_name "0_8_<path_to_miniplie_fusellm_processed>,1_8_<path_to_miniplie_fusellm_processed>,2_8_<path_to_miniplie_fusellm_processed>,3_8_<path_to_miniplie_fusellm_processed>,4_8_<path_to_miniplie_fusellm_processed>,5_8_<path_to_miniplie_fusellm_processed>,6_8_<path_to_miniplie_fusellm_processed>,7_8_<path_to_miniplie_fusellm_processed>" \
  --per_device_train_batch_size 1 \
  --gradient_accumulation_steps 16 \
  --num_train_epochs 1 \
  --eval_steps 500 \
  --optim adamw_torch \
  --adam_beta1 0.9 \
  --adam_beta2 0.95 \
  --learning_rate 1e-5 \
  --weight_decay 0.1 \
  --max_grad_norm 1.0 \
  --seed 42 \
  --gradient_checkpointing True \
  --use_flash_attn True \
  --report_to tensorboard \
  --do_distill \
  --distill_with_ref_model True \
  --distill_with_aligned_model_0 True \
  --distill_with_aligned_model_1 True \
  --distill_loss_type "ce" \
  --distill_teacher_temperature 1.0 \
  --lm_loss_weight 0.9 \
  --distill_greater_as_gt True \
  --distill_greater_as_gt_type "hard" \
  --dataloader_num_workers 10 \
  --remove_unused_columns False 2>&1 | tee "<path_to_log_file>"

Evaluation

The evaluation code we used in our evaluation are list as follows:

Citation

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}
}

Open LLM Leaderboard Evaluation Results

Detailed results can be found here

MetricValue
Avg.51.07
AI2 Reasoning Challenge (25-Shot)53.24
HellaSwag (10-Shot)78.72
MMLU (5-Shot)47.93
TruthfulQA (0-shot)38.17
Winogrande (5-shot)74.03
GSM8k (5-shot)14.33

Как запустить

На своей GPU в ailist. Цена — по текущим предложениям провайдеров

GPU в ailist

Универсальный рантайм · transformers

Можно запустить

Подбираем GPU…

Класс архитектуры
LlamaForCausalLM
Ревизия весов
61c3c47

0 моделей