abhinavkulkarni commited on
Commit
3779a9d
1 Parent(s): 7d69d2b

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +136 -0
README.md ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-sa-3.0
3
+ tags:
4
+ - MosaicML
5
+ - AWQ
6
+ inference: false
7
+ ---
8
+
9
+ # MPT-30B-Instruct (4-bit 128g AWQ Quantized)
10
+ [MPT-30B-Instruct](https://huggingface.co/mosaicml/mpt-30b-chat) is a model for short-form instruction following.
11
+
12
+ This model is a 4-bit 128 group size AWQ quantized model. For more information about AWQ quantization, please click [here](https://github.com/mit-han-lab/llm-awq).
13
+
14
+ ## Model Date
15
+
16
+ July 5, 2023
17
+
18
+ ## Model License
19
+
20
+ Please refer to original MPT model license ([link](https://huggingface.co/mosaicml/mpt-30b-chat)).
21
+
22
+ Please refer to the AWQ quantization license ([link](https://github.com/llm-awq/blob/main/LICENSE)).
23
+
24
+ ## CUDA Version
25
+
26
+ This model was successfully tested on CUDA driver v530.30.02 and runtime v11.7 with Python v3.10.11. Please note that AWQ requires NVIDIA GPUs with compute capability of 80 or higher.
27
+
28
+ For Docker users, the `nvcr.io/nvidia/pytorch:23.06-py3` image is runtime v12.1 but otherwise the same as the configuration above and has also been verified to work.
29
+
30
+ ## How to Use
31
+
32
+ ```bash
33
+ git clone https://github.com/mit-han-lab/llm-awq \
34
+ && cd llm-awq \
35
+ && git checkout 71d8e68df78de6c0c817b029a568c064bf22132d \
36
+ && pip install -e . \
37
+ && cd awq/kernels \
38
+ && python setup.py install
39
+ ```
40
+
41
+ ```python
42
+ import torch
43
+ from awq.quantize.quantizer import real_quantize_model_weight
44
+ from transformers import AutoModelForCausalLM, AutoConfig, AutoTokenizer
45
+ from accelerate import init_empty_weights, load_checkpoint_and_dispatch
46
+ from huggingface_hub import snapshot_download
47
+
48
+ model_name = "mosaicml/mpt-30b-chat"
49
+
50
+ # Config
51
+ config = AutoConfig.from_pretrained(model_name, trust_remote_code=True)
52
+
53
+ # Tokenizer
54
+ tokenizer = AutoTokenizer.from_pretrained(config.tokenizer_name)
55
+
56
+ # Model
57
+ w_bit = 4
58
+ q_config = {
59
+ "zero_point": True,
60
+ "q_group_size": 128,
61
+ }
62
+
63
+ load_quant = snapshot_download('abhinavkulkarni/mpt-30b-chat-w4-g128-awq')
64
+
65
+ with init_empty_weights():
66
+ model = AutoModelForCausalLM.from_config(config=config,
67
+ torch_dtype=torch.float16, trust_remote_code=True)
68
+
69
+ real_quantize_model_weight(model, w_bit=w_bit, q_config=q_config, init_only=True)
70
+
71
+ model = load_checkpoint_and_dispatch(model, load_quant, device_map="balanced")
72
+
73
+ # Inference
74
+ prompt = f'''What is the difference between nuclear fusion and fission?
75
+ ###Response:'''
76
+
77
+ input_ids = tokenizer(prompt, return_tensors='pt').input_ids.cuda()
78
+ output = model.generate(
79
+ inputs=input_ids,
80
+ temperature=0.7,
81
+ max_new_tokens=512,
82
+ top_p=0.15,
83
+ top_k=0,
84
+ repetition_penalty=1.1,
85
+ eos_token_id=tokenizer.eos_token_id
86
+ )
87
+ print(tokenizer.decode(output[0], skip_special_tokens=True))
88
+ ```
89
+
90
+ ## Evaluation
91
+
92
+ This evaluation was done using [LM-Eval](https://github.com/EleutherAI/lm-evaluation-harness).
93
+
94
+ [MPT-30B-Instruct](https://huggingface.co/mosaicml/mpt-30b-chat)
95
+
96
+ | Task |Version| Metric | Value | |Stderr|
97
+ |--------|------:|---------------|------:|---|------|
98
+ |wikitext| 1|word_perplexity|11.5609| | |
99
+ | | |byte_perplexity| 1.5805| | |
100
+ | | |bits_per_byte | 0.6603| | |
101
+
102
+ [MPT-30B-Instruct (4-bit 128-group AWQ)](https://huggingface.co/abhinavkulkarni/mosaicml-mpt-30b-chat-w4-g128-awq)
103
+
104
+ | Task |Version| Metric | Value | |Stderr|
105
+ |--------|------:|---------------|------:|---|------|
106
+ |wikitext| 1|word_perplexity|11.6649| | |
107
+ | | |byte_perplexity| 1.5831| | |
108
+ | | |bits_per_byte | 0.6628| | |
109
+
110
+ ## Acknowledgements
111
+
112
+ The MPT model was originally finetuned by Sam Havens and the MosaicML NLP team. Please cite this model using the following format:
113
+
114
+ ```
115
+ @online{MosaicML2023Introducing,
116
+ author = {MosaicML NLP Team},
117
+ title = {Introducing MPT-30B: A New Standard for Open-Source, Commercially Usable LLMs},
118
+ year = {2023},
119
+ url = {www.mosaicml.com/blog/mpt-30b},
120
+ note = {Accessed: 2023-03-28}, % change this date
121
+ urldate = {2023-03-28} % change this date
122
+ }
123
+ ```
124
+
125
+
126
+ The model was quantized with AWQ technique. If you find AWQ useful or relevant to your research, please kindly cite the paper:
127
+
128
+ ```
129
+ @article{lin2023awq,
130
+ title={AWQ: Activation-aware Weight Quantization for LLM Compression and Acceleration},
131
+ author={Lin, Ji and Tang, Jiaming and Tang, Haotian and Yang, Shang and Dang, Xingyu and Han, Song},
132
+ journal={arXiv},
133
+ year={2023}
134
+ }
135
+ ```
136
+