abhinavkulkarni commited on
Commit
3c9ea33
1 Parent(s): a89bd3f

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +131 -0
README.md ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-sa-3.0
3
+ tags:
4
+ - MosaicML
5
+ - AWQ
6
+ inference: false
7
+ ---
8
+
9
+ # MPT-7B-Chat (4-bit 128g AWQ Quantized)
10
+ [MPT-7B-Chat](https://huggingface.co/mosaicml/mpt-7b-chat) is a chatbot-like model for dialogue generation.
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-7b-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 v12.1 and toolkit v11.7 with Python v3.10.11.
27
+
28
+ ## How to Use
29
+
30
+ ```bash
31
+ git clone https://github.com/mit-han-lab/llm-awq \
32
+ && cd llm-awq \
33
+ && git checkout 71d8e68df78de6c0c817b029a568c064bf22132d \
34
+ && pip install -e .
35
+ ```
36
+
37
+ ```python
38
+ import torch
39
+ from awq.quantize.quantizer import real_quantize_model_weight
40
+ from transformers import AutoModelForCausalLM, AutoConfig, AutoTokenizer
41
+ from accelerate import init_empty_weights, load_checkpoint_and_dispatch
42
+ from huggingface_hub import hf_hub_download
43
+
44
+ model_name = "mosaicml/mpt-7b-chat"
45
+
46
+ # Config
47
+ config = AutoConfig.from_pretrained(model_name, trust_remote_code=True)
48
+
49
+ # Tokenizer
50
+ tokenizer = AutoTokenizer.from_pretrained(config.tokenizer_name)
51
+
52
+ # Model
53
+ w_bit = 4
54
+ q_config = {
55
+ "zero_point": True,
56
+ "q_group_size": 128,
57
+ }
58
+
59
+ load_quant = hf_hub_download('abhinavkulkarni/mpt-7b-chat-w4-g128-awq', 'pytorch_model.bin')
60
+
61
+ with init_empty_weights():
62
+ model = AutoModelForCausalLM.from_pretrained(model_name, config=config,
63
+ torch_dtype=torch.float16, trust_remote_code=True)
64
+
65
+ real_quantize_model_weight(model, w_bit=w_bit, q_config=q_config, init_only=True)
66
+
67
+ model = load_checkpoint_and_dispatch(model, load_quant, device_map="balanced")
68
+
69
+ # Inference
70
+ prompt = f'''What is the difference between nuclear fusion and fission?
71
+ ###Response:'''
72
+
73
+ input_ids = tokenizer(prompt, return_tensors='pt').input_ids.cuda()
74
+ output = model.generate(
75
+ inputs=input_ids,
76
+ temperature=0.7,
77
+ max_new_tokens=512,
78
+ top_p=0.15,
79
+ top_k=0,
80
+ repetition_penalty=1.1,
81
+ eos_token_id=tokenizer.eos_token_id
82
+ )
83
+ print(tokenizer.decode(output[0]))
84
+ ```
85
+
86
+ ## Evaluation
87
+
88
+ This evaluation was done using [LM-Eval](https://github.com/EleutherAI/lm-evaluation-harness).
89
+
90
+ [MPT-7B-Chat](https://huggingface.co/mosaicml/mpt-7b-chat)
91
+
92
+ | Task |Version| Metric | Value | |Stderr|
93
+ |--------|------:|---------------|------:|---|------|
94
+ |wikitext| 1|word_perplexity|13.5936| | |
95
+ | | |byte_perplexity| 1.6291| | |
96
+ | | |bits_per_byte | 0.7040| | |
97
+
98
+ [MPT-7B-Chat (4-bit 128-group AWQ)](https://huggingface.co/abhinavkulkarni/mpt-7b-chat-w4-g128-awq)
99
+
100
+ | Task |Version| Metric | Value | |Stderr|
101
+ |--------|------:|---------------|------:|---|------|
102
+ |wikitext| 1|word_perplexity|14.0922| | |
103
+ | | |byte_perplexity| 1.6401| | |
104
+ | | |bits_per_byte | 0.7138| | |
105
+
106
+
107
+ ## Acknowledgements
108
+
109
+ The MPT model was originally finetuned by Sam Havens and the MosaicML NLP team. Please cite this model using the following format:
110
+
111
+ ```
112
+ @online{MosaicML2023Introducing,
113
+ author = {MosaicML NLP Team},
114
+ title = {Introducing MPT-7B: A New Standard for Open-Source, Commercially Usable LLMs},
115
+ year = {2023},
116
+ url = {www.mosaicml.com/blog/mpt-7b},
117
+ note = {Accessed: 2023-03-28}, % change this date
118
+ urldate = {2023-03-28} % change this date
119
+ }
120
+ ```
121
+
122
+ The model was quantized with AWQ technique. If you find AWQ useful or relevant to your research, please kindly cite the paper:
123
+
124
+ ```
125
+ @article{lin2023awq,
126
+ title={AWQ: Activation-aware Weight Quantization for LLM Compression and Acceleration},
127
+ author={Lin, Ji and Tang, Jiaming and Tang, Haotian and Yang, Shang and Dang, Xingyu and Han, Song},
128
+ journal={arXiv},
129
+ year={2023}
130
+ }
131
+ ```