Views
No views yet
Meta-Llama-3-8B-4bit-64rank, is obtained from LLAMA-3-8B.
The backbone is under LoftQ/Meta-Llama-3-8B-4bit-64rank and LoRA adapters are under the subfolder='loftq_init'.1import torch
2from transformers import AutoModelForCausalLM, BitsAndBytesConfig
3from peft import PeftModel
4
5MODEL_ID = "LoftQ/Meta-Llama-3-8B-4bit-64rank"
6
7base_model = AutoModelForCausalLM.from_pretrained(MODEL_ID)
8peft_model = PeftModel.from_pretrained(
9 base_model,
10 MODEL_ID,
11 subfolder="loftq_init",
12 is_trainable=True,
13)
14
15# Do training with peft_model ...| Model | Bits | Rank | LoRA Initial | GSM8K |
|---|---|---|---|---|
| LLAMA-3-8B | 16 | - | Full model fine-tuning | 70.4±0.7 |
| LLAMA-3-8B | 16 | 64 | Gaussian + 0 (LoRA) | 69.3±1.5 |
| LLAMA-3-8B | 4 | 64 | Gaussian + 0 (QLoRA) | 67.4±1.0 |
| LLAMA-3-8B | 4 | 64 | LoftQ | 68.0±0.6 |
1import torch
2from transformers import AutoModelForCausalLM, BitsAndBytesConfig
3from peft import PeftModel
4
5MODEL_ID = "LoftQ/Meta-Llama-3-8B-4bit-64rank"
6
7base_model = AutoModelForCausalLM.from_pretrained(
8 MODEL_ID,
9 torch_dtype=torch.bfloat16, # you may change it with different models
10 quantization_config=BitsAndBytesConfig(
11 load_in_4bit=True,
12 bnb_4bit_compute_dtype=torch.bfloat16, # bfloat16 is recommended
13 bnb_4bit_use_double_quant=False,
14 bnb_4bit_quant_type='nf4',
15 ),
16)
17peft_model = PeftModel.from_pretrained(
18 base_model,
19 MODEL_ID,
20 subfolder="gsm8k",
21 is_trainable=False,
22)
23
24# Do inference with peft_model ...1@article{li2023loftq,
2 title={Loftq: Lora-fine-tuning-aware quantization for large language models},
3 author={Li, Yixiao and Yu, Yifan and Liang, Chen and He, Pengcheng and Karampatziakis, Nikos and Chen, Weizhu and Zhao, Tuo},
4 journal={arXiv preprint arXiv:2310.08659},
5 year={2023}
6}