Files changed (1) hide show
  1. README.md +168 -30
README.md CHANGED
@@ -1,17 +1,62 @@
1
  ---
2
  license: apache-2.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
4
 
5
  ## Model Details: Neural-Chat-v3-3
6
 
7
- 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 our 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).
8
-
9
- **Note:** Adjust lora modules to trade off truthfulqa and gsm8k performance on DPO stage.
 
 
10
 
11
 
12
  | Model Detail | Description |
13
  | ----------- | ----------- |
14
- | Model Authors - Company | Intel. The NeuralChat team with members from Intel/DCAI/AISE/AIPT. Core team members: Kaokao Lv, Liang Lv, Chang Wang, Wenxin Zhang, Xuhui Ren, and Haihao Shen.|
15
  | Date | December, 2023 |
16
  | Version | v3-3 |
17
  | Type | 7B Large Language Model |
@@ -21,47 +66,140 @@ This model is a fine-tuned 7B parameter LLM on the Intel Gaudi 2 processor from
21
 
22
  | Intended Use | Description |
23
  | ----------- | ----------- |
24
- | 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 and others from Intel are doing. |
25
  | Primary intended users | Anyone doing inference on language-related tasks. |
26
  | 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.|
27
 
28
- ## How to use and Sample Code
29
- Here is the sample code to reproduce the model: [Sample Code](https://github.com/intel/intel-extension-for-transformers/blob/main/intel_extension_for_transformers/neural_chat/examples/finetuning/finetune_neuralchat_v3/README.md).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
- ## Prompt Template
32
- ```plaintext
33
- ### System:
34
- {system}
35
- ### User:
36
- {usr}
37
- ### Assistant:
38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  ```
40
 
41
- ## [Quantitative Analyses: Open LLM Leaderboard Evaluation Results](https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard)
42
- Detailed results can be found [here](https://huggingface.co/datasets/open-llm-leaderboard/details_Intel__neural-chat-7b-v3-3) (**note:** the leaderboard removed drop task)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
 
44
  | Metric | Value |
45
  |-----------------------|---------------------------|
46
- | Avg. | 69.83 |
47
- | ARC (25-shot) | 66.89 |
48
- | HellaSwag (10-shot) | 85.26 |
49
- | MMLU (5-shot) | 63.07 |
50
- | TruthfulQA (0-shot) | 63.01 |
51
- | Winogrande (5-shot) | 79.64 |
52
- | GSM8K (5-shot) | 61.11 |
53
-
54
- ## Useful links
55
- * Intel Neural Compressor [link](https://github.com/intel/neural-compressor)
56
- * Intel Extension for Transformers [link](https://github.com/intel/intel-extension-for-transformers)
57
 
58
  ## Ethical Considerations and Limitations
59
- 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.
60
 
61
  Therefore, before deploying any applications of neural-chat-7b-v3-3, developers should perform safety testing.
62
 
63
- ## Disclaimer
64
 
65
- 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.
66
 
 
 
 
 
 
67
 
 
 
1
  ---
2
  license: apache-2.0
3
+ tags:
4
+ - LLMs
5
+ - mistral
6
+ - Intel
7
+ - math
8
+ model-index:
9
+ - name: neural-chat-7b-v3-3
10
+ results:
11
+ - task:
12
+ type: Large Language Model
13
+ name: Large Language Model
14
+ dataset:
15
+ type: meta-math/MetaMathQA
16
+ name: meta-math/MetaMathQA
17
+ metrics:
18
+ - type: ARC (25-shot)
19
+ value: 66.89
20
+ name: ARC (25-shot)
21
+ verified: true
22
+ - type: HellaSwag (10-shot)
23
+ value: 85.26
24
+ name: HellaSwag (10-shot)
25
+ verified: true
26
+ - type: MMLU (5-shot)
27
+ value: 63.07
28
+ name: MMLU (5-shot)
29
+ verified: true
30
+ - type: TruthfulQA (0-shot)
31
+ value: 63.01
32
+ name: TruthfulQA (0-shot)
33
+ verified: true
34
+ - type: Winogrande (5-shot)
35
+ value: 79.64
36
+ name: Winogrande (5-shot)
37
+ verified: true
38
+ - type: GSM8K (5-shot)
39
+ value: 61.11
40
+ name: GSM8K (5-shot)
41
+ verified: true
42
+ datasets:
43
+ - meta-math/MetaMathQA
44
+ language:
45
+ - en
46
  ---
47
 
48
  ## Model Details: Neural-Chat-v3-3
49
 
50
+ 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).
51
+ <p align="center">
52
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/6297f0e30bd2f58c647abb1d/ctASHUT5QYIxMsOFa-sHC.webp" width="500"/>
53
+ Photo by Google DeepMind on Unsplash
54
+ </p>
55
 
56
 
57
  | Model Detail | Description |
58
  | ----------- | ----------- |
59
+ | 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.|
60
  | Date | December, 2023 |
61
  | Version | v3-3 |
62
  | Type | 7B Large Language Model |
 
66
 
67
  | Intended Use | Description |
68
  | ----------- | ----------- |
69
+ | 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. |
70
  | Primary intended users | Anyone doing inference on language-related tasks. |
71
  | 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.|
72
 
73
+ ## How To Use
74
+ ### Reproduce the model
75
+ 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:
76
+
77
+ ```bash
78
+ git clone https://github.com/intel/intel-extension-for-transformers.git
79
+ cd intel-extension-for-transformers
80
+
81
+ 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
82
+
83
+ 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
84
+
85
+ # after entering docker container
86
+ cd examples/finetuning/finetune_neuralchat_v3
87
+
88
+ ```
89
+ We select the latest pretrained mistralai/Mistral-7B-v0.1 and the open source dataset Open-Orca/SlimOrca to conduct the experiment.
90
+
91
+ 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"`.
92
+
93
+ ```python
94
+ deepspeed --include localhost:0,1,2,3,4,5,6,7 \
95
+ --master_port 29501 \
96
+ finetune_neuralchat_v3.py
97
+ ```
98
+
99
+ Merge the LoRA weights:
100
+
101
+ ```python
102
+ python apply_lora.py \
103
+ --base-model-path mistralai/Mistral-7B-v0.1 \
104
+ --lora-model-path finetuned_model/ \
105
+ --output-path finetuned_model_lora
106
+ ```
107
+
108
+ ### Use the model
109
+ Here is sample code if you want to use the model.
110
+
111
+ ```python
112
+ import transformers
113
+
114
+
115
+ model_name = 'Intel/neural-chat-7b-v3-3'
116
+ model = transformers.AutoModelForCausalLM.from_pretrained(model_name)
117
+ tokenizer = transformers.AutoTokenizer.from_pretrained(model_name)
118
+
119
+ def generate_response(system_input, user_input):
120
+
121
+ # Format the input using the provided template
122
+ prompt = f"### System:\n{system_input}\n### User:\n{user_input}\n### Assistant:\n"
123
+
124
+ # Tokenize and encode the prompt
125
+ inputs = tokenizer.encode(prompt, return_tensors="pt", add_special_tokens=False)
126
 
127
+ # Generate a response
128
+ outputs = model.generate(inputs, max_length=1000, num_return_sequences=1)
129
+ response = tokenizer.decode(outputs[0], skip_special_tokens=True)
 
 
 
 
130
 
131
+ # Extract only the assistant's response
132
+ return response.split("### Assistant:\n")[-1]
133
+
134
+
135
+ # Example usage
136
+ 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."
137
+ user_input = "calculate 100 + 520 + 60"
138
+ response = generate_response(system_input, user_input)
139
+ print(response)
140
+
141
+ # expected response
142
+ """
143
+ To calculate the sum of 100, 520, and 60, we will follow these steps:
144
+
145
+ 1. Add the first two numbers: 100 + 520
146
+ 2. Add the result from step 1 to the third number: (100 + 520) + 60
147
+
148
+ Step 1: Add 100 and 520
149
+ 100 + 520 = 620
150
+
151
+ Step 2: Add the result from step 1 to the third number (60)
152
+ (620) + 60 = 680
153
+
154
+ So, the sum of 100, 520, and 60 is 680.
155
+ """
156
  ```
157
 
158
+ | Factors | Description |
159
+ | ----------- | ----------- |
160
+ | 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. |
161
+ | 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. |
162
+ | Environment | The model was trained on the Intel Gaudi 2 processor (8 cards). |
163
+ | 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). |
164
+
165
+ | Metrics | Description |
166
+ | ----------- | ----------- |
167
+ | 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. |
168
+ | Decision thresholds | No decision thresholds were used. |
169
+ | Approaches to uncertainty and variability | - |
170
+
171
+ | Training and Evaluation Data | Description |
172
+ | ----------- | ----------- |
173
+ | 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.|
174
+ | Motivation | - |
175
+ | Preprocessing | - |
176
+
177
+ ## Quantitative Analyses
178
+ 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:
179
 
180
  | Metric | Value |
181
  |-----------------------|---------------------------|
182
+ | Avg. | 69.83 |
183
+ | ARC (25-shot) | 66.89 |
184
+ | HellaSwag (10-shot) | 85.26 |
185
+ | MMLU (5-shot) | 63.07 |
186
+ | TruthfulQA (0-shot) | 63.01 |
187
+ | Winogrande (5-shot) | 79.64 |
188
+ | GSM8K (5-shot) | 61.11 |
 
 
 
 
189
 
190
  ## Ethical Considerations and Limitations
191
+ 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.
192
 
193
  Therefore, before deploying any applications of neural-chat-7b-v3-3, developers should perform safety testing.
194
 
195
+ ## Caveats and Recommendations
196
 
197
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
198
 
199
+ Here are a couple of useful links to learn more about Intel's AI software:
200
+ * Intel Neural Compressor [link](https://github.com/intel/neural-compressor)
201
+ * Intel Extension for Transformers [link](https://github.com/intel/intel-extension-for-transformers)
202
+
203
+ ## Disclaimer
204
 
205
+ 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.