LoftQ commited on
Commit
cba7046
1 Parent(s): 50e2888

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +66 -0
README.md ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ language:
4
+ - en
5
+ pipeline_tag: text-generation
6
+ tags:
7
+ - 'quantization '
8
+ - lora
9
+ ---
10
+ # LoftQ Initialization
11
+
12
+ | [Paper](https://arxiv.org/abs/2310.08659) | [Code](https://github.com/yxli2123/LoftQ) | [PEFT Example](https://github.com/huggingface/peft/tree/main/examples/loftq_finetuning) |
13
+
14
+ LoftQ (LoRA-fine-tuning-aware Quantization) provides a quantized backbone Q and LoRA adapters A and B, given a full-precision pre-trained weight W.
15
+
16
+ This model, `LoftQ/Phi-3-mini-4k-instruct-4bit-64rank`, is obtained from [Phi-3-mini-4k-instruct](https://huggingface.co/microsoft/Phi-3-mini-4k-instruct).
17
+ The backbone is under `LoftQ/Phi-3-mini-4k-instruct-4bit-64rank` and LoRA adapters are under the `subfolder='loftq_init'`.
18
+
19
+ ## Model Info
20
+ ### Backbone
21
+ - Stored format: nf4
22
+ - Size: ~ 5.5 GiB
23
+ - Loaded format: bitsandbytes nf4
24
+ - Size loaded on GPU: ~1.4 GiB
25
+
26
+ ### LoRA adapters
27
+ - rank: 64
28
+ - lora_alpha: 16
29
+ - target_modules: ["qkv_proj", "o_proj", "up_gate_proj", "down_proj"]
30
+ - rank_pattern: {"qkv_proj": 192, "up_gate_proj": 128}
31
+
32
+ ## Usage
33
+
34
+ **Training** Here's an example of loading this model and preparing for the LoRA fine-tuning.
35
+
36
+ ```python
37
+ import torch
38
+ from transformers import AutoModelForCausalLM, BitsAndBytesConfig
39
+ from peft import PeftModel
40
+
41
+ MODEL_ID = "LoftQ/Phi-3-mini-4k-instruct-4bit-64rank"
42
+
43
+ base_model = AutoModelForCausalLM.from_pretrained(MODEL_ID)
44
+ peft_model = PeftModel.from_pretrained(
45
+ base_model,
46
+ MODEL_ID,
47
+ subfolder="loftq_init",
48
+ is_trainable=True,
49
+ )
50
+
51
+ # Do training with peft_model ...
52
+ ```
53
+
54
+ See the full code at our [Github Repo]((https://github.com/yxli2123/LoftQ))
55
+
56
+
57
+ ## Citation
58
+
59
+ ```bibtex
60
+ @article{li2023loftq,
61
+ title={Loftq: Lora-fine-tuning-aware quantization for large language models},
62
+ author={Li, Yixiao and Yu, Yifan and Liang, Chen and He, Pengcheng and Karampatziakis, Nikos and Chen, Weizhu and Zhao, Tuo},
63
+ journal={arXiv preprint arXiv:2310.08659},
64
+ year={2023}
65
+ }
66
+ ```