abhinavkulkarni commited on
Commit
ad1feeb
1 Parent(s): aeec406

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +130 -0
README.md ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ tags:
4
+ - AWQ
5
+ inference: false
6
+ ---
7
+
8
+ # Falcon-7B-Instruct (4-bit 64g AWQ Quantized)
9
+ [Falcon-7B-Instruct](https://huggingface.co/tiiuae/falcon-7b-instruct) is a 7B parameters causal decoder-only model built by [TII](https://www.tii.ae) based on [Falcon-7B](https://huggingface.co/tiiuae/falcon-7b) and finetuned on a mixture of chat/instruct datasets.
10
+
11
+ This model is a 4-bit 64 group size AWQ quantized model. For more information about AWQ quantization, please click [here](https://github.com/mit-han-lab/llm-awq).
12
+
13
+ ## Model Date
14
+
15
+ July 5, 2023
16
+
17
+ ## Model License
18
+
19
+ Please refer to original Falcon model license ([link](https://huggingface.co/tiiuae/falcon-7b-instruct)).
20
+
21
+ Please refer to the AWQ quantization license ([link](https://github.com/llm-awq/blob/main/LICENSE)).
22
+
23
+ ## CUDA Version
24
+
25
+ This model was successfully tested on CUDA driver v12.1 and toolkit v11.7 with Python v3.10.11.
26
+
27
+ ## How to Use
28
+
29
+ ```bash
30
+ git clone https://github.com/mit-han-lab/llm-awq \
31
+ && cd llm-awq \
32
+ && git checkout 71d8e68df78de6c0c817b029a568c064bf22132d \
33
+ && pip install -e . \
34
+ && cd awq/kernels \
35
+ && python setup.py install
36
+ ```
37
+
38
+ ```python
39
+ import torch
40
+ from awq.quantize.quantizer import real_quantize_model_weight
41
+ from transformers import AutoModelForCausalLM, AutoConfig, AutoTokenizer
42
+ from accelerate import init_empty_weights, load_checkpoint_and_dispatch
43
+ from huggingface_hub import hf_hub_download
44
+
45
+ model_name = "tiiuae/falcon-7b-instruct"
46
+
47
+ # Config
48
+ config = AutoConfig.from_pretrained(model_name, trust_remote_code=True)
49
+
50
+ # Tokenizer
51
+ tokenizer = AutoTokenizer.from_pretrained(config.tokenizer_name)
52
+
53
+ # Model
54
+ w_bit = 4
55
+ q_config = {
56
+ "zero_point": True,
57
+ "q_group_size": 64,
58
+ }
59
+
60
+ load_quant = hf_hub_download('abhinavkulkarni/falcon-7b-instruct-w4-g64-awq', 'pytorch_model.bin')
61
+
62
+ with init_empty_weights():
63
+ model = AutoModelForCausalLM.from_pretrained(model_name, config=config,
64
+ torch_dtype=torch.float16, trust_remote_code=True)
65
+
66
+ real_quantize_model_weight(model, w_bit=w_bit, q_config=q_config, init_only=True)
67
+
68
+ model = load_checkpoint_and_dispatch(model, load_quant, device_map="balanced")
69
+
70
+ # Inference
71
+ prompt = f'''What is the difference between nuclear fusion and fission?
72
+ ###Response:'''
73
+
74
+ input_ids = tokenizer(prompt, return_tensors='pt').input_ids.cuda()
75
+ output = model.generate(
76
+ inputs=input_ids,
77
+ temperature=0.7,
78
+ max_new_tokens=512,
79
+ top_p=0.15,
80
+ top_k=0,
81
+ repetition_penalty=1.1,
82
+ eos_token_id=tokenizer.eos_token_id
83
+ )
84
+ print(tokenizer.decode(output[0], skip_special_tokens=True))
85
+ ```
86
+
87
+ ## Evaluation
88
+
89
+ This evaluation was done using [LM-Eval](https://github.com/EleutherAI/lm-evaluation-harness).
90
+
91
+ [Falcon-7B-Instruct](https://huggingface.co/tiiuae/falcon-7b-instruct)
92
+
93
+ | Task |Version| Metric | Value | |Stderr|
94
+ |--------|------:|---------------|------:|---|------|
95
+ |wikitext| 1|word_perplexity|14.5069| | |
96
+ | | |byte_perplexity| 1.6490| | |
97
+ | | |bits_per_byte | 0.7216| | |
98
+
99
+ [Falcon-7B-Instruct (4-bit 64-group AWQ)](https://huggingface.co/abhinavkulkarni/falcon-7b-instruct-w4-g64-awq)
100
+
101
+ | Task |Version| Metric | Value | |Stderr|
102
+ |--------|------:|---------------|------:|---|------|
103
+ |wikitext| 1|word_perplexity|14.8667| | |
104
+ | | |byte_perplexity| 1.6566| | |
105
+ | | |bits_per_byte | 0.7282| | |
106
+
107
+
108
+ ## Acknowledgements
109
+
110
+ *Paper coming soon* 😊. In the meanwhile, you can use the following information to cite:
111
+ ```
112
+ @article{falcon40b,
113
+ title={{Falcon-40B}: an open large language model with state-of-the-art performance},
114
+ author={Almazrouei, Ebtesam and Alobeidli, Hamza and Alshamsi, Abdulaziz and Cappelli, Alessandro and Cojocaru, Ruxandra and Debbah, Merouane and Goffinet, Etienne and Heslow, Daniel and Launay, Julien and Malartic, Quentin and Noune, Badreddine and Pannier, Baptiste and Penedo, Guilherme},
115
+ year={2023}
116
+ }
117
+ ```
118
+
119
+
120
+ The model was quantized with AWQ technique. If you find AWQ useful or relevant to your research, please kindly cite the paper:
121
+
122
+ ```
123
+ @article{lin2023awq,
124
+ title={AWQ: Activation-aware Weight Quantization for LLM Compression and Acceleration},
125
+ author={Lin, Ji and Tang, Jiaming and Tang, Haotian and Yang, Shang and Dang, Xingyu and Han, Song},
126
+ journal={arXiv},
127
+ year={2023}
128
+ }
129
+ ```
130
+