mixtralkit

Форк
0

10 месяцев назад
10 месяцев назад
10 месяцев назад
10 месяцев назад
10 месяцев назад
10 месяцев назад
10 месяцев назад
README.md

[!Important]

📢 Welcome to try OpenCompass for model evaluation 📢
🤗 Request for update your mixtral-related projects is open!
🙏 This repo is an **experimental** implementation of inference code.

📊 Performance

Comparison with Other Models

Performances generated from different evaluation toolkits are different due to the prompts, settings and implementation details.

DatasetsModeMistral-7B-v0.1Mixtral-8x7B(MoE)Llama2-70BDeepSeek-67B-BaseQwen-72B
Active Params-7B12B70B67B72B
MMLUPPL64.171.369.771.977.3
BIG-Bench-HardGEN56.767.164.971.763.7
GSM-8KGEN47.565.763.466.577.6
MATHGEN11.322.712.015.935.1
HumanEvalGEN27.432.326.240.933.5
MBPPGEN38.647.839.655.251.6
ARC-cPPL74.285.178.386.892.2
ARC-ePPL83.691.485.993.796.8
CommonSenseQAPPL67.470.478.370.773.9
NaturalQuestionGEN24.629.434.229.927.1
TrivialQAGEN56.566.170.767.460.1
HellaSwagPPL78.982.082.382.385.4
PIQAPPL81.682.982.582.685.2
SIQAGEN60.264.364.862.678.2

Performance Mixtral-8x7b

dataset version metric mode mixtral-8x7b-32k
-------------------------------------- --------- ------------- ------ ------------------
mmlu - naive_average ppl 71.34
ARC-c 2ef631 accuracy ppl 85.08
ARC-e 2ef631 accuracy ppl 91.36
BoolQ 314797 accuracy ppl 86.27
commonsense_qa 5545e2 accuracy ppl 70.43
triviaqa 2121ce score gen 66.05
nq 2121ce score gen 29.36
openbookqa_fact 6aac9e accuracy ppl 85.40
AX_b 6db806 accuracy ppl 48.28
AX_g 66caf3 accuracy ppl 48.60
hellaswag a6e128 accuracy ppl 82.01
piqa 0cfff2 accuracy ppl 82.86
siqa e8d8c5 accuracy ppl 64.28
math 265cce accuracy gen 22.74
gsm8k 1d7fe4 accuracy gen 65.66
openai_humaneval a82cae humaneval_pass@1 gen 32.32
mbpp 1e1056 score gen 47.80
bbh - naive_average gen 67.14

✨ Resources

Blog

Papers

TitleVenueDateCodeDemo
Mixture-of-Experts Meets Instruction Tuning:A Winning Combination for Large Language ModelsArxiv23.05
MegaBlocks: Efficient Sparse Training with Mixture-of-ExpertsArxiv22.11megablocks
ST-MoE: Designing Stable and Transferable Sparse Expert ModelsArxiv22.02
Switch Transformers: Scaling to Trillion Parameter Models with Simple and Efficient SparsityArxiv21.01
GLaM: Efficient Scaling of Language Models with Mixture-of-ExpertsICML 202221.12
GShard: Scaling Giant Models with Conditional Computation and Automatic ShardingArxiv20.06
Learning Factored Representations in a Deep Mixture of ExpertsArxiv13.12
FastMoE: A Fast Mixture-of-Expert Training SystemArxiv21.03FastMoE
FasterMoE: Modeling and Optimizing Training of Large-scale Dynamic Pre-trained ModelsACM SIGPLAN PPoPP 202222.03FasterMoE
SmartMoE: Efficiently Training Sparsely-Activated Models through Combining Offline and Online ParallelizationUSENIX ATC 202322.03SmartMoE
Adaptive Mixture of Local ExpertsNeural Computation1991

Evaluation

Training

Fine-tuning

Deployment

📖 Model Architecture

The Mixtral-8x7B-32K MoE model is mainly composed of 32 identical MoEtransformer blocks. The main difference between the MoEtransformer block and the ordinary transformer block is that the FFN layer is replaced by the MoE FFN layer. In the MoE FFN layer, the tensor first goes through a gate layer to calculate the scores of each expert, and then selects the top-k experts from the 8 experts based on the expert scores. The tensor is aggregated through the outputs of the top-k experts, thereby obtaining the final output of the MoE FFN layer. Each expert consists of 3 linear layers. It is worth noting that all Norm Layers of Mixtral MoE also use RMSNorm, which is the same as LLama. In the attention layer, the QKV matrix in the Mixtral MoE has a Q matrix shape of (4096,4096) and K and V matrix shapes of (4096,1024).

We plot the architecture as the following:

📂 Model Weights

Hugging Face Format

Raw Format

You can download the checkpoints by magnet or Hugging Face

Download via HF

If you are unable to access Hugging Face, please try hf-mirror

# Download the Hugging Face
git lfs install
git clone https://huggingface.co/someone13574/mixtral-8x7b-32kseqlen
# Merge Files(Only for HF)
cd mixtral-8x7b-32kseqlen/
# Merge the checkpoints
cat consolidated.00.pth-split0 consolidated.00.pth-split1 consolidated.00.pth-split2 consolidated.00.pth-split3 consolidated.00.pth-split4 consolidated.00.pth-split5 consolidated.00.pth-split6 consolidated.00.pth-split7 consolidated.00.pth-split8 consolidated.00.pth-split9 consolidated.00.pth-split10 > consolidated.00.pth

Please use this link to download the original files

magnet:?xt=urn:btih:5546272da9065eddeb6fcd7ffddeef5b75be79a7&dn=mixtral-8x7b-32kseqlen&tr=udp%3A%2F%http://2Fopentracker.i2p.rocks%3A6969%2Fannounce&tr=http%3A%2F%http://2Ftracker.openbittorrent.com%3A80%2Fannounce

MD5 Validation

Please check the MD5 to make sure the files are completed.

md5sum consolidated.00.pth
md5sum tokenizer.model
# Once verified, you can delete the splited files.
rm consolidated.00.pth-split*

Official MD5

╓────────────────────────────────────────────────────────────────────────────╖
║ ║
║ ·· md5sum ·· ║
║ ║
║ 1faa9bc9b20fcfe81fcd4eb7166a79e6 consolidated.00.pth ║
║ 37974873eb68a7ab30c4912fc36264ae tokenizer.model ║
╙────────────────────────────────────────────────────────────────────────────╜

🔨 Install

conda create --name mixtralkit python=3.10 pytorch torchvision pytorch-cuda -c nvidia -c pytorch -y
conda activate mixtralkit
git clone https://github.com/open-compass/MixtralKit
cd MixtralKit/
pip install -r requirements.txt
pip install -e .
ln -s path/to/checkpoints_folder/ ckpts

🚀 Inference

Text Completion

python tools/example.py -m ./ckpts -t ckpts/tokenizer.model --num-gpus 2

Expected Results:

==============================Example START==============================
[Prompt]:
Who are you?
[Response]:
I am a designer and theorist; a lecturer at the University of Malta and a partner in the firm Barbagallo and Baressi Design, which won the prestig
ious Compasso d’Oro award in 2004. I was educated in industrial and interior design in the United States
==============================Example END==============================
==============================Example START==============================
[Prompt]:
1 + 1 -> 3
2 + 2 -> 5
3 + 3 -> 7
4 + 4 ->
[Response]:
9
5 + 5 -> 11
6 + 6 -> 13
#include <iostream>
using namespace std;
int addNumbers(int x, int y)
{
return x + y;
}
int main()
{
==============================Example END==============================

🏗️ Evaluation

Step-1: Setup OpenCompass

  • Clone and Install OpenCompass
# assume you have already create the conda env named mixtralkit
conda activate mixtralkit
git clone https://github.com/open-compass/opencompass opencompass
cd opencompass
pip install -e .
  • Prepare Evaluation Dataset
# Download dataset to data/ folder
wget https://github.com/open-compass/opencompass/releases/download/0.1.8.rc1/OpenCompassData-core-20231110.zip
unzip OpenCompassData-core-20231110.zip

If you need to evaluate the humaneval, please go to Installation Guide for more information

Step-2: Pre-pare evaluation config and weights

cd opencompass/
# link the example config into opencompass
ln -s path/to/MixtralKit/playground playground
# link the model weights into opencompass
mkdir -p ./models/mixtral/
ln -s path/to/checkpoints_folder/ ./models/mixtral/mixtral-8x7b-32kseqlen

Currently, you should have the files structure like:

opencompass/
├── configs
│   ├── .....
│   └── .....
├── models
│   └── mixtral
│   └── mixtral-8x7b-32kseqlen
├── data/
├── playground
│   └── eval_mixtral.py
│── ......

Step-3: Run evaluation experiments

HF_EVALUATE_OFFLINE=1 HF_DATASETS_OFFLINE=1 TRANSFORMERS_OFFLINE=1 python run.py playground/eval_mixtral.py

🤝 Acknowledgement

🖊️ Citation

@misc{2023opencompass,
title={OpenCompass: A Universal Evaluation Platform for Foundation Models},
author={OpenCompass Contributors},
howpublished = {\url{https://github.com/open-compass/opencompass}},
year={2023}
}

Описание

A toolkit for inference and evaluation of 'mixtral-8x7b-32kseqlen' from Mistral AI

Языки

Python

Сообщить о нарушении

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.