RichardErkhov
commited on
Commit
•
24a8130
1
Parent(s):
3f40657
uploaded readme
Browse files
README.md
ADDED
@@ -0,0 +1,401 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Quantization made by Richard Erkhov.
|
2 |
+
|
3 |
+
[Github](https://github.com/RichardErkhov)
|
4 |
+
|
5 |
+
[Discord](https://discord.gg/pvy7H8DZMG)
|
6 |
+
|
7 |
+
[Request more models](https://github.com/RichardErkhov/quant_request)
|
8 |
+
|
9 |
+
|
10 |
+
neural-chat-7b-v3-3 - GGUF
|
11 |
+
- Model creator: https://huggingface.co/Intel/
|
12 |
+
- Original model: https://huggingface.co/Intel/neural-chat-7b-v3-3/
|
13 |
+
|
14 |
+
|
15 |
+
| Name | Quant method | Size |
|
16 |
+
| ---- | ---- | ---- |
|
17 |
+
| [neural-chat-7b-v3-3.Q2_K.gguf](https://huggingface.co/RichardErkhov/Intel_-_neural-chat-7b-v3-3-gguf/blob/main/neural-chat-7b-v3-3.Q2_K.gguf) | Q2_K | 2.53GB |
|
18 |
+
| [neural-chat-7b-v3-3.Q3_K_S.gguf](https://huggingface.co/RichardErkhov/Intel_-_neural-chat-7b-v3-3-gguf/blob/main/neural-chat-7b-v3-3.Q3_K_S.gguf) | Q3_K_S | 2.95GB |
|
19 |
+
| [neural-chat-7b-v3-3.Q3_K.gguf](https://huggingface.co/RichardErkhov/Intel_-_neural-chat-7b-v3-3-gguf/blob/main/neural-chat-7b-v3-3.Q3_K.gguf) | Q3_K | 3.28GB |
|
20 |
+
| [neural-chat-7b-v3-3.Q3_K_M.gguf](https://huggingface.co/RichardErkhov/Intel_-_neural-chat-7b-v3-3-gguf/blob/main/neural-chat-7b-v3-3.Q3_K_M.gguf) | Q3_K_M | 3.28GB |
|
21 |
+
| [neural-chat-7b-v3-3.Q3_K_L.gguf](https://huggingface.co/RichardErkhov/Intel_-_neural-chat-7b-v3-3-gguf/blob/main/neural-chat-7b-v3-3.Q3_K_L.gguf) | Q3_K_L | 3.56GB |
|
22 |
+
| [neural-chat-7b-v3-3.IQ4_XS.gguf](https://huggingface.co/RichardErkhov/Intel_-_neural-chat-7b-v3-3-gguf/blob/main/neural-chat-7b-v3-3.IQ4_XS.gguf) | IQ4_XS | 3.67GB |
|
23 |
+
| [neural-chat-7b-v3-3.Q4_0.gguf](https://huggingface.co/RichardErkhov/Intel_-_neural-chat-7b-v3-3-gguf/blob/main/neural-chat-7b-v3-3.Q4_0.gguf) | Q4_0 | 3.83GB |
|
24 |
+
| [neural-chat-7b-v3-3.IQ4_NL.gguf](https://huggingface.co/RichardErkhov/Intel_-_neural-chat-7b-v3-3-gguf/blob/main/neural-chat-7b-v3-3.IQ4_NL.gguf) | IQ4_NL | 3.87GB |
|
25 |
+
| [neural-chat-7b-v3-3.Q4_K_S.gguf](https://huggingface.co/RichardErkhov/Intel_-_neural-chat-7b-v3-3-gguf/blob/main/neural-chat-7b-v3-3.Q4_K_S.gguf) | Q4_K_S | 3.86GB |
|
26 |
+
| [neural-chat-7b-v3-3.Q4_K.gguf](https://huggingface.co/RichardErkhov/Intel_-_neural-chat-7b-v3-3-gguf/blob/main/neural-chat-7b-v3-3.Q4_K.gguf) | Q4_K | 4.07GB |
|
27 |
+
| [neural-chat-7b-v3-3.Q4_K_M.gguf](https://huggingface.co/RichardErkhov/Intel_-_neural-chat-7b-v3-3-gguf/blob/main/neural-chat-7b-v3-3.Q4_K_M.gguf) | Q4_K_M | 4.07GB |
|
28 |
+
| [neural-chat-7b-v3-3.Q4_1.gguf](https://huggingface.co/RichardErkhov/Intel_-_neural-chat-7b-v3-3-gguf/blob/main/neural-chat-7b-v3-3.Q4_1.gguf) | Q4_1 | 4.24GB |
|
29 |
+
| [neural-chat-7b-v3-3.Q5_0.gguf](https://huggingface.co/RichardErkhov/Intel_-_neural-chat-7b-v3-3-gguf/blob/main/neural-chat-7b-v3-3.Q5_0.gguf) | Q5_0 | 4.65GB |
|
30 |
+
| [neural-chat-7b-v3-3.Q5_K_S.gguf](https://huggingface.co/RichardErkhov/Intel_-_neural-chat-7b-v3-3-gguf/blob/main/neural-chat-7b-v3-3.Q5_K_S.gguf) | Q5_K_S | 4.65GB |
|
31 |
+
| [neural-chat-7b-v3-3.Q5_K.gguf](https://huggingface.co/RichardErkhov/Intel_-_neural-chat-7b-v3-3-gguf/blob/main/neural-chat-7b-v3-3.Q5_K.gguf) | Q5_K | 4.78GB |
|
32 |
+
| [neural-chat-7b-v3-3.Q5_K_M.gguf](https://huggingface.co/RichardErkhov/Intel_-_neural-chat-7b-v3-3-gguf/blob/main/neural-chat-7b-v3-3.Q5_K_M.gguf) | Q5_K_M | 4.78GB |
|
33 |
+
| [neural-chat-7b-v3-3.Q5_1.gguf](https://huggingface.co/RichardErkhov/Intel_-_neural-chat-7b-v3-3-gguf/blob/main/neural-chat-7b-v3-3.Q5_1.gguf) | Q5_1 | 5.07GB |
|
34 |
+
| [neural-chat-7b-v3-3.Q6_K.gguf](https://huggingface.co/RichardErkhov/Intel_-_neural-chat-7b-v3-3-gguf/blob/main/neural-chat-7b-v3-3.Q6_K.gguf) | Q6_K | 5.53GB |
|
35 |
+
| [neural-chat-7b-v3-3.Q8_0.gguf](https://huggingface.co/RichardErkhov/Intel_-_neural-chat-7b-v3-3-gguf/blob/main/neural-chat-7b-v3-3.Q8_0.gguf) | Q8_0 | 7.17GB |
|
36 |
+
|
37 |
+
|
38 |
+
|
39 |
+
|
40 |
+
Original model description:
|
41 |
+
---
|
42 |
+
license: apache-2.0
|
43 |
+
tags:
|
44 |
+
- LLMs
|
45 |
+
- mistral
|
46 |
+
- math
|
47 |
+
- Intel
|
48 |
+
base_model: Intel/neural-chat-7b-v3-1
|
49 |
+
model-index:
|
50 |
+
- name: neural-chat-7b-v3-3
|
51 |
+
results:
|
52 |
+
- task:
|
53 |
+
type: Large Language Model
|
54 |
+
name: Large Language Model
|
55 |
+
dataset:
|
56 |
+
name: meta-math/MetaMathQA
|
57 |
+
type: meta-math/MetaMathQA
|
58 |
+
metrics:
|
59 |
+
- type: ARC (25-shot)
|
60 |
+
value: 66.89
|
61 |
+
name: ARC (25-shot)
|
62 |
+
verified: true
|
63 |
+
- type: HellaSwag (10-shot)
|
64 |
+
value: 85.26
|
65 |
+
name: HellaSwag (10-shot)
|
66 |
+
verified: true
|
67 |
+
- type: MMLU (5-shot)
|
68 |
+
value: 63.07
|
69 |
+
name: MMLU (5-shot)
|
70 |
+
verified: true
|
71 |
+
- type: TruthfulQA (0-shot)
|
72 |
+
value: 63.01
|
73 |
+
name: TruthfulQA (0-shot)
|
74 |
+
verified: true
|
75 |
+
- type: Winogrande (5-shot)
|
76 |
+
value: 79.64
|
77 |
+
name: Winogrande (5-shot)
|
78 |
+
verified: true
|
79 |
+
- type: GSM8K (5-shot)
|
80 |
+
value: 61.11
|
81 |
+
name: GSM8K (5-shot)
|
82 |
+
verified: true
|
83 |
+
- task:
|
84 |
+
type: text-generation
|
85 |
+
name: Text Generation
|
86 |
+
dataset:
|
87 |
+
name: AI2 Reasoning Challenge (25-Shot)
|
88 |
+
type: ai2_arc
|
89 |
+
config: ARC-Challenge
|
90 |
+
split: test
|
91 |
+
args:
|
92 |
+
num_few_shot: 25
|
93 |
+
metrics:
|
94 |
+
- type: acc_norm
|
95 |
+
value: 66.89
|
96 |
+
name: normalized accuracy
|
97 |
+
source:
|
98 |
+
url: https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard?query=Intel/neural-chat-7b-v3-3
|
99 |
+
name: Open LLM Leaderboard
|
100 |
+
- task:
|
101 |
+
type: text-generation
|
102 |
+
name: Text Generation
|
103 |
+
dataset:
|
104 |
+
name: HellaSwag (10-Shot)
|
105 |
+
type: hellaswag
|
106 |
+
split: validation
|
107 |
+
args:
|
108 |
+
num_few_shot: 10
|
109 |
+
metrics:
|
110 |
+
- type: acc_norm
|
111 |
+
value: 85.26
|
112 |
+
name: normalized accuracy
|
113 |
+
source:
|
114 |
+
url: https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard?query=Intel/neural-chat-7b-v3-3
|
115 |
+
name: Open LLM Leaderboard
|
116 |
+
- task:
|
117 |
+
type: text-generation
|
118 |
+
name: Text Generation
|
119 |
+
dataset:
|
120 |
+
name: MMLU (5-Shot)
|
121 |
+
type: cais/mmlu
|
122 |
+
config: all
|
123 |
+
split: test
|
124 |
+
args:
|
125 |
+
num_few_shot: 5
|
126 |
+
metrics:
|
127 |
+
- type: acc
|
128 |
+
value: 63.07
|
129 |
+
name: accuracy
|
130 |
+
source:
|
131 |
+
url: https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard?query=Intel/neural-chat-7b-v3-3
|
132 |
+
name: Open LLM Leaderboard
|
133 |
+
- task:
|
134 |
+
type: text-generation
|
135 |
+
name: Text Generation
|
136 |
+
dataset:
|
137 |
+
name: TruthfulQA (0-shot)
|
138 |
+
type: truthful_qa
|
139 |
+
config: multiple_choice
|
140 |
+
split: validation
|
141 |
+
args:
|
142 |
+
num_few_shot: 0
|
143 |
+
metrics:
|
144 |
+
- type: mc2
|
145 |
+
value: 63.01
|
146 |
+
source:
|
147 |
+
url: https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard?query=Intel/neural-chat-7b-v3-3
|
148 |
+
name: Open LLM Leaderboard
|
149 |
+
- task:
|
150 |
+
type: text-generation
|
151 |
+
name: Text Generation
|
152 |
+
dataset:
|
153 |
+
name: Winogrande (5-shot)
|
154 |
+
type: winogrande
|
155 |
+
config: winogrande_xl
|
156 |
+
split: validation
|
157 |
+
args:
|
158 |
+
num_few_shot: 5
|
159 |
+
metrics:
|
160 |
+
- type: acc
|
161 |
+
value: 79.64
|
162 |
+
name: accuracy
|
163 |
+
source:
|
164 |
+
url: https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard?query=Intel/neural-chat-7b-v3-3
|
165 |
+
name: Open LLM Leaderboard
|
166 |
+
- task:
|
167 |
+
type: text-generation
|
168 |
+
name: Text Generation
|
169 |
+
dataset:
|
170 |
+
name: GSM8k (5-shot)
|
171 |
+
type: gsm8k
|
172 |
+
config: main
|
173 |
+
split: test
|
174 |
+
args:
|
175 |
+
num_few_shot: 5
|
176 |
+
metrics:
|
177 |
+
- type: acc
|
178 |
+
value: 61.11
|
179 |
+
name: accuracy
|
180 |
+
source:
|
181 |
+
url: https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard?query=Intel/neural-chat-7b-v3-3
|
182 |
+
name: Open LLM Leaderboard
|
183 |
+
---
|
184 |
+
|
185 |
+
## Model Details: Neural-Chat-v3-3
|
186 |
+
|
187 |
+
This model is a fine-tuned 7B parameter LLM on the Intel Gaudi 2 processor from the [Intel/neural-chat-7b-v3-1](https://huggingface.co/Intel/neural-chat-7b-v3-1) on the [meta-math/MetaMathQA](https://huggingface.co/datasets/meta-math/MetaMathQA) dataset. The model was aligned using the Direct Performance Optimization (DPO) method with [Intel/orca_dpo_pairs](https://huggingface.co/datasets/Intel/orca_dpo_pairs). The [Intel/neural-chat-7b-v3-1](https://huggingface.co/Intel/neural-chat-7b-v3-1) was originally fine-tuned from [mistralai/Mistral-7B-v-0.1](https://huggingface.co/mistralai/Mistral-7B-v0.1). For more information, refer to the blog [The Practice of Supervised Fine-tuning and Direct Preference Optimization on Intel Gaudi2](https://medium.com/@NeuralCompressor/the-practice-of-supervised-finetuning-and-direct-preference-optimization-on-habana-gaudi2-a1197d8a3cd3).
|
188 |
+
|
189 |
+
<p align="center">
|
190 |
+
<img src="https://cdn-uploads.huggingface.co/production/uploads/6297f0e30bd2f58c647abb1d/ctASHUT5QYIxMsOFa-sHC.webp" width="500"/>
|
191 |
+
Photo by Google DeepMind on Unsplash
|
192 |
+
</p>
|
193 |
+
|
194 |
+
| Model Detail | Description |
|
195 |
+
| ----------- | ----------- |
|
196 |
+
| Model Authors - Company | Intel. The NeuralChat team with members from DCAI/AISE/AIPT. Core team members: Kaokao Lv, Liang Lv, Chang Wang, Wenxin Zhang, Xuhui Ren, and Haihao Shen.|
|
197 |
+
| Date | December, 2023 |
|
198 |
+
| Version | v3-3 |
|
199 |
+
| Type | 7B Large Language Model |
|
200 |
+
| Paper or Other Resources | [Medium Blog](https://medium.com/@NeuralCompressor/the-practice-of-supervised-finetuning-and-direct-preference-optimization-on-habana-gaudi2-a1197d8a3cd3) |
|
201 |
+
| License | Apache 2.0 |
|
202 |
+
| Questions or Comments | [Community Tab](https://huggingface.co/Intel/neural-chat-7b-v3-3/discussions) and [Intel Developers Discord](https://discord.gg/rv2Gp55UJQ)|
|
203 |
+
|
204 |
+
| Intended Use | Description |
|
205 |
+
| ----------- | ----------- |
|
206 |
+
| Primary intended uses | You can use the fine-tuned model for several language-related tasks. Checkout the [LLM Leaderboard](https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard) to see how this model is doing. |
|
207 |
+
| Primary intended users | Anyone doing inference on language-related tasks. |
|
208 |
+
| Out-of-scope uses | This model in most cases will need to be fine-tuned for your particular task. The model should not be used to intentionally create hostile or alienating environments for people.|
|
209 |
+
|
210 |
+
## How To Use
|
211 |
+
|
212 |
+
Context length for this model: 8192 tokens (same as https://huggingface.co/mistralai/Mistral-7B-v0.1)
|
213 |
+
|
214 |
+
### Reproduce the model
|
215 |
+
Here is the sample code to reproduce the model: [GitHub sample code](https://github.com/intel/intel-extension-for-transformers/blob/main/intel_extension_for_transformers/neural_chat/examples/finetuning/finetune_neuralchat_v3). Here is the documentation to reproduce building the model:
|
216 |
+
|
217 |
+
```bash
|
218 |
+
git clone https://github.com/intel/intel-extension-for-transformers.git
|
219 |
+
cd intel-extension-for-transformers
|
220 |
+
|
221 |
+
docker build --no-cache ./ --target hpu --build-arg REPO=https://github.com/intel/intel-extension-for-transformers.git --build-arg ITREX_VER=main -f ./intel_extension_for_transformers/neural_chat/docker/Dockerfile -t chatbot_finetuning:latest
|
222 |
+
|
223 |
+
docker run -it --runtime=habana -e HABANA_VISIBLE_DEVICES=all -e OMPI_MCA_btl_vader_single_copy_mechanism=none --cap-add=sys_nice --net=host --ipc=host chatbot_finetuning:latest
|
224 |
+
|
225 |
+
# after entering docker container
|
226 |
+
cd examples/finetuning/finetune_neuralchat_v3
|
227 |
+
|
228 |
+
```
|
229 |
+
We select the latest pretrained mistralai/Mistral-7B-v0.1 and the open source dataset Open-Orca/SlimOrca to conduct the experiment.
|
230 |
+
|
231 |
+
The below script use deepspeed zero2 to lanuch the training with 8 cards Gaudi2. In the `finetune_neuralchat_v3.py`, the default `use_habana=True, use_lazy_mode=True, device="hpu"` for Gaudi2. And if you want to run it on NVIDIA GPU, you can set them `use_habana=False, use_lazy_mode=False, device="auto"`.
|
232 |
+
|
233 |
+
```python
|
234 |
+
deepspeed --include localhost:0,1,2,3,4,5,6,7 \
|
235 |
+
--master_port 29501 \
|
236 |
+
finetune_neuralchat_v3.py
|
237 |
+
```
|
238 |
+
|
239 |
+
Merge the LoRA weights:
|
240 |
+
|
241 |
+
```python
|
242 |
+
python apply_lora.py \
|
243 |
+
--base-model-path mistralai/Mistral-7B-v0.1 \
|
244 |
+
--lora-model-path finetuned_model/ \
|
245 |
+
--output-path finetuned_model_lora
|
246 |
+
```
|
247 |
+
|
248 |
+
### Use the model
|
249 |
+
|
250 |
+
### FP32 Inference with Transformers
|
251 |
+
|
252 |
+
```python
|
253 |
+
import transformers
|
254 |
+
|
255 |
+
|
256 |
+
model_name = 'Intel/neural-chat-7b-v3-3'
|
257 |
+
model = transformers.AutoModelForCausalLM.from_pretrained(model_name)
|
258 |
+
tokenizer = transformers.AutoTokenizer.from_pretrained(model_name)
|
259 |
+
|
260 |
+
def generate_response(system_input, user_input):
|
261 |
+
|
262 |
+
# Format the input using the provided template
|
263 |
+
prompt = f"### System:\n{system_input}\n### User:\n{user_input}\n### Assistant:\n"
|
264 |
+
|
265 |
+
# Tokenize and encode the prompt
|
266 |
+
inputs = tokenizer.encode(prompt, return_tensors="pt", add_special_tokens=False)
|
267 |
+
|
268 |
+
# Generate a response
|
269 |
+
outputs = model.generate(inputs, max_length=1000, num_return_sequences=1)
|
270 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
271 |
+
|
272 |
+
# Extract only the assistant's response
|
273 |
+
return response.split("### Assistant:\n")[-1]
|
274 |
+
|
275 |
+
|
276 |
+
# Example usage
|
277 |
+
system_input = "You are a math expert assistant. Your mission is to help users understand and solve various math problems. You should provide step-by-step solutions, explain reasonings and give the correct answer."
|
278 |
+
user_input = "calculate 100 + 520 + 60"
|
279 |
+
response = generate_response(system_input, user_input)
|
280 |
+
print(response)
|
281 |
+
|
282 |
+
# expected response
|
283 |
+
"""
|
284 |
+
To calculate the sum of 100, 520, and 60, we will follow these steps:
|
285 |
+
|
286 |
+
1. Add the first two numbers: 100 + 520
|
287 |
+
2. Add the result from step 1 to the third number: (100 + 520) + 60
|
288 |
+
|
289 |
+
Step 1: Add 100 and 520
|
290 |
+
100 + 520 = 620
|
291 |
+
|
292 |
+
Step 2: Add the result from step 1 to the third number (60)
|
293 |
+
(620) + 60 = 680
|
294 |
+
|
295 |
+
So, the sum of 100, 520, and 60 is 680.
|
296 |
+
"""
|
297 |
+
```
|
298 |
+
|
299 |
+
### BF16 Inference with Intel Extension for Transformers and Intel Extension for Pytorch
|
300 |
+
```python
|
301 |
+
from transformers import AutoTokenizer, TextStreamer
|
302 |
+
import torch
|
303 |
+
from intel_extension_for_transformers.transformers import AutoModelForCausalLM
|
304 |
+
import intel_extension_for_pytorch as ipex
|
305 |
+
|
306 |
+
model_name = "Intel/neural-chat-7b-v3-3"
|
307 |
+
prompt = "Once upon a time, there existed a little girl,"
|
308 |
+
|
309 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
|
310 |
+
inputs = tokenizer(prompt, return_tensors="pt").input_ids
|
311 |
+
streamer = TextStreamer(tokenizer)
|
312 |
+
|
313 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16)
|
314 |
+
model = ipex.optimize(model.eval(), dtype=torch.bfloat16, inplace=True, level="O1", auto_kernel_selection=True)
|
315 |
+
|
316 |
+
outputs = model.generate(inputs, streamer=streamer, max_new_tokens=300)
|
317 |
+
```
|
318 |
+
|
319 |
+
### INT4 Inference with Transformers and Intel Extension for Transformers
|
320 |
+
```python
|
321 |
+
from transformers import AutoTokenizer, TextStreamer
|
322 |
+
from intel_extension_for_transformers.transformers import AutoModelForCausalLM, WeightOnlyQuantConfig
|
323 |
+
model_name = "Intel/neural-chat-7b-v3-3"
|
324 |
+
|
325 |
+
# for int8, should set weight_dtype="int8"
|
326 |
+
config = WeightOnlyQuantConfig(compute_dtype="bf16", weight_dtype="int4")
|
327 |
+
prompt = "Once upon a time, there existed a little girl,"
|
328 |
+
|
329 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
|
330 |
+
inputs = tokenizer(prompt, return_tensors="pt").input_ids
|
331 |
+
streamer = TextStreamer(tokenizer)
|
332 |
+
|
333 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, quantization_config=config)
|
334 |
+
outputs = model.generate(inputs, streamer=streamer, max_new_tokens=300)
|
335 |
+
|
336 |
+
```
|
337 |
+
|
338 |
+
|
339 |
+
| Factors | Description |
|
340 |
+
| ----------- | ----------- |
|
341 |
+
| Groups | More details about the dataset and annotations can be found at [meta-math/MetaMathQA](https://huggingface.co/datasets/meta-math/MetaMathQA), the project page https://meta-math.github.io/, and the associated paper at https://arxiv.org/abs/2309.12284. |
|
342 |
+
| Instrumentation | The performance of the model can vary depending on the inputs to the model. In this case, the prompts provided can drastically change the prediction of the language model. |
|
343 |
+
| Environment | The model was trained on the Intel Gaudi 2 processor (8 cards). |
|
344 |
+
| Card Prompts | Model deployment on alternate hardware and software will change model performance. The model evaluation factors are from the Hugging Face LLM leaderboard: ARC, HellaSwag, MMLU, TruthfulQA, Winogrande, and GSM8K (see Quantitative Analyses below). |
|
345 |
+
|
346 |
+
| Metrics | Description |
|
347 |
+
| ----------- | ----------- |
|
348 |
+
| Model performance measures | The model performance was evaluated against other LLMs according to the measures on the LLM leaderboard. These were selected as this has become the standard for LLM performance. |
|
349 |
+
| Decision thresholds | No decision thresholds were used. |
|
350 |
+
| Approaches to uncertainty and variability | - |
|
351 |
+
|
352 |
+
| Training and Evaluation Data | Description |
|
353 |
+
| ----------- | ----------- |
|
354 |
+
| Datasets | The training data are from [meta-math/MetaMathQA](https://huggingface.co/datasets/meta-math/MetaMathQA), which is augmented from the GSM8k and MATH training sets. There is no contamination from the GSM8k test set, as this was left out during training.|
|
355 |
+
| Motivation | - |
|
356 |
+
| Preprocessing | - |
|
357 |
+
|
358 |
+
## Quantitative Analyses
|
359 |
+
The Open LLM Leaderboard results can be found here: [https://huggingface.co/datasets/open-llm-leaderboard/details_Intel__neural-chat-7b-v3-3](https://huggingface.co/datasets/open-llm-leaderboard/details_Intel__neural-chat-7b-v3-3). The metrics came out to:
|
360 |
+
|
361 |
+
| Metric | Value |
|
362 |
+
|-----------------------|---------------------------|
|
363 |
+
| Avg. | 69.83 |
|
364 |
+
| ARC (25-shot) | 66.89 |
|
365 |
+
| HellaSwag (10-shot) | 85.26 |
|
366 |
+
| MMLU (5-shot) | 63.07 |
|
367 |
+
| TruthfulQA (0-shot) | 63.01 |
|
368 |
+
| Winogrande (5-shot) | 79.64 |
|
369 |
+
| GSM8K (5-shot) | 61.11 |
|
370 |
+
|
371 |
+
## Ethical Considerations and Limitations
|
372 |
+
Neural-chat-7b-v3-3 can produce factually incorrect output, and should not be relied on to produce factually accurate information. Because of the limitations of the pretrained model and the finetuning datasets, it is possible that this model could generate lewd, biased or otherwise offensive outputs.
|
373 |
+
|
374 |
+
Therefore, before deploying any applications of neural-chat-7b-v3-3, developers should perform safety testing.
|
375 |
+
|
376 |
+
## Caveats and Recommendations
|
377 |
+
|
378 |
+
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
|
379 |
+
|
380 |
+
Here are a couple of useful links to learn more about Intel's AI software:
|
381 |
+
* Intel Neural Compressor [link](https://github.com/intel/neural-compressor)
|
382 |
+
* Intel Extension for Transformers [link](https://github.com/intel/intel-extension-for-transformers)
|
383 |
+
|
384 |
+
## Disclaimer
|
385 |
+
|
386 |
+
The license on this model does not constitute legal advice. We are not responsible for the actions of third parties who use this model. Please cosult an attorney before using this model for commercial purposes.
|
387 |
+
# [Open LLM Leaderboard Evaluation Results](https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard)
|
388 |
+
Detailed results can be found [here](https://huggingface.co/datasets/open-llm-leaderboard/details_Intel__neural-chat-7b-v3-3)
|
389 |
+
|
390 |
+
| Metric |Value|
|
391 |
+
|---------------------------------|----:|
|
392 |
+
|Avg. |69.83|
|
393 |
+
|AI2 Reasoning Challenge (25-Shot)|66.89|
|
394 |
+
|HellaSwag (10-Shot) |85.26|
|
395 |
+
|MMLU (5-Shot) |63.07|
|
396 |
+
|TruthfulQA (0-shot) |63.01|
|
397 |
+
|Winogrande (5-shot) |79.64|
|
398 |
+
|GSM8k (5-shot) |61.11|
|
399 |
+
|
400 |
+
|
401 |
+
|