Lin-K76 commited on
Commit
779e3bb
·
verified ·
1 Parent(s): 87b86c0

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +177 -14
README.md CHANGED
@@ -7,22 +7,185 @@ tags:
7
  # Meta-Llama-3-70B-Instruct-FP8
8
 
9
  ## Model Overview
10
- Meta-Llama-3-70B-Instruct quantized to FP8 weights and activations using per-tensor quantization, ready for inference with vLLM >= 0.5.0.
 
 
 
 
 
 
 
 
 
 
11
 
12
- ## Usage and Creation
13
- Produced using [AutoFP8 with calibration samples from ultrachat](https://github.com/neuralmagic/AutoFP8/blob/147fa4d9e1a90ef8a93f96fc7d9c33056ddc017a/example_dataset.py).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
  ## Evaluation
16
 
17
- ### Open LLM Leaderboard evaluation scores
18
- | | Meta-Llama-3-70B-Instruct | Meta-Llama-3-70B-Instruct-FP8<br>(this model) |
19
- | :------------------: | :----------------------: | :------------------------------------------------: |
20
- | arc-c<br>25-shot | 72.69 | 72.61 |
21
- | hellaswag<br>10-shot | 85.50 | 85.41 |
22
- | mmlu<br>5-shot | 80.18 | 80.06 |
23
- | truthfulqa<br>0-shot | 62.90 | 62.73 |
24
- | winogrande<br>5-shot | 83.34 | 83.03 |
25
- | gsm8k<br>5-shot | 92.49 | 91.12 |
26
- | **Average<br>Accuracy** | **79.51** | **79.16** |
27
- | **Recovery** | **100%** | **99.55%** |
28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  # Meta-Llama-3-70B-Instruct-FP8
8
 
9
  ## Model Overview
10
+ - **Model Architecture:** Meta-Llama-3
11
+ - **Input:** Text
12
+ - **Output:** Text
13
+ - **Model Optimizations:**
14
+ - **Weight quantization:** FP8
15
+ - **Activation quantization:** FP8
16
+ - **Intended Use Cases:** Intended for commercial and research use in English. Similarly to [Meta-Llama-3-70B-Instruct](https://huggingface.co/meta-llama/Meta-Llama-3-70B-Instruct), this models is intended for assistant-like chat.
17
+ - **Out-of-scope:** Use in any manner that violates applicable laws or regulations (including trade compliance laws). Use in languages other than English.
18
+ - **Release Date:** 6/8/2024
19
+ - **Version:** 1.0
20
+ - **Model Developers:** Neural Magic
21
 
22
+ Quantized version of [Meta-Llama-3-70B-Instruct](https://huggingface.co/meta-llama/Meta-Llama-3-70B-Instruct).
23
+ It achieves an average score of 68.22 on the [OpenLLM](https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard) benchmark (version 1), whereas the unquantized model achieves 68.71.
24
+
25
+ ### Model Optimizations
26
+
27
+ This model was obtained by quantizing the weights and activations of [Meta-Llama-3-70B-Instruct](https://huggingface.co/meta-llama/Meta-Llama-3-70B-Instruct) to FP8 data type, ready for inference with vLLM >= 0.5.0.
28
+ This optimization reduces the number of bits per parameter from 16 to 8, reducing the disk size and GPU memory requirements by approximately 50%.
29
+
30
+ Only the weights and activations of the linear operators within transformers blocks are quantized. Symmetric per-channel quantization is applied, in which a linear scaling per output dimension maps the FP8 representations of the quantized weights and activations.
31
+ [AutoFP8](https://github.com/neuralmagic/AutoFP8) is used for quantization with 512 sequences of UltraChat.
32
+
33
+ ## Deployment
34
+
35
+ ### Use with vLLM
36
+
37
+ This model can be deployed efficiently using the [vLLM](https://docs.vllm.ai/en/latest/) backend, as shown in the example below.
38
+
39
+ ```python
40
+ from vllm import LLM, SamplingParams
41
+ from transformers import AutoTokenizer
42
+
43
+ model_id = "neuralmagic/Meta-Llama-3-70B-Instruct-FP8"
44
+
45
+ sampling_params = SamplingParams(temperature=0.6, top_p=0.9, max_tokens=256)
46
+
47
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
48
+
49
+ messages = [
50
+ {"role": "system", "content": "You are a pirate chatbot who always responds in pirate speak!"},
51
+ {"role": "user", "content": "Who are you?"},
52
+ ]
53
+
54
+ prompts = tokenizer.apply_chat_template(messages, tokenize=False)
55
+
56
+ llm = LLM(model=model_id)
57
+
58
+ outputs = llm.generate(prompts, sampling_params)
59
+
60
+ generated_text = outputs[0].outputs[0].text
61
+ print(generated_text)
62
+ ```
63
+
64
+ vLLM aslo supports OpenAI-compatible serving. See the [documentation](https://docs.vllm.ai/en/latest/) for more details.
65
+
66
+ ## Creation
67
+
68
+ This model was created by applying [AutoFP8 with calibration samples from ultrachat](https://github.com/neuralmagic/AutoFP8/blob/147fa4d9e1a90ef8a93f96fc7d9c33056ddc017a/example_dataset.py), as presented in the code snipet below.
69
+ Although AutoFP8 was used for this particular model, Neural Magic is transitioning to using [llm-compressor](https://github.com/vllm-project/llm-compressor) which supports several quantization schemes and models not supported by AutoFP8.
70
+
71
+ ```python
72
+ from datasets import load_dataset
73
+ from transformers import AutoTokenizer
74
+
75
+ from auto_fp8 import AutoFP8ForCausalLM, BaseQuantizeConfig
76
+
77
+ pretrained_model_dir = "meta-llama/Meta-Llama-3-70B-Instruct"
78
+ quantized_model_dir = "Meta-Llama-3-70B-Instruct-FP8"
79
+
80
+ tokenizer = AutoTokenizer.from_pretrained(pretrained_model_dir, use_fast=True, model_max_length=4096)
81
+ tokenizer.pad_token = tokenizer.eos_token
82
+
83
+ ds = load_dataset("mgoin/ultrachat_2k", split="train_sft").select(range(512))
84
+ examples = [tokenizer.apply_chat_template(batch["messages"], tokenize=False) for batch in ds]
85
+ examples = tokenizer(examples, padding=True, truncation=True, return_tensors="pt").to("cuda")
86
+
87
+ quantize_config = BaseQuantizeConfig(quant_method="fp8", activation_scheme="static")
88
+
89
+ model = AutoFP8ForCausalLM.from_pretrained(
90
+ pretrained_model_dir, quantize_config=quantize_config
91
+ )
92
+ model.quantize(examples)
93
+ model.save_quantized(quantized_model_dir)
94
+ ```
95
 
96
  ## Evaluation
97
 
98
+ The model was evaluated on the [OpenLLM](https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard) leaderboard tasks (version 1) with the [lm-evaluation-harness](https://github.com/EleutherAI/lm-evaluation-harness/tree/383bbd54bc621086e05aa1b030d8d4d5635b25e6) (commit 383bbd54bc621086e05aa1b030d8d4d5635b25e6) and the [vLLM](https://docs.vllm.ai/en/stable/) engine, using the following command:
99
+ ```
100
+ lm_eval \
101
+ --model vllm \
102
+ --model_args pretrained="neuralmagic/Meta-Llama-3-70B-Instruct-FP8",dtype=auto,gpu_memory_utilization=0.4,add_bos_token=True,max_model_len=4096 \
103
+ --tasks openllm \
104
+ --batch_size auto
105
+ ```
106
+
107
+ ### Accuracy
 
108
 
109
+ #### Open LLM Leaderboard evaluation scores
110
+ <table>
111
+ <tr>
112
+ <td><strong>Benchmark</strong>
113
+ </td>
114
+ <td><strong>Meta-Llama-3-70B-Instruct </strong>
115
+ </td>
116
+ <td><strong>Meta-Llama-3-70B-Instruct-FP8(this model)</strong>
117
+ </td>
118
+ <td><strong>Recovery</strong>
119
+ </td>
120
+ </tr>
121
+ <tr>
122
+ <td>MMLU (5-shot)
123
+ </td>
124
+ <td>80.18
125
+ </td>
126
+ <td>80.06
127
+ </td>
128
+ <td>99.85%
129
+ </td>
130
+ </tr>
131
+ <tr>
132
+ <td>ARC Challenge (25-shot)
133
+ </td>
134
+ <td>72.69
135
+ </td>
136
+ <td>72.61
137
+ </td>
138
+ <td>99.88%
139
+ </td>
140
+ </tr>
141
+ <tr>
142
+ <td>GSM-8K (5-shot, strict-match)
143
+ </td>
144
+ <td>92.49
145
+ </td>
146
+ <td>91.12
147
+ </td>
148
+ <td>98.51%
149
+ </td>
150
+ </tr>
151
+ <tr>
152
+ <td>Hellaswag (10-shot)
153
+ </td>
154
+ <td>85.50
155
+ </td>
156
+ <td>85.41
157
+ </td>
158
+ <td>99.89%
159
+ </td>
160
+ </tr>
161
+ <tr>
162
+ <td>Winogrande (5-shot)
163
+ </td>
164
+ <td>83.34
165
+ </td>
166
+ <td>83.03
167
+ </td>
168
+ <td>99.62%
169
+ </td>
170
+ </tr>
171
+ <tr>
172
+ <td>TruthfulQA (0-shot)
173
+ </td>
174
+ <td>62.90
175
+ </td>
176
+ <td>62.73
177
+ </td>
178
+ <td>99.72%
179
+ </td>
180
+ </tr>
181
+ <tr>
182
+ <td><strong>Average</strong>
183
+ </td>
184
+ <td><strong>79.51</strong>
185
+ </td>
186
+ <td><strong>79.16</strong>
187
+ </td>
188
+ <td><strong>99.55%</strong>
189
+ </td>
190
+ </tr>
191
+ </table>