mav23 commited on
Commit
25363be
·
verified ·
1 Parent(s): 4b6e7c0

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. .gitattributes +1 -0
  2. README.md +268 -0
  3. neural-chat-7b-v3.Q4_0.gguf +3 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ neural-chat-7b-v3.Q4_0.gguf filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,268 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ tags:
4
+ - LLMs
5
+ - mistral
6
+ - Intel
7
+ pipeline_tag: text-generation
8
+ base_model: mistralai/Mistral-7B-v0.1
9
+ model-index:
10
+ - name: neural-chat-7b-v3
11
+ results:
12
+ - task:
13
+ type: Large Language Model
14
+ name: Large Language Model
15
+ dataset:
16
+ type: Open-Orca/SlimOrca
17
+ name: Open-Orca/SlimOrca
18
+ metrics:
19
+ - type: ARC (25-shot)
20
+ value: 67.15
21
+ name: ARC (25-shot)
22
+ verified: true
23
+ - type: HellaSwag (10-shot)
24
+ value: 83.29
25
+ name: HellaSwag (10-shot)
26
+ verified: true
27
+ - type: MMLU (5-shot)
28
+ value: 62.26
29
+ name: MMLU (5-shot)
30
+ verified: true
31
+ - type: TruthfulQA (0-shot)
32
+ value: 58.77
33
+ name: TruthfulQA (0-shot)
34
+ verified: true
35
+ - type: Winogrande (5-shot)
36
+ value: 78.06
37
+ name: Winogrande (5-shot)
38
+ verified: true
39
+ - type: GSM8K (5-shot)
40
+ value: 1.21
41
+ name: GSM8K (5-shot)
42
+ verified: true
43
+ - type: DROP (3-shot)
44
+ value: 50.43
45
+ name: DROP (3-shot)
46
+ verified: true
47
+ datasets:
48
+ - Open-Orca/SlimOrca
49
+ language:
50
+ - en
51
+ ---
52
+
53
+ ## Model Details: Neural-Chat-v3
54
+
55
+ This model is a fine-tuned 7B parameter LLM on the Intel Gaudi 2 processor from the [mistralai/Mistral-7B-v0.1](https://huggingface.co/mistralai/Mistral-7B-v0.1) on the open source dataset [Open-Orca/SlimOrca](https://huggingface.co/datasets/Open-Orca/SlimOrca). The model was aligned using the Direct Performance Optimization (DPO) method with [Intel/orca_dpo_pairs](https://huggingface.co/datasets/Intel/orca_dpo_pairs). For more information, refer to the Medium article [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).
56
+
57
+ <p align="center">
58
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/6297f0e30bd2f58c647abb1d/ctASHUT5QYIxMsOFa-sHC.webp" width="500"/>
59
+ Photo by Google DeepMind on Unsplash
60
+ </p>
61
+
62
+ | Model Detail | Description |
63
+ | ----------- | ----------- |
64
+ | 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.|
65
+ | Date | October, 2023 |
66
+ | Version | v3 |
67
+ | Type | 7B Large Language Model |
68
+ | Paper or Other Resources | [Medium Blog](https://medium.com/@NeuralCompressor/the-practice-of-supervised-finetuning-and-direct-preference-optimization-on-habana-gaudi2-a1197d8a3cd3) |
69
+ | License | Apache 2.0 |
70
+ | Questions or Comments | [Community Tab](https://huggingface.co/Intel/neural-chat-7b-v3/discussions) and [Intel DevHub Discord](https://discord.gg/rv2Gp55UJQ)|
71
+
72
+ | Intended Use | Description |
73
+ | ----------- | ----------- |
74
+ | 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. |
75
+ | Primary intended users | Anyone doing inference on language-related tasks. |
76
+ | 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.|
77
+
78
+ ## How To Use
79
+
80
+ Context length for this model: 8192 tokens (same as [mistralai/Mistral-7B-v0.1](https://huggingface.co/mistralai/Mistral-7B-v0.1))
81
+
82
+ ### Training hyperparameters
83
+
84
+ The following hyperparameters were used during training:
85
+ - learning_rate: 1e-04
86
+ - train_batch_size: 1
87
+ - eval_batch_size: 2
88
+ - seed: 42
89
+ - distributed_type: multi-HPU
90
+ - num_devices: 8
91
+ - gradient_accumulation_steps: 8
92
+ - total_train_batch_size: 64
93
+ - total_eval_batch_size:
94
+ - optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
95
+ - lr_scheduler_type: cosine
96
+ - lr_scheduler_warmup_ratio: 0.03
97
+ - num_epochs: 2.0
98
+
99
+ ### Reproduce the model
100
+ 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:
101
+
102
+ ```bash
103
+ git clone https://github.com/intel/intel-extension-for-transformers.git
104
+ cd intel-extension-for-transformers
105
+
106
+ 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
107
+
108
+ 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
109
+
110
+ # after entering docker container
111
+ cd examples/finetuning/finetune_neuralchat_v3
112
+
113
+ ```
114
+ We select the latest pretrained mistralai/Mistral-7B-v0.1 and the open source dataset Open-Orca/SlimOrca to conduct the experiment.
115
+
116
+ 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"`.
117
+
118
+ ```python
119
+ deepspeed --include localhost:0,1,2,3,4,5,6,7 \
120
+ --master_port 29501 \
121
+ finetune_neuralchat_v3.py
122
+ ```
123
+
124
+ Merge the LoRA weights:
125
+
126
+ ```python
127
+ python apply_lora.py \
128
+ --base-model-path mistralai/Mistral-7B-v0.1 \
129
+ --lora-model-path finetuned_model/ \
130
+ --output-path finetuned_model_lora
131
+ ```
132
+
133
+ You can then align the model following the steps in the [GitHub sample code](https://github.com/intel/intel-extension-for-transformers/blob/main/intel_extension_for_transformers/neural_chat/examples/finetuning/finetune_neuralchat_v3).
134
+
135
+ ### Use the model
136
+
137
+ ### FP32 Inference with Transformers
138
+
139
+ ```python
140
+ import transformers
141
+
142
+
143
+ model_name = 'Intel/neural-chat-7b-v3'
144
+ model = transformers.AutoModelForCausalLM.from_pretrained(model_name)
145
+ tokenizer = transformers.AutoTokenizer.from_pretrained(model_name)
146
+
147
+ def generate_response(system_input, user_input):
148
+
149
+ # Format the input using the provided template
150
+ prompt = f"### System:\n{system_input}\n### User:\n{user_input}\n### Assistant:\n"
151
+
152
+ # Tokenize and encode the prompt
153
+ inputs = tokenizer.encode(prompt, return_tensors="pt", add_special_tokens=False)
154
+
155
+ # Generate a response
156
+ outputs = model.generate(inputs, max_length=1000, num_return_sequences=1)
157
+ response = tokenizer.decode(outputs[0], skip_special_tokens=True)
158
+
159
+ # Extract only the assistant's response
160
+ return response.split("### Assistant:\n")[-1]
161
+
162
+
163
+ # Example usage
164
+ 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."
165
+ user_input = "calculate 100 + 520 + 60"
166
+ response = generate_response(system_input, user_input)
167
+ print(response)
168
+
169
+ # expected response
170
+ """
171
+ To calculate the sum of 100, 520, and 60, we will follow these steps:
172
+
173
+ 1. Add the first two numbers: 100 + 520
174
+ 2. Add the result from step 1 to the third number: (100 + 520) + 60
175
+
176
+ Step 1: Add 100 and 520
177
+ 100 + 520 = 620
178
+
179
+ Step 2: Add the result from step 1 to the third number (60)
180
+ (620) + 60 = 680
181
+
182
+ So, the sum of 100, 520, and 60 is 680.
183
+ """
184
+ ```
185
+
186
+ ### BF16 Inference with Intel Extension for Transformers and Intel Extension for Pytorch
187
+ ```python
188
+ from transformers import AutoTokenizer, TextStreamer
189
+ import torch
190
+ from intel_extension_for_transformers.transformers import AutoModelForCausalLM
191
+ import intel_extension_for_pytorch as ipex
192
+
193
+ model_name = "Intel/neural-chat-7b-v3"
194
+ prompt = "Once upon a time, there existed a little girl,"
195
+
196
+ tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
197
+ inputs = tokenizer(prompt, return_tensors="pt").input_ids
198
+ streamer = TextStreamer(tokenizer)
199
+
200
+ model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16)
201
+ model = ipex.optimize(model.eval(), dtype=torch.bfloat16, inplace=True, level="O1", auto_kernel_selection=True)
202
+
203
+ outputs = model.generate(inputs, streamer=streamer, max_new_tokens=300)
204
+ ```
205
+
206
+
207
+ ### INT4 Inference with Transformers and Intel Extension for Transformers
208
+ ```python
209
+ from transformers import AutoTokenizer, TextStreamer
210
+ from intel_extension_for_transformers.transformers import AutoModelForCausalLM, WeightOnlyQuantConfig
211
+ model_name = "Intel/neural-chat-7b-v3"
212
+
213
+ # for int8, should set weight_dtype="int8"
214
+ config = WeightOnlyQuantConfig(compute_dtype="bf16", weight_dtype="int4")
215
+ prompt = "Once upon a time, there was a horse in the forest,"
216
+
217
+ tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
218
+ inputs = tokenizer(prompt, return_tensors="pt").input_ids
219
+ streamer = TextStreamer(tokenizer)
220
+
221
+ model = AutoModelForCausalLM.from_pretrained(model_name, quantization_config=config)
222
+ outputs = model.generate(inputs, streamer=streamer, max_new_tokens=300)
223
+
224
+ ```
225
+
226
+ | Factors | Description |
227
+ | ----------- | ----------- |
228
+ | Groups | More details about the dataset and annotations can be found at [Open-Orca/SlimOrca](https://huggingface.co/datasets/Open-Orca/SlimOrca) and the associated paper at https://arxiv.org/abs/2306.02707. |
229
+ | 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. |
230
+ | Environment | The model was trained on the Intel Gaudi 2 processor (8 cards). |
231
+ | 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, GSM8K, and DROP (see Quantitative Analyses below). |
232
+
233
+ | Metrics | Description |
234
+ | ----------- | ----------- |
235
+ | 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. |
236
+ | Decision thresholds | No decision thresholds were used. |
237
+ | Approaches to uncertainty and variability | - |
238
+
239
+ | Training and Evaluation Data | Description |
240
+ | ----------- | ----------- |
241
+ | Datasets | The training data are from [Open-Orca/SlimOrca](https://huggingface.co/datasets/Open-Orca/SlimOrca). There is no contamination from the GSM8k test set, as this is not a part of the Open-Orca/SlimOrca dataset.|
242
+ | Motivation | - |
243
+ | Preprocessing | - |
244
+
245
+ ## Quantitative Analyses
246
+ The model was submitted to the [LLM Leaderboard](https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard). The detailed submission can be found here: [https://huggingface.co/datasets/open-llm-leaderboard/details_Intel__neural-chat-7b-v3](https://huggingface.co/datasets/open-llm-leaderboard/details_Intel__neural-chat-7b-v3). The metrics can be found below and show that the model has significantly improved performance from Mistral-7B-v0.1.
247
+
248
+ | Model | Average ⬆️| ARC (25-s) ⬆️ | HellaSwag (10-s) ⬆️ | MMLU (5-s) ⬆️| TruthfulQA (MC) (0-s) ⬆️ | Winogrande (5-s) | GSM8K (5-s) | DROP (3-s) |
249
+ | --- | --- | --- | --- | --- | --- | --- | --- | --- |
250
+ |[mistralai/Mistral-7B-v0.1](https://huggingface.co/mistralai/Mistral-7B-v0.1) | 50.32 | 59.58 | 83.31 | 64.16 | 42.15 | 78.37 | 18.12 | 6.14 |
251
+ | [Intel/neural-chat-7b-v3](https://huggingface.co/Intel/neural-chat-7b-v3) | **57.31** | 67.15 | 83.29 | 62.26 | 58.77 | 78.06 | 1.21 | 50.43 |
252
+
253
+ ## Ethical Considerations and Limitations
254
+ Neural-chat-7b-v3 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.
255
+
256
+ Therefore, before deploying any applications of the model, developers should perform safety testing.
257
+
258
+ ## Caveats and Recommendations
259
+
260
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
261
+
262
+ Here are a couple of useful links to learn more about Intel's AI software:
263
+ * Intel Neural Compressor [link](https://github.com/intel/neural-compressor)
264
+ * Intel Extension for Transformers [link](https://github.com/intel/intel-extension-for-transformers)
265
+
266
+ ## Disclaimer
267
+
268
+ 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.
neural-chat-7b-v3.Q4_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:40aa7c4c1c9784d6e07f844f505cb1313cf0c0b911e9c7e02499aa66a35e335c
3
+ size 4108917248