update fast usage
Browse files- LICENSE +8 -9
- NOTICE +26 -1
- README.md +10 -3
- config.json +1 -1
- tokenization_qwen.py +1 -1
LICENSE
CHANGED
@@ -6,13 +6,12 @@ By clicking to agree or by using or distributing any portion or element of the T
|
|
6 |
|
7 |
1. Definitions
|
8 |
a. This Tongyi Qianwen LICENSE AGREEMENT (this "Agreement") shall mean the terms and conditions for use, reproduction, distribution and modification of the Materials as defined by this Agreement.
|
9 |
-
b.
|
10 |
-
c.
|
11 |
-
d.
|
12 |
-
e. "Tongyi Qianwen" shall mean the large language models (including Qwen-
|
13 |
-
algorithms, consisting of trained model weights, parameters (including optimizer states), machine-learning model code, inference-enabling code, training-enabling code, fine-tuning enabling code and other elements of the foregoing distributed by Us.
|
14 |
f. "Materials" shall mean, collectively, Alibaba Cloud's proprietary Tongyi Qianwen and Documentation (and any portion thereof) made available under this Agreement.
|
15 |
-
g.
|
16 |
h. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation,
|
17 |
and conversions to other media types.
|
18 |
|
@@ -23,7 +22,7 @@ You are granted a non-exclusive, worldwide, non-transferable and royalty-free li
|
|
23 |
You may reproduce and distribute copies of the Materials or derivative works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
24 |
a. You shall give any other recipients of the Materials or derivative works a copy of this Agreement;
|
25 |
b. You shall cause any modified files to carry prominent notices stating that You changed the files;
|
26 |
-
c. You shall retain in all copies of the Materials that You distribute the following attribution notices
|
27 |
d. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such derivative works as a whole, provided Your use, reproduction, and distribution of the work otherwise complies with the terms and conditions of this Agreement.
|
28 |
|
29 |
4. Restrictions
|
@@ -40,10 +39,10 @@ If you are commercially using the Materials, and your product or service has mor
|
|
40 |
|
41 |
7. Disclaimer of Warranty and Limitation of Liability
|
42 |
|
43 |
-
a. We are not obligated to support, update, provide training for, or develop any further version of the Tongyi
|
44 |
b. THE MATERIALS ARE PROVIDED "AS IS" WITHOUT ANY EXPRESS OR IMPLIED WARRANTY OF ANY KIND INCLUDING WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, OR FITNESS FOR A PARTICULAR PURPOSE. WE MAKE NO WARRANTY AND ASSUME NO RESPONSIBILITY FOR THE SAFETY OR STABILITY OF THE MATERIALS AND ANY OUTPUT THEREFROM.
|
45 |
c. IN NO EVENT SHALL WE BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO ANY DIRECT, OR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM YOUR USE OR INABILITY TO USE THE MATERIALS OR ANY OUTPUT OF IT, NO MATTER HOW IT’S CAUSED.
|
46 |
-
d. You will indemnify and hold
|
47 |
|
48 |
8. Survival and Termination.
|
49 |
a. The term of this Agreement shall commence upon your acceptance of this Agreement or access to the Materials and will continue in full force and effect until terminated in accordance with the terms and conditions herein.
|
|
|
6 |
|
7 |
1. Definitions
|
8 |
a. This Tongyi Qianwen LICENSE AGREEMENT (this "Agreement") shall mean the terms and conditions for use, reproduction, distribution and modification of the Materials as defined by this Agreement.
|
9 |
+
b. "We"(or "Us") shall mean Alibaba Cloud.
|
10 |
+
c. "You" (or "Your") shall mean a natural person or legal entity exercising the rights granted by this Agreement and/or using the Materials for any purpose and in any field of use.
|
11 |
+
d. "Third Parties" shall mean individuals or legal entities that are not under common control with Us or You.
|
12 |
+
e. "Tongyi Qianwen" shall mean the large language models (including Qwen-7B model and Qwen-7B-Chat model), and software and algorithms, consisting of trained model weights, parameters (including optimizer states), machine-learning model code, inference-enabling code, training-enabling code, fine-tuning enabling code and other elements of the foregoing distributed by Us.
|
|
|
13 |
f. "Materials" shall mean, collectively, Alibaba Cloud's proprietary Tongyi Qianwen and Documentation (and any portion thereof) made available under this Agreement.
|
14 |
+
g. "Source" form shall mean the preferred form for making modifications, including but not limited to model source code, documentation source, and configuration files.
|
15 |
h. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation,
|
16 |
and conversions to other media types.
|
17 |
|
|
|
22 |
You may reproduce and distribute copies of the Materials or derivative works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
23 |
a. You shall give any other recipients of the Materials or derivative works a copy of this Agreement;
|
24 |
b. You shall cause any modified files to carry prominent notices stating that You changed the files;
|
25 |
+
c. You shall retain in all copies of the Materials that You distribute the following attribution notices within a "Notice" text file distributed as a part of such copies: "Tongyi Qianwen is licensed under the Tongyi Qianwen LICENSE AGREEMENT, Copyright (c) Alibaba Cloud. All Rights Reserved."; and
|
26 |
d. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such derivative works as a whole, provided Your use, reproduction, and distribution of the work otherwise complies with the terms and conditions of this Agreement.
|
27 |
|
28 |
4. Restrictions
|
|
|
39 |
|
40 |
7. Disclaimer of Warranty and Limitation of Liability
|
41 |
|
42 |
+
a. We are not obligated to support, update, provide training for, or develop any further version of the Tongyi Qianwen Materials or to grant any license thereto.
|
43 |
b. THE MATERIALS ARE PROVIDED "AS IS" WITHOUT ANY EXPRESS OR IMPLIED WARRANTY OF ANY KIND INCLUDING WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, OR FITNESS FOR A PARTICULAR PURPOSE. WE MAKE NO WARRANTY AND ASSUME NO RESPONSIBILITY FOR THE SAFETY OR STABILITY OF THE MATERIALS AND ANY OUTPUT THEREFROM.
|
44 |
c. IN NO EVENT SHALL WE BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO ANY DIRECT, OR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM YOUR USE OR INABILITY TO USE THE MATERIALS OR ANY OUTPUT OF IT, NO MATTER HOW IT’S CAUSED.
|
45 |
+
d. You will defend, indemnify and hold harmless Us from and against any claim by any third party arising out of or related to your use or distribution of the Materials.
|
46 |
|
47 |
8. Survival and Termination.
|
48 |
a. The term of this Agreement shall commence upon your acceptance of this Agreement or access to the Materials and will continue in full force and effect until terminated in accordance with the terms and conditions herein.
|
NOTICE
CHANGED
@@ -24,4 +24,29 @@ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
24 |
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
25 |
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
26 |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
27 |
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
25 |
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
26 |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
27 |
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
28 |
+
|
29 |
+
|
30 |
+
------------- LICENSE FOR OpenAI tiktoken code --------------
|
31 |
+
|
32 |
+
MIT License
|
33 |
+
|
34 |
+
Copyright (c) 2022 OpenAI, Shantanu Jain
|
35 |
+
|
36 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
37 |
+
of this software and associated documentation files (the "Software"), to deal
|
38 |
+
in the Software without restriction, including without limitation the rights
|
39 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
40 |
+
copies of the Software, and to permit persons to whom the Software is
|
41 |
+
furnished to do so, subject to the following conditions:
|
42 |
+
|
43 |
+
The above copyright notice and this permission notice shall be included in all
|
44 |
+
copies or substantial portions of the Software.
|
45 |
+
|
46 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
47 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
48 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
49 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
50 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
51 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
52 |
+
SOFTWARE.
|
README.md
CHANGED
@@ -271,9 +271,17 @@ Qwen-7B-Chat also has the capability to be used as a [HuggingFace Agent](https:/
|
|
271 |
|
272 |
## 量化(Quantization)
|
273 |
|
274 |
-
如希望使用更低精度的量化模型,如4比特和8
|
275 |
|
276 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
277 |
|
278 |
```python
|
279 |
from transformers import BitsAndBytesConfig
|
@@ -285,7 +293,6 @@ quantization_config = BitsAndBytesConfig(
|
|
285 |
bnb_4bit_compute_dtype=torch.bfloat16
|
286 |
)
|
287 |
|
288 |
-
|
289 |
# quantization configuration for Int8 (8 bits)
|
290 |
quantization_config = BitsAndBytesConfig(load_in_8bit=True)
|
291 |
|
|
|
271 |
|
272 |
## 量化(Quantization)
|
273 |
|
274 |
+
如希望使用更低精度的量化模型,如4比特和8比特的模型,我们提供了简单的示例来说明如何快速使用量化模型。在开始前,确保你已经安装了`bitsandbytes`。
|
275 |
|
276 |
+
We provide examples to show how to load models in `NF4` and `Int8`. For starters, make sure you have implemented `bitsandbytes`.
|
277 |
+
|
278 |
+
```bash
|
279 |
+
pip install bitsandbytes
|
280 |
+
```
|
281 |
+
|
282 |
+
你只需要在`AutoModelForCausalLM.from_pretrained`中添加你的量化配置,即可使用量化模型。如下所示:
|
283 |
+
|
284 |
+
Then you only need to add your quantization configuration to `AutoModelForCausalLM.from_pretrained`. See the example below:
|
285 |
|
286 |
```python
|
287 |
from transformers import BitsAndBytesConfig
|
|
|
293 |
bnb_4bit_compute_dtype=torch.bfloat16
|
294 |
)
|
295 |
|
|
|
296 |
# quantization configuration for Int8 (8 bits)
|
297 |
quantization_config = BitsAndBytesConfig(load_in_8bit=True)
|
298 |
|
config.json
CHANGED
@@ -9,7 +9,7 @@
|
|
9 |
"AutoModelForCausalLM": "modeling_qwen.QWenLMHeadModel"
|
10 |
},
|
11 |
"attn_pdrop": 0.0,
|
12 |
-
"bf16":
|
13 |
"bias_dropout_fusion": true,
|
14 |
"bos_token_id": 151643,
|
15 |
"embd_pdrop": 0.1,
|
|
|
9 |
"AutoModelForCausalLM": "modeling_qwen.QWenLMHeadModel"
|
10 |
},
|
11 |
"attn_pdrop": 0.0,
|
12 |
+
"bf16": false,
|
13 |
"bias_dropout_fusion": true,
|
14 |
"bos_token_id": 151643,
|
15 |
"embd_pdrop": 0.1,
|
tokenization_qwen.py
CHANGED
@@ -160,7 +160,7 @@ class QWenTokenizer(PreTrainedTokenizer):
|
|
160 |
)
|
161 |
return ids
|
162 |
|
163 |
-
def save_vocabulary(self, save_directory: str) -> Tuple[str]:
|
164 |
"""
|
165 |
Save only the vocabulary of the tokenizer (vocabulary + added tokens).
|
166 |
|
|
|
160 |
)
|
161 |
return ids
|
162 |
|
163 |
+
def save_vocabulary(self, save_directory: str, **kwargs) -> Tuple[str]:
|
164 |
"""
|
165 |
Save only the vocabulary of the tokenizer (vocabulary + added tokens).
|
166 |
|