Commit
·
3a9e452
verified
·
0
Parent(s):
Duplicate from tencent/HunyuanImage-2.1
Browse filesCo-authored-by: TencentOpen <[email protected]>
- .gitattributes +36 -0
- LICENSE +77 -0
- NOTICE +173 -0
- README.md +279 -0
- README_CN.md +251 -0
- assets/comparison.png +3 -0
- assets/demo.png +3 -0
- assets/framework_overall.png +3 -0
- assets/framework_prompt_rewrite.png +3 -0
- assets/gsb.png +3 -0
- assets/logo.png +3 -0
- assets/reprompt.png +3 -0
- assets/show_cases.png +3 -0
- checkpoints-download.md +74 -0
- config.json +3 -0
- dit/hunyuanimage-refiner.safetensors +3 -0
- dit/hunyuanimage2.1-distilled.safetensors +3 -0
- dit/hunyuanimage2.1.safetensors +3 -0
- reprompt/chat_template.jinja +144 -0
- reprompt/config.json +60 -0
- reprompt/generation_config.json +13 -0
- reprompt/hy.tiktoken +0 -0
- reprompt/model-00001-of-00004.safetensors +3 -0
- reprompt/model-00002-of-00004.safetensors +3 -0
- reprompt/model-00003-of-00004.safetensors +3 -0
- reprompt/model-00004-of-00004.safetensors +3 -0
- reprompt/model.safetensors.index.json +362 -0
- reprompt/special_tokens_map.json +12 -0
- reprompt/tokenization_hy.py +298 -0
- reprompt/tokenizer_config.json +29 -0
- vae/vae_2_1/config.json +21 -0
- vae/vae_2_1/pytorch_model.ckpt +3 -0
- vae/vae_refiner/config.json +23 -0
- vae/vae_refiner/pytorch_model.pt +3 -0
.gitattributes
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
*.png filter=lfs diff=lfs merge=lfs -text
|
LICENSE
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
TENCENT HUNYUAN COMMUNITY LICENSE AGREEMENT
|
2 |
+
Tencent HunyuanImage 2.1 Release Date: September 8, 2025
|
3 |
+
THIS LICENSE AGREEMENT DOES NOT APPLY IN THE EUROPEAN UNION, UNITED KINGDOM AND SOUTH KOREA AND IS EXPRESSLY LIMITED TO THE TERRITORY, AS DEFINED BELOW.
|
4 |
+
By clicking to agree or by using, reproducing, modifying, distributing, performing or displaying any portion or element of the Tencent Hunyuan Works, including via any Hosted Service, You will be deemed to have recognized and accepted the content of this Agreement, which is effective immediately.
|
5 |
+
1. DEFINITIONS.
|
6 |
+
a. “Acceptable Use Policy” shall mean the policy made available by Tencent as set forth in the Exhibit A.
|
7 |
+
b. “Agreement” shall mean the terms and conditions for use, reproduction, distribution, modification, performance and displaying of Tencent Hunyuan Works or any portion or element thereof set forth herein.
|
8 |
+
c. “Documentation” shall mean the specifications, manuals and documentation for Tencent Hunyuan made publicly available by Tencent.
|
9 |
+
d. “Hosted Service” shall mean a hosted service offered via an application programming interface (API), web access, or any other electronic or remote means.
|
10 |
+
e. “Licensee,” “You” or “Your” shall mean a natural person or legal entity exercising the rights granted by this Agreement and/or using the Tencent Hunyuan Works for any purpose and in any field of use.
|
11 |
+
f. “Materials” shall mean, collectively, Tencent’s proprietary Tencent Hunyuan and Documentation (and any portion thereof) as made available by Tencent under this Agreement.
|
12 |
+
g. “Model Derivatives” shall mean all: (i) modifications to Tencent Hunyuan or any Model Derivative of Tencent Hunyuan; (ii) works based on Tencent Hunyuan or any Model Derivative of Tencent Hunyuan; or (iii) any other machine learning model which is created by transfer of patterns of the weights, parameters, operations, or Output of Tencent Hunyuan or any Model Derivative of Tencent Hunyuan, to that model in order to cause that model to perform similarly to Tencent Hunyuan or a Model Derivative of Tencent Hunyuan, including distillation methods, methods that use intermediate data representations, or methods based on the generation of synthetic data Outputs by Tencent Hunyuan or a Model Derivative of Tencent Hunyuan for training that model. For clarity, Outputs by themselves are not deemed Model Derivatives.
|
13 |
+
h. “Output” shall mean the information and/or content output of Tencent Hunyuan or a Model Derivative that results from operating or otherwise using Tencent Hunyuan or a Model Derivative, including via a Hosted Service.
|
14 |
+
i. “Tencent,” “We” or “Us” shall mean the applicable entity or entities in the Tencent corporate family that own(s) intellectual property or other rights embodied in or utilized by the Materials.
|
15 |
+
j. “Tencent Hunyuan” shall mean the large language models, text/image/video/audio/3D generation models, and multimodal large language models and their software and algorithms, including 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 made publicly available by Us, including, without limitation to, Tencent HunyuanImage 2.1 released at [https://github.com/Tencent-Hunyuan/HunyuanImage-2.1/blob/master/LICENSE;https://huggingface.co/tencent/HunyuanImage-2.1/blob/main/LICENSE].
|
16 |
+
k. “Tencent Hunyuan Works” shall mean: (i) the Materials; (ii) Model Derivatives; and (iii) all derivative works thereof.
|
17 |
+
l. “Territory” shall mean the worldwide territory, excluding the territory of the European Union, United Kingdom and South Korea.
|
18 |
+
m. “Third Party” or “Third Parties” shall mean individuals or legal entities that are not under common control with Us or You.
|
19 |
+
n. “including” shall mean including but not limited to.
|
20 |
+
2. GRANT OF RIGHTS.
|
21 |
+
We grant You, for the Territory only, a non-exclusive, non-transferable and royalty-free limited license under Tencent’s intellectual property or other rights owned by Us embodied in or utilized by the Materials to use, reproduce, distribute, create derivative works of (including Model Derivatives), and make modifications to the Materials, only in accordance with the terms of this Agreement and the Acceptable Use Policy, and You must not violate (or encourage or permit anyone else to violate) any term of this Agreement or the Acceptable Use Policy.
|
22 |
+
3. DISTRIBUTION.
|
23 |
+
You may, subject to Your compliance with this Agreement, distribute or make available to Third Parties the Tencent Hunyuan Works, exclusively in the Territory, provided that You meet all of the following conditions:
|
24 |
+
a. You must provide all such Third Party recipients of the Tencent Hunyuan Works or products or services using them a copy of this Agreement;
|
25 |
+
b. You must cause any modified files to carry prominent notices stating that You changed the files;
|
26 |
+
c. You are encouraged to: (i) publish at least one technology introduction blogpost or one public statement expressing Your experience of using the Tencent Hunyuan Works; and (ii) mark the products or services developed by using the Tencent Hunyuan Works to indicate that the product/service is “Powered by Tencent Hunyuan”; and
|
27 |
+
d. All distributions to Third Parties (other than through a Hosted Service) must be accompanied by a “Notice” text file that contains the following notice: “Tencent Hunyuan is licensed under the Tencent Hunyuan Community License Agreement, Copyright © 2025 Tencent. All Rights Reserved. The trademark rights of “Tencent Hunyuan” are owned by Tencent or its affiliate.”
|
28 |
+
You may add Your own copyright statement to Your modifications and, except as set forth in this Section and in Section 5, may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Model Derivatives as a whole, provided Your use, reproduction, modification, distribution, performance and display of the work otherwise complies with the terms and conditions of this Agreement (including as regards the Territory). If You receive Tencent Hunyuan Works from a Licensee as part of an integrated end user product, then this Section 3 of this Agreement will not apply to You.
|
29 |
+
4. ADDITIONAL COMMERCIAL TERMS.
|
30 |
+
If, on the Tencent Hunyuan version release date, the monthly active users of all products or services made available by or for Licensee is greater than 100 million monthly active users in the preceding calendar month, You must request a license from Tencent, which Tencent may grant to You in its sole discretion, and You are not authorized to exercise any of the rights under this Agreement unless or until Tencent otherwise expressly grants You such rights.
|
31 |
+
5. RULES OF USE.
|
32 |
+
a. Your use of the Tencent Hunyuan Works must comply with applicable laws and regulations (including trade compliance laws and regulations) and adhere to the Acceptable Use Policy for the Tencent Hunyuan Works, which is hereby incorporated by reference into this Agreement. You must include the use restrictions referenced in these Sections 5(a) and 5(b) as an enforceable provision in any agreement (e.g., license agreement, terms of use, etc.) governing the use and/or distribution of Tencent Hunyuan Works and You must provide notice to subsequent users to whom You distribute that Tencent Hunyuan Works are subject to the use restrictions in these Sections 5(a) and 5(b).
|
33 |
+
b. You must not use the Tencent Hunyuan Works or any Output or results of the Tencent Hunyuan Works to improve any other AI model (other than Tencent Hunyuan or Model Derivatives thereof).
|
34 |
+
c. You must not use, reproduce, modify, distribute, or display the Tencent Hunyuan Works, Output or results of the Tencent Hunyuan Works outside the Territory. Any such use outside the Territory is unlicensed and unauthorized under this Agreement.
|
35 |
+
6. INTELLECTUAL PROPERTY.
|
36 |
+
a. Subject to Tencent’s ownership of Tencent Hunyuan Works made by or for Tencent and intellectual property rights therein, conditioned upon Your compliance with the terms and conditions of this Agreement, as between You and Tencent, You will be the owner of any derivative works and modifications of the Materials and any Model Derivatives that are made by or for You.
|
37 |
+
b. No trademark licenses are granted under this Agreement, and in connection with the Tencent Hunyuan Works, Licensee may not use any name or mark owned by or associated with Tencent or any of its affiliates, except as required for reasonable and customary use in describing and distributing the Tencent Hunyuan Works. Tencent hereby grants You a license to use “Tencent Hunyuan” (the “Mark”) in the Territory solely as required to comply with the provisions of Section 3(c), provided that You comply with any applicable laws related to trademark protection. All goodwill arising out of Your use of the Mark will inure to the benefit of Tencent.
|
38 |
+
c. If You commence a lawsuit or other proceedings (including a cross-claim or counterclaim in a lawsuit) against Us or any person or entity alleging that the Materials or any Output, or any portion of any of the foregoing, infringe any intellectual property or other right owned or licensable by You, then all licenses granted to You under this Agreement shall terminate as of the date such lawsuit or other proceeding is filed. You will defend, indemnify and hold harmless Us from and against any claim by any Third Party arising out of or related to Your or the Third Party’s use or distribution of the Tencent Hunyuan Works.
|
39 |
+
d. Tencent claims no rights in Outputs You generate. You and Your users are solely responsible for Outputs and their subsequent uses.
|
40 |
+
7. DISCLAIMERS OF WARRANTY AND LIMITATIONS OF LIABILITY.
|
41 |
+
a. We are not obligated to support, update, provide training for, or develop any further version of the Tencent Hunyuan Works or to grant any license thereto.
|
42 |
+
b. UNLESS AND ONLY TO THE EXTENT REQUIRED BY APPLICABLE LAW, THE TENCENT HUNYUAN WORKS AND ANY OUTPUT AND RESULTS THEREFROM ARE PROVIDED “AS IS” WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES OF ANY KIND INCLUDING ANY WARRANTIES OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, COURSE OF DEALING, USAGE OF TRADE, OR FITNESS FOR A PARTICULAR PURPOSE. YOU ARE SOLELY RESPONSIBLE FOR DETERMINING THE APPROPRIATENESS OF USING, REPRODUCING, MODIFYING, PERFORMING, DISPLAYING OR DISTRIBUTING ANY OF THE TENCENT HUNYUAN WORKS OR OUTPUTS AND ASSUME ANY AND ALL RISKS ASSOCIATED WITH YOUR OR A THIRD PARTY’S USE OR DISTRIBUTION OF ANY OF THE TENCENT HUNYUAN WORKS OR OUTPUTS AND YOUR EXERCISE OF RIGHTS AND PERMISSIONS UNDER THIS AGREEMENT.
|
43 |
+
c. TO THE FULLEST EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL TENCENT OR ITS AFFILIATES BE LIABLE UNDER ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, TORT, NEGLIGENCE, PRODUCTS LIABILITY, OR OTHERWISE, FOR ANY DAMAGES, INCLUDING ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL, EXEMPLARY, CONSEQUENTIAL OR PUNITIVE DAMAGES, OR LOST PROFITS OF ANY KIND ARISING FROM THIS AGREEMENT OR RELATED TO ANY OF THE TENCENT HUNYUAN WORKS OR OUTPUTS, EVEN IF TENCENT OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF ANY OF THE FOREGOING.
|
44 |
+
8. SURVIVAL AND TERMINATION.
|
45 |
+
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.
|
46 |
+
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 promptly delete and cease use of the Tencent Hunyuan Works. Sections 6(a), 6(c), 7 and 9 shall survive the termination of this Agreement.
|
47 |
+
9. GOVERNING LAW AND JURISDICTION.
|
48 |
+
a. This Agreement and any dispute arising out of or relating to it will be governed by the laws of the Hong Kong Special Administrative Region of the People’s Republic 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.
|
49 |
+
b. Exclusive jurisdiction and venue for any dispute arising out of or relating to this Agreement will be a court of competent jurisdiction in the Hong Kong Special Administrative Region of the People’s Republic of China, and Tencent and Licensee consent to the exclusive jurisdiction of such court with respect to any such dispute.
|
50 |
+
|
51 |
+
EXHIBIT A
|
52 |
+
ACCEPTABLE USE POLICY
|
53 |
+
|
54 |
+
Tencent reserves the right to update this Acceptable Use Policy from time to time.
|
55 |
+
Last modified: November 5, 2024
|
56 |
+
|
57 |
+
Tencent endeavors to promote safe and fair use of its tools and features, including Tencent Hunyuan. You agree not to use Tencent Hunyuan or Model Derivatives:
|
58 |
+
1. Outside the Territory;
|
59 |
+
2. In any way that violates any applicable national, federal, state, local, international or any other law or regulation;
|
60 |
+
3. To harm Yourself or others;
|
61 |
+
4. To repurpose or distribute output from Tencent Hunyuan or any Model Derivatives to harm Yourself or others;
|
62 |
+
5. To override or circumvent the safety guardrails and safeguards We have put in place;
|
63 |
+
6. For the purpose of exploiting, harming or attempting to exploit or harm minors in any way;
|
64 |
+
7. To generate or disseminate verifiably false information and/or content with the purpose of harming others or influencing elections;
|
65 |
+
8. To generate or facilitate false online engagement, including fake reviews and other means of fake online engagement;
|
66 |
+
9. To intentionally defame, disparage or otherwise harass others;
|
67 |
+
10. To generate and/or disseminate malware (including ransomware) or any other content to be used for the purpose of harming electronic systems;
|
68 |
+
11. To generate or disseminate personal identifiable information with the purpose of harming others;
|
69 |
+
12. To generate or disseminate information (including images, code, posts, articles), and place the information in any public context (including –through the use of bot generated tweets), without expressly and conspicuously identifying that the information and/or content is machine generated;
|
70 |
+
13. To impersonate another individual without consent, authorization, or legal right;
|
71 |
+
14. To make high-stakes automated decisions in domains that affect an individual’s safety, rights or wellbeing (e.g., law enforcement, migration, medicine/health, management of critical infrastructure, safety components of products, essential services, credit, employment, housing, education, social scoring, or insurance);
|
72 |
+
15. In a manner that violates or disrespects the social ethics and moral standards of other countries or regions;
|
73 |
+
16. To perform, facilitate, threaten, incite, plan, promote or encourage violent extremism or terrorism;
|
74 |
+
17. For any use intended to discriminate against or harm individuals or groups based on protected characteristics or categories, online or offline social behavior or known or predicted personal or personality characteristics;
|
75 |
+
18. To intentionally exploit any of the vulnerabilities of a specific group of persons based on their age, social, physical or mental characteristics, in order to materially distort the behavior of a person pertaining to that group in a manner that causes or is likely to cause that person or another person physical or psychological harm;
|
76 |
+
19. For military purposes;
|
77 |
+
20. To engage in the unauthorized or unlicensed practice of any profession including, but not limited to, financial, legal, medical/health, or other professional practices.
|
NOTICE
ADDED
@@ -0,0 +1,173 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Usage and Legal Notices:
|
2 |
+
|
3 |
+
Tencent is pleased to support the open source community by making Tencent HunyuanImage 2.1 available.
|
4 |
+
|
5 |
+
Copyright (C) 2025 Tencent. All rights reserved. The below model in this distribution may have been modified by Tencent ("Tencent Modifications"). All Tencent Modifications are Copyright (C) Tencent.
|
6 |
+
|
7 |
+
Tencent HunyuanImage 2.1 is licensed under Tencent Hunyuan Community License Agreement, which can be found in this repository called "LICENSE", except for the third-party components listed below. Tencent HunyuanImage 2.1 does not impose any additional limitations beyond what is outlined in the respective licenses of these third-party components. Users must comply with all terms and conditions of original licenses of these third-party components and must ensure that the usage of the third party components adheres to all relevant laws and regulations.
|
8 |
+
|
9 |
+
For avoidance of doubts, Tencent HunyuanImage 2.1 means the large language models and their software and algorithms, including 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 made publicly available by Tencent in accordance with the Tencent Hunyuan Community License Agreement.
|
10 |
+
|
11 |
+
|
12 |
+
|
13 |
+
Other dependencies and licenses:
|
14 |
+
|
15 |
+
Open Source Software Licensed under the Apache License Version 2.0:
|
16 |
+
The below software in this distribution may have been modified by Tencent.
|
17 |
+
--------------------------------------------------------------------
|
18 |
+
1. Glyph-ByT5
|
19 |
+
Copyright (c) Glyph-ByT5 and its authors.
|
20 |
+
Please find the original component at following site: https://github.com/AIGText/Glyph-ByT5
|
21 |
+
|
22 |
+
|
23 |
+
Terms of the Apache License Version 2.0:
|
24 |
+
--------------------------------------------------------------------
|
25 |
+
Apache License
|
26 |
+
|
27 |
+
Version 2.0, January 2004
|
28 |
+
|
29 |
+
http://www.apache.org/licenses/
|
30 |
+
|
31 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
32 |
+
1. Definitions.
|
33 |
+
|
34 |
+
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
35 |
+
|
36 |
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
37 |
+
|
38 |
+
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
39 |
+
|
40 |
+
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
41 |
+
|
42 |
+
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
43 |
+
|
44 |
+
"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, and conversions to other media types.
|
45 |
+
|
46 |
+
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
47 |
+
|
48 |
+
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
49 |
+
|
50 |
+
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
51 |
+
|
52 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
53 |
+
|
54 |
+
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
55 |
+
|
56 |
+
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
57 |
+
|
58 |
+
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
59 |
+
|
60 |
+
You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
61 |
+
|
62 |
+
You must cause any modified files to carry prominent notices stating that You changed the files; and
|
63 |
+
|
64 |
+
You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
65 |
+
|
66 |
+
If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
67 |
+
|
68 |
+
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 conditions stated in this License.
|
69 |
+
|
70 |
+
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
71 |
+
|
72 |
+
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
73 |
+
|
74 |
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
75 |
+
|
76 |
+
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
77 |
+
|
78 |
+
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
79 |
+
|
80 |
+
END OF TERMS AND CONDITIONS
|
81 |
+
|
82 |
+
--------------------------------------------------------------------
|
83 |
+
|
84 |
+
Open Source Software Licensed under the TENCENT HUNYUAN COMMUNITY LICENSE AGREEMENT and Other Licenses of the Third-Party Components therein:
|
85 |
+
The below software in this distribution may have been modified by Tencent ("Tencent Modifications"). All Tencent Modifications are Copyright (C) 2025 Tencent.
|
86 |
+
|
87 |
+
--------------------------------------------------------------------
|
88 |
+
1. HunyuanVideo
|
89 |
+
Copyright (C) 2024 THL A29 Limited, a Tencent company. All rights reserved.
|
90 |
+
|
91 |
+
|
92 |
+
Terms of the TENCENT HUNYUAN COMMUNITY LICENSE AGREEMENT:
|
93 |
+
--------------------------------------------------------------------
|
94 |
+
TENCENT HUNYUAN COMMUNITY LICENSE AGREEMENT
|
95 |
+
Tencent HunyuanVideo Release Date: December 3, 2024
|
96 |
+
THIS LICENSE AGREEMENT DOES NOT APPLY IN THE EUROPEAN UNION, UNITED KINGDOM AND SOUTH KOREA AND IS EXPRESSLY LIMITED TO THE TERRITORY, AS DEFINED BELOW.
|
97 |
+
By clicking to agree or by using, reproducing, modifying, distributing, performing or displaying any portion or element of the Tencent Hunyuan Works, including via any Hosted Service, You will be deemed to have recognized and accepted the content of this Agreement, which is effective immediately.
|
98 |
+
1. DEFINITIONS.
|
99 |
+
a. “Acceptable Use Policy” shall mean the policy made available by Tencent as set forth in the Exhibit A.
|
100 |
+
b. “Agreement” shall mean the terms and conditions for use, reproduction, distribution, modification, performance and displaying of Tencent Hunyuan Works or any portion or element thereof set forth herein.
|
101 |
+
c. “Documentation” shall mean the specifications, manuals and documentation for Tencent Hunyuan made publicly available by Tencent.
|
102 |
+
d. “Hosted Service” shall mean a hosted service offered via an application programming interface (API), web access, or any other electronic or remote means.
|
103 |
+
e. “Licensee,” “You” or “Your” shall mean a natural person or legal entity exercising the rights granted by this Agreement and/or using the Tencent Hunyuan Works for any purpose and in any field of use.
|
104 |
+
f. “Materials” shall mean, collectively, Tencent’s proprietary Tencent Hunyuan and Documentation (and any portion thereof) as made available by Tencent under this Agreement.
|
105 |
+
g. “Model Derivatives” shall mean all: (i) modifications to Tencent Hunyuan or any Model Derivative of Tencent Hunyuan; (ii) works based on Tencent Hunyuan or any Model Derivative of Tencent Hunyuan; or (iii) any other machine learning model which is created by transfer of patterns of the weights, parameters, operations, or Output of Tencent Hunyuan or any Model Derivative of Tencent Hunyuan, to that model in order to cause that model to perform similarly to Tencent Hunyuan or a Model Derivative of Tencent Hunyuan, including distillation methods, methods that use intermediate data representations, or methods based on the generation of synthetic data Outputs by Tencent Hunyuan or a Model Derivative of Tencent Hunyuan for training that model. For clarity, Outputs by themselves are not deemed Model Derivatives.
|
106 |
+
h. “Output” shall mean the information and/or content output of Tencent Hunyuan or a Model Derivative that results from operating or otherwise using Tencent Hunyuan or a Model Derivative, including via a Hosted Service.
|
107 |
+
i. “Tencent,” “We” or “Us” shall mean THL A29 Limited.
|
108 |
+
j. “Tencent Hunyuan” shall mean the large language models, text/image/video/audio/3D generation models, and multimodal large language models and their software and algorithms, including 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 made publicly available by Us, including, without limitation to, Tencent HunyuanVideo released at [https://github.com/Tencent/HunyuanVideo].
|
109 |
+
k. “Tencent Hunyuan Works” shall mean: (i) the Materials; (ii) Model Derivatives; and (iii) all derivative works thereof.
|
110 |
+
l. “Territory” shall mean the worldwide territory, excluding the territory of the European Union, United Kingdom and South Korea.
|
111 |
+
m. “Third Party” or “Third Parties” shall mean individuals or legal entities that are not under common control with Us or You.
|
112 |
+
n. “including” shall mean including but not limited to.
|
113 |
+
2. GRANT OF RIGHTS.
|
114 |
+
We grant You, for the Territory only, a non-exclusive, non-transferable and royalty-free limited license under Tencent’s intellectual property or other rights owned by Us embodied in or utilized by the Materials to use, reproduce, distribute, create derivative works of (including Model Derivatives), and make modifications to the Materials, only in accordance with the terms of this Agreement and the Acceptable Use Policy, and You must not violate (or encourage or permit anyone else to violate) any term of this Agreement or the Acceptable Use Policy.
|
115 |
+
3. DISTRIBUTION.
|
116 |
+
You may, subject to Your compliance with this Agreement, distribute or make available to Third Parties the Tencent Hunyuan Works, exclusively in the Territory, provided that You meet all of the following conditions:
|
117 |
+
a. You must provide all such Third Party recipients of the Tencent Hunyuan Works or products or services using them a copy of this Agreement;
|
118 |
+
b. You must cause any modified files to carry prominent notices stating that You changed the files;
|
119 |
+
c. You are encouraged to: (i) publish at least one technology introduction blogpost or one public statement expressing Your experience of using the Tencent Hunyuan Works; and (ii) mark the products or services developed by using the Tencent Hunyuan Works to indicate that the product/service is “Powered by Tencent Hunyuan”; and
|
120 |
+
d. All distributions to Third Parties (other than through a Hosted Service) must be accompanied by a “Notice” text file that contains the following notice: “Tencent Hunyuan is licensed under the Tencent Hunyuan Community License Agreement, Copyright © 2024 Tencent. All Rights Reserved. The trademark rights of “Tencent Hunyuan” are owned by Tencent or its affiliate.”
|
121 |
+
You may add Your own copyright statement to Your modifications and, except as set forth in this Section and in Section 5, may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Model Derivatives as a whole, provided Your use, reproduction, modification, distribution, performance and display of the work otherwise complies with the terms and conditions of this Agreement (including as regards the Territory). If You receive Tencent Hunyuan Works from a Licensee as part of an integrated end user product, then this Section 3 of this Agreement will not apply to You.
|
122 |
+
4. ADDITIONAL COMMERCIAL TERMS.
|
123 |
+
If, on the Tencent Hunyuan version release date, the monthly active users of all products or services made available by or for Licensee is greater than 100 million monthly active users in the preceding calendar month, You must request a license from Tencent, which Tencent may grant to You in its sole discretion, and You are not authorized to exercise any of the rights under this Agreement unless or until Tencent otherwise expressly grants You such rights.
|
124 |
+
5. RULES OF USE.
|
125 |
+
a. Your use of the Tencent Hunyuan Works must comply with applicable laws and regulations (including trade compliance laws and regulations) and adhere to the Acceptable Use Policy for the Tencent Hunyuan Works, which is hereby incorporated by reference into this Agreement. You must include the use restrictions referenced in these Sections 5(a) and 5(b) as an enforceable provision in any agreement (e.g., license agreement, terms of use, etc.) governing the use and/or distribution of Tencent Hunyuan Works and You must provide notice to subsequent users to whom You distribute that Tencent Hunyuan Works are subject to the use restrictions in these Sections 5(a) and 5(b).
|
126 |
+
b. You must not use the Tencent Hunyuan Works or any Output or results of the Tencent Hunyuan Works to improve any other AI model (other than Tencent Hunyuan or Model Derivatives thereof).
|
127 |
+
c. You must not use, reproduce, modify, distribute, or display the Tencent Hunyuan Works, Output or results of the Tencent Hunyuan Works outside the Territory. Any such use outside the Territory is unlicensed and unauthorized under this Agreement.
|
128 |
+
6. INTELLECTUAL PROPERTY.
|
129 |
+
a. Subject to Tencent’s ownership of Tencent Hunyuan Works made by or for Tencent and intellectual property rights therein, conditioned upon Your compliance with the terms and conditions of this Agreement, as between You and Tencent, You will be the owner of any derivative works and modifications of the Materials and any Model Derivatives that are made by or for You.
|
130 |
+
b. No trademark licenses are granted under this Agreement, and in connection with the Tencent Hunyuan Works, Licensee may not use any name or mark owned by or associated with Tencent or any of its affiliates, except as required for reasonable and customary use in describing and distributing the Tencent Hunyuan Works. Tencent hereby grants You a license to use “Tencent Hunyuan” (the “Mark”) in the Territory solely as required to comply with the provisions of Section 3(c), provided that You comply with any applicable laws related to trademark protection. All goodwill arising out of Your use of the Mark will inure to the benefit of Tencent.
|
131 |
+
c. If You commence a lawsuit or other proceedings (including a cross-claim or counterclaim in a lawsuit) against Us or any person or entity alleging that the Materials or any Output, or any portion of any of the foregoing, infringe any intellectual property or other right owned or licensable by You, then all licenses granted to You under this Agreement shall terminate as of the date such lawsuit or other proceeding is filed. You will defend, indemnify and hold harmless Us from and against any claim by any Third Party arising out of or related to Your or the Third Party’s use or distribution of the Tencent Hunyuan Works.
|
132 |
+
d. Tencent claims no rights in Outputs You generate. You and Your users are solely responsible for Outputs and their subsequent uses.
|
133 |
+
7. DISCLAIMERS OF WARRANTY AND LIMITATIONS OF LIABILITY.
|
134 |
+
a. We are not obligated to support, update, provide training for, or develop any further version of the Tencent Hunyuan Works or to grant any license thereto.
|
135 |
+
b. UNLESS AND ONLY TO THE EXTENT REQUIRED BY APPLICABLE LAW, THE TENCENT HUNYUAN WORKS AND ANY OUTPUT AND RESULTS THEREFROM ARE PROVIDED “AS IS” WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES OF ANY KIND INCLUDING ANY WARRANTIES OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, COURSE OF DEALING, USAGE OF TRADE, OR FITNESS FOR A PARTICULAR PURPOSE. YOU ARE SOLELY RESPONSIBLE FOR DETERMINING THE APPROPRIATENESS OF USING, REPRODUCING, MODIFYING, PERFORMING, DISPLAYING OR DISTRIBUTING ANY OF THE TENCENT HUNYUAN WORKS OR OUTPUTS AND ASSUME ANY AND ALL RISKS ASSOCIATED WITH YOUR OR A THIRD PARTY’S USE OR DISTRIBUTION OF ANY OF THE TENCENT HUNYUAN WORKS OR OUTPUTS AND YOUR EXERCISE OF RIGHTS AND PERMISSIONS UNDER THIS AGREEMENT.
|
136 |
+
c. TO THE FULLEST EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL TENCENT OR ITS AFFILIATES BE LIABLE UNDER ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, TORT, NEGLIGENCE, PRODUCTS LIABILITY, OR OTHERWISE, FOR ANY DAMAGES, INCLUDING ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL, EXEMPLARY, CONSEQUENTIAL OR PUNITIVE DAMAGES, OR LOST PROFITS OF ANY KIND ARISING FROM THIS AGREEMENT OR RELATED TO ANY OF THE TENCENT HUNYUAN WORKS OR OUTPUTS, EVEN IF TENCENT OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF ANY OF THE FOREGOING.
|
137 |
+
8. SURVIVAL AND TERMINATION.
|
138 |
+
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.
|
139 |
+
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 promptly delete and cease use of the Tencent Hunyuan Works. Sections 6(a), 6(c), 7 and 9 shall survive the termination of this Agreement.
|
140 |
+
9. GOVERNING LAW AND JURISDICTION.
|
141 |
+
a. This Agreement and any dispute arising out of or relating to it will be governed by the laws of the Hong Kong Special Administrative Region of the People’s Republic 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.
|
142 |
+
b. Exclusive jurisdiction and venue for any dispute arising out of or relating to this Agreement will be a court of competent jurisdiction in the Hong Kong Special Administrative Region of the People’s Republic of China, and Tencent and Licensee consent to the exclusive jurisdiction of such court with respect to any such dispute.
|
143 |
+
|
144 |
+
EXHIBIT A
|
145 |
+
ACCEPTABLE USE POLICY
|
146 |
+
|
147 |
+
Tencent reserves the right to update this Acceptable Use Policy from time to time.
|
148 |
+
Last modified: November 5, 2024
|
149 |
+
|
150 |
+
Tencent endeavors to promote safe and fair use of its tools and features, including Tencent Hunyuan. You agree not to use Tencent Hunyuan or Model Derivatives:
|
151 |
+
1. Outside the Territory;
|
152 |
+
2. In any way that violates any applicable national, federal, state, local, international or any other law or regulation;
|
153 |
+
3. To harm Yourself or others;
|
154 |
+
4. To repurpose or distribute output from Tencent Hunyuan or any Model Derivatives to harm Yourself or others;
|
155 |
+
5. To override or circumvent the safety guardrails and safeguards We have put in place;
|
156 |
+
6. For the purpose of exploiting, harming or attempting to exploit or harm minors in any way;
|
157 |
+
7. To generate or disseminate verifiably false information and/or content with the purpose of harming others or influencing elections;
|
158 |
+
8. To generate or facilitate false online engagement, including fake reviews and other means of fake online engagement;
|
159 |
+
9. To intentionally defame, disparage or otherwise harass others;
|
160 |
+
10. To generate and/or disseminate malware (including ransomware) or any other content to be used for the purpose of harming electronic systems;
|
161 |
+
11. To generate or disseminate personal identifiable information with the purpose of harming others;
|
162 |
+
12. To generate or disseminate information (including images, code, posts, articles), and place the information in any public context (including –through the use of bot generated tweets), without expressly and conspicuously identifying that the information and/or content is machine generated;
|
163 |
+
13. To impersonate another individual without consent, authorization, or legal right;
|
164 |
+
14. To make high-stakes automated decisions in domains that affect an individual’s safety, rights or wellbeing (e.g., law enforcement, migration, medicine/health, management of critical infrastructure, safety components of products, essential services, credit, employment, housing, education, social scoring, or insurance);
|
165 |
+
15. In a manner that violates or disrespects the social ethics and moral standards of other countries or regions;
|
166 |
+
16. To perform, facilitate, threaten, incite, plan, promote or encourage violent extremism or terrorism;
|
167 |
+
17. For any use intended to discriminate against or harm individuals or groups based on protected characteristics or categories, online or offline social behavior or known or predicted personal or personality characteristics;
|
168 |
+
18. To intentionally exploit any of the vulnerabilities of a specific group of persons based on their age, social, physical or mental characteristics, in order to materially distort the behavior of a person pertaining to that group in a manner that causes or is likely to cause that person or another person physical or psychological harm;
|
169 |
+
19. For military purposes;
|
170 |
+
20. To engage in the unauthorized or unlicensed practice of any profession including, but not limited to, financial, legal, medical/health, or other professional practices.
|
171 |
+
|
172 |
+
For the license of other third party components, please refer to the following URL:
|
173 |
+
https://github.com/Tencent-Hunyuan/HunyuanVideo/blob/ff2dd59277b3177785d8279d4170968afa3b1d55/Notice
|
README.md
ADDED
@@ -0,0 +1,279 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
library_name: HunyuanImage-2.1
|
3 |
+
license: other
|
4 |
+
license_name: tencent-hunyuan-community
|
5 |
+
license_link: https://github.com/Tencent-Hunyuan/HunyuanImage-2.1/blob/master/LICENSE
|
6 |
+
language:
|
7 |
+
- en
|
8 |
+
- zh
|
9 |
+
tags:
|
10 |
+
- text-to-image
|
11 |
+
pipeline_tag: text-to-image
|
12 |
+
extra_gated_eu_disallowed: true
|
13 |
+
---
|
14 |
+
|
15 |
+
|
16 |
+
[中文阅读](./README_CN.md)
|
17 |
+
|
18 |
+
<p align="center">
|
19 |
+
<img src="./assets/logo.png" height=100>
|
20 |
+
</p>
|
21 |
+
|
22 |
+
<div align="center">
|
23 |
+
|
24 |
+
# HunyuanImage-2.1: An Efficient Diffusion Model for High-Resolution (2K) Text-to-Image Generation
|
25 |
+
|
26 |
+
</div>
|
27 |
+
|
28 |
+
<div align="center">
|
29 |
+
<a href=https://github.com/Tencent-Hunyuan/HunyuanImage-2.1 target="_blank"><img src=https://img.shields.io/badge/Code-black.svg?logo=github height=22px></a>
|
30 |
+
<a href="https://huggingface.co/spaces/tencent/HunyuanImage-2.1" target="_blank">
|
31 |
+
<img src="https://img.shields.io/badge/Demo%20Page-blue" height="22px"></a>
|
32 |
+
<a href=https://huggingface.co/tencent/HunyuanImage-2.1 target="_blank"><img src=https://img.shields.io/badge/%F0%9F%A4%97%20Models-d96902.svg height=22px></a>
|
33 |
+
<a href="#" target="_blank"><img src="https://img.shields.io/badge/Report-Coming%20Soon-blue" height="22px"></a>
|
34 |
+
<a href= https://hunyuan-promptenhancer.github.io/ target="_blank"><img src=https://img.shields.io/badge/PromptEnhancer-bb8a2e.svg?logo=github height=22px></a>
|
35 |
+
<a href=https://x.com/TencentHunyuan target="_blank"><img src=https://img.shields.io/badge/Hunyuan-black.svg?logo=x height=22px></a>
|
36 |
+
</div>
|
37 |
+
|
38 |
+
|
39 |
+
-----
|
40 |
+
|
41 |
+
This repo contains PyTorch model definitions, pretrained weights and inference/sampling code for our HunyuanImage-2.1. You can find more visualizations on our [project page](https://hunyuan.tencent.com/image/en?tabIndex=0).
|
42 |
+
|
43 |
+
|
44 |
+
## 🔥🔥🔥 Latest Updates
|
45 |
+
|
46 |
+
- September 8, 2025: 🚀 Released inference code and model weights for HunyuanImage-2.1.
|
47 |
+
|
48 |
+
## 🎥 Demo
|
49 |
+
|
50 |
+
<div align="center">
|
51 |
+
<img src="./assets/show_cases.png" width=100% alt="HunyuanImage 2.1 Demo">
|
52 |
+
</div>
|
53 |
+
|
54 |
+
## Contents
|
55 |
+
- [HunyuanImage-2.1: An Efficient Diffusion Model for High-Resolution (2K) Text-to-Image Generation](#hunyuanimage-21-an-efficient-diffusion-model-for-high-resolution-2k-text-to-image-generation)
|
56 |
+
- [🔥🔥🔥 Latest Updates](#-latest-updates)
|
57 |
+
- [🎥 Demo](#-demo)
|
58 |
+
- [Contents](#contents)
|
59 |
+
- [Abstract](#abstract)
|
60 |
+
- [HunyuanImage-2.1 Overall Pipeline](#hunyuanimage-21-overall-pipeline)
|
61 |
+
- [Training Data and Caption](#training-data-and-caption)
|
62 |
+
- [Text-to-Image Model Architecture](#text-to-image-model-architecture)
|
63 |
+
- [Reinforcement Learning from Human Feedback](#reinforcement-learning-from-human-feedback)
|
64 |
+
- [Rewriting Model](#rewriting-model)
|
65 |
+
- [Model distillation](#model-distillation)
|
66 |
+
- [🎉 HunyuanImage-2.1 Key Features](#-hunyuanimage-21-key-features)
|
67 |
+
- [Prompt Enhanced Demo](#prompt-enhanced-demo)
|
68 |
+
- [📈 Comparisons](#-comparisons)
|
69 |
+
- [SSAE Evaluation](#ssae-evaluation)
|
70 |
+
- [GSB Evaluation](#gsb-evaluation)
|
71 |
+
- [📜 System Requirements](#-system-requirements)
|
72 |
+
- [🛠️ Dependencies and Installation](#️-dependencies-and-installation)
|
73 |
+
- [🧱 Download Pretrained Models](#-download-pretrained-models)
|
74 |
+
- [🔑 Usage](#-usage)
|
75 |
+
- [🔗 BibTeX](#-bibtex)
|
76 |
+
- [Acknowledgements](#acknowledgements)
|
77 |
+
- [Github Star History](#github-star-history)
|
78 |
+
|
79 |
+
---
|
80 |
+
<!-- - [🧩 Community Contributions](#-community-contributions) -->
|
81 |
+
## Abstract
|
82 |
+
We present HunyuanImage-2.1, a highly efficient text-to-image model that is capable of generating 2K (2048 × 2048) resolution images. Leveraging an extensive dataset and structured captions involving multiple expert models, we significantly enhance text-image alignment capabilities. The model employs a highly expressive VAE with a (32 × 32) spatial compression ratio, substantially reducing computational costs.
|
83 |
+
|
84 |
+
Our architecture consists of two stages:
|
85 |
+
1. Base text-to-image Model: The first stage is a text-to-image model that utilizes two text encoders: a multimodal large language model (MLLM) to improve image-text alignment, and a multi-language, character-aware encoder to enhance text rendering across various languages. This stage features a single- and dual-stream diffusion transformer with 17 billion parameters. To optimize aesthetics and structural coherence, we apply reinforcement learning from human feedback (RLHF).
|
86 |
+
2. Refiner Model: The second stage introduces a refiner model that further enhances image quality and clarity, while minimizing artifacts.
|
87 |
+
|
88 |
+
Additionally, we developed the PromptEnhancer module to further boost model performance, and employed meanflow distillation for efficient inference. HunyuanImage-2.1 demonstrates robust semantic alignment and cross-scenario generalization, leading to improved consistency between text and image, enhanced control of scene details, character poses, and expressions, and the ability to generate multiple objects with distinct descriptions.
|
89 |
+
|
90 |
+
|
91 |
+
|
92 |
+
|
93 |
+
## HunyuanImage-2.1 Overall Pipeline
|
94 |
+
|
95 |
+
### Training Data and Caption
|
96 |
+
|
97 |
+
Structured captions provide hierarchical semantic information at short, medium, long, and extra-long levels, significantly enhancing the model’s responsiveness to complex semantics. Innovatively, an OCR agent and IP RAG are introduced to address the shortcomings of general VLM captioners in dense text and world knowledge descriptions, while a bidirectional verification strategy ensures caption accuracy.
|
98 |
+
|
99 |
+
|
100 |
+
### Text-to-Image Model Architecture
|
101 |
+
|
102 |
+
<p align="center">
|
103 |
+
<img src="./assets/framework_overall.png" width=100% alt="HunyuanImage 2.1 Architecture">
|
104 |
+
</p>
|
105 |
+
|
106 |
+
|
107 |
+
|
108 |
+
Core Components:
|
109 |
+
* High-Compression VAE with REPA Training Acceleration:
|
110 |
+
* A VAE with a 32× compression rate drastically reduces the number of input tokens for the DiT model. By aligning its feature space with DINOv2 features, we facilitate the training of high-compression VAEs. As a result, our model generates 2K images with the same token length (and thus similar inference time) as other models require for 1K images, achieving superior inference efficiency.
|
111 |
+
* Multi-bucket, multi-resolution REPA loss aligns DiT features with a high-dimensional semantic feature space, accelerating model convergence.
|
112 |
+
* Dual Text Encoder:
|
113 |
+
* A vision-language multimodal encoder is employed to better understand scene descriptions, character actions, and detailed requirements.
|
114 |
+
* A multilingual ByT5 text encoder is introduced to specialize in text generation and multilingual expression.
|
115 |
+
* Network: A single- and dual-stream diffusion transformer with 17 billion parameters.
|
116 |
+
|
117 |
+
### Reinforcement Learning from Human Feedback
|
118 |
+
Two-Stage Post-Training with Reinforcement Learning: Supervised Fine-Tuning (SFT) and Reinforcement Learning (RL) are applied sequentially in two post-training stages. We introduce a Reward Distribution Alignment algorithm, which innovatively incorporates high-quality images as selected samples to ensure stable and improved reinforcement learning outcomes.
|
119 |
+
|
120 |
+
### Rewriting Model
|
121 |
+
<p align="center">
|
122 |
+
<img src="./assets/framework_prompt_rewrite.png" width=90% alt="HunyuanImage 2.1 Architecture">
|
123 |
+
</p>
|
124 |
+
|
125 |
+
* The first systematic industrial-level rewriting model. SFT training structurally rewrites user text instructions to enrich visual expression, while GRPO training employs a fine-grained semantic AlignEvaluator reward model to substantially improve the semantics of images generated from rewritten text. The AlignEvaluator covers 6 major categories and 24 fine-grained assessment points. PromptEnhancer supports both Chinese and English rewriting and demonstrates general applicability in enhancing semantics for both open-source and proprietary text-to-image models.
|
126 |
+
|
127 |
+
### Model distillation
|
128 |
+
We propose a novel distillation method based on meanflow that addresses the key challenges of instability and inefficiency inherent in standard meanflow training. This approach enables high-quality image generation with only a few sampling steps. To our knowledge, this is the first successful application of meanflow to an industrial-scale model.
|
129 |
+
|
130 |
+
|
131 |
+
|
132 |
+
|
133 |
+
|
134 |
+
## 🎉 HunyuanImage-2.1 Key Features
|
135 |
+
|
136 |
+
- **High-Quality Generation**: Efficiently produces ultra-high-definition (2K) images with cinematic composition.
|
137 |
+
- **Multilingual Support**: Provides native support for both Chinese and English prompts.
|
138 |
+
- **Advanced Architecture**: Built on a multi-modal, single- and dual-stream combined DiT (Diffusion Transformer) backbone.
|
139 |
+
- **Glyph-Aware Processing**: Utilizes ByT5's text rendering capabilities for improved text generation accuracy.
|
140 |
+
- **Flexible Aspect Ratios**: Supports a variety of image aspect ratios (1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 2:3).
|
141 |
+
- **Prompt Enhancement**: Automatically rewrites prompts to improve descriptive accuracy and visual quality.
|
142 |
+
|
143 |
+
|
144 |
+
## Prompt Enhanced Demo
|
145 |
+
To improve the quality and detail of generated images, we use a prompt rewriting model. This model automatically enhances user-provided text prompts by adding detailed and descriptive information.
|
146 |
+
<p align="center">
|
147 |
+
<img src="./assets/reprompt.png" width=100% alt="Human Evaluation with Other Models">
|
148 |
+
</p>
|
149 |
+
|
150 |
+
|
151 |
+
## 📈 Comparisons
|
152 |
+
|
153 |
+
### SSAE Evaluation
|
154 |
+
SSAE (Structured Semantic Alignment Evaluation) is an intelligent evaluation metric for image-text alignment based on advanced multimodal large language models (MLLMs). We extracted 3500 key points across 12 categories, then used multimodal large language models to automatically evaluate and score by comparing the generated images with these key points based on the visual content of the images. Mean Image Accuracy represents the image-wise average score across all key points, while Global Accuracy directly calculates the average score across all key points.
|
155 |
+
<p align="center">
|
156 |
+
<table>
|
157 |
+
<thead>
|
158 |
+
<tr>
|
159 |
+
<th rowspan="2">Model</th> <th rowspan="2">Open Source</th> <th rowspan="2">Mean Image Accuracy</th> <th rowspan="2">Global Accuracy</th> <th colspan="4" style="text-align: center;">Primary Subject</th> <th colspan="3" style="text-align: center;">Secondary Subject</th> <th colspan="2" style="text-align: center;">Scene</th> <th colspan="3" style="text-align: center;">Other</th>
|
160 |
+
</tr>
|
161 |
+
<tr>
|
162 |
+
<th>Noun</th> <th>Key Attributes</th> <th>Other Attributes</th> <th>Action</th> <th>Noun</th> <th>Attributes</th> <th>Action</th> <th>Noun</th> <th>Attributes</th> <th>Shot</th> <th>Style</th> <th>Composition</th>
|
163 |
+
</tr>
|
164 |
+
</thead>
|
165 |
+
<tbody>
|
166 |
+
<tr>
|
167 |
+
<td>FLUX-dev</td> <td>✅</td> <td>0.7122</td> <td>0.6995</td> <td>0.7965</td> <td>0.7824</td> <td>0.5993</td> <td>0.5777</td> <td>0.7950</td> <td>0.6826</td> <td>0.6923</td> <td>0.8453</td> <td>0.8094</td> <td>0.6452</td> <td>0.7096</td> <td>0.6190</td>
|
168 |
+
</tr>
|
169 |
+
<tr>
|
170 |
+
<td>Seedream-3.0</td> <td>❌</td> <td>0.8827</td> <td>0.8792</td> <td>0.9490</td> <td>0.9311</td> <td>0.8242</td> <td>0.8177</td> <td>0.9747</td> <td>0.9103</td> <td>0.8400</td> <td>0.9489</td> <td>0.8848</td> <td>0.7582</td> <td>0.8726</td> <td>0.7619</td>
|
171 |
+
</tr>
|
172 |
+
<tr>
|
173 |
+
<td>Qwen-Image</td> <td>✅</td> <td>0.8854</td> <td>0.8828</td> <td>0.9502</td> <td>0.9231</td> <td>0.8351</td> <td>0.8161</td> <td>0.9938</td> <td>0.9043</td> <td>0.8846</td> <td>0.9613</td> <td>0.8978</td> <td>0.7634</td> <td>0.8548</td> <td>0.8095</td>
|
174 |
+
</tr>
|
175 |
+
<tr>
|
176 |
+
<td>GPT-Image</td> <td>❌</td> <td> 0.8952</td> <td>0.8929</td> <td>0.9448</td> <td>0.9289</td> <td>0.8655</td> <td>0.8445</td> <td>0.9494</td> <td>0.9283</td> <td>0.8800</td> <td>0.9432</td> <td>0.9017</td> <td>0.7253</td> <td>0.8582</td> <td>0.7143</td>
|
177 |
+
</tr>
|
178 |
+
<tr>
|
179 |
+
<td><strong>HunyuanImage 2.1</strong></td> <td>✅</td> <td><strong>0.8888</strong></td> <td><strong>0.8832</strong></td> <td>0.9339</td> <td>0.9341</td> <td>0.8363</td> <td>0.8342</td> <td>0.9627</td> <td>0.8870</td> <td>0.9615</td> <td>0.9448</td> <td>0.9254</td> <td>0.7527</td> <td>0.8689</td> <td>0.7619</td>
|
180 |
+
</tr>
|
181 |
+
</tbody>
|
182 |
+
</table>
|
183 |
+
</p>
|
184 |
+
|
185 |
+
From the SSAE evaluation results, our model has currently achieved the optimal performance among open-source models in terms of semantic alignment, and is very close to the performance of closed-source commercial models (GPT-Image).
|
186 |
+
|
187 |
+
### GSB Evaluation
|
188 |
+
|
189 |
+
<p align="center">
|
190 |
+
<img src="./assets/gsb.png" width=70% alt="Human Evaluation with Other Models">
|
191 |
+
</p>
|
192 |
+
|
193 |
+
We adopted the GSB evaluation method commonly used to assess the relative performance between two models from an overall image perception perspective. In total, we utilized 1000 text prompts, generating an equal number of image samples for all compared models in a single run. For a fair comparison, we conducted inference only once for each prompt, avoiding any cherry-picking of results. When comparing with the baseline methods, we maintained the default settings for all selected models. The evaluation was performed by more than 100 professional evaluators.
|
194 |
+
From the results, HunyuanImage 2.1 achieved a relative win rate of -1.36% against Seedream3.0 (closed-source) and 2.89% outperforming Qwen-Image (open-source). The GSB evaluation results demonstrate that HunyuanImage 2.1, as an open-source model, has reached a level of image generation quality comparable to closed-source commercial models (Seedream3.0), while showing certain advantages in comparison with similar open-source models (Qwen-Image). This fully validates the technical advancement and practical value of HunyuanImage 2.1 in text-to-image generation tasks.
|
195 |
+
|
196 |
+
## 📜 System Requirements
|
197 |
+
|
198 |
+
|
199 |
+
**Hardware and OS Requirements:**
|
200 |
+
- NVIDIA GPU with CUDA support.
|
201 |
+
- **Minimum:** 59 GB GPU memory for 2048x2048 image generation (batch size = 1).
|
202 |
+
- Supported operating system: Linux.
|
203 |
+
|
204 |
+
> **Note:** The memory requirements above are measured with model CPU offloading enabled. If your GPU has sufficient memory, you may disable offloading for improved inference speed.
|
205 |
+
|
206 |
+
## 🛠️ Dependencies and Installation
|
207 |
+
|
208 |
+
1. Clone the repository:
|
209 |
+
```bash
|
210 |
+
git clone https://github.com/Tencent-Hunyuan/HunyuanImage-2.1.git
|
211 |
+
cd HunyuanImage-2.1
|
212 |
+
```
|
213 |
+
|
214 |
+
2. Install dependencies:
|
215 |
+
```bash
|
216 |
+
pip install -r requirements.txt
|
217 |
+
pip install flash-attn==2.7.3 --no-build-isolation
|
218 |
+
```
|
219 |
+
|
220 |
+
## 🧱 Download Pretrained Models
|
221 |
+
|
222 |
+
The details of download pretrained models are shown [here](checkpoints-download.md).
|
223 |
+
|
224 |
+
## 🔑 Usage
|
225 |
+
|
226 |
+
```python
|
227 |
+
import torch
|
228 |
+
from hyimage.diffusion.pipelines.hunyuanimage_pipeline import HunyuanImagePipeline
|
229 |
+
|
230 |
+
# Supported model_name: hunyuanimage-v2.1, hunyuanimage-v2.1-distilled
|
231 |
+
model_name = "hunyuanimage-v2.1"
|
232 |
+
pipe = HunyuanImagePipeline.from_pretrained(model_name=model_name, torch_dtype='bf16')
|
233 |
+
pipe = pipe.to("cuda")
|
234 |
+
|
235 |
+
prompt = "A cute, cartoon-style anthropomorphic penguin plush toy with fluffy fur, standing in a painting studio, wearing a red knitted scarf and a red beret with the word “Tencent” on it, holding a paintbrush with a focused expression as it paints an oil painting of the Mona Lisa, rendered in a photorealistic photographic style."
|
236 |
+
image = pipe(
|
237 |
+
prompt=prompt,
|
238 |
+
width=2048,
|
239 |
+
height=2048,
|
240 |
+
use_reprompt=True, # Enable prompt enhancement
|
241 |
+
use_refiner=True, # Enable refiner model
|
242 |
+
# For the distilled model, use 8 steps for faster inference.
|
243 |
+
# For the non-distilled model, use 50 steps for better quality
|
244 |
+
num_inference_steps=8 if "distilled" in model_name else 50,
|
245 |
+
guidance_scale=3.5,
|
246 |
+
shift=5,
|
247 |
+
seed=649151,
|
248 |
+
)
|
249 |
+
|
250 |
+
image.save(f"generated_image.png")
|
251 |
+
```
|
252 |
+
|
253 |
+
|
254 |
+
## 🔗 BibTeX
|
255 |
+
|
256 |
+
If you find this project useful for your research and applications, please cite as:
|
257 |
+
|
258 |
+
```BibTeX
|
259 |
+
@misc{HunyuanImage-2.1,
|
260 |
+
title={HunyuanImage 2.1: An Efficient Diffusion Model for High-Resolution (2K) Text-to-Image Generation},
|
261 |
+
author={Tencent Hunyuan Team},
|
262 |
+
year={2025},
|
263 |
+
howpublished={\url{https://github.com/Tencent-Hunyuan/HunyuanImage-2.1}},
|
264 |
+
}
|
265 |
+
```
|
266 |
+
|
267 |
+
## Acknowledgements
|
268 |
+
|
269 |
+
We would like to thank the following open-source projects and communities for their contributions to open research and exploration: [Qwen](https://huggingface.co/Qwen), [FLUX](https://github.com/black-forest-labs/flux), [diffusers](https://github.com/huggingface/diffusers) and [HuggingFace](https://huggingface.co).
|
270 |
+
|
271 |
+
## Github Star History
|
272 |
+
<a href="https://star-history.com/#Tencent-Hunyuan/HunyuanImage-2.1&Date">
|
273 |
+
<picture>
|
274 |
+
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=Tencent-Hunyuan/HunyuanImage-2.1&type=Date&theme=dark" />
|
275 |
+
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=Tencent-Hunyuan/HunyuanImage-2.1&type=Date" />
|
276 |
+
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=Tencent-Hunyuan/HunyuanImage-2.1&type=Date" />
|
277 |
+
</picture>
|
278 |
+
</a>
|
279 |
+
|
README_CN.md
ADDED
@@ -0,0 +1,251 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<p align="center">
|
2 |
+
<img src="./assets/logo.png" height=100>
|
3 |
+
</p>
|
4 |
+
|
5 |
+
# 混元图像 2.1:一种用于高分辨率(2K)文本到图像生成的高效扩散模型
|
6 |
+
|
7 |
+
<div align="center">
|
8 |
+
<a href=https://github.com/Tencent-Hunyuan/HunyuanImage-2.1 target="_blank"><img src=https://img.shields.io/badge/Code-black.svg?logo=github height=22px></a>
|
9 |
+
<a href="https://huggingface.co/spaces/tencent/HunyuanImage-2.1" target="_blank">
|
10 |
+
<img src="https://img.shields.io/badge/Demo%20Page-blue" height="22px"></a>
|
11 |
+
<a href=https://huggingface.co/tencent/HunyuanImage-2.1 target="_blank"><img src=https://img.shields.io/badge/%F0%9F%A4%97%20Models-d96902.svg height=22px></a>
|
12 |
+
<a href="#" target="_blank"><img src="https://img.shields.io/badge/Report-Coming%20Soon-blue" height="22px"></a>
|
13 |
+
<a href= https://hunyuan-promptenhancer.github.io/ target="_blank"><img src=https://img.shields.io/badge/PromptEnhancer-bb8a2e.svg?logo=github height=22px></a>
|
14 |
+
<a href=https://x.com/TencentHunyuan target="_blank"><img src=https://img.shields.io/badge/Hunyuan-black.svg?logo=x height=22px></a>
|
15 |
+
</div>
|
16 |
+
|
17 |
+
----
|
18 |
+
|
19 |
+
|
20 |
+
本仓库包含我们关于混元图像 2.1 的 PyTorch 模型定义、预训练权重,以及推理/采样代码。更多可视化示例请访问我们的<a href="https://hunyuan.tencent.com/image/en?tabIndex=0">项目主页</a>。
|
21 |
+
|
22 |
+
|
23 |
+
## 🔥🔥🔥 最新动态
|
24 |
+
|
25 |
+
- 2025 年 9 月 8 日:🚀 发布混元图像 2.1 的推理代码与模型权重。
|
26 |
+
|
27 |
+
## 🎥 示例
|
28 |
+
|
29 |
+
<div align="center">
|
30 |
+
<img src="./assets/show_cases.png" width=100% alt="HunyuanImage 2.1 Demo">
|
31 |
+
</div>
|
32 |
+
|
33 |
+
|
34 |
+
## 目录
|
35 |
+
- [混元图像 2.1:一种用于高分辨率(2K)文本到图像生成的高效扩散模型](#混元图像-21一种用于高分辨率2k文本到图像生成的高效扩散模型)
|
36 |
+
- [🔥🔥🔥 最新动态](#-最新动态)
|
37 |
+
- [🎥 示例](#-示例)
|
38 |
+
- [目录](#目录)
|
39 |
+
- [摘要](#摘要)
|
40 |
+
- [混元图像 2.1 整体流程](#混元图像-21-整体流程)
|
41 |
+
- [训练数据和标注](#训练数据和标注)
|
42 |
+
- [文本到图像模型架构](#文本到图像模型架构)
|
43 |
+
- [人类反馈强化学习](#人类反馈强化学习)
|
44 |
+
- [改写模型](#改写模型)
|
45 |
+
- [模型蒸馏](#模型蒸馏)
|
46 |
+
- [🎉 关键特性](#-关键特性)
|
47 |
+
- [提示词增强示例](#提示词增强示例)
|
48 |
+
- [📈 对比](#-对比)
|
49 |
+
- [SSAE 评测](#ssae-评测)
|
50 |
+
- [GSB 评测](#gsb-评测)
|
51 |
+
- [📜 系统要求](#-系统要求)
|
52 |
+
- [🛠️ 依赖与安装](#️-依赖与安装)
|
53 |
+
- [🧱 模型下载](#-模型下载)
|
54 |
+
- [🔑 使用](#-使用)
|
55 |
+
- [🔗 BibTeX](#-bibtex)
|
56 |
+
- [致谢](#致谢)
|
57 |
+
- [Github Star 历史](#github-star-历史)
|
58 |
+
|
59 |
+
---
|
60 |
+
|
61 |
+
## 摘要
|
62 |
+
|
63 |
+
我们提出了混元图像 2.1(HunyuanImage-2.1),这是一个能够生成 2K(2048 × 2048)分辨率图像的高效文本到图像模型。通过利用大规模数据集和涉及多个专家模型的结构化标注,我们显著增强了文本-图像对齐能力。该模型采用高表达性的 VAE,具有(32 × 32)的空间压缩比,大幅降低了计算成本。
|
64 |
+
|
65 |
+
我们的架构包含两个阶段:
|
66 |
+
1. **基础文本到图像模型**:第一阶段是一个文本到图像模型,利用两个文本编码器:一个多模态大语言模型(MLLM)来改善图像-文本对齐,以及一个多语言、字符感知编码器来增强各种语言的文本渲染。该阶段具有 170 亿参数的单流和双流 Diffusion Transformer。为了优化美学和结构连贯性,我们应用了人类反馈强化学习(RLHF)。
|
67 |
+
2. **精修模型**:第二阶段引入了一个精修模型,进一步提升了图像质量和清晰度。
|
68 |
+
|
69 |
+
此外,我们开发了 PromptEnhancer 模块来进一步提升模型性能,并采用 MeanFlow 蒸馏进行高效推理。混元图像 2.1 展现了强大的语义对齐和跨场景泛化能力,提升了文本与图像之间的一致性,增强了对场景细节、人物姿态和表情的控制,并能够生成具有不同描述的多个物体。
|
70 |
+
|
71 |
+
## 混元图像 2.1 整体流程
|
72 |
+
|
73 |
+
### 训练数据和标注
|
74 |
+
|
75 |
+
结构化标注在短、中、长和超长级别提供分层语义信息,显著增强了模型对复杂语义的响应能力。创新性地引入了 OCR 专家模型和 IP RAG 来解决通用 VLM 标注器在密集文本和世界知识描述方面的不足,而双向验证策略确保了标注的准确性。
|
76 |
+
|
77 |
+
### 文本到图像模型架构
|
78 |
+
|
79 |
+
<p align="center">
|
80 |
+
<img src="./assets/framework_overall.png" width=100% alt="HunyuanImage 2.1 Architecture">
|
81 |
+
</p>
|
82 |
+
|
83 |
+
**核心组件:**
|
84 |
+
* **高压缩 VAE 与 REPA 训练加速**:
|
85 |
+
* 具有 32× 压缩率的 VAE 大幅减少了 DiT 模型的输入 token 数量。其特征空间与 DINOv2 特征对齐,便于高压缩 VAE 的训练。这显著提高了推理效率,使得HunyuanImage 2.1 生成 2K 图像的时间与其他模型生成 1K 图像的时间相同。
|
86 |
+
* 多桶、多分辨率 REPA 损失将 DiT 特征与高维语义特征空间对齐,加速模型收敛。
|
87 |
+
* **双文本编码器**:
|
88 |
+
* 采���视觉-语言多模态编码器来更好地理解场景描述、人物动作和详细要求。
|
89 |
+
* 引入多语言 ByT5 文本编码器,专门用于文本生成和多语言表达。
|
90 |
+
* **网络**:具有 170 亿参数的单流和双流 Diffusion Transformer。
|
91 |
+
|
92 |
+
### 人类反馈强化学习
|
93 |
+
**两阶段后训练与强化学习**:监督微调(SFT)和强化学习(RL)在两个后训练阶段中顺序应用。我们引入了奖励分布对齐算法,创新性地将高质量图像作为选定样本,确保稳定和改进的强化学习结果。
|
94 |
+
|
95 |
+
### 改写模型
|
96 |
+
<p align="center">
|
97 |
+
<img src="./assets/framework_prompt_rewrite.png" width=90% alt="HunyuanImage 2.1 Architecture">
|
98 |
+
</p>
|
99 |
+
|
100 |
+
* **首个系统性工业级改写模型**:SFT 训练结构化地重写用户文本指令以丰富视觉表达,而 GRPO 训练采用细粒度语义 AlignEvaluator 奖励模型来大幅提升从重写文本生成的图像语义。AlignEvaluator 涵盖 6 个主要类别和 24 个细粒度评估点。PromptEnhancer 支持中英文重写,并在增强开源和专有文本到图像模型的语义方面展现了通用适用性。
|
101 |
+
|
102 |
+
### 模型蒸馏
|
103 |
+
我们提出了一种基于 MeanFlow 的新型蒸馏方法,解决了标准均值流训练固有的不稳定性和低效率的关键挑战。这种方法能够仅用少量采样步骤生成高质量图像。据我们所知,这是 MeanFlow 在工业级模型上的首次成功应用。
|
104 |
+
|
105 |
+
|
106 |
+
## 🎉 关键特性
|
107 |
+
|
108 |
+
- 高质量生成:可生成超高清(2K)图像,具电影级构图
|
109 |
+
- 多语言支持:原生支持中文与英文提示词
|
110 |
+
- 先进架构:基于多模态的先进单双流结合的 DiT(Diffusion Transformer)骨干网络
|
111 |
+
- 字形感知:结合 ByT5 的文本渲染能力,提升嵌字/文本生成准确性
|
112 |
+
- 灵活的宽高比:支持多种图像宽高比(1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 2:3)
|
113 |
+
- 提示词增强:自动重写提示词,提高描述精度与画面质量
|
114 |
+
|
115 |
+
## 提示词增强示例
|
116 |
+
为了提升生成图像的质量和细节,我们引入了提示词增强模型。该模型能够自动丰富用户提供的文本提示,添加丰富的描述性细节。
|
117 |
+
<p align="center">
|
118 |
+
<img src="./assets/reprompt.png" width=100% alt="Human Evaluation with Other Models">
|
119 |
+
</p>
|
120 |
+
|
121 |
+
|
122 |
+
## 📈 对比
|
123 |
+
|
124 |
+
### SSAE 评测
|
125 |
+
SSAE(结构化语义对齐评估)是一种基于先进多模态大语言模型(MLLMs)的图文对齐智能评测指标。我们在 12 个类别中共提取了 3500 个关键要点,然后利用多模态大语言模型,基于图像的视觉内容,将生成的图像与这些关键要点进行比对,自动完成评估与打分。平均图像准确率(Mean Image Accuracy)表示以图像为单位在所有关键要点上的平均得分,而全局准确率(Global Accuracy) 则直接对所有关键要点的平均得分进行计算。
|
126 |
+
|
127 |
+
|
128 |
+
<p align="center">
|
129 |
+
<table>
|
130 |
+
<thead>
|
131 |
+
<tr>
|
132 |
+
<th rowspan="2">模型</th> <th rowspan="2">开源</th> <th rowspan="2">平均图像准确率</th> <th rowspan="2">全局准确率</th> <th colspan="4" style="text-align: center;">主体</th> <th colspan="3" style="text-align: center;">次要主体</th> <th colspan="2" style="text-align: center;">场景</th> <th colspan="3" style="text-align: center;">其他</th>
|
133 |
+
</tr>
|
134 |
+
<tr>
|
135 |
+
<th>名词</th> <th>关键属性</th> <th>其他属性</th> <th>动作</th> <th>名词</th> <th>属性</th> <th>动作</th> <th>名词</th> <th>属性</th> <th>镜头</th> <th>风格</th> <th>构图</th>
|
136 |
+
</tr>
|
137 |
+
</thead>
|
138 |
+
<tbody>
|
139 |
+
<tr>
|
140 |
+
<td>FLUX-dev</td> <td>✅</td> <td>0.7122</td> <td>0.6995</td> <td>0.7965</td> <td>0.7824</td> <td>0.5993</td> <td>0.5777</td> <td>0.7950</td> <td>0.6826</td> <td>0.6923</td> <td>0.8453</td> <td>0.8094</td> <td>0.6452</td> <td>0.7096</td> <td>0.6190</td>
|
141 |
+
</tr>
|
142 |
+
<tr>
|
143 |
+
<td>Seedream-3.0</td> <td>❌</td> <td>0.8827</td> <td>0.8792</td> <td>0.9490</td> <td>0.9311</td> <td>0.8242</td> <td>0.8177</td> <td>0.9747</td> <td>0.9103</td> <td>0.8400</td> <td>0.9489</td> <td>0.8848</td> <td>0.7582</td> <td>0.8726</td> <td>0.7619</td>
|
144 |
+
</tr>
|
145 |
+
<tr>
|
146 |
+
<td>Qwen-Image</td> <td>✅</td> <td>0.8854</td> <td>0.8828</td> <td>0.9502</td> <td>0.9231</td> <td>0.8351</td> <td>0.8161</td> <td>0.9938</td> <td>0.9043</td> <td>0.8846</td> <td>0.9613</td> <td>0.8978</td> <td>0.7634</td> <td>0.8548</td> <td>0.8095</td>
|
147 |
+
</tr>
|
148 |
+
<tr>
|
149 |
+
<td>GPT-Image</td> <td>❌</td> <td> 0.8952</td> <td>0.8929</td> <td>0.9448</td> <td>0.9289</td> <td>0.8655</td> <td>0.8445</td> <td>0.9494</td> <td>0.9283</td> <td>0.8800</td> <td>0.9432</td> <td>0.9017</td> <td>0.7253</td> <td>0.8582</td> <td>0.7143</td>
|
150 |
+
</tr>
|
151 |
+
<tr>
|
152 |
+
<td><strong>HunyuanImage 2.1</strong></td> <td>✅</td> <td><strong>0.8888</strong></td> <td><strong>0.8832</strong></td> <td>0.9339</td> <td>0.9341</td> <td>0.8363</td> <td>0.8342</td> <td>0.9627</td> <td>0.8870</td> <td>0.9615</td> <td>0.9448</td> <td>0.9254</td> <td>0.7527</td> <td>0.8689</td> <td>0.7619</td>
|
153 |
+
</tr>
|
154 |
+
</tbody>
|
155 |
+
</table>
|
156 |
+
</p>
|
157 |
+
|
158 |
+
从 SSAE 的评估结果上看,我们的模型在语义对齐上目前达到了开源模型���最优的效果,并且非常接近闭源商业模型 (GPT-Image) 的效果。
|
159 |
+
|
160 |
+
### GSB 评测
|
161 |
+
|
162 |
+
<p align="center">
|
163 |
+
<img src="./assets/gsb.png" width=70% alt="Human Evaluation with Other Models">
|
164 |
+
</p>
|
165 |
+
我们采用了 GSB 评测方法,该方法常用于从整体图像感知角度评估两个模型之间的相对性能。我们共使用了 1000 条文本提示,并生成等数量的图像样本。为保证公平比较,我们仅进行一次推理,避免任何挑选结果的行为。与基线方法比较时,我们对所有选定模型均保持默认设置。评测由 100 多位专业评审完成。
|
166 |
+
从结果来看,HunyuanImage 2.1 相对于 Seedream3.0(闭源)的相对胜率为 -1.36%,相对于 Qwen-Image(开源)为 2.89%。GSB 评测结果表明,作为开源模型的 HunyuanImage 2.1,其图像生成质量已达到可与闭源商业模型(Seedream3.0)相媲美的水平,同时相较于同类开源模型(Qwen-Image)展现出一定优势。这充分验证了 HunyuanImage 2.1 在文生图任务中的技术先进性和实践价值。
|
167 |
+
|
168 |
+
## 📜 系统要求
|
169 |
+
|
170 |
+
|
171 |
+
**硬件和操作系统要求:**
|
172 |
+
- 支持 CUDA 的 NVIDIA GPU。
|
173 |
+
- **最低要求:** 59 GB 显存用于 2048x2048 图像生成(batch size = 1)。
|
174 |
+
- 支持的操作系统:Linux。
|
175 |
+
|
176 |
+
|
177 |
+
> **注意:** 上述内存要求是在启用模型 CPU offloading 的情况下测量的。如果您的 GPU 有足够的显存,可以禁用 CPU offloading 以提高推理速度。
|
178 |
+
|
179 |
+
## 🛠️ 依赖与安装
|
180 |
+
|
181 |
+
1. 克隆仓库:
|
182 |
+
```bash
|
183 |
+
git clone https://github.com/Tencent-Hunyuan/HunyuanImage-2.1.git
|
184 |
+
cd HunyuanImage-2.1
|
185 |
+
```
|
186 |
+
|
187 |
+
2. 安装依赖:
|
188 |
+
```bash
|
189 |
+
pip install -r requirements.txt
|
190 |
+
pip install flash-attn==2.7.3 --no-build-isolation
|
191 |
+
```
|
192 |
+
|
193 |
+
## 🧱 模型下载
|
194 |
+
|
195 |
+
模型的下载与说明请参考[这里](ckpts/checkpoints-download.md)。
|
196 |
+
|
197 |
+
## 🔑 使用
|
198 |
+
|
199 |
+
```python
|
200 |
+
import torch
|
201 |
+
from hyimage.diffusion.pipelines.hunyuanimage_pipeline import HunyuanImagePipeline
|
202 |
+
|
203 |
+
# 支持的 model_name:hunyuanimage-v2.1, hunyuanimage-v2.1-distilled
|
204 |
+
model_name = "hunyuanimage-v2.1"
|
205 |
+
pipe = HunyuanImagePipeline.from_pretrained(model_name=model_name, torch_dtype='bf16')
|
206 |
+
pipe = pipe.to("cuda")
|
207 |
+
|
208 |
+
prompt = "A cute, cartoon-style anthropomorphic penguin plush toy with fluffy fur, standing in a painting studio, wearing a red knitted scarf and a red beret with the word “Tencent” on it, holding a paintbrush with a focused expression as it paints an oil painting of the Mona Lisa, rendered in a photorealistic photographic style."
|
209 |
+
image = pipe(
|
210 |
+
prompt=prompt,
|
211 |
+
width=2048,
|
212 |
+
height=2048,
|
213 |
+
use_reprompt=True, # 启用提示词增强
|
214 |
+
use_refiner=True, # 启用精修模型, 以获得更高画质
|
215 |
+
# 对于蒸馏版模型,建议使用 8 步以加快推理速度;
|
216 |
+
# 对于非蒸馏版模型,建议使用 50 步以获得更高画质
|
217 |
+
num_inference_steps=8 if "distilled" in model_name else 50,
|
218 |
+
guidance_scale=3.5,
|
219 |
+
shift=5,
|
220 |
+
seed=649151,
|
221 |
+
)
|
222 |
+
|
223 |
+
image.save("generated_image.png")
|
224 |
+
```
|
225 |
+
|
226 |
+
## 🔗 BibTeX
|
227 |
+
|
228 |
+
如果本项目对你的研究或应用有帮助,请引用:
|
229 |
+
|
230 |
+
```BibTeX
|
231 |
+
@misc{HunyuanImage-2.1,
|
232 |
+
title={HunyuanImage 2.1: An Efficient Diffusion Model for High-Resolution (2K) Text-to-Image Generation},
|
233 |
+
author={Tencent Hunyuan Team},
|
234 |
+
year={2025},
|
235 |
+
howpublished={\url{https://github.com/Tencent-Hunyuan/HunyuanImage-2.1}},
|
236 |
+
}
|
237 |
+
```
|
238 |
+
|
239 |
+
## 致谢
|
240 |
+
|
241 |
+
感谢以下开源项目与社区为开放研究和探索所做的贡献:[Qwen](https://huggingface.co/Qwen)、
|
242 |
+
[FLUX](https://github.com/black-forest-labs/flux)、[diffusers](https://github.com/huggingface/diffusers) 与 [HuggingFace](https://huggingface.co)。
|
243 |
+
|
244 |
+
## Github Star 历史
|
245 |
+
<a href="https://star-history.com/#Tencent-Hunyuan/HunyuanImage-2.1&Date">
|
246 |
+
<picture>
|
247 |
+
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=Tencent-Hunyuan/HunyuanImage-2.1&type=Date&theme=dark" />
|
248 |
+
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=Tencent-Hunyuan/HunyuanImage-2.1&type=Date" />
|
249 |
+
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=Tencent-Hunyuan/HunyuanImage-2.1&type=Date" />
|
250 |
+
</picture>
|
251 |
+
</a>
|
assets/comparison.png
ADDED
![]() |
Git LFS Details
|
assets/demo.png
ADDED
![]() |
Git LFS Details
|
assets/framework_overall.png
ADDED
![]() |
Git LFS Details
|
assets/framework_prompt_rewrite.png
ADDED
![]() |
Git LFS Details
|
assets/gsb.png
ADDED
![]() |
Git LFS Details
|
assets/logo.png
ADDED
![]() |
Git LFS Details
|
assets/reprompt.png
ADDED
![]() |
Git LFS Details
|
assets/show_cases.png
ADDED
![]() |
Git LFS Details
|
checkpoints-download.md
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
# Download the pretrained checkpoints:
|
3 |
+
|
4 |
+
First, make sure you have installed the huggingface CLI and modelscope CLI.
|
5 |
+
|
6 |
+
```bash
|
7 |
+
pip install -U "huggingface_hub[cli]"
|
8 |
+
pip install modelscope
|
9 |
+
```
|
10 |
+
|
11 |
+
|
12 |
+
### Download the pretrained DiT and VAE checkpoints:
|
13 |
+
```bash
|
14 |
+
hf download tencent/HunyuanImage-2.1 --local-dir ./ckpts
|
15 |
+
```
|
16 |
+
|
17 |
+
### Downloading TextEncoders
|
18 |
+
|
19 |
+
HunyuanImage uses an MLLM and a byT5 as text encoders.
|
20 |
+
|
21 |
+
* **MLLM**
|
22 |
+
|
23 |
+
HunyuanImage can be integrated with different MLLMs (including HunyuanMLLM and other open-source MLLM models).
|
24 |
+
|
25 |
+
At this stage, we have not yet released the latest HunyuanMLLM. We recommend the users in community to use an open-source alternative, such as Qwen2.5-VL-7B-Instruct provided by Qwen Team, which can be downloaded by the following command:
|
26 |
+
```bash
|
27 |
+
hf download Qwen/Qwen2.5-VL-7B-Instruct --local-dir ./ckpts/text_encoder/llm
|
28 |
+
```
|
29 |
+
|
30 |
+
* **ByT5 encoder**
|
31 |
+
|
32 |
+
We use [Glyph-SDXL-v2](https://modelscope.cn/models/AI-ModelScope/Glyph-SDXL-v2) as our [byT5](https://github.com/google-research/byt5) encoder, which can be downloaded by the following command:
|
33 |
+
|
34 |
+
```bash
|
35 |
+
hf download google/byt5-small --local-dir ./ckpts/text_encoder/byt5-small
|
36 |
+
modelscope download --model AI-ModelScope/Glyph-SDXL-v2 --local_dir ./ckpts/text_encoder/Glyph-SDXL-v2
|
37 |
+
```
|
38 |
+
You can also manually download the checkpoints from [here](https://modelscope.cn/models/AI-ModelScope/Glyph-SDXL-v2/files) and place them in the text_encoder folder like:
|
39 |
+
```
|
40 |
+
ckpts
|
41 |
+
├── text_encoder
|
42 |
+
│ ├── Glyph-SDXL-v2
|
43 |
+
│ │ ├── assets
|
44 |
+
│ │ │ ├── color_idx.json
|
45 |
+
│ │ │ ├── multilingual_10-lang_idx.json
|
46 |
+
│ │ │ └── ...
|
47 |
+
│ │ └── checkpoints
|
48 |
+
│ │ ├── byt5_model.pt
|
49 |
+
│ │ └── ...
|
50 |
+
│ └─ ...
|
51 |
+
└─ ...
|
52 |
+
```
|
53 |
+
|
54 |
+
<details>
|
55 |
+
|
56 |
+
<summary>💡Tips for using hf/huggingface-cli (network problem)</summary>
|
57 |
+
|
58 |
+
##### 1. Using HF-Mirror
|
59 |
+
|
60 |
+
If you encounter slow download speeds in China, you can try a mirror to speed up the download process:
|
61 |
+
|
62 |
+
```shell
|
63 |
+
HF_ENDPOINT=https://hf-mirror.com hf download tencent/HunyuanImage-2.1 --local-dir ./ckpts
|
64 |
+
```
|
65 |
+
|
66 |
+
##### 2. Resume Download
|
67 |
+
|
68 |
+
`huggingface-cli` supports resuming downloads. If the download is interrupted, you can just rerun the download
|
69 |
+
command to resume the download process.
|
70 |
+
|
71 |
+
Note: If an `No such file or directory: 'ckpts/.huggingface/.gitignore.lock'` like error occurs during the download
|
72 |
+
process, you can ignore the error and rerun the download command.
|
73 |
+
|
74 |
+
</details>
|
config.json
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"model_name": "HunyuanImage-2.1"
|
3 |
+
}
|
dit/hunyuanimage-refiner.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a5abd9fe57fb48330add64fd660f0833dc8a94929359fb083659c5a84f637b40
|
3 |
+
size 30078032944
|
dit/hunyuanimage2.1-distilled.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:446ae6f68d0b4600e9c8cf8927fc27eed53953ef36299c3a444330d4c4ff92a4
|
3 |
+
size 34906811096
|
dit/hunyuanimage2.1.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:049634539c631a6c097d989efc2f29942637ddbb718a834a13d0c8cba22cf087
|
3 |
+
size 34851687040
|
reprompt/chat_template.jinja
ADDED
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{%- if not add_generation_prompt is defined %}
|
2 |
+
{%- set add_generation_prompt = false %}
|
3 |
+
{%- endif %}
|
4 |
+
{%- set ns = namespace(is_first=false, is_tool=false, is_output_first=true, system_prompt='', is_first_sp=true, is_first_user=true, is_last_user=false) %}
|
5 |
+
{%- for message in messages %}
|
6 |
+
{%- if message['role'] == 'system' %}
|
7 |
+
{%- if ns.is_first_sp %}
|
8 |
+
{%- set ns.system_prompt = ns.system_prompt + message['content'] %}
|
9 |
+
{%- set ns.is_first_sp = false %}
|
10 |
+
{%- else %}
|
11 |
+
{%- set ns.system_prompt = ns.system_prompt + '
|
12 |
+
|
13 |
+
' + message['content'] %}
|
14 |
+
{%- endif %}
|
15 |
+
{%- endif %}
|
16 |
+
{%- endfor %}
|
17 |
+
{{- bos_token }}
|
18 |
+
{{- ns.system_prompt }}
|
19 |
+
{%- if tools %}
|
20 |
+
{%- if ns.system_prompt != '' %}
|
21 |
+
{{- '
|
22 |
+
|
23 |
+
# Tools
|
24 |
+
|
25 |
+
You may call one or more functions to assist with the user query.' }}
|
26 |
+
{%- else %}
|
27 |
+
{{- '# Tools
|
28 |
+
|
29 |
+
You may call one or more functions to assist with the user query.' }}
|
30 |
+
{%- endif %}
|
31 |
+
{{- '
|
32 |
+
|
33 |
+
You are provided with function signatures within <tools></tools> XML tags:' }}
|
34 |
+
{{- '
|
35 |
+
<tools>
|
36 |
+
' }}
|
37 |
+
{%- for tool in tools %}
|
38 |
+
{%- if loop.index0 > 0 %}
|
39 |
+
{{- '
|
40 |
+
' }}
|
41 |
+
{%- endif %}
|
42 |
+
{{- tool | tojson }}
|
43 |
+
{%- endfor %}
|
44 |
+
{{- '
|
45 |
+
</tools>
|
46 |
+
|
47 |
+
' }}
|
48 |
+
{{- 'For function call returns, you should first print <tool_calls>' }}
|
49 |
+
{{- 'For each function call, you should return object like:
|
50 |
+
' }}
|
51 |
+
{{- '<tool_call>function_name
|
52 |
+
```json
|
53 |
+
function_arguments_in_json_format
|
54 |
+
```</tool_call>' }}
|
55 |
+
{{- 'At the end of function call returns, you should print </tool_calls>' }}
|
56 |
+
{%- endif %}
|
57 |
+
{%- if ns.system_prompt != '' or tools %}
|
58 |
+
{{- '<|extra_4|>' }}
|
59 |
+
{%- endif %}
|
60 |
+
{%- for message in messages %}
|
61 |
+
{%- if message['role'] == 'user' %}
|
62 |
+
{%- set ns.is_tool = false %}
|
63 |
+
{%- set ns.is_first = false %}
|
64 |
+
{%- set ns.is_last_user = true %}
|
65 |
+
{%- if ns.is_first_user %}
|
66 |
+
{{- message['content'] + '<|extra_0|>' }}
|
67 |
+
{%- set ns.is_first_user = false %}
|
68 |
+
{%- else %}
|
69 |
+
{{- bos_token + message['content'] + '<|extra_0|>' }}
|
70 |
+
{%- endif %}
|
71 |
+
{%- endif %}
|
72 |
+
{%- if message['role'] == 'assistant' and message['tool_calls'] is defined and message['tool_calls'] is not none %}
|
73 |
+
{%- set ns.is_last_user = false %}
|
74 |
+
{%- if ns.is_tool %}
|
75 |
+
{{- '</tool_responses>' + '<|extra_0|>' }}
|
76 |
+
{%- endif %}
|
77 |
+
{%- set ns.is_first = false %}
|
78 |
+
{%- set ns.is_tool = false %}
|
79 |
+
{%- set ns.is_output_first = true %}
|
80 |
+
{%- for tool in message['tool_calls'] %}
|
81 |
+
{%- set arguments = tool['function']['arguments'] %}
|
82 |
+
{%- if arguments is not string %}
|
83 |
+
{%- set arguments = arguments | tojson %}
|
84 |
+
{%- endif %}
|
85 |
+
{%- if not ns.is_first %}
|
86 |
+
{%- if message['content'] is none %}
|
87 |
+
{{- '<tool_calls><tool_call>' + tool['function']['name'] + '
|
88 |
+
' + '```json' + '
|
89 |
+
' + arguments + '
|
90 |
+
' + '```' + '</tool_call>' }}
|
91 |
+
{%- else %}
|
92 |
+
{{- message['content'] + '<tool_calls><tool_call>' + tool['function']['name'] + '
|
93 |
+
' + '```json' + '
|
94 |
+
' + arguments + '
|
95 |
+
' + '```' + '</tool_call>' }}
|
96 |
+
{%- endif %}
|
97 |
+
{%- set ns.is_first = true %}
|
98 |
+
{%- else %}
|
99 |
+
{{- '
|
100 |
+
' + '<tool_call>' + tool['function']['name'] + '
|
101 |
+
' + '```json' + '
|
102 |
+
' + arguments + '
|
103 |
+
' + '```' + '</tool_call>' }}
|
104 |
+
{%- endif %}
|
105 |
+
{%- endfor %}
|
106 |
+
{{- '</tool_calls>' + eos_token }}
|
107 |
+
{%- endif %}
|
108 |
+
{%- if message['role'] == 'assistant' and (message['tool_calls'] is not defined or message['tool_calls'] is none) %}
|
109 |
+
{%- set content = message['content'] %}
|
110 |
+
{%- if '<answer>' in content and not loop.last %}
|
111 |
+
{%- set content = content.split('<answer>')[-1].strip('</answer>').strip() %}
|
112 |
+
{%- endif %}
|
113 |
+
{%- set ns.is_last_user = false %}
|
114 |
+
{%- if ns.is_tool %}
|
115 |
+
{{- '</tool_responses>' + '<|extra_0|>' + content + eos_token }}
|
116 |
+
{%- set ns.is_tool = false %}
|
117 |
+
{%- else %}
|
118 |
+
{{- content + eos_token }}
|
119 |
+
{%- endif %}
|
120 |
+
{%- endif %}
|
121 |
+
{%- if message['role'] == 'tool' %}
|
122 |
+
{%- set ns.is_last_user = false %}
|
123 |
+
{%- set ns.is_tool = true %}
|
124 |
+
{%- if ns.is_output_first %}
|
125 |
+
{{- bos_token + '<tool_responses><tool_response>' + message['content'] + '</tool_response>' }}
|
126 |
+
{%- set ns.is_output_first = false %}
|
127 |
+
{%- else %}
|
128 |
+
{{- '
|
129 |
+
<tool_response>' + message['content'] + '</tool_response>' }}
|
130 |
+
{%- endif %}
|
131 |
+
{%- endif %}
|
132 |
+
{%- endfor %}
|
133 |
+
{%- if ns.is_tool %}
|
134 |
+
{{- '</tool_responses>' + '<|extra_0|>' }}
|
135 |
+
{%- endif %}
|
136 |
+
{%- if add_generation_prompt and not ns.is_last_user and not ns.is_tool %}
|
137 |
+
{{- '<|extra_0|>' }}
|
138 |
+
{%- endif %}
|
139 |
+
{%- if enable_thinking is defined and not enable_thinking %}
|
140 |
+
{{- '<think>
|
141 |
+
|
142 |
+
</think>
|
143 |
+
' }}
|
144 |
+
{%- endif %}
|
reprompt/config.json
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"add_classification_head": false,
|
3 |
+
"architectures": [
|
4 |
+
"HunYuanDenseV1ForCausalLM"
|
5 |
+
],
|
6 |
+
"attention_bias": false,
|
7 |
+
"attention_dropout": 0.1,
|
8 |
+
"attention_head_dim": 128,
|
9 |
+
"bos_token_id": 1,
|
10 |
+
"cla_share_factor": 2,
|
11 |
+
"class_num": 0,
|
12 |
+
"dense_list": [
|
13 |
+
4096,
|
14 |
+
0
|
15 |
+
],
|
16 |
+
"eos_token_id": 127960,
|
17 |
+
"head_dim": 128,
|
18 |
+
"hidden_act": "silu",
|
19 |
+
"hidden_size": 4096,
|
20 |
+
"im_end_id": 5,
|
21 |
+
"im_newline_id": 11,
|
22 |
+
"im_start_id": 4,
|
23 |
+
"initializer_range": 0.02,
|
24 |
+
"intermediate_size": 14336,
|
25 |
+
"mask_init_id": 12,
|
26 |
+
"max_position_embeddings": 32768,
|
27 |
+
"mlp_bias": false,
|
28 |
+
"model_type": "hunyuan_v1_dense",
|
29 |
+
"norm_type": "rms",
|
30 |
+
"num_attention_heads": 32,
|
31 |
+
"num_hidden_layers": 32,
|
32 |
+
"num_key_value_heads": 8,
|
33 |
+
"org_vocab_size": 128167,
|
34 |
+
"pad_id": 127961,
|
35 |
+
"pad_token_id": 127961,
|
36 |
+
"pool_type": "last",
|
37 |
+
"pretraining_tp": 1,
|
38 |
+
"rms_norm_eps": 1e-05,
|
39 |
+
"rope_scaling": {
|
40 |
+
"alpha": 1000.0,
|
41 |
+
"beta_fast": 32,
|
42 |
+
"beta_slow": 1,
|
43 |
+
"factor": 1.0,
|
44 |
+
"mscale": 1.0,
|
45 |
+
"mscale_all_dim": 1.0,
|
46 |
+
"type": "dynamic"
|
47 |
+
},
|
48 |
+
"rope_theta": 10000.0,
|
49 |
+
"sep_token_id": 127962,
|
50 |
+
"text_end_id": 7,
|
51 |
+
"text_start_id": 6,
|
52 |
+
"tie_word_embeddings": true,
|
53 |
+
"torch_dtype": "bfloat16",
|
54 |
+
"transformers_version": "4.55.0.dev0",
|
55 |
+
"use_cache": false,
|
56 |
+
"use_cla": false,
|
57 |
+
"use_qk_norm": true,
|
58 |
+
"use_rotary_pos_emb": true,
|
59 |
+
"vocab_size": 128167
|
60 |
+
}
|
reprompt/generation_config.json
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"do_sample": true,
|
3 |
+
"eos_token_id": [
|
4 |
+
127960,
|
5 |
+
127967
|
6 |
+
],
|
7 |
+
"pad_token_id": 127961,
|
8 |
+
"repetition_penalty": 1.05,
|
9 |
+
"temperature": 0.7,
|
10 |
+
"top_k": 20,
|
11 |
+
"top_p": 0.8,
|
12 |
+
"transformers_version": "4.55.0.dev0"
|
13 |
+
}
|
reprompt/hy.tiktoken
ADDED
The diff for this file is too large to render.
See raw diff
|
|
reprompt/model-00001-of-00004.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4ae7b92a03f82401b8167bd06c356352232908c1665800977ba29e8b704a4635
|
3 |
+
size 4975976336
|
reprompt/model-00002-of-00004.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:234ce217d5be6d69af8e8fb973aa43f4f3884c828da084504b7515e7bf04fb4d
|
3 |
+
size 4999811728
|
reprompt/model-00003-of-00004.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:29afb43350f898385a391b8c2ec4332a016d6a0f3b34c1d6bfd9c291da5fd822
|
3 |
+
size 4915924448
|
reprompt/model-00004-of-00004.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:363aad84039c635e939fa3a512b5393806b0a881b9b87544b4a9870cf50e906f
|
3 |
+
size 117465544
|
reprompt/model.safetensors.index.json
ADDED
@@ -0,0 +1,362 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"metadata": {
|
3 |
+
"total_parameters": 0,
|
4 |
+
"total_size": 15009136640
|
5 |
+
},
|
6 |
+
"weight_map": {
|
7 |
+
"model.embed_tokens.weight": "model-00001-of-00004.safetensors",
|
8 |
+
"model.layers.0.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
9 |
+
"model.layers.0.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
10 |
+
"model.layers.0.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
11 |
+
"model.layers.0.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
12 |
+
"model.layers.0.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
13 |
+
"model.layers.0.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
14 |
+
"model.layers.0.self_attn.key_layernorm.weight": "model-00001-of-00004.safetensors",
|
15 |
+
"model.layers.0.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
16 |
+
"model.layers.0.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
17 |
+
"model.layers.0.self_attn.query_layernorm.weight": "model-00001-of-00004.safetensors",
|
18 |
+
"model.layers.0.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
19 |
+
"model.layers.1.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
20 |
+
"model.layers.1.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
21 |
+
"model.layers.1.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
22 |
+
"model.layers.1.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
23 |
+
"model.layers.1.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
24 |
+
"model.layers.1.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
25 |
+
"model.layers.1.self_attn.key_layernorm.weight": "model-00001-of-00004.safetensors",
|
26 |
+
"model.layers.1.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
27 |
+
"model.layers.1.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
28 |
+
"model.layers.1.self_attn.query_layernorm.weight": "model-00001-of-00004.safetensors",
|
29 |
+
"model.layers.1.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
30 |
+
"model.layers.10.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
31 |
+
"model.layers.10.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
32 |
+
"model.layers.10.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
33 |
+
"model.layers.10.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
34 |
+
"model.layers.10.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
35 |
+
"model.layers.10.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
36 |
+
"model.layers.10.self_attn.key_layernorm.weight": "model-00002-of-00004.safetensors",
|
37 |
+
"model.layers.10.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
38 |
+
"model.layers.10.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
39 |
+
"model.layers.10.self_attn.query_layernorm.weight": "model-00002-of-00004.safetensors",
|
40 |
+
"model.layers.10.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
41 |
+
"model.layers.11.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
42 |
+
"model.layers.11.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
43 |
+
"model.layers.11.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
44 |
+
"model.layers.11.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
45 |
+
"model.layers.11.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
46 |
+
"model.layers.11.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
47 |
+
"model.layers.11.self_attn.key_layernorm.weight": "model-00002-of-00004.safetensors",
|
48 |
+
"model.layers.11.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
49 |
+
"model.layers.11.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
50 |
+
"model.layers.11.self_attn.query_layernorm.weight": "model-00002-of-00004.safetensors",
|
51 |
+
"model.layers.11.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
52 |
+
"model.layers.12.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
53 |
+
"model.layers.12.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
54 |
+
"model.layers.12.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
55 |
+
"model.layers.12.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
56 |
+
"model.layers.12.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
57 |
+
"model.layers.12.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
58 |
+
"model.layers.12.self_attn.key_layernorm.weight": "model-00002-of-00004.safetensors",
|
59 |
+
"model.layers.12.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
60 |
+
"model.layers.12.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
61 |
+
"model.layers.12.self_attn.query_layernorm.weight": "model-00002-of-00004.safetensors",
|
62 |
+
"model.layers.12.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
63 |
+
"model.layers.13.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
64 |
+
"model.layers.13.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
65 |
+
"model.layers.13.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
66 |
+
"model.layers.13.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
67 |
+
"model.layers.13.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
68 |
+
"model.layers.13.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
69 |
+
"model.layers.13.self_attn.key_layernorm.weight": "model-00002-of-00004.safetensors",
|
70 |
+
"model.layers.13.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
71 |
+
"model.layers.13.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
72 |
+
"model.layers.13.self_attn.query_layernorm.weight": "model-00002-of-00004.safetensors",
|
73 |
+
"model.layers.13.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
74 |
+
"model.layers.14.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
75 |
+
"model.layers.14.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
76 |
+
"model.layers.14.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
77 |
+
"model.layers.14.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
78 |
+
"model.layers.14.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
79 |
+
"model.layers.14.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
80 |
+
"model.layers.14.self_attn.key_layernorm.weight": "model-00002-of-00004.safetensors",
|
81 |
+
"model.layers.14.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
82 |
+
"model.layers.14.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
83 |
+
"model.layers.14.self_attn.query_layernorm.weight": "model-00002-of-00004.safetensors",
|
84 |
+
"model.layers.14.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
85 |
+
"model.layers.15.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
86 |
+
"model.layers.15.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
87 |
+
"model.layers.15.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
88 |
+
"model.layers.15.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
89 |
+
"model.layers.15.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
90 |
+
"model.layers.15.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
91 |
+
"model.layers.15.self_attn.key_layernorm.weight": "model-00002-of-00004.safetensors",
|
92 |
+
"model.layers.15.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
93 |
+
"model.layers.15.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
94 |
+
"model.layers.15.self_attn.query_layernorm.weight": "model-00002-of-00004.safetensors",
|
95 |
+
"model.layers.15.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
96 |
+
"model.layers.16.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
97 |
+
"model.layers.16.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
98 |
+
"model.layers.16.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
99 |
+
"model.layers.16.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
100 |
+
"model.layers.16.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
101 |
+
"model.layers.16.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
102 |
+
"model.layers.16.self_attn.key_layernorm.weight": "model-00002-of-00004.safetensors",
|
103 |
+
"model.layers.16.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
104 |
+
"model.layers.16.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
105 |
+
"model.layers.16.self_attn.query_layernorm.weight": "model-00002-of-00004.safetensors",
|
106 |
+
"model.layers.16.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
107 |
+
"model.layers.17.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
108 |
+
"model.layers.17.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
109 |
+
"model.layers.17.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
110 |
+
"model.layers.17.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
111 |
+
"model.layers.17.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
112 |
+
"model.layers.17.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
113 |
+
"model.layers.17.self_attn.key_layernorm.weight": "model-00002-of-00004.safetensors",
|
114 |
+
"model.layers.17.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
115 |
+
"model.layers.17.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
116 |
+
"model.layers.17.self_attn.query_layernorm.weight": "model-00002-of-00004.safetensors",
|
117 |
+
"model.layers.17.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
118 |
+
"model.layers.18.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
119 |
+
"model.layers.18.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
120 |
+
"model.layers.18.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
121 |
+
"model.layers.18.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
122 |
+
"model.layers.18.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
123 |
+
"model.layers.18.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
124 |
+
"model.layers.18.self_attn.key_layernorm.weight": "model-00002-of-00004.safetensors",
|
125 |
+
"model.layers.18.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
126 |
+
"model.layers.18.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
127 |
+
"model.layers.18.self_attn.query_layernorm.weight": "model-00002-of-00004.safetensors",
|
128 |
+
"model.layers.18.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
129 |
+
"model.layers.19.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
130 |
+
"model.layers.19.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
131 |
+
"model.layers.19.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
132 |
+
"model.layers.19.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
133 |
+
"model.layers.19.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
134 |
+
"model.layers.19.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
135 |
+
"model.layers.19.self_attn.key_layernorm.weight": "model-00002-of-00004.safetensors",
|
136 |
+
"model.layers.19.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
137 |
+
"model.layers.19.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
138 |
+
"model.layers.19.self_attn.query_layernorm.weight": "model-00002-of-00004.safetensors",
|
139 |
+
"model.layers.19.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
140 |
+
"model.layers.2.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
141 |
+
"model.layers.2.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
142 |
+
"model.layers.2.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
143 |
+
"model.layers.2.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
144 |
+
"model.layers.2.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
145 |
+
"model.layers.2.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
146 |
+
"model.layers.2.self_attn.key_layernorm.weight": "model-00001-of-00004.safetensors",
|
147 |
+
"model.layers.2.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
148 |
+
"model.layers.2.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
149 |
+
"model.layers.2.self_attn.query_layernorm.weight": "model-00001-of-00004.safetensors",
|
150 |
+
"model.layers.2.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
151 |
+
"model.layers.20.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
152 |
+
"model.layers.20.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
153 |
+
"model.layers.20.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
154 |
+
"model.layers.20.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
155 |
+
"model.layers.20.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
156 |
+
"model.layers.20.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
157 |
+
"model.layers.20.self_attn.key_layernorm.weight": "model-00002-of-00004.safetensors",
|
158 |
+
"model.layers.20.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
159 |
+
"model.layers.20.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
160 |
+
"model.layers.20.self_attn.query_layernorm.weight": "model-00002-of-00004.safetensors",
|
161 |
+
"model.layers.20.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
162 |
+
"model.layers.21.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
163 |
+
"model.layers.21.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
164 |
+
"model.layers.21.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
165 |
+
"model.layers.21.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
166 |
+
"model.layers.21.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
167 |
+
"model.layers.21.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
168 |
+
"model.layers.21.self_attn.key_layernorm.weight": "model-00003-of-00004.safetensors",
|
169 |
+
"model.layers.21.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
170 |
+
"model.layers.21.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
171 |
+
"model.layers.21.self_attn.query_layernorm.weight": "model-00003-of-00004.safetensors",
|
172 |
+
"model.layers.21.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
173 |
+
"model.layers.22.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
174 |
+
"model.layers.22.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
175 |
+
"model.layers.22.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
176 |
+
"model.layers.22.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
177 |
+
"model.layers.22.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
178 |
+
"model.layers.22.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
179 |
+
"model.layers.22.self_attn.key_layernorm.weight": "model-00003-of-00004.safetensors",
|
180 |
+
"model.layers.22.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
181 |
+
"model.layers.22.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
182 |
+
"model.layers.22.self_attn.query_layernorm.weight": "model-00003-of-00004.safetensors",
|
183 |
+
"model.layers.22.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
184 |
+
"model.layers.23.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
185 |
+
"model.layers.23.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
186 |
+
"model.layers.23.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
187 |
+
"model.layers.23.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
188 |
+
"model.layers.23.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
189 |
+
"model.layers.23.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
190 |
+
"model.layers.23.self_attn.key_layernorm.weight": "model-00003-of-00004.safetensors",
|
191 |
+
"model.layers.23.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
192 |
+
"model.layers.23.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
193 |
+
"model.layers.23.self_attn.query_layernorm.weight": "model-00003-of-00004.safetensors",
|
194 |
+
"model.layers.23.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
195 |
+
"model.layers.24.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
196 |
+
"model.layers.24.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
197 |
+
"model.layers.24.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
198 |
+
"model.layers.24.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
199 |
+
"model.layers.24.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
200 |
+
"model.layers.24.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
201 |
+
"model.layers.24.self_attn.key_layernorm.weight": "model-00003-of-00004.safetensors",
|
202 |
+
"model.layers.24.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
203 |
+
"model.layers.24.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
204 |
+
"model.layers.24.self_attn.query_layernorm.weight": "model-00003-of-00004.safetensors",
|
205 |
+
"model.layers.24.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
206 |
+
"model.layers.25.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
207 |
+
"model.layers.25.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
208 |
+
"model.layers.25.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
209 |
+
"model.layers.25.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
210 |
+
"model.layers.25.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
211 |
+
"model.layers.25.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
212 |
+
"model.layers.25.self_attn.key_layernorm.weight": "model-00003-of-00004.safetensors",
|
213 |
+
"model.layers.25.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
214 |
+
"model.layers.25.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
215 |
+
"model.layers.25.self_attn.query_layernorm.weight": "model-00003-of-00004.safetensors",
|
216 |
+
"model.layers.25.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
217 |
+
"model.layers.26.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
218 |
+
"model.layers.26.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
219 |
+
"model.layers.26.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
220 |
+
"model.layers.26.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
221 |
+
"model.layers.26.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
222 |
+
"model.layers.26.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
223 |
+
"model.layers.26.self_attn.key_layernorm.weight": "model-00003-of-00004.safetensors",
|
224 |
+
"model.layers.26.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
225 |
+
"model.layers.26.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
226 |
+
"model.layers.26.self_attn.query_layernorm.weight": "model-00003-of-00004.safetensors",
|
227 |
+
"model.layers.26.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
228 |
+
"model.layers.27.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
229 |
+
"model.layers.27.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
230 |
+
"model.layers.27.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
231 |
+
"model.layers.27.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
232 |
+
"model.layers.27.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
233 |
+
"model.layers.27.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
234 |
+
"model.layers.27.self_attn.key_layernorm.weight": "model-00003-of-00004.safetensors",
|
235 |
+
"model.layers.27.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
236 |
+
"model.layers.27.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
237 |
+
"model.layers.27.self_attn.query_layernorm.weight": "model-00003-of-00004.safetensors",
|
238 |
+
"model.layers.27.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
239 |
+
"model.layers.28.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
240 |
+
"model.layers.28.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
241 |
+
"model.layers.28.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
242 |
+
"model.layers.28.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
243 |
+
"model.layers.28.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
244 |
+
"model.layers.28.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
245 |
+
"model.layers.28.self_attn.key_layernorm.weight": "model-00003-of-00004.safetensors",
|
246 |
+
"model.layers.28.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
247 |
+
"model.layers.28.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
248 |
+
"model.layers.28.self_attn.query_layernorm.weight": "model-00003-of-00004.safetensors",
|
249 |
+
"model.layers.28.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
250 |
+
"model.layers.29.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
251 |
+
"model.layers.29.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
252 |
+
"model.layers.29.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
253 |
+
"model.layers.29.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
254 |
+
"model.layers.29.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
255 |
+
"model.layers.29.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
256 |
+
"model.layers.29.self_attn.key_layernorm.weight": "model-00003-of-00004.safetensors",
|
257 |
+
"model.layers.29.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
258 |
+
"model.layers.29.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
259 |
+
"model.layers.29.self_attn.query_layernorm.weight": "model-00003-of-00004.safetensors",
|
260 |
+
"model.layers.29.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
261 |
+
"model.layers.3.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
262 |
+
"model.layers.3.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
263 |
+
"model.layers.3.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
264 |
+
"model.layers.3.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
265 |
+
"model.layers.3.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
266 |
+
"model.layers.3.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
267 |
+
"model.layers.3.self_attn.key_layernorm.weight": "model-00001-of-00004.safetensors",
|
268 |
+
"model.layers.3.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
269 |
+
"model.layers.3.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
270 |
+
"model.layers.3.self_attn.query_layernorm.weight": "model-00001-of-00004.safetensors",
|
271 |
+
"model.layers.3.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
272 |
+
"model.layers.30.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
273 |
+
"model.layers.30.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
274 |
+
"model.layers.30.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
275 |
+
"model.layers.30.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
276 |
+
"model.layers.30.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
277 |
+
"model.layers.30.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
278 |
+
"model.layers.30.self_attn.key_layernorm.weight": "model-00003-of-00004.safetensors",
|
279 |
+
"model.layers.30.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
280 |
+
"model.layers.30.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
281 |
+
"model.layers.30.self_attn.query_layernorm.weight": "model-00003-of-00004.safetensors",
|
282 |
+
"model.layers.30.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
283 |
+
"model.layers.31.input_layernorm.weight": "model-00004-of-00004.safetensors",
|
284 |
+
"model.layers.31.mlp.down_proj.weight": "model-00004-of-00004.safetensors",
|
285 |
+
"model.layers.31.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
286 |
+
"model.layers.31.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
287 |
+
"model.layers.31.post_attention_layernorm.weight": "model-00004-of-00004.safetensors",
|
288 |
+
"model.layers.31.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
289 |
+
"model.layers.31.self_attn.key_layernorm.weight": "model-00003-of-00004.safetensors",
|
290 |
+
"model.layers.31.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
291 |
+
"model.layers.31.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
292 |
+
"model.layers.31.self_attn.query_layernorm.weight": "model-00003-of-00004.safetensors",
|
293 |
+
"model.layers.31.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
294 |
+
"model.layers.4.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
295 |
+
"model.layers.4.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
296 |
+
"model.layers.4.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
297 |
+
"model.layers.4.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
298 |
+
"model.layers.4.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
299 |
+
"model.layers.4.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
300 |
+
"model.layers.4.self_attn.key_layernorm.weight": "model-00001-of-00004.safetensors",
|
301 |
+
"model.layers.4.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
302 |
+
"model.layers.4.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
303 |
+
"model.layers.4.self_attn.query_layernorm.weight": "model-00001-of-00004.safetensors",
|
304 |
+
"model.layers.4.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
305 |
+
"model.layers.5.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
306 |
+
"model.layers.5.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
307 |
+
"model.layers.5.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
308 |
+
"model.layers.5.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
309 |
+
"model.layers.5.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
310 |
+
"model.layers.5.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
311 |
+
"model.layers.5.self_attn.key_layernorm.weight": "model-00001-of-00004.safetensors",
|
312 |
+
"model.layers.5.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
313 |
+
"model.layers.5.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
314 |
+
"model.layers.5.self_attn.query_layernorm.weight": "model-00001-of-00004.safetensors",
|
315 |
+
"model.layers.5.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
316 |
+
"model.layers.6.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
317 |
+
"model.layers.6.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
318 |
+
"model.layers.6.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
319 |
+
"model.layers.6.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
320 |
+
"model.layers.6.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
321 |
+
"model.layers.6.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
322 |
+
"model.layers.6.self_attn.key_layernorm.weight": "model-00001-of-00004.safetensors",
|
323 |
+
"model.layers.6.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
324 |
+
"model.layers.6.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
325 |
+
"model.layers.6.self_attn.query_layernorm.weight": "model-00001-of-00004.safetensors",
|
326 |
+
"model.layers.6.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
327 |
+
"model.layers.7.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
328 |
+
"model.layers.7.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
329 |
+
"model.layers.7.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
330 |
+
"model.layers.7.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
331 |
+
"model.layers.7.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
332 |
+
"model.layers.7.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
333 |
+
"model.layers.7.self_attn.key_layernorm.weight": "model-00001-of-00004.safetensors",
|
334 |
+
"model.layers.7.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
335 |
+
"model.layers.7.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
336 |
+
"model.layers.7.self_attn.query_layernorm.weight": "model-00001-of-00004.safetensors",
|
337 |
+
"model.layers.7.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
338 |
+
"model.layers.8.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
339 |
+
"model.layers.8.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
340 |
+
"model.layers.8.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
341 |
+
"model.layers.8.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
342 |
+
"model.layers.8.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
343 |
+
"model.layers.8.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
344 |
+
"model.layers.8.self_attn.key_layernorm.weight": "model-00001-of-00004.safetensors",
|
345 |
+
"model.layers.8.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
346 |
+
"model.layers.8.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
347 |
+
"model.layers.8.self_attn.query_layernorm.weight": "model-00001-of-00004.safetensors",
|
348 |
+
"model.layers.8.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
349 |
+
"model.layers.9.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
350 |
+
"model.layers.9.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
351 |
+
"model.layers.9.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
352 |
+
"model.layers.9.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
353 |
+
"model.layers.9.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
354 |
+
"model.layers.9.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
355 |
+
"model.layers.9.self_attn.key_layernorm.weight": "model-00002-of-00004.safetensors",
|
356 |
+
"model.layers.9.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
357 |
+
"model.layers.9.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
358 |
+
"model.layers.9.self_attn.query_layernorm.weight": "model-00002-of-00004.safetensors",
|
359 |
+
"model.layers.9.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
360 |
+
"model.norm.weight": "model-00004-of-00004.safetensors"
|
361 |
+
}
|
362 |
+
}
|
reprompt/special_tokens_map.json
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"additional_special_tokens": [
|
3 |
+
"<|startoftext|>",
|
4 |
+
"<|extra_0|>",
|
5 |
+
"<|extra_4|>",
|
6 |
+
"<|extra_5|>",
|
7 |
+
"<|eos|>"
|
8 |
+
],
|
9 |
+
"bos_token": "<|startoftext|>",
|
10 |
+
"eos_token": "<|eos|>",
|
11 |
+
"pad_token": "<|pad|>"
|
12 |
+
}
|
reprompt/tokenization_hy.py
ADDED
@@ -0,0 +1,298 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import base64
|
2 |
+
import logging
|
3 |
+
import os
|
4 |
+
import unicodedata
|
5 |
+
from typing import Collection, Dict, List, Set, Tuple, Union
|
6 |
+
|
7 |
+
import tiktoken
|
8 |
+
from transformers import PreTrainedTokenizer, AddedToken
|
9 |
+
|
10 |
+
logger = logging.getLogger(__name__)
|
11 |
+
|
12 |
+
|
13 |
+
VOCAB_FILES_NAMES = {"vocab_file": "hy.tiktoken"}
|
14 |
+
|
15 |
+
PAT_STR = r"""(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\r\n\p{L}\p{N}]?\p{L}+|\p{N}| ?[^\s\p{L}\p{N}]+[\r\n]*|\s*[\r\n]+|\s+(?!\S)|\s+"""
|
16 |
+
# PAT_STR = r"""(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\r\n\p{L}\p{N}]?\p{L}+|\p{N}{1,3}| ?[^\s\p{L}\p{N}]+[\r\n]*|\s*[\r\n]+|\s+(?!\S)|\s+"""
|
17 |
+
ENDOFTEXT = "<|endoftext|>"
|
18 |
+
STARTOFTEXT = "<|startoftext|>"
|
19 |
+
BOSTOKEN = "<|bos|>"
|
20 |
+
EOSTOKEN = "<|eos|>"
|
21 |
+
PADTOKEN = "<|pad|>"
|
22 |
+
|
23 |
+
# as the default behavior is changed to allow special tokens in
|
24 |
+
# regular texts, the surface forms of special tokens need to be
|
25 |
+
# as different as possible to minimize the impact
|
26 |
+
EXTRAS = tuple((f"<|extra_{i}|>" for i in range(205)))
|
27 |
+
# changed to use actual index to avoid misconfiguration with vocabulary expansion
|
28 |
+
|
29 |
+
|
30 |
+
SPECIAL_START_ID = 127957
|
31 |
+
|
32 |
+
def _load_tiktoken_bpe(tiktoken_bpe_file: str) -> Dict[bytes, int]:
|
33 |
+
# with open(tiktoken_bpe_file, "rb", encoding="utf-8") as f:
|
34 |
+
# contents = f.read()
|
35 |
+
dic = {}
|
36 |
+
rank = 0
|
37 |
+
for line in open(tiktoken_bpe_file, "rb"):
|
38 |
+
if line:
|
39 |
+
token, _ = line.split()
|
40 |
+
if base64.b64decode(token) in dic:
|
41 |
+
continue
|
42 |
+
dic[base64.b64decode(token)] = int(rank)
|
43 |
+
rank += 1
|
44 |
+
global SPECIAL_START_ID
|
45 |
+
SPECIAL_START_ID=rank
|
46 |
+
return dic
|
47 |
+
|
48 |
+
# NOTE: Please use the code line to check `SPECIAL_START_ID` right, this will affect the SPECIAL_START_ID
|
49 |
+
# _load_tiktoken_bpe('/apdcephfs/share_1502809/shaneshu/tokenizer_exp/other_tokenizer_vocab/hy/' + VOCAB_FILES_NAMES['vocab_file'])
|
50 |
+
# print(SPECIAL_START_ID)
|
51 |
+
|
52 |
+
SPECIAL_TOKENS = tuple(
|
53 |
+
enumerate(
|
54 |
+
(
|
55 |
+
(
|
56 |
+
ENDOFTEXT,
|
57 |
+
STARTOFTEXT,
|
58 |
+
BOSTOKEN,
|
59 |
+
EOSTOKEN,
|
60 |
+
PADTOKEN,
|
61 |
+
)
|
62 |
+
+ EXTRAS
|
63 |
+
),
|
64 |
+
start=SPECIAL_START_ID,
|
65 |
+
)
|
66 |
+
)
|
67 |
+
# NOTE: Unused Token ID starts from 127962
|
68 |
+
SPECIAL_TOKENS_SET = set(t for i, t in SPECIAL_TOKENS)
|
69 |
+
|
70 |
+
class HYTokenizer(PreTrainedTokenizer):
|
71 |
+
"""hunyuan tokenizer."""
|
72 |
+
|
73 |
+
vocab_files_names = VOCAB_FILES_NAMES
|
74 |
+
|
75 |
+
def __init__(
|
76 |
+
self,
|
77 |
+
vocab_file,
|
78 |
+
errors="replace",
|
79 |
+
extra_vocab_file=None,
|
80 |
+
**kwargs,
|
81 |
+
):
|
82 |
+
super().__init__(**kwargs)
|
83 |
+
|
84 |
+
# how to handle errors in decoding UTF-8 byte sequences
|
85 |
+
# use ignore if you are in streaming inference
|
86 |
+
self.errors = errors
|
87 |
+
|
88 |
+
self.mergeable_ranks = _load_tiktoken_bpe(vocab_file) # type: Dict[bytes, int]
|
89 |
+
self.special_tokens = {
|
90 |
+
token: index
|
91 |
+
for index, token in SPECIAL_TOKENS
|
92 |
+
}
|
93 |
+
|
94 |
+
# try load extra vocab from file
|
95 |
+
if extra_vocab_file is not None:
|
96 |
+
used_ids = set(self.mergeable_ranks.values()) | set(self.special_tokens.values())
|
97 |
+
extra_mergeable_ranks = _load_tiktoken_bpe(extra_vocab_file)
|
98 |
+
for token, index in extra_mergeable_ranks.items():
|
99 |
+
if token in self.mergeable_ranks:
|
100 |
+
logger.info(f"extra token {token} exists, skipping")
|
101 |
+
continue
|
102 |
+
if index in used_ids:
|
103 |
+
logger.info(f'the index {index} for extra token {token} exists, skipping')
|
104 |
+
continue
|
105 |
+
self.mergeable_ranks[token] = index
|
106 |
+
# the index may be sparse after this, but don't worry tiktoken.Encoding will handle this
|
107 |
+
|
108 |
+
enc = tiktoken.Encoding(
|
109 |
+
"HunYuan",
|
110 |
+
pat_str=PAT_STR,
|
111 |
+
mergeable_ranks=self.mergeable_ranks,
|
112 |
+
special_tokens=self.special_tokens,
|
113 |
+
)
|
114 |
+
assert (
|
115 |
+
len(self.mergeable_ranks) + len(self.special_tokens) == enc.n_vocab
|
116 |
+
), f"{len(self.mergeable_ranks)} + {len(self.special_tokens)} != {enc.n_vocab} in encoding"
|
117 |
+
|
118 |
+
self.decoder = {
|
119 |
+
v: k for k, v in self.mergeable_ranks.items()
|
120 |
+
} # type: dict[int, bytes|str]
|
121 |
+
self.decoder.update({v: k for k, v in self.special_tokens.items()})
|
122 |
+
|
123 |
+
self.tokenizer = enc # type: tiktoken.Encoding
|
124 |
+
|
125 |
+
self.eod_id = self.tokenizer.eot_token
|
126 |
+
self.bod_id = self.special_tokens[STARTOFTEXT]
|
127 |
+
self.bos_id = self.special_tokens[BOSTOKEN]
|
128 |
+
self.eos_id = self.special_tokens[EOSTOKEN]
|
129 |
+
self.pad_id = self.special_tokens[PADTOKEN]
|
130 |
+
|
131 |
+
def __getstate__(self):
|
132 |
+
# for pickle lovers
|
133 |
+
state = self.__dict__.copy()
|
134 |
+
del state["tokenizer"]
|
135 |
+
return state
|
136 |
+
|
137 |
+
def __setstate__(self, state):
|
138 |
+
# tokenizer is not python native; don't pass it; rebuild it
|
139 |
+
self.__dict__.update(state)
|
140 |
+
enc = tiktoken.Encoding(
|
141 |
+
"HunYuan",
|
142 |
+
pat_str=PAT_STR,
|
143 |
+
mergeable_ranks=self.mergeable_ranks,
|
144 |
+
special_tokens=self.special_tokens,
|
145 |
+
)
|
146 |
+
self.tokenizer = enc
|
147 |
+
|
148 |
+
def __len__(self) -> int:
|
149 |
+
return self.tokenizer.n_vocab
|
150 |
+
|
151 |
+
def get_vocab(self) -> Dict[bytes, int]:
|
152 |
+
return self.mergeable_ranks
|
153 |
+
|
154 |
+
def convert_tokens_to_ids(
|
155 |
+
self, tokens: Union[bytes, str, List[Union[bytes, str]]]
|
156 |
+
) -> List[int]:
|
157 |
+
ids = []
|
158 |
+
if isinstance(tokens, (str, bytes)):
|
159 |
+
if tokens in self.special_tokens:
|
160 |
+
return self.special_tokens[tokens]
|
161 |
+
else:
|
162 |
+
return self.mergeable_ranks.get(tokens)
|
163 |
+
for token in tokens:
|
164 |
+
if token in self.special_tokens:
|
165 |
+
ids.append(self.special_tokens[token])
|
166 |
+
else:
|
167 |
+
ids.append(self.mergeable_ranks.get(token))
|
168 |
+
return ids
|
169 |
+
|
170 |
+
def _add_tokens(
|
171 |
+
self,
|
172 |
+
new_tokens: Union[List[str], List[AddedToken]],
|
173 |
+
special_tokens: bool = False,
|
174 |
+
) -> int:
|
175 |
+
if not special_tokens and new_tokens:
|
176 |
+
raise ValueError("Adding regular tokens is not supported")
|
177 |
+
for token in new_tokens:
|
178 |
+
surface_form = token.content if isinstance(token, AddedToken) else token
|
179 |
+
if surface_form not in SPECIAL_TOKENS_SET:
|
180 |
+
raise ValueError("Adding unknown special tokens is not supported")
|
181 |
+
return 0
|
182 |
+
|
183 |
+
def save_vocabulary(self, save_directory: str, **kwargs) -> Tuple[str]:
|
184 |
+
"""
|
185 |
+
Save only the vocabulary of the tokenizer (vocabulary).
|
186 |
+
Returns:
|
187 |
+
`Tuple(str)`: Paths to the files saved.
|
188 |
+
"""
|
189 |
+
file_path = os.path.join(save_directory, "hy.tiktoken")
|
190 |
+
with open(file_path, "w", encoding="utf-8") as w:
|
191 |
+
for k, v in self.mergeable_ranks.items():
|
192 |
+
line = base64.b64encode(k).decode("utf-8") + " " + str(v) + "\n"
|
193 |
+
w.write(line)
|
194 |
+
return (file_path,)
|
195 |
+
|
196 |
+
def tokenize(
|
197 |
+
self,
|
198 |
+
text: str,
|
199 |
+
allowed_special: Union[Set, str] = "all",
|
200 |
+
disallowed_special: Union[Collection, str] = (),
|
201 |
+
**kwargs,
|
202 |
+
) -> List[Union[bytes, str]]:
|
203 |
+
"""
|
204 |
+
Converts a string in a sequence of tokens.
|
205 |
+
Args:
|
206 |
+
text (`str`):
|
207 |
+
The sequence to be encoded.
|
208 |
+
allowed_special (`Literal["all"]` or `set`):
|
209 |
+
The surface forms of the tokens to be encoded as special tokens in regular texts.
|
210 |
+
Default to "all".
|
211 |
+
disallowed_special (`Literal["all"]` or `Collection`):
|
212 |
+
The surface forms of the tokens that should not be in regular texts and trigger errors.
|
213 |
+
Default to an empty tuple.
|
214 |
+
kwargs (additional keyword arguments, *optional*):
|
215 |
+
Will be passed to the underlying model specific encode method.
|
216 |
+
Returns:
|
217 |
+
`List[bytes|str]`: The list of tokens.
|
218 |
+
"""
|
219 |
+
tokens = []
|
220 |
+
text = unicodedata.normalize("NFC", text)
|
221 |
+
|
222 |
+
# this implementation takes a detour: text -> token id -> token surface forms
|
223 |
+
for t in self.tokenizer.encode(
|
224 |
+
text, allowed_special=allowed_special, disallowed_special=disallowed_special
|
225 |
+
):
|
226 |
+
tokens.append(self.decoder[t])
|
227 |
+
return tokens
|
228 |
+
|
229 |
+
def convert_tokens_to_string(self, tokens: List[Union[bytes, str]]) -> str:
|
230 |
+
"""
|
231 |
+
Converts a sequence of tokens in a single string.
|
232 |
+
"""
|
233 |
+
text = ""
|
234 |
+
temp = b""
|
235 |
+
for t in tokens:
|
236 |
+
if isinstance(t, str):
|
237 |
+
if temp:
|
238 |
+
text += temp.decode("utf-8", errors=self.errors)
|
239 |
+
temp = b""
|
240 |
+
text += t
|
241 |
+
elif isinstance(t, bytes):
|
242 |
+
temp += t
|
243 |
+
else:
|
244 |
+
raise TypeError("token should only be of type types or str")
|
245 |
+
if temp:
|
246 |
+
text += temp.decode("utf-8", errors=self.errors)
|
247 |
+
return text
|
248 |
+
|
249 |
+
@property
|
250 |
+
def vocab_size(self):
|
251 |
+
return self.tokenizer.n_vocab
|
252 |
+
|
253 |
+
def _convert_id_to_token(self, index: int) -> Union[bytes, str]:
|
254 |
+
"""Converts an id to a token, special tokens included"""
|
255 |
+
if index in self.decoder:
|
256 |
+
return self.decoder[index]
|
257 |
+
raise ValueError("unknown ids")
|
258 |
+
|
259 |
+
def _convert_token_to_id(self, token: Union[bytes, str]) -> int:
|
260 |
+
"""Converts a token to an id using the vocab, special tokens included"""
|
261 |
+
if token in self.special_tokens:
|
262 |
+
return self.special_tokens[token]
|
263 |
+
if token in self.mergeable_ranks:
|
264 |
+
return self.mergeable_ranks[token]
|
265 |
+
raise ValueError("unknown token")
|
266 |
+
|
267 |
+
def _tokenize(self, text: str, **kwargs):
|
268 |
+
"""
|
269 |
+
Converts a string in a sequence of tokens (string), using the tokenizer. Split in words for word-based
|
270 |
+
vocabulary or sub-words for sub-word-based vocabularies (BPE/SentencePieces/WordPieces).
|
271 |
+
Do NOT take care of added tokens.
|
272 |
+
"""
|
273 |
+
raise NotImplementedError
|
274 |
+
|
275 |
+
def _decode(
|
276 |
+
self,
|
277 |
+
token_ids: Union[int, List[int]],
|
278 |
+
skip_special_tokens: bool = False,
|
279 |
+
errors: str = None,
|
280 |
+
**kwargs,
|
281 |
+
) -> str:
|
282 |
+
if isinstance(token_ids, int):
|
283 |
+
token_ids = [token_ids]
|
284 |
+
if skip_special_tokens:
|
285 |
+
token_ids = [i for i in token_ids if i < self.eod_id]
|
286 |
+
return self.tokenizer.decode(token_ids, errors=errors or self.errors)
|
287 |
+
|
288 |
+
# tests
|
289 |
+
if __name__ == "__main__":
|
290 |
+
tokenizer = HYTokenizer.from_pretrained('./other_tokenizer_vocab/hy')
|
291 |
+
text = '你好,世界'
|
292 |
+
tokens = tokenizer.tokenize(text)
|
293 |
+
print(tokens)
|
294 |
+
ids = tokenizer.convert_tokens_to_ids(tokens)
|
295 |
+
print(ids)
|
296 |
+
text2 = tokenizer.convert_tokens_to_string(tokens)
|
297 |
+
print(text2)
|
298 |
+
ids2 = tokenizer.convert_tokens_to_ids(tokens)
|
reprompt/tokenizer_config.json
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"added_tokens_decoder": {},
|
3 |
+
"additional_special_tokens": [
|
4 |
+
"<|startoftext|>",
|
5 |
+
"<|extra_0|>",
|
6 |
+
"<|extra_4|>",
|
7 |
+
"<|extra_5|>",
|
8 |
+
"<|eos|>"
|
9 |
+
],
|
10 |
+
"architectures": [
|
11 |
+
"GPT2LMHeadModel"
|
12 |
+
],
|
13 |
+
"auto_map": {
|
14 |
+
"AutoTokenizer": [
|
15 |
+
"tokenization_hy.HYTokenizer",
|
16 |
+
null
|
17 |
+
]
|
18 |
+
},
|
19 |
+
"bos_token": "<|startoftext|>",
|
20 |
+
"clean_up_tokenization_spaces": false,
|
21 |
+
"eos_token": "<|eos|>",
|
22 |
+
"extra_special_tokens": {},
|
23 |
+
"model_max_length": 262144,
|
24 |
+
"model_type": "gpt2",
|
25 |
+
"pad_token": "<|pad|>",
|
26 |
+
"padding_side": "right",
|
27 |
+
"split_special_tokens": false,
|
28 |
+
"tokenizer_class": "HYTokenizer"
|
29 |
+
}
|
vae/vae_2_1/config.json
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_class_name": "HYVAE2D",
|
3 |
+
"block_out_channels": [
|
4 |
+
128,
|
5 |
+
256,
|
6 |
+
512,
|
7 |
+
512,
|
8 |
+
1024,
|
9 |
+
1024
|
10 |
+
],
|
11 |
+
"in_channels": 3,
|
12 |
+
"out_channels": 3,
|
13 |
+
"latent_channels": 64,
|
14 |
+
"layers_per_block": 2,
|
15 |
+
"ffactor_spatial": 32,
|
16 |
+
"sample_size": 384,
|
17 |
+
"sample_tsize": 96,
|
18 |
+
"scaling_factor": 0.75289,
|
19 |
+
"downsample_match_channel": true,
|
20 |
+
"upsample_match_channel": true
|
21 |
+
}
|
vae/vae_2_1/pytorch_model.ckpt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:85a0aec2ffb92ba1bba363c6e9c673e1b52997808a4a496e2b127b1e62733e90
|
3 |
+
size 1622406234
|
vae/vae_refiner/config.json
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_class_name": "AutoencoderKLConv3D",
|
3 |
+
"block_out_channels": [
|
4 |
+
128,
|
5 |
+
256,
|
6 |
+
512,
|
7 |
+
1024,
|
8 |
+
1024
|
9 |
+
],
|
10 |
+
"in_channels": 3,
|
11 |
+
"out_channels": 3,
|
12 |
+
"latent_channels": 32,
|
13 |
+
"layers_per_block": 2,
|
14 |
+
"ffactor_spatial": 16,
|
15 |
+
"ffactor_temporal": 4,
|
16 |
+
"sample_size": 256,
|
17 |
+
"sample_tsize": 64,
|
18 |
+
"downsample_match_channel": true,
|
19 |
+
"spatial_compression_ratio": 16,
|
20 |
+
"time_compression_ratio": 4,
|
21 |
+
"upsample_match_channel": true,
|
22 |
+
"scaling_factor": 1.03682
|
23 |
+
}
|
vae/vae_refiner/pytorch_model.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:25e13ce1c72e356ee6743ab75c1a597f2b28cf5d9f294448545288c6e1740f8a
|
3 |
+
size 5365502622
|