nm-research commited on
Commit
36b167c
·
verified ·
1 Parent(s): 7429386

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +177 -0
README.md ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ license_link: https://huggingface.co/microsoft/phi-4/resolve/main/LICENSE
4
+ language:
5
+ - en
6
+ pipeline_tag: text-generation
7
+ base_model: microsoft/phi-4
8
+ tags:
9
+ - phi
10
+ - nlp
11
+ - math
12
+ - code
13
+ - chat
14
+ - conversational
15
+ - neuralmagic
16
+ - redhat
17
+ - llmcompressor
18
+ - quantized
19
+ - int4
20
+ ---
21
+
22
+ # phi-4-quantized.w4a16
23
+
24
+ ## Model Overview
25
+ - **Model Architecture:** Phi3ForCausalLM
26
+ - **Input:** Text
27
+ - **Output:** Text
28
+ - **Model Optimizations:**
29
+ - **Weight quantization:** INT4
30
+ - **Intended Use Cases:** This model is designed to accelerate research on language models, for use as a building block for generative AI powered features. It provides uses for general purpose AI systems and applications (primarily in English) which require:
31
+ 1. Memory/compute constrained environments.
32
+ 2. Latency bound scenarios.
33
+ 3. Reasoning and logic.
34
+ - **Out-of-scope:** This model is not specifically designed or evaluated for all downstream purposes, thus:
35
+ 1. Developers should consider common limitations of language models as they select use cases, and evaluate and mitigate for accuracy, safety, and fairness before using within a specific downstream use case, particularly for high-risk scenarios.
36
+ 2. Developers should be aware of and adhere to applicable laws or regulations (including privacy, trade compliance laws, etc.) that are relevant to their use case, including the model’s focus on English.
37
+ 3. Nothing contained in this Model Card should be interpreted as or deemed a restriction or modification to the license the model is released under.
38
+ - **Release Date:** 03/03/2025
39
+ - **Version:** 1.0
40
+ - **Model Developers:** RedHat (Neural Magic)
41
+
42
+
43
+ ### Model Optimizations
44
+
45
+ This model was obtained by quantizing the weights of [phi-4]https://huggingface.co/microsoft/phi-4) to INT4 data type.
46
+ This optimization reduces the number of bits per parameter from 16 to 4, reducing the disk size and GPU memory requirements by approximately 75%.
47
+
48
+ Only the weights of the linear operators within transformers blocks are quantized.
49
+ Weights are quantized using a symmetric per-group scheme, with group size 128.
50
+ The [GPTQ](https://arxiv.org/abs/2210.17323) algorithm is applied for quantization, as implemented in the [llm-compressor](https://github.com/vllm-project/llm-compressor) library.
51
+
52
+
53
+ ## Deployment
54
+
55
+ This model can be deployed efficiently using the [vLLM](https://docs.vllm.ai/en/latest/) backend, as shown in the example below.
56
+
57
+ ```python
58
+ from vllm import LLM, SamplingParams
59
+ from transformers import AutoTokenizer
60
+
61
+ model_id = "neuralmagic-ent/phi-4-quantized.w4a16"
62
+ number_gpus = 1
63
+
64
+ sampling_params = SamplingParams(temperature=0.7, top_p=0.8, max_tokens=256)
65
+
66
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
67
+
68
+ prompt = "Give me a short introduction to large language model."
69
+
70
+ llm = LLM(model=model_id, tensor_parallel_size=number_gpus)
71
+
72
+ outputs = llm.generate(prompt, sampling_params)
73
+
74
+ generated_text = outputs[0].outputs[0].text
75
+ print(generated_text)
76
+ ```
77
+
78
+ vLLM aslo supports OpenAI-compatible serving. See the [documentation](https://docs.vllm.ai/en/latest/) for more details.
79
+
80
+
81
+ ## Evaluation
82
+
83
+ The model was evaluated on the OpenLLM leaderboard tasks (version 1) with the [lm-evaluation-harness](https://github.com/EleutherAI/lm-evaluation-harness) and the [vLLM](https://docs.vllm.ai/en/stable/) engine, using the following command:
84
+ ```
85
+ lm_eval \
86
+ --model vllm \
87
+ --model_args pretrained="neuralmagic-ent/phi-4-quantized.w4a16",dtype=auto,gpu_memory_utilization=0.6,max_model_len=4096,enable_chunk_prefill=True,tensor_parallel_size=1 \
88
+ --tasks openllm \
89
+ --batch_size auto
90
+ ```
91
+
92
+ ### Accuracy
93
+
94
+ #### Open LLM Leaderboard evaluation scores
95
+ <table>
96
+ <tr>
97
+ <td><strong>Benchmark</strong>
98
+ </td>
99
+ <td><strong>phi-4</strong>
100
+ </td>
101
+ <td><strong>phi-4-quantized.w4a16<br>(this model)</strong>
102
+ </td>
103
+ <td><strong>Recovery</strong>
104
+ </td>
105
+ </tr>
106
+ <tr>
107
+ <td>MMLU (5-shot)
108
+ </td>
109
+ <td>80.30
110
+ </td>
111
+ <td>79.87
112
+ </td>
113
+ <td>99.5%
114
+ </td>
115
+ </tr>
116
+ <tr>
117
+ <td>ARC Challenge (25-shot)
118
+ </td>
119
+ <td>64.42
120
+ </td>
121
+ <td>62.88
122
+ </td>
123
+ <td>97.6%
124
+ </td>
125
+ </tr>
126
+ <tr>
127
+ <td>GSM-8K (5-shot, strict-match)
128
+ </td>
129
+ <td>90.07
130
+ </td>
131
+ <td>89.69
132
+ </td>
133
+ <td>99.6%
134
+ </td>
135
+ </tr>
136
+ <tr>
137
+ <td>Hellaswag (10-shot)
138
+ </td>
139
+ <td>84.37
140
+ </td>
141
+ <td>83.42
142
+ </td>
143
+ <td>98.9%
144
+ </td>
145
+ </tr>
146
+ <tr>
147
+ <td>Winogrande (5-shot)
148
+ </td>
149
+ <td>80.58
150
+ </td>
151
+ <td>80.74
152
+ </td>
153
+ <td>100.2%
154
+ </td>
155
+ </tr>
156
+ <tr>
157
+ <td>TruthfulQA (0-shot, mc2)
158
+ </td>
159
+ <td>59.37
160
+ </td>
161
+ <td>59.18
162
+ </td>
163
+ <td>99.7%
164
+ </td>
165
+ </tr>
166
+ <tr>
167
+ <td><strong>Average</strong>
168
+ </td>
169
+ <td><strong>76.52</strong>
170
+ </td>
171
+ <td><strong>75.96</strong>
172
+ </td>
173
+ <td><strong>99.3%</strong>
174
+ </td>
175
+ </tr>
176
+ </table>
177
+