update README.md
Browse filesRevamped the README.md to include a lot more information, including more code snippets. I also included all of the previous PR suggestions in here as well.
README.md
CHANGED
@@ -1,25 +1,81 @@
|
|
1 |
---
|
2 |
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
4 |
|
5 |
-
##
|
6 |
|
7 |
-
This model is a fine-tuned
|
8 |
|
9 |
-
|
10 |
-
|
|
|
|
|
11 |
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
-
|
|
|
|
|
|
|
|
|
15 |
|
16 |
-
|
17 |
-
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
18 |
-
|[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 |
|
19 |
-
| [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 |
|
20 |
-
| [Intel/neural-chat-7b-v3-1](https://huggingface.co/Intel/neural-chat-7b-v3-1) | **59.06** | 66.21 | 83.64 | 62.37 | 59.65 | 78.14 | 19.56 | 43.84 |
|
21 |
-
|
22 |
-
## Training procedure
|
23 |
|
24 |
### Training hyperparameters
|
25 |
|
@@ -38,27 +94,46 @@ The following hyperparameters were used during training:
|
|
38 |
- lr_scheduler_warmup_ratio: 0.03
|
39 |
- num_epochs: 2.0
|
40 |
|
41 |
-
###
|
42 |
-
Here is the sample code to reproduce the model: [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
-
|
|
|
45 |
|
46 |
```
|
47 |
-
|
48 |
-
{system}
|
49 |
-
### User:
|
50 |
-
{usr}
|
51 |
-
### Assistant:
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
```
|
54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
|
56 |
-
|
|
|
57 |
|
58 |
```python
|
59 |
import transformers
|
60 |
|
61 |
-
|
62 |
model_name = 'Intel/neural-chat-7b-v3-1'
|
63 |
model = transformers.AutoModelForCausalLM.from_pretrained(model_name)
|
64 |
tokenizer = transformers.AutoTokenizer.from_pretrained(model_name)
|
@@ -100,36 +175,66 @@ Step 2: Add the result from step 1 to the third number (60)
|
|
100 |
|
101 |
So, the sum of 100, 520, and 60 is 680.
|
102 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
|
104 |
```
|
105 |
|
106 |
-
|
107 |
-
|
|
|
|
|
|
|
|
|
108 |
|
109 |
-
|
|
|
|
|
|
|
|
|
110 |
|
111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
|
113 |
-
|
|
|
114 |
|
115 |
-
|
|
|
|
|
116 |
|
117 |
-
|
118 |
|
119 |
-
|
120 |
* Intel Neural Compressor [link](https://github.com/intel/neural-compressor)
|
121 |
* Intel Extension for Transformers [link](https://github.com/intel/intel-extension-for-transformers)
|
122 |
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
| Metric | Value |
|
127 |
-
|-----------------------|---------------------------|
|
128 |
-
| Avg. | 59.06 |
|
129 |
-
| ARC (25-shot) | 66.21 |
|
130 |
-
| HellaSwag (10-shot) | 83.64 |
|
131 |
-
| MMLU (5-shot) | 62.37 |
|
132 |
-
| TruthfulQA (0-shot) | 59.65 |
|
133 |
-
| Winogrande (5-shot) | 78.14 |
|
134 |
-
| GSM8K (5-shot) | 19.56 |
|
135 |
-
| DROP (3-shot) | 43.84 |
|
|
|
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-1
|
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: 66.21
|
21 |
+
name: ARC (25-shot)
|
22 |
+
verified: true
|
23 |
+
- type: HellaSwag (10-shot)
|
24 |
+
value: 83.64
|
25 |
+
name: HellaSwag (10-shot)
|
26 |
+
verified: true
|
27 |
+
- type: MMLU (5-shot)
|
28 |
+
value: 62.37
|
29 |
+
name: MMLU (5-shot)
|
30 |
+
verified: true
|
31 |
+
- type: TruthfulQA (0-shot)
|
32 |
+
value: 59.65
|
33 |
+
name: TruthfulQA (0-shot)
|
34 |
+
verified: true
|
35 |
+
- type: Winogrande (5-shot)
|
36 |
+
value: 78.14
|
37 |
+
name: Winogrande (5-shot)
|
38 |
+
verified: true
|
39 |
+
- type: GSM8K (5-shot)
|
40 |
+
value: 19.56
|
41 |
+
name: GSM8K (5-shot)
|
42 |
+
verified: true
|
43 |
+
- type: DROP (3-shot)
|
44 |
+
value: 43.84
|
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-1
|
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](https://unsplash.com/@googledeepmind?utm_source=medium&utm_medium=referral)
|
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-1 |
|
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-1/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 |
### Training hyperparameters
|
81 |
|
|
|
94 |
- lr_scheduler_warmup_ratio: 0.03
|
95 |
- num_epochs: 2.0
|
96 |
|
97 |
+
### Reproduce the model
|
98 |
+
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:
|
99 |
+
|
100 |
+
```bash
|
101 |
+
git clone https://github.com/intel/intel-extension-for-transformers.git
|
102 |
+
cd intel-extension-for-transformers
|
103 |
+
|
104 |
+
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
|
105 |
+
|
106 |
+
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
|
107 |
|
108 |
+
# after entering docker container
|
109 |
+
cd examples/finetuning/finetune_neuralchat_v3
|
110 |
|
111 |
```
|
112 |
+
We select the latest pretrained mistralai/Mistral-7B-v0.1 and the open source dataset Open-Orca/SlimOrca to conduct the experiment.
|
|
|
|
|
|
|
|
|
113 |
|
114 |
+
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"`.
|
115 |
+
|
116 |
+
```python
|
117 |
+
deepspeed --include localhost:0,1,2,3,4,5,6,7 \
|
118 |
+
--master_port 29501 \
|
119 |
+
finetune_neuralchat_v3.py
|
120 |
```
|
121 |
|
122 |
+
Merge the LoRA weights:
|
123 |
+
|
124 |
+
```python
|
125 |
+
python apply_lora.py \
|
126 |
+
--base-model-path mistralai/Mistral-7B-v0.1 \
|
127 |
+
--lora-model-path finetuned_model/ \
|
128 |
+
--output-path finetuned_model_lora
|
129 |
+
```
|
130 |
|
131 |
+
|
132 |
+
### FP32 Inference with Transformers
|
133 |
|
134 |
```python
|
135 |
import transformers
|
136 |
|
|
|
137 |
model_name = 'Intel/neural-chat-7b-v3-1'
|
138 |
model = transformers.AutoModelForCausalLM.from_pretrained(model_name)
|
139 |
tokenizer = transformers.AutoTokenizer.from_pretrained(model_name)
|
|
|
175 |
|
176 |
So, the sum of 100, 520, and 60 is 680.
|
177 |
"""
|
178 |
+
```
|
179 |
+
|
180 |
+
### INT4 Inference with Transformers and Intel Extension for Transformers
|
181 |
+
```python
|
182 |
+
from transformers import AutoTokenizer, TextStreamer
|
183 |
+
from intel_extension_for_transformers.transformers import AutoModelForCausalLM, WeightOnlyQuantConfig
|
184 |
+
model_name = "Intel/neural-chat-7b-v3-1"
|
185 |
+
config = WeightOnlyQuantConfig(compute_dtype="int8", weight_dtype="int4")
|
186 |
+
prompt = "Once upon a time, there existed a little girl,"
|
187 |
+
|
188 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
|
189 |
+
inputs = tokenizer(prompt, return_tensors="pt").input_ids
|
190 |
+
streamer = TextStreamer(tokenizer)
|
191 |
+
|
192 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, quantization_config=config)
|
193 |
+
outputs = model.generate(inputs, streamer=streamer, max_new_tokens=300)
|
194 |
|
195 |
```
|
196 |
|
197 |
+
| Factors | Description |
|
198 |
+
| ----------- | ----------- |
|
199 |
+
| 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. |
|
200 |
+
| 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. |
|
201 |
+
| Environment | The model was trained on the Intel Gaudi 2 processor (8 cards). |
|
202 |
+
| 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). |
|
203 |
|
204 |
+
| Metrics | Description |
|
205 |
+
| ----------- | ----------- |
|
206 |
+
| 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. |
|
207 |
+
| Decision thresholds | No decision thresholds were used. |
|
208 |
+
| Approaches to uncertainty and variability | - |
|
209 |
|
210 |
+
| Training and Evaluation Data | Description |
|
211 |
+
| ----------- | ----------- |
|
212 |
+
| 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.|
|
213 |
+
| Motivation | - |
|
214 |
+
| Preprocessing | - |
|
215 |
+
|
216 |
+
## Quantitative Analyses
|
217 |
+
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-1](https://huggingface.co/datasets/open-llm-leaderboard/details_Intel__neural-chat-7b-v3-1). The metrics can be found below and show that the model has significantly improved performance from Mistral-7B-v0.1 and neural-chat-7b-v3.
|
218 |
+
|
219 |
+
| Model | Average ⬆️| ARC (25-s) ⬆️ | HellaSwag (10-s) ⬆️ | MMLU (5-s) ⬆️| TruthfulQA (MC) (0-s) ⬆️ | Winogrande (5-s) | GSM8K (5-s) | DROP (3-s) |
|
220 |
+
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
221 |
+
|[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 |
|
222 |
+
| [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 |
|
223 |
+
| [Intel/neural-chat-7b-v3-1](https://huggingface.co/Intel/neural-chat-7b-v3-1) | **59.06** | 66.21 | 83.64 | 62.37 | 59.65 | 78.14 | 19.56 | 43.84 |
|
224 |
|
225 |
+
## Ethical Considerations and Limitations
|
226 |
+
Neural-chat-7b-v3-1 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.
|
227 |
|
228 |
+
Therefore, before deploying any applications of neural-chat-7b-v3-1, developers should perform safety testing.
|
229 |
+
|
230 |
+
## Caveats and Recommendations
|
231 |
|
232 |
+
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
|
233 |
|
234 |
+
Here are a couple of useful links to learn more about Intel's AI software:
|
235 |
* Intel Neural Compressor [link](https://github.com/intel/neural-compressor)
|
236 |
* Intel Extension for Transformers [link](https://github.com/intel/intel-extension-for-transformers)
|
237 |
|
238 |
+
## Disclaimer
|
239 |
+
|
240 |
+
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|