llama-moe/LLaMA-MoE-v1-3_5B-4_16

Model

LLaMA-MoE-v1-3.5B (4/16)

16

8 commits

1 linked in READMEs

updated Jun 25, 2024

See the code

README

LLaMA-MoE-v1-3.5B (4/16)

[πŸ’» Code] | [πŸ“œ Technical Report]

πŸ‘‹ Very nice to meet you here~

❀️ This repo contains the model LLaMA-MoE-v1-3.5B (4/16), which activates 4 out of 16 experts (3.5B parameters). This model is NOT fine-tuned by instruction pairs, so it may not be good enough to act like a chatbot.

πŸ“’ LLaMA-MoE is a series of Mixture-of-Expert (MoE) models based on LLaMA-2. You can find the code for training this model at this repo.

πŸ’Ž This series of models are obtained by partitioning original LLaMA FFNs into experts and further continual pre-training. The total model size is only 6.7B parameters, which is very convenient for deployment and research usage. More details could be found at our technical report.

πŸš€ QuickStart

# python>=3.10

import torch
from transformers import AutoTokenizer, AutoModelForCausalLM

model_dir = "llama-moe/LLaMA-MoE-v1-3_5B-4_16"
tokenizer = AutoTokenizer.from_pretrained(model_dir, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(model_dir, torch_dtype=torch.bfloat16, trust_remote_code=True)
model.eval()
model.to("cuda:0")

input_text = "Suzhou is famous of"
inputs = tokenizer(input_text, return_tensors="pt")
inputs = inputs.to("cuda:0")

pred = model.generate(**inputs, max_length=50, temperature=0.0)
print(tokenizer.decode(pred.cpu()[0], skip_special_tokens=True))
# Suzhou is famous of its beautiful gardens. The most famous one is the Humble Administrator's Garden. It is a classical Chinese garden with a history of more than 600 years. The garden is divided into three

πŸ“Š Performance

Model#Activated Experts#Experts#Activated ParamsLinks
LLaMA-MoE-3.0B2163.0B[πŸ€— HF Weights]
LLaMA-MoE-3.5B (4/16)4163.5B[πŸ€— HF Weights]
LLaMA-MoE-3.5B (2/8)283.5B[πŸ€— HF Weights]
ModelSciQPIQAWinoGrandeARC-eARC-c (25)HellaSwag (10)LogiQABoolQ (32)LAMBADANQ (32)MMLU (5)Average
OPT-2.7B78.974.860.854.434.061.425.863.363.610.725.850.3
Pythia-2.8B83.273.659.658.836.760.728.165.964.68.726.851.5
INCITE-BASE-3B85.673.963.561.740.364.727.565.865.415.227.253.7
Open-LLaMA-3B-v288.077.963.163.340.171.428.169.267.416.026.855.6
Sheared-LLaMA-2.7B87.576.965.063.341.671.028.373.668.317.627.356.4
LLaMA-MoE-3.0B84.277.563.660.240.970.830.671.966.617.026.855.5
LLaMA-MoE-3.5B (4/16)87.677.965.565.644.273.329.775.069.520.326.857.7
LLaMA-MoE-3.5B (2/8)88.477.666.765.343.173.329.673.969.419.827.057.6

πŸ“– Details

Training Data: 200B tokens from SlimPajama with the same data sampling weights as Sheared LLaMA.

πŸ“ƒ Citation

@article{llama-moe,
  title={LLaMA-MoE: Building Mixture-of-Experts from LLaMA with Continual Pre-training},
  author={Tong Zhu and Xiaoye Qu and Daize Dong and Jiacheng Ruan and Jingqi Tong and Conghui He and Yu Cheng},
  journal={arXiv preprint arXiv:2406.16554},
  year={2024},
  url={https://arxiv.org/abs/2406.16554},
}
custom_code
llama_moe
pytorch
text-generation
transformers

Contributors

Spico

8 commits

llama-moe/LLaMA-MoE-v1-3_5B-4_16

Model

LLaMA-MoE-v1-3.5B (4/16)

16

8 commits

1 linked in READMEs

updated Jun 25, 2024

See the code

README

LLaMA-MoE-v1-3.5B (4/16)

[πŸ’» Code] | [πŸ“œ Technical Report]

πŸ‘‹ Very nice to meet you here~

❀️ This repo contains the model LLaMA-MoE-v1-3.5B (4/16), which activates 4 out of 16 experts (3.5B parameters). This model is NOT fine-tuned by instruction pairs, so it may not be good enough to act like a chatbot.

πŸ“’ LLaMA-MoE is a series of Mixture-of-Expert (MoE) models based on LLaMA-2. You can find the code for training this model at this repo.

πŸ’Ž This series of models are obtained by partitioning original LLaMA FFNs into experts and further continual pre-training. The total model size is only 6.7B parameters, which is very convenient for deployment and research usage. More details could be found at our technical report.

πŸš€ QuickStart

# python>=3.10

import torch
from transformers import AutoTokenizer, AutoModelForCausalLM

model_dir = "llama-moe/LLaMA-MoE-v1-3_5B-4_16"
tokenizer = AutoTokenizer.from_pretrained(model_dir, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(model_dir, torch_dtype=torch.bfloat16, trust_remote_code=True)
model.eval()
model.to("cuda:0")

input_text = "Suzhou is famous of"
inputs = tokenizer(input_text, return_tensors="pt")
inputs = inputs.to("cuda:0")

pred = model.generate(**inputs, max_length=50, temperature=0.0)
print(tokenizer.decode(pred.cpu()[0], skip_special_tokens=True))
# Suzhou is famous of its beautiful gardens. The most famous one is the Humble Administrator's Garden. It is a classical Chinese garden with a history of more than 600 years. The garden is divided into three

πŸ“Š Performance

Model#Activated Experts#Experts#Activated ParamsLinks
LLaMA-MoE-3.0B2163.0B[πŸ€— HF Weights]
LLaMA-MoE-3.5B (4/16)4163.5B[πŸ€— HF Weights]
LLaMA-MoE-3.5B (2/8)283.5B[πŸ€— HF Weights]
ModelSciQPIQAWinoGrandeARC-eARC-c (25)HellaSwag (10)LogiQABoolQ (32)LAMBADANQ (32)MMLU (5)Average
OPT-2.7B78.974.860.854.434.061.425.863.363.610.725.850.3
Pythia-2.8B83.273.659.658.836.760.728.165.964.68.726.851.5
INCITE-BASE-3B85.673.963.561.740.364.727.565.865.415.227.253.7
Open-LLaMA-3B-v288.077.963.163.340.171.428.169.267.416.026.855.6
Sheared-LLaMA-2.7B87.576.965.063.341.671.028.373.668.317.627.356.4
LLaMA-MoE-3.0B84.277.563.660.240.970.830.671.966.617.026.855.5
LLaMA-MoE-3.5B (4/16)87.677.965.565.644.273.329.775.069.520.326.857.7
LLaMA-MoE-3.5B (2/8)88.477.666.765.343.173.329.673.969.419.827.057.6

πŸ“– Details

Training Data: 200B tokens from SlimPajama with the same data sampling weights as Sheared LLaMA.

πŸ“ƒ Citation

@article{llama-moe,
  title={LLaMA-MoE: Building Mixture-of-Experts from LLaMA with Continual Pre-training},
  author={Tong Zhu and Xiaoye Qu and Daize Dong and Jiacheng Ruan and Jingqi Tong and Conghui He and Yu Cheng},
  journal={arXiv preprint arXiv:2406.16554},
  year={2024},
  url={https://arxiv.org/abs/2406.16554},
}
custom_code
llama_moe
pytorch
text-generation
transformers

Contributors

Spico

8 commits