Home

Awesome

πŸ“±πŸ¦™ MobiLlama: Towards Accurate and Lightweight Fully Transparent GPT

<p align="center"> <img src="./images/MobileLLaMa.png" height="400px" alt="Oryx MobiLLama"> </p> <p align="center"> <img src="https://i.imgur.com/waxVImv.png" alt="Oryx MobiLLama"> </p> <p align="center"> <a href="https://github.com/mbzuai-oryx/MobiLlama/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-Apache_2.0-blue.svg" alt="license"></a> </p>

Omkar Thawakar, Ashmal Vayani, Salman Khan, Hisham Cholakkal, Rao Muhammad Anwer, Michael Felsberg, Timothy Baldwin, Eric Xing and Fahad Khan

Mohamed Bin Zayed University of Artificial Intelligence (MBZUAI), UAE and Linköping University, Sweden

paper πŸ€— HuggingFace Demo


πŸ“’ Latest Updates

Overview

Bigger the better has been the predominant trend in recent Large Language Models (LLMs) development. However, LLMs do not suit well for scenarios that require on-device processing, energy efficiency, low memory footprint, and response efficiency. These requisites are crucial for privacy, security, and sustainable deployment. This paper explores the less is more paradigm by addressing the challenge of designing accurate yet efficient Small Language Models (SLMs) for resource constrained devices. Our primary contribution is the introduction of an accurate and fully transparent open-source 0.5 billion (0.5B) parameter SLM, named MobiLlama, catering to the specific needs of resource-constrained computing with an emphasis on enhanced performance with reduced resource demands. MobiLlama is a SLM design that initiates from a larger model and applies a careful parameter sharing scheme to reduce both the pre-training and the deployment cost.

⚑ Model Download

Model NameLink Download
MobiLlama-05BHuggingFace
MobiLlama-08BHuggingFace
MobiLlama-1BHuggingFace
MobiLlama-05B-ChatHuggingFace
MobiLlama-1B-ChatHuggingFace

Generation with MobiLlama

<p align="center"> <img src="images/mobillama_generation.gif"/> </p>

Model Description

Loading MobiLlama

from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained("MBZUAI/MobiLlama-05B", trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained("MBZUAI/MobiLlama-05B", trust_remote_code=True)

model.to('cuda')
text = "I was walking towards the river when "
input_ids = tokenizer(text, return_tensors="pt").to('cuda').input_ids
outputs = model.generate(input_ids, max_length=1000, repetition_penalty=1.2, pad_token_id=tokenizer.eos_token_id)
print(tokenizer.batch_decode(outputs[:, input_ids.shape[1]:-1])[0].strip())

Load intermediate Checkpoints

model = AutoModelForCausalLM.from_pretrained("MBZUAI/MobiLlama-05B", revision="ckpt_352", trust_remote_code=True)

All the intermediate checkpoints are available from ckpt_100 to ckpt_358.

Dataset

Download the preprocessed Amber data from huggingface. The entire training data has 360 chunks totalling the size of ~8 TB. Amber dataset contains total 1.2 Trillion tokens with gathered from different data sources shown below.

SubsetTokens (Billion)
Arxiv30.00
Book28.86
C4197.67
Refined-Web665.01
StarCoder291.92
StackExchange21.75
Wikipedia23.90
Total1259.13

Installation

First install PyTorch according to the instructions specific to your operating system.

To install from source (recommended for training/fine-tuning) run:

conda create -n mobillama python=3.10
conda activate mibillama
git clone https://github.com/mbzuai-oryx/MobiLlama.git
cd MobiLlama
pip install -r  requirements.txt

pretrain

For MobiLlama (using 20 nodes of A100 80GB GPUS)

sbatch pretrain.sh

For large-base use main_largebase.py in L:11 of pretrain.sh

πŸ”Ž Evaluation

We used Analysis-360 to evaluate our model on different llm benchmarks.

πŸ“Š Results

Model Name#ParamsHellaSwagTruthfulqaMMLUArc_CCrowsPairspiqaracesiqawinograndeAverage
gpt-neo-125m0.15B30.2645.5825.9722.9561.5562.4627.5640.3351.7840.93
tiny-starcoder0.17B28.1747.6826.7920.9949.6852.5525.4538.2851.2237.86
cerebras-gpt-256m0.26B28.9945.9826.8322.0160.5261.4227.4640.5352.4940.69
opt-350m0.35B36.7340.8326.0223.5564.1264.7429.8541.5552.6442.22
megatron-gpt2-345m0.38B39.1841.5124.3224.2364.8266.8731.1940.2852.9642.81
LiteLlama0.46B38.4741.5926.1724.9162.9067.7328.4240.2749.8842.26
gpt-sw3-356m0.47B37.0542.5525.9323.6361.5964.8532.1541.5653.0442.48
pythia-410m0.51B40.8541.2227.2526.1964.2067.1930.7141.4053.1243.57
xglm-564m0.56B34.6440.4325.1824.5762.2564.8529.2842.6853.0341.87
Lamini-GPT-LM0.59B31.5540.7225.5324.2363.0963.8729.9540.7847.7540.83
MobiLlama (Ours)0.5B52.5238.0526.4529.5264.0372.0333.6840.2257.5346.00
Lamini-GPT-LM0.77B43.8340.2526.2427.5566.1269.3137.1242.4756.5945.49
MobiLlama (Ours)0.8B54.0938.4826.9230.2064.8273.1733.3741.6057.4546.67

The table provides a comparative analysis of various models, including our MobiLlama, across several LLM benchmarks. It highlights MobiLlama's superior performance, particularly in its 0.5B and 0.8B configurations, showcasing its efficiency and effectiveness in processing complex language tasks. This comparison underscores MobiLlama's advancements in achieving higher accuracy and demonstrates its potential as a leading solution in the field of LLM.


Model#ParamsHellaSwagTruthfulqaMMLUArc_CCrowsPairspiqaracesiqawinograndeAverage
Boomer1B31.6239.4225.4222.2661.2657.9928.9940.3250.9839.80
Pythia-Dedup1B49.6338.9224.2929.0967.1170.2332.4442.6353.9845.36
Falcon-RW1B63.1235.9625.3635.0669.0474.1036.0740.2361.8848.98
TinyLlama1.1B60.2237.5926.1133.6170.6073.2836.4541.6559.1848.74
OLMo1.2B62.5032.9425.8634.4569.5973.7036.7441.1458.9048.42
Cerebras-GPT1.3B38.5142.7026.6626.1063.6766.7530.3342.4253.5943.41
Lamini1.3B38.0536.4328.4726.6264.6267.8933.3943.1950.5943.25
OPT1.3B54.5038.6724.6329.6070.7072.4734.1642.4759.7447.43
GPT-NEO1.3B48.4939.6124.8231.3165.6771.0534.0641.8157.0645.98
Pythia-Deduped1.4B55.0038.6325.4532.5967.3372.6834.6442.6856.9047.32
large-base1.2B62.9935.9024.7934.5568.4975.5735.3141.9662.0349.06

Comprehensive comparisons with existing < 2B params fully open-source LLM models on 9 benchmarks. Our 1.2B "large-base" model pre-trained on 1.2T tokens achieves superior performance compared to both the recent OLMo 1.17B model and TinyLlama 1.1B model, which are pre-trained on a substantially larger data of 3T tokens.

πŸ“± MobiLlama on Android

To run our model on an android app, please download and install the APK from here.

πŸ™ Acknowledgements

πŸ“œ Citation

@misc{thawakar2024mobillama,
      title={MobiLlama: Towards Accurate and Lightweight Fully Transparent GPT}, 
      author={Omkar Thawakar and Ashmal Vayani and Salman Khan and Hisham Cholakkal and Rao Muhammad Anwer and Michael Felsberg and Timothy Baldwin and Eric P. Xing and Fahad Shahbaz Khan},
      year={2024},
      eprint={2402.16840},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
}