update
Browse files- LICENSE +53 -0
- NOTICE +280 -0
- README.md +425 -0
- assets/logo.jpg +0 -0
- assets/qwen_72b_needle_in_a_haystack.png +0 -0
- assets/wechat.png +0 -0
- modeling_qwen.py +0 -5
LICENSE
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Tongyi Qianwen LICENSE AGREEMENT
|
2 |
+
|
3 |
+
Tongyi Qianwen Release Date: August 3, 2023
|
4 |
+
|
5 |
+
By clicking to agree or by using or distributing any portion or element of the Tongyi Qianwen Materials, you will be deemed to have recognized and accepted the content of this Agreement, which is effective immediately.
|
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 model and Qwen-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 |
+
|
18 |
+
2. Grant of Rights
|
19 |
+
You are granted a non-exclusive, worldwide, non-transferable and royalty-free limited license under Alibaba Cloud's intellectual property or other rights owned by Us embodied in the Materials to use, reproduce, distribute, copy, create derivative works of, and make modifications to the Materials.
|
20 |
+
|
21 |
+
3. Redistribution
|
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
|
29 |
+
If you are commercially using the Materials, and your product or service has more than 100 million monthly active users, You shall request a license from Us. You cannot exercise your rights under this Agreement without our express authorization.
|
30 |
+
|
31 |
+
5. Rules of use
|
32 |
+
a. The Materials may be subject to export controls or restrictions in China, the United States or other countries or regions. You shall comply with applicable laws and regulations in your use of the Materials.
|
33 |
+
b. You can not use the Materials or any output therefrom to improve any other large language model (excluding Tongyi Qianwen or derivative works thereof).
|
34 |
+
|
35 |
+
6. Intellectual Property
|
36 |
+
a. We retain ownership of all intellectual property rights in and to the Materials and derivatives made by or for Us. Conditioned upon compliance with the terms and conditions of this Agreement, with respect to any derivative works and modifications of the Materials that are made by you, you are and will be the owner of such derivative works and modifications.
|
37 |
+
b. No trademark license is granted to use the trade names, trademarks, service marks, or product names of Us, except as required to fulfill notice requirements under this Agreement or as required for reasonable and customary use in describing and redistributing the Materials.
|
38 |
+
c. If you commence a lawsuit or other proceedings (including a cross-claim or counterclaim in a lawsuit) against Us or any entity alleging that the Materials or any output therefrom, or any part of the foregoing, infringe any intellectual property or other right owned or licensable by you, then all licences granted to you under this Agreement shall terminate as of the date such lawsuit or other proceeding is commenced or brought.
|
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.
|
49 |
+
b. We may terminate this Agreement if you breach any of the terms or conditions of this Agreement. Upon termination of this Agreement, you must delete and cease use of the Materials. Sections 7 and 9 shall survive the termination of this Agreement.
|
50 |
+
|
51 |
+
9. Governing Law and Jurisdiction.
|
52 |
+
a. This Agreement and any dispute arising out of or relating to it will be governed by the laws of China, without regard to conflict of law principles, and the UN Convention on Contracts for the International Sale of Goods does not apply to this Agreement.
|
53 |
+
b. The People's Courts in Hangzhou City shall have exclusive jurisdiction over any dispute arising out of this Agreement.
|
NOTICE
ADDED
@@ -0,0 +1,280 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
------------- LICENSE FOR NVIDIA Megatron-LM code --------------
|
2 |
+
|
3 |
+
Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
4 |
+
|
5 |
+
Redistribution and use in source and binary forms, with or without
|
6 |
+
modification, are permitted provided that the following conditions
|
7 |
+
are met:
|
8 |
+
* Redistributions of source code must retain the above copyright
|
9 |
+
notice, this list of conditions and the following disclaimer.
|
10 |
+
* Redistributions in binary form must reproduce the above copyright
|
11 |
+
notice, this list of conditions and the following disclaimer in the
|
12 |
+
documentation and/or other materials provided with the distribution.
|
13 |
+
* Neither the name of NVIDIA CORPORATION nor the names of its
|
14 |
+
contributors may be used to endorse or promote products derived
|
15 |
+
from this software without specific prior written permission.
|
16 |
+
|
17 |
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
18 |
+
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
19 |
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
20 |
+
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
21 |
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
22 |
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
23 |
+
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.
|
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.
|
53 |
+
|
54 |
+
------------- LICENSE FOR stanford_alpaca code --------------
|
55 |
+
|
56 |
+
Apache License
|
57 |
+
Version 2.0, January 2004
|
58 |
+
http://www.apache.org/licenses/
|
59 |
+
|
60 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
61 |
+
|
62 |
+
1. Definitions.
|
63 |
+
|
64 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
65 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
66 |
+
|
67 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
68 |
+
the copyright owner that is granting the License.
|
69 |
+
|
70 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
71 |
+
other entities that control, are controlled by, or are under common
|
72 |
+
control with that entity. For the purposes of this definition,
|
73 |
+
"control" means (i) the power, direct or indirect, to cause the
|
74 |
+
direction or management of such entity, whether by contract or
|
75 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
76 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
77 |
+
|
78 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
79 |
+
exercising permissions granted by this License.
|
80 |
+
|
81 |
+
"Source" form shall mean the preferred form for making modifications,
|
82 |
+
including but not limited to software source code, documentation
|
83 |
+
source, and configuration files.
|
84 |
+
|
85 |
+
"Object" form shall mean any form resulting from mechanical
|
86 |
+
transformation or translation of a Source form, including but
|
87 |
+
not limited to compiled object code, generated documentation,
|
88 |
+
and conversions to other media types.
|
89 |
+
|
90 |
+
"Work" shall mean the work of authorship, whether in Source or
|
91 |
+
Object form, made available under the License, as indicated by a
|
92 |
+
copyright notice that is included in or attached to the work
|
93 |
+
(an example is provided in the Appendix below).
|
94 |
+
|
95 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
96 |
+
form, that is based on (or derived from) the Work and for which the
|
97 |
+
editorial revisions, annotations, elaborations, or other modifications
|
98 |
+
represent, as a whole, an original work of authorship. For the purposes
|
99 |
+
of this License, Derivative Works shall not include works that remain
|
100 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
101 |
+
the Work and Derivative Works thereof.
|
102 |
+
|
103 |
+
"Contribution" shall mean any work of authorship, including
|
104 |
+
the original version of the Work and any modifications or additions
|
105 |
+
to that Work or Derivative Works thereof, that is intentionally
|
106 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
107 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
108 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
109 |
+
means any form of electronic, verbal, or written communication sent
|
110 |
+
to the Licensor or its representatives, including but not limited to
|
111 |
+
communication on electronic mailing lists, source code control systems,
|
112 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
113 |
+
Licensor for the purpose of discussing and improving the Work, but
|
114 |
+
excluding communication that is conspicuously marked or otherwise
|
115 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
116 |
+
|
117 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
118 |
+
on behalf of whom a Contribution has been received by Licensor and
|
119 |
+
subsequently incorporated within the Work.
|
120 |
+
|
121 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
122 |
+
this License, each Contributor hereby grants to You a perpetual,
|
123 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
124 |
+
copyright license to reproduce, prepare Derivative Works of,
|
125 |
+
publicly display, publicly perform, sublicense, and distribute the
|
126 |
+
Work and such Derivative Works in Source or Object form.
|
127 |
+
|
128 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
129 |
+
this License, each Contributor hereby grants to You a perpetual,
|
130 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
131 |
+
(except as stated in this section) patent license to make, have made,
|
132 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
133 |
+
where such license applies only to those patent claims licensable
|
134 |
+
by such Contributor that are necessarily infringed by their
|
135 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
136 |
+
with the Work to which such Contribution(s) was submitted. If You
|
137 |
+
institute patent litigation against any entity (including a
|
138 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
139 |
+
or a Contribution incorporated within the Work constitutes direct
|
140 |
+
or contributory patent infringement, then any patent licenses
|
141 |
+
granted to You under this License for that Work shall terminate
|
142 |
+
as of the date such litigation is filed.
|
143 |
+
|
144 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
145 |
+
Work or Derivative Works thereof in any medium, with or without
|
146 |
+
modifications, and in Source or Object form, provided that You
|
147 |
+
meet the following conditions:
|
148 |
+
|
149 |
+
(a) You must give any other recipients of the Work or
|
150 |
+
Derivative Works a copy of this License; and
|
151 |
+
|
152 |
+
(b) You must cause any modified files to carry prominent notices
|
153 |
+
stating that You changed the files; and
|
154 |
+
|
155 |
+
(c) You must retain, in the Source form of any Derivative Works
|
156 |
+
that You distribute, all copyright, patent, trademark, and
|
157 |
+
attribution notices from the Source form of the Work,
|
158 |
+
excluding those notices that do not pertain to any part of
|
159 |
+
the Derivative Works; and
|
160 |
+
|
161 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
162 |
+
distribution, then any Derivative Works that You distribute must
|
163 |
+
include a readable copy of the attribution notices contained
|
164 |
+
within such NOTICE file, excluding those notices that do not
|
165 |
+
pertain to any part of the Derivative Works, in at least one
|
166 |
+
of the following places: within a NOTICE text file distributed
|
167 |
+
as part of the Derivative Works; within the Source form or
|
168 |
+
documentation, if provided along with the Derivative Works; or,
|
169 |
+
within a display generated by the Derivative Works, if and
|
170 |
+
wherever such third-party notices normally appear. The contents
|
171 |
+
of the NOTICE file are for informational purposes only and
|
172 |
+
do not modify the License. You may add Your own attribution
|
173 |
+
notices within Derivative Works that You distribute, alongside
|
174 |
+
or as an addendum to the NOTICE text from the Work, provided
|
175 |
+
that such additional attribution notices cannot be construed
|
176 |
+
as modifying the License.
|
177 |
+
|
178 |
+
You may add Your own copyright statement to Your modifications and
|
179 |
+
may provide additional or different license terms and conditions
|
180 |
+
for use, reproduction, or distribution of Your modifications, or
|
181 |
+
for any such Derivative Works as a whole, provided Your use,
|
182 |
+
reproduction, and distribution of the Work otherwise complies with
|
183 |
+
the conditions stated in this License.
|
184 |
+
|
185 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
186 |
+
any Contribution intentionally submitted for inclusion in the Work
|
187 |
+
by You to the Licensor shall be under the terms and conditions of
|
188 |
+
this License, without any additional terms or conditions.
|
189 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
190 |
+
the terms of any separate license agreement you may have executed
|
191 |
+
with Licensor regarding such Contributions.
|
192 |
+
|
193 |
+
6. Trademarks. This License does not grant permission to use the trade
|
194 |
+
names, trademarks, service marks, or product names of the Licensor,
|
195 |
+
except as required for reasonable and customary use in describing the
|
196 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
197 |
+
|
198 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
199 |
+
agreed to in writing, Licensor provides the Work (and each
|
200 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
201 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
202 |
+
implied, including, without limitation, any warranties or conditions
|
203 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
204 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
205 |
+
appropriateness of using or redistributing the Work and assume any
|
206 |
+
risks associated with Your exercise of permissions under this License.
|
207 |
+
|
208 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
209 |
+
whether in tort (including negligence), contract, or otherwise,
|
210 |
+
unless required by applicable law (such as deliberate and grossly
|
211 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
212 |
+
liable to You for damages, including any direct, indirect, special,
|
213 |
+
incidental, or consequential damages of any character arising as a
|
214 |
+
result of this License or out of the use or inability to use the
|
215 |
+
Work (including but not limited to damages for loss of goodwill,
|
216 |
+
work stoppage, computer failure or malfunction, or any and all
|
217 |
+
other commercial damages or losses), even if such Contributor
|
218 |
+
has been advised of the possibility of such damages.
|
219 |
+
|
220 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
221 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
222 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
223 |
+
or other liability obligations and/or rights consistent with this
|
224 |
+
License. However, in accepting such obligations, You may act only
|
225 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
226 |
+
of any other Contributor, and only if You agree to indemnify,
|
227 |
+
defend, and hold each Contributor harmless for any liability
|
228 |
+
incurred by, or claims asserted against, such Contributor by reason
|
229 |
+
of your accepting any such warranty or additional liability.
|
230 |
+
|
231 |
+
END OF TERMS AND CONDITIONS
|
232 |
+
|
233 |
+
APPENDIX: How to apply the Apache License to your work.
|
234 |
+
|
235 |
+
To apply the Apache License to your work, attach the following
|
236 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
237 |
+
replaced with your own identifying information. (Don't include
|
238 |
+
the brackets!) The text should be enclosed in the appropriate
|
239 |
+
comment syntax for the file format. We also recommend that a
|
240 |
+
file or class name and description of purpose be included on the
|
241 |
+
same "printed page" as the copyright notice for easier
|
242 |
+
identification within third-party archives.
|
243 |
+
|
244 |
+
Copyright 2023 Rohan Taori, Ishaan Gulrajani, Tianyi Zhang, Yann Dubois, Xuechen Li
|
245 |
+
|
246 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
247 |
+
you may not use this file except in compliance with the License.
|
248 |
+
You may obtain a copy of the License at
|
249 |
+
|
250 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
251 |
+
|
252 |
+
Unless required by applicable law or agreed to in writing, software
|
253 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
254 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
255 |
+
See the License for the specific language governing permissions and
|
256 |
+
limitations under the License.
|
257 |
+
|
258 |
+
------------- LICENSE FOR PanQiWei AutoGPTQ code --------------
|
259 |
+
|
260 |
+
MIT License
|
261 |
+
|
262 |
+
Copyright (c) 2023 潘其威(William)
|
263 |
+
|
264 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
265 |
+
of this software and associated documentation files (the "Software"), to deal
|
266 |
+
in the Software without restriction, including without limitation the rights
|
267 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
268 |
+
copies of the Software, and to permit persons to whom the Software is
|
269 |
+
furnished to do so, subject to the following conditions:
|
270 |
+
|
271 |
+
The above copyright notice and this permission notice shall be included in all
|
272 |
+
copies or substantial portions of the Software.
|
273 |
+
|
274 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
275 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
276 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
277 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
278 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
279 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
280 |
+
SOFTWARE.
|
README.md
ADDED
@@ -0,0 +1,425 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- zh
|
4 |
+
- en
|
5 |
+
tags:
|
6 |
+
- qwen
|
7 |
+
pipeline_tag: text-generation
|
8 |
+
inference: false
|
9 |
+
---
|
10 |
+
|
11 |
+
# Qwen-72B-Chat-Int4
|
12 |
+
|
13 |
+
<p align="center">
|
14 |
+
<img src="https://qianwen-res.oss-cn-beijing.aliyuncs.com/logo_qwen.jpg" width="400"/>
|
15 |
+
<p>
|
16 |
+
<br>
|
17 |
+
|
18 |
+
<p align="center">
|
19 |
+
🤗 <a href="https://huggingface.co/Qwen">Hugging Face</a>   |   🤖 <a href="https://modelscope.cn/organization/qwen">ModelScope</a>   |    📑 <a href="https://arxiv.org/abs/2309.16609">Paper</a>    |   🖥️ <a href="https://modelscope.cn/studios/qwen/Qwen-72B-Chat-Demo/summary">Demo</a>
|
20 |
+
<br>
|
21 |
+
<a href="assets/wechat.png">WeChat (微信)</a>   |   <a href="https://discord.gg/z3GAxXZ9Ce">Discord</a>   |   <a href="https://dashscope.aliyun.com">API</a>
|
22 |
+
</p>
|
23 |
+
<br>
|
24 |
+
|
25 |
+
## 介绍(Introduction)
|
26 |
+
|
27 |
+
**通义千问-72B**(**Qwen-72B**)是阿里云研发的通义千问大模型系列的720亿参数规模的模型。Qwen-72B是基于Transformer的大语言模型, 在超大规模的预训练数据上进行训练得到。预训练数据类型多样,覆盖广泛,包括大量网络文本、专业书籍、代码等。同时,在Qwen-72B的基础上,我们使用对齐机制打造了基于大语言模型的AI助手Qwen-72B-Chat。本仓库为Qwen-72B-Chat的Int4量化模型的仓库。
|
28 |
+
|
29 |
+
通义千问-72B(Qwen-72B)主要有以下特点:
|
30 |
+
|
31 |
+
1. **大规模高质量训练语料**:使用超过3万亿tokens的数据进行预训练,包含高质量中、英、多语言、代码、数学等数据,涵盖通用及专业领域的训练语料。通过大量对比实验对预训练语料分布进行了优化。
|
32 |
+
2. **强大的性能**:Qwen-72B在多个中英文下游评测任务上(涵盖常识推理、代码、数学、翻译等),效果显著超越现有的开源模型。具体评测结果请详见下文。
|
33 |
+
3. **覆盖更全面的词表**:相比目前以中英词表为主的开源模型,Qwen-72B使用了约15万大小的词表。该词表对多语言更加友好,方便用户在不扩展词表的情况下对部分语种进行能力增强和扩展。
|
34 |
+
4. **更长的上下文支持**:Qwen-72B支持32k的上下文长度。
|
35 |
+
5. **系统指令跟随**:Qwen-72B-Chat可以通过调整系统指令,实现**角色扮演**,**语言风格迁移**,**任务设定**,和**行为设定**等能力。
|
36 |
+
|
37 |
+
如果您想了解更多关于通义千问72B开源模型的细节,我们建议您参阅[GitHub代码库](https://github.com/QwenLM/Qwen)。
|
38 |
+
|
39 |
+
**Qwen-72B** is the 72B-parameter version of the large language model series, Qwen (abbr. Tongyi Qianwen), proposed by Alibaba Cloud. Qwen-72B is a Transformer-based large language model, which is pretrained on a large volume of data, including web texts, books, codes, etc. Additionally, based on the pretrained Qwen-72B, we release Qwen-72B-Chat, a large-model-based AI assistant, which is trained with alignment techniques. This repository is the one for the Int4 quantized model of Qwen-72B-Chat.
|
40 |
+
|
41 |
+
The features of Qwen-72B include:
|
42 |
+
|
43 |
+
1. **Large-scale high-quality training corpora**: It is pretrained on over 3 trillion tokens, including Chinese, English, multilingual texts, code, and mathematics, covering general and professional fields. The distribution of the pre-training corpus has been optimized through a large number of ablation experiments.
|
44 |
+
2. **Competitive performance**: It significantly surpasses existing open-source models on multiple Chinese and English downstream evaluation tasks (including commonsense, reasoning, code, mathematics, etc.). See below for specific evaluation results.
|
45 |
+
3. **More comprehensive vocabulary coverage**: Compared with other open-source models based on Chinese and English vocabularies, Qwen-72B uses a vocabulary of over 150K tokens. This vocabulary is more friendly to multiple languages, enabling users to directly further enhance the capability for certain languages without expanding the vocabulary.
|
46 |
+
4. **Longer context support**: Qwen-72B supports 32k context length.
|
47 |
+
5. **System prompt**: Qwen-72B can realize roly playing, language style transfer, task setting, and behavior setting by using system prompt.
|
48 |
+
|
49 |
+
For more details about the open-source model of Qwen-72B, please refer to the [GitHub](https://github.com/QwenLM/Qwen) code repository.
|
50 |
+
<br>
|
51 |
+
|
52 |
+
|
53 |
+
## 要求(Requirements)
|
54 |
+
|
55 |
+
* python 3.8及以上版本
|
56 |
+
* pytorch 2.0及以上版本
|
57 |
+
* 建议使用CUDA 11.4及以上(GPU用户、flash-attention用户等需考虑此选项)
|
58 |
+
* * **至少需要48GB显存(例如1xA100-80G或2xV100-32G)**
|
59 |
+
* python 3.8 and above
|
60 |
+
* pytorch 2.0 and above, 2.0 and above are recommended
|
61 |
+
* CUDA 11.4 and above are recommended (this is for GPU users, flash-attention users, etc.)
|
62 |
+
* **at least 48GB GPU memory is required (e.g., 1xA100-80G or 2xV100-32G)**
|
63 |
+
<br>
|
64 |
+
|
65 |
+
|
66 |
+
## 依赖项(Dependency)
|
67 |
+
|
68 |
+
运行Qwen-72B-Chat-Int4,请确保满足上述要求,再执行以下pip命令安装依赖库。如安装`auto-gptq`遇到问题,我们建议您到官方[repo](https://github.com/PanQiWei/AutoGPTQ)搜索合适的预编译wheel。
|
69 |
+
|
70 |
+
To run Qwen-72B-Chat-Int4, please make sure you meet the above requirements, and then execute the following pip commands to install the dependent libraries. If you meet problems installing `auto-gptq`, we advise you to check out the official [repo](https://github.com/PanQiWei/AutoGPTQ) to find a pre-build wheel.
|
71 |
+
|
72 |
+
```bash
|
73 |
+
pip install "transformers>=4.32.0" accelerate tiktoken einops scipy transformers_stream_generator==0.0.4 peft deepspeed
|
74 |
+
pip install auto-gptq optimum
|
75 |
+
```
|
76 |
+
|
77 |
+
> 注意:预编译的`auto-gptq`版本对`torch`版本及其CUDA版本要求严格。同时,由于
|
78 |
+
> 其近期更新,你可能会遇到`transformers`、`optimum`或`peft`抛出的版本错误。
|
79 |
+
> 我们建议使用符合以下要求的最新版本:
|
80 |
+
> - torch==2.1 auto-gptq>=0.5.1 transformers>=4.35.0 optimum>=1.14.0 peft>=0.6.1
|
81 |
+
> - torch>=2.0,<2.1 auto-gptq<0.5.0 transformers<4.35.0 optimum<1.14.0 peft>=0.5.0,<0.6.0
|
82 |
+
> Note: The pre-compiled `auto-gptq` packages strongly depend on the version of `torch` and its CUDA version. Moreover, due to recent update,
|
83 |
+
> you may also encounter unsupported version errors from `transformers`, `optimum`, or `peft`.
|
84 |
+
> We recommend using the latest versions meeting the following requirements :
|
85 |
+
> - torch==2.1 auto-gptq>=0.5.1 transformers>=4.35.0 optimum>=1.14.0 peft>=0.6.1
|
86 |
+
> - torch>=2.0,<2.1 auto-gptq<0.5.0 transformers<4.35.0 optimum<1.14.0 peft>=0.5.0,<0.6.0
|
87 |
+
|
88 |
+
另外,推荐安装`flash-attention`库(**当前已支持flash attention 2**),以实现更高的效率和更低的显存占用。
|
89 |
+
|
90 |
+
In addition, it is recommended to install the `flash-attention` library (**we support flash attention 2 now.**) for higher efficiency and lower memory usage.
|
91 |
+
|
92 |
+
```bash
|
93 |
+
git clone https://github.com/Dao-AILab/flash-attention
|
94 |
+
cd flash-attention && pip install .
|
95 |
+
# 下方安装可选,安装可能比较缓慢。
|
96 |
+
# Below are optional. Installing them might be slow.
|
97 |
+
# pip install csrc/layer_norm
|
98 |
+
# 如果你的flash-attn版本高于2.1.1,下方不需要安装。
|
99 |
+
# If the version of flash-attn is higher than 2.1.1, the following is not needed.
|
100 |
+
# pip install csrc/rotary
|
101 |
+
```
|
102 |
+
<br>
|
103 |
+
|
104 |
+
|
105 |
+
|
106 |
+
## 快速使用(Quickstart)
|
107 |
+
|
108 |
+
下面我们展示了一个使用Qwen-72B-Chat-Int4模型的样例:
|
109 |
+
|
110 |
+
We show an example of how to use Qwen-72B-Chat-Int4 in the following code:
|
111 |
+
|
112 |
+
```python
|
113 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
114 |
+
|
115 |
+
# Note: The default behavior now has injection attack prevention off.
|
116 |
+
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen-72B-Chat-Int4", trust_remote_code=True)
|
117 |
+
|
118 |
+
model = AutoModelForCausalLM.from_pretrained(
|
119 |
+
"Qwen/Qwen-72B-Chat-Int4",
|
120 |
+
device_map="auto",
|
121 |
+
trust_remote_code=True
|
122 |
+
).eval()
|
123 |
+
response, history = model.chat(tokenizer, "你好", history=None)
|
124 |
+
print(response)
|
125 |
+
# 你好!很高兴为你提供帮助。
|
126 |
+
|
127 |
+
# Qwen-72B-Chat现在可以通过调整系统指令(System Prompt),实现角色扮演,语言风格迁移,任务设定,行为设定等能力。
|
128 |
+
# Qwen-72B-Chat can realize roly playing, language style transfer, task setting, and behavior setting by system prompt.
|
129 |
+
response, _ = model.chat(tokenizer, "你好呀", history=None, system="请用二次元可爱语气和我说话")
|
130 |
+
print(response)
|
131 |
+
# 哎呀,你好哇!是怎么找到人家的呢?是不是被人家的魅力吸引过来的呀~(≧▽≦)/~
|
132 |
+
|
133 |
+
response, _ = model.chat(tokenizer, "My colleague works diligently", history=None, system="You will write beautiful compliments according to needs")
|
134 |
+
print(response)
|
135 |
+
# Your colleague is a shining example of dedication and hard work. Their commitment to their job is truly commendable, and it shows in the quality of their work.
|
136 |
+
# They are an asset to the team, and their efforts do not go unnoticed. Keep up the great work!
|
137 |
+
```
|
138 |
+
|
139 |
+
注意:vLLM暂不支持gptq量化方案,我们将近期给出解决方案。
|
140 |
+
|
141 |
+
Note: vLLM does not currently support the `gpt` quantization, and we will provide a solution in the near future.
|
142 |
+
|
143 |
+
关于更多的使用说明,请参考我们的[GitHub repo](https://github.com/QwenLM/Qwen)获取更多信息。
|
144 |
+
|
145 |
+
For more information, please refer to our [GitHub repo](https://github.com/QwenLM/Qwen) for more information.
|
146 |
+
<br>
|
147 |
+
|
148 |
+
|
149 |
+
|
150 |
+
## 量化 (Quantization)
|
151 |
+
|
152 |
+
### 效果评测
|
153 |
+
|
154 |
+
我们对BF16,Int8和Int4模型在基准评测上做了测试(使用zero-shot设置),结果如下所示:
|
155 |
+
|
156 |
+
We illustrate the zero-shot performance of both BF16, Int8 and Int4 models on the benchmark. Results are shown below:
|
157 |
+
|
158 |
+
| Quantization | MMLU | CEval (val) | GSM8K | Humaneval |
|
159 |
+
|--------------|:----:|:-----------:|:-----:|:---------:|
|
160 |
+
| BF16 | 74.4 | 80.1 | 76.4 | 64.6 |
|
161 |
+
| Int8 | 73.5 | 80.1 | 73.5 | 62.2 |
|
162 |
+
| Int4 | 73.4 | 80.1 | 75.3 | 61.6 |
|
163 |
+
|
164 |
+
### 推理速度及显存使用 (Inference Speed & GPU Memory Usage)
|
165 |
+
|
166 |
+
我们测算了不同精度模型、不同FlashAttn库版本、以及是否使用vLLM的情况下,模型在不同输入长度下生成2048词的平均推���速度以及显存使用。
|
167 |
+
|
168 |
+
We measured the average inference speed and GPU memory usage of generating 2048 tokens across several settings, including input lengths, quantization levels, versions of flash-attention, and whether vLLM is used.
|
169 |
+
|
170 |
+
| Quantization | Setting | # of A100-80G GPUs | Context Length | Generation Length | Speed (Tokens/s) | Total GPU Memory Usage |
|
171 |
+
| ------------- | :---------------: | :----------------: | :-------------: | :---------------: | :---------------:| :---------------------:|
|
172 |
+
| BF16 | HF + FlashAttn-v2 | 2 | 1 | 2048 | 8.48 | 144.69GB |
|
173 |
+
| BF16 | HF + FlashAttn-v1 | 2 | 1 | 2048 | 8.31 | 144.69GB |
|
174 |
+
| BF16 | HF + No FlashAttn | 2 | 1 | 2048 | 7.89 | 144.69GB |
|
175 |
+
| BF16 | vLLM | 2 | 1 | 2048 | 17.60 | Pre-Allocated* |
|
176 |
+
| BF16 | vLLM | 4 | 1 | 2048 | 26.16 | Pre-Allocated* |
|
177 |
+
| BF16 | HF + FlashAttn-v2 | 4 | 6144 | 2048 | 5.37 | 181.47GB |
|
178 |
+
| BF16 | HF + FlashAttn-v1 | 4 | 6144 | 2048 | 4.96 | 181.47GB |
|
179 |
+
| BF16 | HF + No FlashAttn | 4 | 6144 | 2048 | 4.72 | 202.74GB |
|
180 |
+
| BF16 | vLLM | 4 | 6144 | 2048 | 24.41 | Pre-Allocated* |
|
181 |
+
| BF16 | vLLM | 4 | 14336 | 2048 | 21.24 | Pre-Allocated* |
|
182 |
+
| BF16 | vLLM | 4 | 30720 | 2048 | 17.55 | Pre-Allocated* |
|
183 |
+
| Int8 | HF + FlashAttn-v2 | 2 | 1 | 2048 | 9.05 | 81.27GB |
|
184 |
+
| Int8 | HF + FlashAttn-v1 | 2 | 1 | 2048 | 8.97 | 81.27GB |
|
185 |
+
| Int8 | HF + No FlashAttn | 2 | 1 | 2048 | 8.32 | 81.27GB |
|
186 |
+
| Int8 | HF + FlashAttn-v2 | 3 | 6144 | 2048 | 5.76 | 118.06GB |
|
187 |
+
| Int8 | HF + FlashAttn-v1 | 3 | 6144 | 2048 | 5.72 | 118.06GB |
|
188 |
+
| Int8 | HF + No FlashAttn | 2 | 6144 | 2048 | 4.50 | 129.83GB |
|
189 |
+
| Int8 | HF + FlashAttn-v2 | 4 | 14336 | 2048 | 3.44 | 180.44GB |
|
190 |
+
| Int8 | HF + FlashAttn-v1 | 4 | 14336 | 2048 | 3.19 | 180.44GB |
|
191 |
+
| Int8 | HF + No FlashAttn | 4 | 14336 | 2048 | OOM | OOM |
|
192 |
+
| Int4 | HF + FlashAttn-v2 | 1 | 1 | 2048 | 11.67 | 48.86GB |
|
193 |
+
| Int4 | HF + FlashAttn-v1 | 1 | 1 | 2048 | 11.27 | 48.86GB |
|
194 |
+
| Int4 | HF + No FlashAttn | 1 | 1 | 2048 | 11.32 | 48.86GB |
|
195 |
+
| Int4 | HF + FlashAttn-v2 | 2 | 6144 | 2048 | 6.75 | 85.99GB |
|
196 |
+
| Int4 | HF + FlashAttn-v1 | 2 | 6144 | 2048 | 6.32 | 85.99GB |
|
197 |
+
| Int4 | HF + No FlashAttn | 2 | 6144 | 2048 | 5.97 | 88.30GB |
|
198 |
+
| Int4 | HF + FlashAttn-v2 | 3 | 14336 | 2048 | 4.18 | 85.99GB |
|
199 |
+
| Int4 | HF + FlashAttn-v1 | 3 | 14336 | 2048 | 3.72 | 85.99GB |
|
200 |
+
| Int4 | HF + No FlashAttn | 3 | 14336 | 2048 | OOM | OOM |
|
201 |
+
|
202 |
+
\* vLLM会提前预分配显存,因此无法探测最大显存使用情况。HF是指使用Huggingface Transformers库进行推理。
|
203 |
+
|
204 |
+
\* vLLM pre-allocates GPU memory, so we cannot detect the maximum usage. HF refers to using the Huggingface Transformers library for inference.
|
205 |
+
|
206 |
+
HuggingFace Transformers的性能测算使用[此脚本](https://qianwen-res.oss-cn-beijing.aliyuncs.com/profile.py)完成。评测使用A100-SXM4-80G GPU,使用PyTorch 2.0.1 (Huggingface Transformers) / PyTorch 2.1.0 (vLLM)和CUDA 11.8。
|
207 |
+
|
208 |
+
The speed and memory profiling of HuggingFace Transformers are conducted using [this script](https://qianwen-res.oss-cn-beijing.aliyuncs.com/profile.py). The profiling runs on A100-SXM4-80G GPUs with PyTorch 2.0.1 (for Huggingface Transformers) / PyTorch 2.1.0 (for vLLM) and CUDA 11.8.
|
209 |
+
<br>
|
210 |
+
|
211 |
+
## Tokenizer
|
212 |
+
|
213 |
+
> 注:作为术语的“tokenization”在中文中尚无共识的概念对应,本文档采用英文表达以利说明。
|
214 |
+
|
215 |
+
基于tiktoken的分词器有别于其他分词器,比如sentencepiece分词器。尤其在微调阶段,需要特别注意特殊token的使用。关于tokenizer的更多信息,以及微调时涉及的相关使用,请参阅[文档](https://github.com/QwenLM/Qwen/blob/main/tokenization_note_zh.md)。
|
216 |
+
|
217 |
+
Our tokenizer based on tiktoken is different from other tokenizers, e.g., sentencepiece tokenizer. You need to pay attention to special tokens, especially in finetuning. For more detailed information on the tokenizer and related use in fine-tuning, please refer to the [documentation](https://github.com/QwenLM/Qwen/blob/main/tokenization_note.md).
|
218 |
+
<br>
|
219 |
+
|
220 |
+
|
221 |
+
|
222 |
+
## 模型细节(Model)
|
223 |
+
|
224 |
+
与Qwen-72B预训练模型相同,Qwen-72B-Chat模型规模基本情况如下所示
|
225 |
+
|
226 |
+
The details of the model architecture of Qwen-72B-Chat are listed as follows
|
227 |
+
|
228 |
+
| Hyperparameter | Value |
|
229 |
+
|:----------------|:-------|
|
230 |
+
| n_layers | 80 |
|
231 |
+
| n_heads | 64 |
|
232 |
+
| d_model | 8192 |
|
233 |
+
| vocab size | 151851 |
|
234 |
+
| sequence length | 32768 |
|
235 |
+
|
236 |
+
在位置编码、FFN激活函数和normalization的实现方式上,我们也采用了目前最流行的做法,
|
237 |
+
即RoPE相对位置编码、SwiGLU激活函数、RMSNorm(可选安装flash-attention加速)。
|
238 |
+
|
239 |
+
在分词器方面,相比目前主流开源模型以中英词表为主,Qwen-72B-Chat使用了约15万token大小的词表。
|
240 |
+
该词表在GPT-4使用的BPE词表`cl100k_base`基础上,对中文、多语言进行了优化,在对中、英、代码数据的高效编解码的基础上,对部分多语言更加友好,方便用户在不扩展词表的情况下对部分语种进行能力增强。
|
241 |
+
词表对数字按单个数字位切分。调用较为高效的[tiktoken分词库](https://github.com/openai/tiktoken)进行分词。
|
242 |
+
|
243 |
+
For position encoding, FFN activation function, and normalization calculation methods, we adopt the prevalent practices, i.e., RoPE relative position encoding, SwiGLU for activation function, and RMSNorm for normalization (optional installation of flash-attention for acceleration).
|
244 |
+
|
245 |
+
For tokenization, compared to the current mainstream open-source models based on Chinese and English vocabularies, Qwen-72B-Chat uses a vocabulary of over 150K tokens.
|
246 |
+
It first considers efficient encoding of Chinese, English, and code data, and is also more friendly to multilingual languages, enabling users to directly enhance the capability of some languages without expanding the vocabulary.
|
247 |
+
It segments numbers by single digit, and calls the [tiktoken](https://github.com/openai/tiktoken) tokenizer library for efficient tokenization.
|
248 |
+
<br>
|
249 |
+
|
250 |
+
|
251 |
+
|
252 |
+
## 评测效果(Evaluation)
|
253 |
+
|
254 |
+
对于Qwen-72B-Chat模型,我们同样评测了常规的中文理解(C-Eval)、英文理解(MMLU)、代码(HumanEval)和数学(GSM8K)等权威任务,同时包含了长序列任务的评测结果。由于Qwen-72B-Chat模型经过对齐后,激发了较强的外部系统调用能力,我们还进行了工具使用能力方面的评测。
|
255 |
+
|
256 |
+
提示:由于硬件和框架造成的舍入误差,复现结果如有波动属于正常现象。
|
257 |
+
|
258 |
+
For Qwen-72B-Chat, we also evaluate the model on C-Eval, MMLU, HumanEval, GSM8K, etc., as well as the benchmark evaluation for long-context understanding, and tool usage.
|
259 |
+
|
260 |
+
Note: Due to rounding errors caused by hardware and framework, differences in reproduced results are possible.
|
261 |
+
|
262 |
+
### 中文评测(Chinese Evaluation)
|
263 |
+
|
264 |
+
#### C-Eval
|
265 |
+
|
266 |
+
在[C-Eval](https://arxiv.org/abs/2305.08322)验证集上,我们评价了Qwen-72B-Chat模型的0-shot & 5-shot准确率
|
267 |
+
|
268 |
+
We demonstrate the 0-shot & 5-shot accuracy of Qwen-72B-Chat on C-Eval validation set
|
269 |
+
|
270 |
+
| Model | Avg. Acc. |
|
271 |
+
|:--------------------------------:|:---------:|
|
272 |
+
| LLaMA2-7B-Chat | 31.9 |
|
273 |
+
| LLaMA2-13B-Chat | 36.2 |
|
274 |
+
| LLaMA2-70B-Chat | 44.3 |
|
275 |
+
| ChatGPT3.5 | 52.5 |
|
276 |
+
| ChatGPT4 | 69.9 |
|
277 |
+
| Yi-34B-Chat (0-shot) | 77.0 |
|
278 |
+
| Yi-34B-Chat (5-shot) | 78.5 |
|
279 |
+
| Qwen-7B-Chat (original) (0-shot) | 54.2 |
|
280 |
+
| **Qwen-7B-Chat (0-shot)** | 59.7 |
|
281 |
+
| **Qwen-7B-Chat (5-shot)** | 59.3 |
|
282 |
+
| **Qwen-14B-Chat (0-shot)** | 69.8 |
|
283 |
+
| **Qwen-14B-Chat (5-shot)** | 71.7 |
|
284 |
+
| **Qwen-72B-Chat (0-shot)** | 80.1 |
|
285 |
+
| **Qwen-72B-Chat (5-shot)** | 82.9 |
|
286 |
+
|
287 |
+
|
288 |
+
C-Eval测试集上,Qwen-72B-Chat模型的zero-shot准确率结果如下:
|
289 |
+
|
290 |
+
The zero-shot accuracy of Qwen-72B-Chat on C-Eval testing set is provided below:
|
291 |
+
|
292 |
+
| Model | Avg. | STEM | Social Sciences | Humanities | Others |
|
293 |
+
| :---------------------- | :------: | :--: | :-------------: | :--------: | :----: |
|
294 |
+
| Qwen-7B-Chat (original) | 54.6 | 47.8 | 67.6 | 59.3 | 50.6 |
|
295 |
+
| **Qwen-7B-Chat** | 58.6 | 53.3 | 72.1 | 62.8 | 52.0 |
|
296 |
+
| **Qwen-14B-Chat** | 69.1 | 65.1 | 80.9 | 71.2 | 63.4 |
|
297 |
+
| **Qwen-72B-Chat** | 79.5 | 74.5 | 89.1 | 81.2 | 78.1 |
|
298 |
+
|
299 |
+
### 英文评测(English Evaluation)
|
300 |
+
|
301 |
+
#### MMLU
|
302 |
+
|
303 |
+
[MMLU](https://arxiv.org/abs/2009.03300)评测集上,Qwen-7B-Chat模型的 0-shot & 5-shot 准确率如下,效果同样在同类对齐模型中同样表现较优。
|
304 |
+
|
305 |
+
The 0-shot & 5-shot accuracy of Qwen-72B-Chat on MMLU is provided below.
|
306 |
+
The performance of Qwen-72B-Chat still on the top between other human-aligned models with comparable size.
|
307 |
+
|
308 |
+
| Model | Avg. Acc. |
|
309 |
+
|:--------------------------------:|:---------:|
|
310 |
+
| LLaMA2-7B-Chat | 46.2 |
|
311 |
+
| LLaMA2-13B-Chat | 54.6 |
|
312 |
+
| LLaMA2-70B-Chat | 63.8 |
|
313 |
+
| Yi-34B-Chat (0-shot) | 67.6 |
|
314 |
+
| Yi-34B-Chat (5-shot) | 73.4 |
|
315 |
+
| ChatGPT3.5 | 69.1 |
|
316 |
+
| ChatGPT4 | 83.0 |
|
317 |
+
| Qwen-7B-Chat (original) (0-shot) | 53.9 |
|
318 |
+
| **Qwen-7B-Chat (0-shot)** | 55.8 |
|
319 |
+
| **Qwen-7B-Chat (5-shot)** | 57.0 |
|
320 |
+
| **Qwen-14B-Chat (0-shot)** | 64.6 |
|
321 |
+
| **Qwen-14B-Chat (5-shot)** | 66.5 |
|
322 |
+
| **Qwen-72B-Chat (0-shot)** | 74.3 |
|
323 |
+
| **Qwen-72B-Chat (5-shot)** | 75.0 |
|
324 |
+
|
325 |
+
### 代码评测(Coding Evaluation)
|
326 |
+
|
327 |
+
Qwen-72B-Chat在[HumanEval](https://github.com/openai/human-eval)的zero-shot Pass@1效果如下
|
328 |
+
|
329 |
+
The zero-shot Pass@1 of Qwen-72B-Chat on [HumanEval](https://github.com/openai/human-eval) is demonstrated below
|
330 |
+
|
331 |
+
| Model | Pass@1 |
|
332 |
+
|:-----------------------:|:--------:|
|
333 |
+
| LLaMA2-7B-Chat | 12.2 |
|
334 |
+
| LLaMA2-13B-Chat | 18.9 |
|
335 |
+
| LLaMA2-70B-Chat | 32.3 |
|
336 |
+
| Yi-34B-Chat | 33.5 |
|
337 |
+
| ChatGPT3.5 | 73.2 |
|
338 |
+
| ChatGPT4 | 86.6 |
|
339 |
+
| Qwen-7B-Chat (original) | 24.4 |
|
340 |
+
| **Qwen-7B-Chat** | 37.2 |
|
341 |
+
| **Qwen-14B-Chat** | 43.9 |
|
342 |
+
| **Qwen-72B-Chat** | 64.6 |
|
343 |
+
|
344 |
+
### 数学评测(Mathematics Evaluation)
|
345 |
+
|
346 |
+
在评测数学能力的[GSM8K](https://github.com/openai/grade-school-math)上,Qwen-72B-Chat的准确率结果如下
|
347 |
+
|
348 |
+
The accuracy of Qwen-72B-Chat on GSM8K is shown below
|
349 |
+
|
350 |
+
| Model | Acc. |
|
351 |
+
|:--------------------------------:|:--------:|
|
352 |
+
| LLaMA2-7B-Chat | 26.3 |
|
353 |
+
| LLaMA2-13B-Chat | 37.1 |
|
354 |
+
| LLaMA2-70B-Chat | 59.3 |
|
355 |
+
| Yi-34B-Chat | 71.6 |
|
356 |
+
| ChatGPT3.5 | 73.2 |
|
357 |
+
| ChatGPT4 | 91.4 |
|
358 |
+
| Qwen-7B-Chat (original) (0-shot) | 41.1 |
|
359 |
+
| **Qwen-7B-Chat (0-shot)** | 50.3 |
|
360 |
+
| **Qwen-7B-Chat (8-shot)** | 54.1 |
|
361 |
+
| **Qwen-14B-Chat (0-shot)** | 60.1 |
|
362 |
+
| **Qwen-14B-Chat (8-shot)** | 59.3 |
|
363 |
+
| **Qwen-72B-Chat (0-shot)** | 76.4 |
|
364 |
+
| **Qwen-72B-Chat (8-shot)** | 75.7 |
|
365 |
+
|
366 |
+
### 长序列评测(Long-Context Understanding)
|
367 |
+
|
368 |
+
Qwen-72B-Chat支持最长32k的上下文长度,在[L-Eval](https://arxiv.org/abs/2307.11088)客观题的评分结果如下:
|
369 |
+
|
370 |
+
Qwen-72B-Chat supports context lengths of up to 32k. The scores of [L-Eval](https://arxiv.org/abs/2307.11088) (closed-ended tasks) are as follows:
|
371 |
+
|
372 |
+
| Model | Average | Coursera | GSM | QuALITY | TOEFL | CodeU | SFcition |
|
373 |
+
|:------------------|:----------:|:----------:|:----------:|:----------:|:----------:|:----------:|:----------:|
|
374 |
+
| ChatGPT-3.5-16k | 60.73 | **63.51** | **84.00** | 61.38 | 78.43 | **12.22** | 64.84 |
|
375 |
+
| **Qwen-72B-Chat** | **62.30** | 58.13 | 76.00 | **77.22** | **86.24** | 6.66 | **69.53** |
|
376 |
+
|
377 |
+
|
378 |
+
我们进一步进行了“大海捞针”实验(想法来自于[@Greg Kamradt](https://twitter.com/GregKamradt/status/1727018183608193393)),测试模型在不同长度的输入下,是否能检索到文章不同位置的信息,结果如下:
|
379 |
+
|
380 |
+
We conducted the "needle in a haystack" experiment (the idea came from [@Greg Kamradt](https://twitter.com/GregKamradt/status/1727018183608193393)) to test whether the model can retrieve information at different positions in the inputs of different lengths, the result is as follows:
|
381 |
+
|
382 |
+
![](assets/qwen_72b_needle_in_a_haystack.png)
|
383 |
+
|
384 |
+
以上结果说明,Qwen-72B-Chat可以能准确检索到32k以内的输入长度中放在各种位置的信息,证明了其具有优秀的长文本处理能力。
|
385 |
+
|
386 |
+
The above results show that Qwen-72B-Chat can accurately retrieve information placed in various positions within an input length of 32k, proving its excellent long text understanding capabilities.
|
387 |
+
|
388 |
+
## FAQ
|
389 |
+
|
390 |
+
如遇到问题,敬请查阅[FAQ](https://github.com/QwenLM/Qwen/blob/main/FAQ_zh.md)以及issue区,如仍无法解决再提交issue。
|
391 |
+
|
392 |
+
If you meet problems, please refer to [FAQ](https://github.com/QwenLM/Qwen/blob/main/FAQ.md) and the issues first to search a solution before you launch a new issue.
|
393 |
+
<br>
|
394 |
+
|
395 |
+
## 引用 (Citation)
|
396 |
+
|
397 |
+
如果你觉得我们的工作对你有帮助,欢迎引用!
|
398 |
+
|
399 |
+
If you find our work helpful, feel free to give us a cite.
|
400 |
+
|
401 |
+
```
|
402 |
+
@article{qwen,
|
403 |
+
title={Qwen Technical Report},
|
404 |
+
author={Jinze Bai and Shuai Bai and Yunfei Chu and Zeyu Cui and Kai Dang and Xiaodong Deng and Yang Fan and Wenbin Ge and Yu Han and Fei Huang and Binyuan Hui and Luo Ji and Mei Li and Junyang Lin and Runji Lin and Dayiheng Liu and Gao Liu and Chengqiang Lu and Keming Lu and Jianxin Ma and Rui Men and Xingzhang Ren and Xuancheng Ren and Chuanqi Tan and Sinan Tan and Jianhong Tu and Peng Wang and Shijie Wang and Wei Wang and Shengguang Wu and Benfeng Xu and Jin Xu and An Yang and Hao Yang and Jian Yang and Shusheng Yang and Yang Yao and Bowen Yu and Hongyi Yuan and Zheng Yuan and Jianwei Zhang and Xingxuan Zhang and Yichang Zhang and Zhenru Zhang and Chang Zhou and Jingren Zhou and Xiaohuan Zhou and Tianhang Zhu},
|
405 |
+
journal={arXiv preprint arXiv:2309.16609},
|
406 |
+
year={2023}
|
407 |
+
}
|
408 |
+
```
|
409 |
+
<br>
|
410 |
+
|
411 |
+
## 使用协议(License Agreement)
|
412 |
+
|
413 |
+
我们的代码和模型权重对学术研究完全开放,并支持商用。请查看[LICENSE](https://github.com/QwenLM/Qwen/blob/main/Tongyi%20Qianwen%20LICENSE%20AGREEMENT)了解具体的开源协议细节。如需商用,请填写[问卷](https://dashscope.console.aliyun.com/openModelApply/Qwen-72B-Chat)申请。
|
414 |
+
|
415 |
+
Our code and checkpoints are open to research purpose, and they are allowed for commercial purposes. Check [LICENSE](https://github.com/QwenLM/Qwen/blob/main/Tongyi%20Qianwen%20LICENSE%20AGREEMENT) for more details about the license. If you have requirements for commercial use, please fill out the [form](https://dashscope.console.aliyun.com/openModelApply/Qwen-72B-Chat) to apply.
|
416 |
+
<br>
|
417 |
+
|
418 |
+
|
419 |
+
|
420 |
+
## 联系我们(Contact Us)
|
421 |
+
|
422 |
+
如果你想给我们的研发团队和产品团队留言,欢迎加入我们的微信群、钉钉群以及Discord!同时,也欢迎通过邮件(qianwen_opensource@alibabacloud.com)联系我们。
|
423 |
+
|
424 |
+
If you are interested to leave a message to either our research team or product team, join our Discord or WeChat groups! Also, feel free to send an email to qianwen_opensource@alibabacloud.com.
|
425 |
+
|
assets/logo.jpg
ADDED
assets/qwen_72b_needle_in_a_haystack.png
ADDED
assets/wechat.png
ADDED
modeling_qwen.py
CHANGED
@@ -937,11 +937,6 @@ class QWenLMHeadModel(QWenPreTrainedModel):
|
|
937 |
assert (
|
938 |
config.bf16 + config.fp16 + config.fp32 <= 1
|
939 |
), "Only one of \"bf16\", \"fp16\", \"fp32\" can be true"
|
940 |
-
logger.warn(
|
941 |
-
"Warning: please make sure that you are using the latest codes and checkpoints, "
|
942 |
-
"especially if you used Qwen-7B before 09.25.2023."
|
943 |
-
"请使用最新模型和代码,尤其如果你在9月25日前已经开始使用Qwen-7B,千万注意不要使用错误代码和模型。"
|
944 |
-
)
|
945 |
|
946 |
autoset_precision = config.bf16 + config.fp16 + config.fp32 == 0
|
947 |
|
|
|
937 |
assert (
|
938 |
config.bf16 + config.fp16 + config.fp32 <= 1
|
939 |
), "Only one of \"bf16\", \"fp16\", \"fp32\" can be true"
|
|
|
|
|
|
|
|
|
|
|
940 |
|
941 |
autoset_precision = config.bf16 + config.fp16 + config.fp32 == 0
|
942 |
|