Text Generation
Transformers
Safetensors
English
Chinese
ernie5_5_moe
ERNIE5.5
MoE
agent
Eval Results
8-bit precision
fp8
Instructions to use baidu/ERNIE-5.5-Flash-Preview with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use baidu/ERNIE-5.5-Flash-Preview with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="baidu/ERNIE-5.5-Flash-Preview")# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("baidu/ERNIE-5.5-Flash-Preview", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use baidu/ERNIE-5.5-Flash-Preview with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "baidu/ERNIE-5.5-Flash-Preview" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "baidu/ERNIE-5.5-Flash-Preview", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/baidu/ERNIE-5.5-Flash-Preview
- SGLang
How to use baidu/ERNIE-5.5-Flash-Preview with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "baidu/ERNIE-5.5-Flash-Preview" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "baidu/ERNIE-5.5-Flash-Preview", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "baidu/ERNIE-5.5-Flash-Preview" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "baidu/ERNIE-5.5-Flash-Preview", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use baidu/ERNIE-5.5-Flash-Preview with Docker Model Runner:
docker model run hf.co/baidu/ERNIE-5.5-Flash-Preview
Upload folder using huggingface_hub
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +4 -0
- LICENSE +203 -0
- README.md +269 -0
- __init__.py +5 -0
- assets/eval-results.png +3 -0
- assets/logo.png +3 -0
- config.json +166 -0
- decoding_ernie.py +275 -0
- encoding_ernie.py +377 -0
- flashindexer/flashindexer.safetensors +3 -0
- generation_config.json +10 -0
- model-00001-of-00128.safetensors +3 -0
- model-00002-of-00128.safetensors +3 -0
- model-00003-of-00128.safetensors +3 -0
- model-00004-of-00128.safetensors +3 -0
- model-00005-of-00128.safetensors +3 -0
- model-00006-of-00128.safetensors +3 -0
- model-00007-of-00128.safetensors +3 -0
- model-00008-of-00128.safetensors +3 -0
- model-00009-of-00128.safetensors +3 -0
- model-00010-of-00128.safetensors +3 -0
- model-00011-of-00128.safetensors +3 -0
- model-00012-of-00128.safetensors +3 -0
- model-00013-of-00128.safetensors +3 -0
- model-00014-of-00128.safetensors +3 -0
- model-00015-of-00128.safetensors +3 -0
- model-00016-of-00128.safetensors +3 -0
- model-00017-of-00128.safetensors +3 -0
- model-00018-of-00128.safetensors +3 -0
- model-00019-of-00128.safetensors +3 -0
- model-00020-of-00128.safetensors +3 -0
- model-00021-of-00128.safetensors +3 -0
- model-00022-of-00128.safetensors +3 -0
- model-00023-of-00128.safetensors +3 -0
- model-00024-of-00128.safetensors +3 -0
- model-00025-of-00128.safetensors +3 -0
- model-00026-of-00128.safetensors +3 -0
- model-00027-of-00128.safetensors +3 -0
- model-00028-of-00128.safetensors +3 -0
- model-00029-of-00128.safetensors +3 -0
- model-00030-of-00128.safetensors +3 -0
- model-00031-of-00128.safetensors +3 -0
- model-00032-of-00128.safetensors +3 -0
- model-00033-of-00128.safetensors +3 -0
- model-00034-of-00128.safetensors +3 -0
- model-00035-of-00128.safetensors +3 -0
- model-00036-of-00128.safetensors +3 -0
- model-00037-of-00128.safetensors +3 -0
- model-00038-of-00128.safetensors +3 -0
- model-00039-of-00128.safetensors +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,7 @@ saved_model/**/* 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
assets/eval-results.png filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
assets/logo.png filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
model.safetensors.index.json filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
LICENSE
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Terms of the Apache-2.0:
|
| 2 |
+
--------------------------------------------------------------------
|
| 3 |
+
Apache License
|
| 4 |
+
Version 2.0, January 2004
|
| 5 |
+
http://www.apache.org/licenses/
|
| 6 |
+
|
| 7 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
| 8 |
+
|
| 9 |
+
1. Definitions.
|
| 10 |
+
|
| 11 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
| 12 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
| 13 |
+
|
| 14 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
| 15 |
+
the copyright owner that is granting the License.
|
| 16 |
+
|
| 17 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
| 18 |
+
other entities that control, are controlled by, or are under common
|
| 19 |
+
control with that entity. For the purposes of this definition,
|
| 20 |
+
"control" means (i) the power, direct or indirect, to cause the
|
| 21 |
+
direction or management of such entity, whether by contract or
|
| 22 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
| 23 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
| 24 |
+
|
| 25 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
| 26 |
+
exercising permissions granted by this License.
|
| 27 |
+
|
| 28 |
+
"Source" form shall mean the preferred form for making modifications,
|
| 29 |
+
including but not limited to software source code, documentation
|
| 30 |
+
source, and configuration files.
|
| 31 |
+
|
| 32 |
+
"Object" form shall mean any form resulting from mechanical
|
| 33 |
+
transformation or translation of a Source form, including but
|
| 34 |
+
not limited to compiled object code, generated documentation,
|
| 35 |
+
and conversions to other media types.
|
| 36 |
+
|
| 37 |
+
"Work" shall mean the work of authorship, whether in Source or
|
| 38 |
+
Object form, made available under the License, as indicated by a
|
| 39 |
+
copyright notice that is included in or attached to the work
|
| 40 |
+
(an example is provided in the Appendix below).
|
| 41 |
+
|
| 42 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
| 43 |
+
form, that is based on (or derived from) the Work and for which the
|
| 44 |
+
editorial revisions, annotations, elaborations, or other modifications
|
| 45 |
+
represent, as a whole, an original work of authorship. For the purposes
|
| 46 |
+
of this License, Derivative Works shall not include works that remain
|
| 47 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
| 48 |
+
the Work and Derivative Works thereof.
|
| 49 |
+
|
| 50 |
+
"Contribution" shall mean any work of authorship, including
|
| 51 |
+
the original version of the Work and any modifications or additions
|
| 52 |
+
to that Work or Derivative Works thereof, that is intentionally
|
| 53 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
| 54 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
| 55 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
| 56 |
+
means any form of electronic, verbal, or written communication sent
|
| 57 |
+
to the Licensor or its representatives, including but not limited to
|
| 58 |
+
communication on electronic mailing lists, source code control systems,
|
| 59 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
| 60 |
+
Licensor for the purpose of discussing and improving the Work, but
|
| 61 |
+
excluding communication that is conspicuously marked or otherwise
|
| 62 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
| 63 |
+
|
| 64 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
| 65 |
+
on behalf of whom a Contribution has been received by Licensor and
|
| 66 |
+
subsequently incorporated within the Work.
|
| 67 |
+
|
| 68 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
| 69 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 70 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 71 |
+
copyright license to reproduce, prepare Derivative Works of,
|
| 72 |
+
publicly display, publicly perform, sublicense, and distribute the
|
| 73 |
+
Work and such Derivative Works in Source or Object form.
|
| 74 |
+
|
| 75 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
| 76 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 77 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 78 |
+
(except as stated in this section) patent license to make, have made,
|
| 79 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
| 80 |
+
where such license applies only to those patent claims licensable
|
| 81 |
+
by such Contributor that are necessarily infringed by their
|
| 82 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
| 83 |
+
with the Work to which such Contribution(s) was submitted. If You
|
| 84 |
+
institute patent litigation against any entity (including a
|
| 85 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
| 86 |
+
or a Contribution incorporated within the Work constitutes direct
|
| 87 |
+
or contributory patent infringement, then any patent licenses
|
| 88 |
+
granted to You under this License for that Work shall terminate
|
| 89 |
+
as of the date such litigation is filed.
|
| 90 |
+
|
| 91 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
| 92 |
+
Work or Derivative Works thereof in any medium, with or without
|
| 93 |
+
modifications, and in Source or Object form, provided that You
|
| 94 |
+
meet the following conditions:
|
| 95 |
+
|
| 96 |
+
(a) You must give any other recipients of the Work or
|
| 97 |
+
Derivative Works a copy of this License; and
|
| 98 |
+
|
| 99 |
+
(b) You must cause any modified files to carry prominent notices
|
| 100 |
+
stating that You changed the files; and
|
| 101 |
+
|
| 102 |
+
(c) You must retain, in the Source form of any Derivative Works
|
| 103 |
+
that You distribute, all copyright, patent, trademark, and
|
| 104 |
+
attribution notices from the Source form of the Work,
|
| 105 |
+
excluding those notices that do not pertain to any part of
|
| 106 |
+
the Derivative Works; and
|
| 107 |
+
|
| 108 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
| 109 |
+
distribution, then any Derivative Works that You distribute must
|
| 110 |
+
include a readable copy of the attribution notices contained
|
| 111 |
+
within such NOTICE file, excluding those notices that do not
|
| 112 |
+
pertain to any part of the Derivative Works, in at least one
|
| 113 |
+
of the following places: within a NOTICE text file distributed
|
| 114 |
+
as part of the Derivative Works; within the Source form or
|
| 115 |
+
documentation, if provided along with the Derivative Works; or,
|
| 116 |
+
within a display generated by the Derivative Works, if and
|
| 117 |
+
wherever such third-party notices normally appear. The contents
|
| 118 |
+
of the NOTICE file are for informational purposes only and
|
| 119 |
+
do not modify the License. You may add Your own attribution
|
| 120 |
+
notices within Derivative Works that You distribute, alongside
|
| 121 |
+
or as an addendum to the NOTICE text from the Work, provided
|
| 122 |
+
that such additional attribution notices cannot be construed
|
| 123 |
+
as modifying the License.
|
| 124 |
+
|
| 125 |
+
You may add Your own copyright statement to Your modifications and
|
| 126 |
+
may provide additional or different license terms and conditions
|
| 127 |
+
for use, reproduction, or distribution of Your modifications, or
|
| 128 |
+
for any such Derivative Works as a whole, provided Your use,
|
| 129 |
+
reproduction, and distribution of the Work otherwise complies with
|
| 130 |
+
the conditions stated in this License.
|
| 131 |
+
|
| 132 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
| 133 |
+
any Contribution intentionally submitted for inclusion in the Work
|
| 134 |
+
by You to the Licensor shall be under the terms and conditions of
|
| 135 |
+
this License, without any additional terms or conditions.
|
| 136 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
| 137 |
+
the terms of any separate license agreement you may have executed
|
| 138 |
+
with Licensor regarding such Contributions.
|
| 139 |
+
|
| 140 |
+
6. Trademarks. This License does not grant permission to use the trade
|
| 141 |
+
names, trademarks, service marks, or product names of the Licensor,
|
| 142 |
+
except as required for reasonable and customary use in describing the
|
| 143 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
| 144 |
+
|
| 145 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
| 146 |
+
agreed to in writing, Licensor provides the Work (and each
|
| 147 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
| 148 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 149 |
+
implied, including, without limitation, any warranties or conditions
|
| 150 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
| 151 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
| 152 |
+
appropriateness of using or redistributing the Work and assume any
|
| 153 |
+
risks associated with Your exercise of permissions under this License.
|
| 154 |
+
|
| 155 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
| 156 |
+
whether in tort (including negligence), contract, or otherwise,
|
| 157 |
+
unless required by applicable law (such as deliberate and grossly
|
| 158 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
| 159 |
+
liable to You for damages, including any direct, indirect, special,
|
| 160 |
+
incidental, or consequential damages of any character arising as a
|
| 161 |
+
result of this License or out of the use or inability to use the
|
| 162 |
+
Work (including but not limited to damages for loss of goodwill,
|
| 163 |
+
work stoppage, computer failure or malfunction, or any and all
|
| 164 |
+
other commercial damages or losses), even if such Contributor
|
| 165 |
+
has been advised of the possibility of such damages.
|
| 166 |
+
|
| 167 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
| 168 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
| 169 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
| 170 |
+
or other liability obligations and/or rights consistent with this
|
| 171 |
+
License. However, in accepting such obligations, You may act only
|
| 172 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
| 173 |
+
of any other Contributor, and only if You agree to indemnify,
|
| 174 |
+
defend, and hold each Contributor harmless for any liability
|
| 175 |
+
incurred by, or claims asserted against, such Contributor by reason
|
| 176 |
+
of your accepting any such warranty or additional liability.
|
| 177 |
+
|
| 178 |
+
END OF TERMS AND CONDITIONS
|
| 179 |
+
|
| 180 |
+
APPENDIX: How to apply the Apache License to your work.
|
| 181 |
+
|
| 182 |
+
To apply the Apache License to your work, attach the following
|
| 183 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
| 184 |
+
replaced with your own identifying information. (Don't include
|
| 185 |
+
the brackets!) The text should be enclosed in the appropriate
|
| 186 |
+
comment syntax for the file format. We also recommend that a
|
| 187 |
+
file or class name and description of purpose be included on the
|
| 188 |
+
same "printed page" as the copyright notice for easier
|
| 189 |
+
identification within third-party archives.
|
| 190 |
+
|
| 191 |
+
Copyright [yyyy] [name of copyright owner]
|
| 192 |
+
|
| 193 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 194 |
+
you may not use this file except in compliance with the License.
|
| 195 |
+
You may obtain a copy of the License at
|
| 196 |
+
|
| 197 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 198 |
+
|
| 199 |
+
Unless required by applicable law or agreed to in writing, software
|
| 200 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 201 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 202 |
+
See the License for the specific language governing permissions and
|
| 203 |
+
limitations under the License.
|
README.md
CHANGED
|
@@ -1,3 +1,272 @@
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
- zh
|
| 6 |
+
pipeline_tag: text-generation
|
| 7 |
+
library_name: transformers
|
| 8 |
+
base_model:
|
| 9 |
+
- baidu/ERNIE-5.5-Flash-Base
|
| 10 |
+
base_model_relation: finetune
|
| 11 |
+
tags:
|
| 12 |
+
- ERNIE5.5
|
| 13 |
+
- MoE
|
| 14 |
+
- agent
|
| 15 |
---
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
<div align="center">
|
| 19 |
+
<img src="assets/logo.png" width="50%" alt="Baidu Inc." />
|
| 20 |
+
</div>
|
| 21 |
+
|
| 22 |
+
<div align="center">
|
| 23 |
+
|
| 24 |
+
<a href="https://ernie.baidu.com/release/ernie-5-5-flash-preview/"><img src="https://img.shields.io/badge/Blog-ERNIE%205.5%20Flash%20Preview-1f6feb" alt="Blog"></a>
|
| 25 |
+
<a href="https://ernie.baidu.com/web"><img src="https://img.shields.io/badge/Chat-ERNIE-2e7d32" alt="Chat"></a>
|
| 26 |
+
<a href="https://cloud.baidu.com/product/qianfan.html"><img src="https://img.shields.io/badge/API-Qianfan-ff6f00" alt="API"></a>
|
| 27 |
+
<a href="https://x.com/Baidu_ERNIE"><img src="https://img.shields.io/badge/X-Baidu__ERNIE-000000" alt="X"></a>
|
| 28 |
+
<a href="https://huggingface.co/baidu/ERNIE-5.5-Flash-Preview/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-Apache%202.0-blue" alt="License"></a>
|
| 29 |
+
|
| 30 |
+
</div>
|
| 31 |
+
|
| 32 |
+
# ERNIE 5.5 Flash Preview
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
## Introduction
|
| 36 |
+
|
| 37 |
+
ERNIE 5.5 Flash Preview is the first post-trained model built on [ERNIE 5.5 Flash Base](https://huggingface.co/baidu/ERNIE-5.5-Flash-Base), which we released earlier. It is a Mixture-of-Experts (MoE) language model with **280B total parameters, 14B of them active per token**, and a **1M-token context window**. It does well at coding, 3D modeling, knowledge work and content creation, scores competitively on major benchmarks, and still decodes quickly.
|
| 38 |
+
|
| 39 |
+
The Preview shares its architecture and tokenizer with ERNIE 5.5 Flash Base. Its new capabilities come from mid-training and post-training, and mid-training also extends the training context length from 128K to 1M tokens. Our [blog post](https://ernie.baidu.com/release/ernie-5-5-flash-preview/) shows work the model completed end to end in an agent harness.
|
| 40 |
+
|
| 41 |
+
ERNIE 5.5 Flash Preview is an intermediate checkpoint from post-training. It already performs competitively among models of its size, but some capabilities may still fall short because training is not finished. Post-training is ongoing and ERNIE 5.5 Flash is improving quickly. We will watch how the Preview performs in real use, listen to user feedback, and address what we learn in the official release.
|
| 42 |
+
|
| 43 |
+
## Highlights
|
| 44 |
+
|
| 45 |
+
The Preview is trained for the following kinds of work.
|
| 46 |
+
|
| 47 |
+
**Coding and game development**: Handles coding work that ranges from fixes in real codebases to building complex applications from scratch, and plans, executes and iterates steadily over long tasks. It knows how development is done in Unreal Engine, Unity and Godot. In a single 11-hour coding task it wrote a complete third-person wuxia game in C++ on Unreal Engine 5.8, and from game design documents it built nearly 100 mobile mini-games.
|
| 48 |
+
|
| 49 |
+
**3D modeling and design**: Works out shape, proportion and spatial relationships from a text description, then writes scripts that drive Blender and CAD software to build anything from engine parts to buildings. It can also bring existing assets into the same workflow to assemble large, detailed scenes.
|
| 50 |
+
|
| 51 |
+
**Knowledge work**: Takes scattered material, works through the steps a request calls for, and delivers professional-quality spreadsheets, documents or slide decks. It was trained in 300,000 workspaces for domains such as finance and law, holding 10 million reference files in more than 40 file types.
|
| 52 |
+
|
| 53 |
+
**Video creation**: Gathers, generates and arranges material, sets the visuals and pacing, and delivers a finished video, working for one to two hours on a single piece. It was trained in more than 150,000 creation environments for popular-science explainers, motion comics, creative edits and takes on trending topics.
|
| 54 |
+
|
| 55 |
+
**Fast to serve, easy to build on**: FP4 expert weights and the DSpark draft head make long-running agent tasks much faster, with little loss in accuracy. The architecture and tokenizer match ERNIE 5.5 Flash Base, so tooling built for the Base model carries over.
|
| 56 |
+
|
| 57 |
+
## Model Overview
|
| 58 |
+
|
| 59 |
+
ERNIE 5.5 Flash Preview keeps the architecture of ERNIE 5.5 Flash Base and adds a DSpark draft head for speculative decoding. See the [Base model card](https://huggingface.co/baidu/ERNIE-5.5-Flash-Base) for architecture details.
|
| 60 |
+
|
| 61 |
+
| Key | Value |
|
| 62 |
+
| --- | --- |
|
| 63 |
+
| Modality | Text in, text out |
|
| 64 |
+
| Total Params | 280B |
|
| 65 |
+
| Activated Params per Token | 14B |
|
| 66 |
+
| Layers | 43 (1 dense + 42 MoE) |
|
| 67 |
+
| Hidden Size | 4096 |
|
| 68 |
+
| Attention | 37 × HCA (head dim 512) + 6 × MLA-DSA (head dim 256), 64 heads |
|
| 69 |
+
| Experts | 512 routed (top-10) + 1 shared |
|
| 70 |
+
| Vocabulary | 201,216 |
|
| 71 |
+
| Context Length | 1,048,576 |
|
| 72 |
+
| Thinking | Always on; reasoning is returned in `reasoning_content` |
|
| 73 |
+
| Precision | Blockwise FP8; routed experts in MXFP4 (W4A8, quantization-aware trained); FP8 KV cache; FP4 DSA indexer |
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
## Model Downloads
|
| 77 |
+
|
| 78 |
+
| Model | Weights | Context | Download |
|
| 79 |
+
| :--- | :--- | :---: | :---: |
|
| 80 |
+
| ERNIE-5.5-Flash-Preview | FP8 (blockwise) + FP4 experts, with DSpark draft head | 1M | [🤗 Hugging Face](https://huggingface.co/baidu/ERNIE-5.5-Flash-Preview) · [ModelScope](https://www.modelscope.cn/models/baidu/ERNIE-5.5-Flash-Preview) |
|
| 81 |
+
| ERNIE-5.5-Flash-Preview-FP8 | FP8 (blockwise), with DSpark draft head | 1M | [🤗 Hugging Face](https://huggingface.co/baidu/ERNIE-5.5-Flash-Preview-FP8) · [ModelScope](https://www.modelscope.cn/models/baidu/ERNIE-5.5-Flash-Preview-FP8) |
|
| 82 |
+
| ERNIE-5.5-Flash-Preview-BF16 | BF16, with DSpark draft head | 1M | [🤗 Hugging Face](https://huggingface.co/baidu/ERNIE-5.5-Flash-Preview-BF16) · [ModelScope](https://www.modelscope.cn/models/baidu/ERNIE-5.5-Flash-Preview-BF16) |
|
| 83 |
+
|
| 84 |
+
The default repository contains the FP4 expert weights. On hardware without FP4 kernels, use the FP8 or BF16 repository. For fine-tuning, start from the BF16 repository.
|
| 85 |
+
|
| 86 |
+
## Evaluation
|
| 87 |
+
|
| 88 |
+

|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
The chart shows eight of the benchmarks, and the table below lists all 20. How to read the table:
|
| 92 |
+
|
| 93 |
+
- All ERNIE 5.5 Flash Preview scores are from our own evaluations.
|
| 94 |
+
- For other models, unmarked scores are taken from official reports or the Artificial Analysis (AA) leaderboard, and * marks our own evaluations. Where both are available, the cell shows the reported score first and our own second.
|
| 95 |
+
- † marks the text-only subset of HLE, and – means no result.
|
| 96 |
+
- All models are evaluated at their highest available reasoning setting. We use a benchmark's official harness when it has one. Otherwise, GPT-series models run in Codex, DeepSeek models run in DSH on some benchmarks, and all other models run in Claude Code.
|
| 97 |
+
|
| 98 |
+
| Benchmark | ERNIE 5.5 Flash Preview | Hy4 | DeepSeek-V4.1-Flash-1017 | GLM-5.3-Flash | GLM-5.3 | GPT-6.1 Sol | Claude Opus 5.5 |
|
| 99 |
+
| :--- | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
|
| 100 |
+
| **Agentic Coding** | | | | | | | |
|
| 101 |
+
| Terminal-Bench 4.0 | 46.5 | 44.4 / 42.4* | 42.3 / 40.9* | 35.8 / 37.9* | 41.8 / 38.8* | 56.1 | 66.4 / 63.6* |
|
| 102 |
+
| DeepSWE v1.1 | 71.2 | 74.9 | 77.0 | 63.4 | 66.9 | 75.2 | 74.2 |
|
| 103 |
+
| ProgramBench (Almost Solved) | 29.5 | 30.0 / 28.5* | 29.1 / 27.5* | 15.0* | 19.0 / 19.0* | – | 65.0 |
|
| 104 |
+
| NL2Repo-Bench | 64.8 | 65.8* | 68.1 / 62.7* | 56.3 / 57.5* | 58.0 / 58.8* | – | – |
|
| 105 |
+
| Terminal-Bench-Science 0.1 | 21.0 | 19.8 / 17.1* | 15.7 / 14.3* | 5.7* | 8.1 | 57.0 | 63.3 |
|
| 106 |
+
| CookieBench | 88.2 | 88.8* | 87.9* | 76.9* | 80.4* | 89.7* | 91.5* |
|
| 107 |
+
| BlenderWorld (text-only) | 79.0 | 76.8* | 79.2* | 71.4* | 69.7* | 85.3* | 86.1* |
|
| 108 |
+
| **Knowledge Work** | | | | | | | |
|
| 109 |
+
| AutomationBench | 61.9 | 56.2 / 55.2* | 60.5 / 57.2* | 48.8 / 48.7* | 48.2 / 50.7* | 49.3* | 58.0* |
|
| 110 |
+
| APEX-Agents 1.1 | 64.2 | 77.6 / 75.0* | 69.8 / 43.9* | 52.8 / 52.9* | 56.6 / 59.2* | 60.0 / 59.2* | 73.5 / 72.9* |
|
| 111 |
+
| DRACO | 84.9 | 90.7* | 83.6* | 78.4* | 82.3* | 79.4* | 87.4 / 87.9* |
|
| 112 |
+
| SpreadsheetBench V2 | 36.4 | 34.5* | 34.7* | 31.5* | 32.7* | 32.0* | 35.1* |
|
| 113 |
+
| OfficeQA Pro V2 | 67.9 | 63.8* | 63.4* | 64.4* | 59.3* | 70.0* | 62.2 |
|
| 114 |
+
| **General Agent** | | | | | | | |
|
| 115 |
+
| Agents' Last Exam (CLI) | 29.0 | 32.4* | 35.2* | 28.6* | 22.9* | 29.5* | 34.3 / 32.4* |
|
| 116 |
+
| SkillsBench 1.1 (text-only) | 73.5 | 77.4* | 67.5* | 65.4* | 62.0* | 72.6* | 71.8* |
|
| 117 |
+
| Toolathlon-Verified | 75.0 | 73.1* | 71.2* | 78.5 / 76.8* | 73.0 / 72.2* | 67.8* | 80.1* |
|
| 118 |
+
| MCP-Atlas | 84.6 | 83.0* | 77.8* | 78.8* | 82.4* | 81.0* | 84.2* |
|
| 119 |
+
| BrowseComp | 87.4 | 91.8* | 80.3* | 74.6* | 77.8* | 87.5* | 90.8 |
|
| 120 |
+
| **Reasoning** | | | | | | | |
|
| 121 |
+
| HLE (w/o tools) | 46.4† | 46.7*† | 44.0† | 39.9 | 42.0† | 52.9 | 61.4 |
|
| 122 |
+
| AA-Omniscience-Public | 25.2 | 20.2* | 11.5* | 16.0* | 21.0* | 52.8* | 62.0* |
|
| 123 |
+
| AA-LCR v1.1 | 79.0 | 80.0* | 82.7 / 80.7* | 77.3* | 79.7 / 78.0* | 83.0 / 78.0* | 84.7 / 81.7* |
|
| 124 |
+
|
| 125 |
+
## Inference Performance Optimization
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
ERNIE 5.5 Flash Preview is designed to be inexpensive to serve. The savings come from three places: the architecture, the way the model is trained, and the serving kernels.
|
| 129 |
+
|
| 130 |
+
The architecture is inherited from ERNIE 5.5 Flash Base and keeps each decoding step light. Of the 43 layers, 37 use Heavily Compressed Attention (HCA), which caches one entry per 128 tokens of history and so keeps the KV cache small. The other six keep token-level history but use sparse attention (DSA), so each step attends only to selected positions. On top of this, quantization and speculative decoding are trained together with the model under settings that match inference, and the serving kernels are tuned for the ERNIE 5.5 Flash architecture.
|
| 131 |
+
|
| 132 |
+
### W4A8 quantization-aware training
|
| 133 |
+
|
| 134 |
+
The routed experts hold most of the model's parameters. They are stored in MXFP4 and run as W4A8 (4-bit weights, 8-bit activations). We apply W4A8 quantization-aware training during post-training, and the fake quantization in training uses the same granularity, scaling factors, and rounding rules as inference. Training and inference therefore agree numerically, which removes the accuracy gap that a mismatch between them would otherwise cause. Training throughput is largely unaffected, and the released weights deploy directly in W4A8, with no extra conversion or calibration.
|
| 135 |
+
|
| 136 |
+
All other weights stay in blockwise FP8, the KV cache is FP8, and the DSA indexer runs in FP4.
|
| 137 |
+
|
| 138 |
+
### DSpark speculative decoding
|
| 139 |
+
|
| 140 |
+
In speculative decoding, a draft model proposes the next few tokens and the main model verifies them in a single forward pass. The Preview's draft model is DSpark, a draft head that proposes a whole block of tokens in parallel.
|
| 141 |
+
|
| 142 |
+
ERNIE 5.5 Flash is pre-trained with single-step [ECHO](https://arxiv.org/abs/2610.24766) MTP (multi-token prediction), which drafts tokens one after another. In post-training, ECHO can be trained further into multi-step MTP with dynamic depth sampling. It extrapolates well across steps: with 7 draft steps, it reaches an average acceptance length above 5.5 on real-world multi-turn conversations.
|
| 143 |
+
|
| 144 |
+
Autoregressive drafting (ECHO) and parallel drafting (DSpark) each do better on different tasks, depending on whether the output is high- or low-entropy, so post-training also trains DSpark. A single training setup supports both. DSpark is updated continuously as the main model changes, so the two stay aligned and the acceptance rate does not degrade. After training converges, online distillation adapts DSpark to a broader range of data, raising its acceptance length in production by more than 10%.
|
| 145 |
+
|
| 146 |
+
The Preview ships with DSpark only, and the head is included in the model weights; later releases will offer both DSpark and ECHO MTP. We recommend larger draft blocks (up to 7 tokens) at low concurrency and smaller blocks (2–3 tokens) at high concurrency.
|
| 147 |
+
|
| 148 |
+
### Lightweight indexer with head routing
|
| 149 |
+
|
| 150 |
+
In the six DSA layers, a lightweight indexer scores past tokens and selects the 2,048 highest-scoring positions for attention. Two changes make this step cheaper. First, a plug-in head-routing module picks a subset of indexer heads for each query, which cuts the cost of computing the indexer logits. Second, a threshold-based pre-filter drops low-scoring candidates early. The filtering is exact, and even with TopK as large as 2,048 it removes much of the TopK computation. At a 1M-token context, it gives a 40% speedup.
|
| 151 |
+
|
| 152 |
+
### Decoding kernel optimization
|
| 153 |
+
|
| 154 |
+
Every part of the decoding step is tuned for the ERNIE 5.5 Flash architecture.
|
| 155 |
+
|
| 156 |
+
- **Attention and residual paths**: Mathematically equivalent rewrites of the [Virtual Head Attention (VHA)](https://arxiv.org/abs/2610.17959) and mHC (Manifold-constrained Hyper-Connections) residual computations let fused Mega Kernels merge each operation with the lightweight operators around it, and the computation is reordered to hide more latency.
|
| 157 |
+
- **HCA compression**: HCA layers do not need to compress tokens at every decoding step, so compression runs separately on a side stream.
|
| 158 |
+
- **MoE**: For [Multi-Router Latent MoE](https://arxiv.org/abs/2610.40577), a single Mega Kernel fuses routing, expert computation, and the projections into and out of the latent space, which avoids repeated kernel launches and shortens the serial MoE path.
|
| 159 |
+
- **Scheduling**: PDL (Programmatic Dependent Launch) and multi-stream scheduling cut serving overhead further.
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
## Deployment
|
| 163 |
+
|
| 164 |
+
ERNIE 5.5 Flash Preview can be served in production with SGLang or vLLM. For full deployment instructions, see the [SGLang Cookbook](https://docs.sglang.io/cookbook/autoregressive/Baidu/ERNIE-5.5-Flash#hw=b300&quant=fp8&strategy=low-latency&nodes=single) and [vLLM-ERNIE](https://github.com/baidu/vLLM-ERNIE).
|
| 165 |
+
|
| 166 |
+
The commands below set a 131,072-token context. For longer inputs, raise `--context-length` (SGLang) or `--max-model-len` (vLLM); both servers accept up to 1,048,576 tokens.
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
### SGLang
|
| 170 |
+
|
| 171 |
+
Launch a container from the official prebuilt Docker image and open a shell in it:
|
| 172 |
+
|
| 173 |
+
```bash
|
| 174 |
+
docker run -d -it --name ernie55 \
|
| 175 |
+
--gpus all \
|
| 176 |
+
--network host \
|
| 177 |
+
--ipc host \
|
| 178 |
+
-v ~/.cache/huggingface:/root/.cache/huggingface \
|
| 179 |
+
lmsysorg/sglang:latest
|
| 180 |
+
|
| 181 |
+
docker exec -it ernie55 bash
|
| 182 |
+
```
|
| 183 |
+
|
| 184 |
+
Inside the container, start the server with DSpark enabled:
|
| 185 |
+
|
| 186 |
+
```bash
|
| 187 |
+
sglang serve \
|
| 188 |
+
--model-path baidu/ERNIE-5.5-Flash-Preview \
|
| 189 |
+
--host 0.0.0.0 \
|
| 190 |
+
--port 30000 \
|
| 191 |
+
--tp 4 \
|
| 192 |
+
--attn-dp-size 4 \
|
| 193 |
+
--context-length 131072 \
|
| 194 |
+
--max-running-requests 128 \
|
| 195 |
+
--speculative-algorithm DSPARK \
|
| 196 |
+
--reasoning-parser ernie55 \
|
| 197 |
+
--tool-call-parser ernie55
|
| 198 |
+
```
|
| 199 |
+
|
| 200 |
+
### vLLM
|
| 201 |
+
|
| 202 |
+
Install vLLM and the ERNIE 5.5 plugin:
|
| 203 |
+
|
| 204 |
+
```bash
|
| 205 |
+
uv venv --python 3.12 ernie5-venv
|
| 206 |
+
source ernie5-venv/bin/activate
|
| 207 |
+
|
| 208 |
+
uv pip install vllm==0.32.0
|
| 209 |
+
uv pip install git+https://github.com/baidu/vLLM-ERNIE.git
|
| 210 |
+
```
|
| 211 |
+
|
| 212 |
+
Start the server:
|
| 213 |
+
|
| 214 |
+
```bash
|
| 215 |
+
export VLLM_ENGINE_READY_TIMEOUT_S=3600
|
| 216 |
+
vllm serve baidu/ERNIE-5.5-Flash-Preview \
|
| 217 |
+
--trust-remote-code \
|
| 218 |
+
--host 0.0.0.0 \
|
| 219 |
+
--port 30000 \
|
| 220 |
+
--data-parallel-size 4 \
|
| 221 |
+
--enable-expert-parallel \
|
| 222 |
+
--kv-cache-dtype fp8 \
|
| 223 |
+
--max-model-len 131072 \
|
| 224 |
+
--reasoning-parser ernie5 \
|
| 225 |
+
--tool-call-parser ernie5 \
|
| 226 |
+
--enable-auto-tool-choice \
|
| 227 |
+
--attention-config '{"indexer_kv_dtype":"mxfp4"}' \
|
| 228 |
+
--speculative-config '{"method":"dspark","num_speculative_tokens":7,"draft_sample_method":"probabilistic"}'
|
| 229 |
+
```
|
| 230 |
+
|
| 231 |
+
### Send Requests
|
| 232 |
+
|
| 233 |
+
Once the server is up, send a test request to check that it works.
|
| 234 |
+
|
| 235 |
+
```bash
|
| 236 |
+
curl http://localhost:30000/v1/chat/completions \
|
| 237 |
+
-H "Content-Type: application/json" \
|
| 238 |
+
-d '{
|
| 239 |
+
"model": "baidu/ERNIE-5.5-Flash-Preview",
|
| 240 |
+
"messages": [{"role": "user", "content": "Explain speculative decoding in two sentences."}],
|
| 241 |
+
"max_tokens": 1024
|
| 242 |
+
}'
|
| 243 |
+
```
|
| 244 |
+
|
| 245 |
+
The model always thinks before it answers. In the response, the reasoning is in `message.reasoning_content` and the answer is in `message.content`.
|
| 246 |
+
|
| 247 |
+
## Fine-tuning
|
| 248 |
+
|
| 249 |
+
ERNIE 5.5 Flash Preview can be fine-tuned with NVIDIA Megatron-Bridge; see the [ERNIE 5.5 example](https://github.com/NVIDIA-NeMo/Megatron-Bridge/blob/main/examples/models/ernie55/). We recommend starting from the BF16 repository.
|
| 250 |
+
|
| 251 |
+
|
| 252 |
+
## License
|
| 253 |
+
|
| 254 |
+
ERNIE 5.5 Flash Preview is released under the Apache License 2.0; see [LICENSE](https://huggingface.co/baidu/ERNIE-5.5-Flash-Preview/blob/main/LICENSE) for details. This license covers the ERNIE 5.5 Flash Preview weights only. [ERNIE 5.5 Flash Base](https://huggingface.co/baidu/ERNIE-5.5-Flash-Base) remains under its own license, the ERNIE 5.5 Flash Base Model License Agreement v1.0. Copyright © 2026 Baidu. All Rights Reserved.
|
| 255 |
+
|
| 256 |
+
## Citation
|
| 257 |
+
|
| 258 |
+
If you use ERNIE 5.5 Flash Preview in your research or projects, please cite our blog post:
|
| 259 |
+
|
| 260 |
+
```bibtex
|
| 261 |
+
@misc{ernie5.5flashpreview,
|
| 262 |
+
title = {ERNIE 5.5 Flash Preview},
|
| 263 |
+
author = {{Baidu ERNIE Team}},
|
| 264 |
+
year = {2026},
|
| 265 |
+
howpublished = {ERNIE Blog},
|
| 266 |
+
url = {https://ernie.baidu.com/release/ernie-5-5-flash-preview/}
|
| 267 |
+
}
|
| 268 |
+
```
|
| 269 |
+
|
| 270 |
+
## Contact
|
| 271 |
+
|
| 272 |
+
For questions, contact us at [Baidu_ERNIE@baidu.com](mailto:Baidu_ERNIE@baidu.com).
|
__init__.py
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""ERNIE chatv2p3 Python protocol implementation."""
|
| 2 |
+
|
| 3 |
+
from .encoding_ernie import EncodeSegment, RenderedChat, build_chat_segments, encode_messages, render_chat
|
| 4 |
+
|
| 5 |
+
__all__ = ["EncodeSegment", "RenderedChat", "build_chat_segments", "encode_messages", "render_chat"]
|
assets/eval-results.png
ADDED
|
Git LFS Details
|
assets/logo.png
ADDED
|
Git LFS Details
|
config.json
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"activation_situ_beta": 4.0,
|
| 3 |
+
"activation_situ_linear_beta": 25.0,
|
| 4 |
+
"add_full_attention_sink_bias": true,
|
| 5 |
+
"architectures": [
|
| 6 |
+
"Ernie5_5_MoeForCausalLM"
|
| 7 |
+
],
|
| 8 |
+
"attention_bias": false,
|
| 9 |
+
"bos_token_id": 1,
|
| 10 |
+
"compress_ratios": [
|
| 11 |
+
128,
|
| 12 |
+
128,
|
| 13 |
+
128,
|
| 14 |
+
128,
|
| 15 |
+
128,
|
| 16 |
+
128,
|
| 17 |
+
128,
|
| 18 |
+
-2,
|
| 19 |
+
128,
|
| 20 |
+
128,
|
| 21 |
+
128,
|
| 22 |
+
128,
|
| 23 |
+
128,
|
| 24 |
+
128,
|
| 25 |
+
-2,
|
| 26 |
+
128,
|
| 27 |
+
128,
|
| 28 |
+
128,
|
| 29 |
+
128,
|
| 30 |
+
128,
|
| 31 |
+
128,
|
| 32 |
+
-2,
|
| 33 |
+
128,
|
| 34 |
+
128,
|
| 35 |
+
128,
|
| 36 |
+
128,
|
| 37 |
+
128,
|
| 38 |
+
128,
|
| 39 |
+
-2,
|
| 40 |
+
128,
|
| 41 |
+
128,
|
| 42 |
+
128,
|
| 43 |
+
128,
|
| 44 |
+
128,
|
| 45 |
+
128,
|
| 46 |
+
-2,
|
| 47 |
+
128,
|
| 48 |
+
128,
|
| 49 |
+
128,
|
| 50 |
+
128,
|
| 51 |
+
128,
|
| 52 |
+
128,
|
| 53 |
+
-2
|
| 54 |
+
],
|
| 55 |
+
"compress_rope_theta": 160000.0,
|
| 56 |
+
"csa_dense_mode": true,
|
| 57 |
+
"dspark_block_size": 7,
|
| 58 |
+
"dspark_markov_rank": 256,
|
| 59 |
+
"dspark_noise_token_id": 1024,
|
| 60 |
+
"dspark_target_layer_ids": [
|
| 61 |
+
40,
|
| 62 |
+
41,
|
| 63 |
+
42
|
| 64 |
+
],
|
| 65 |
+
"enable_hyper_connections": true,
|
| 66 |
+
"eos_token_id": 2,
|
| 67 |
+
"experimental_attention_variant": "dsv4_hybrid",
|
| 68 |
+
"first_k_dense_replace": 1,
|
| 69 |
+
"gated_attn_act": "sigmoid",
|
| 70 |
+
"gated_attn_use_q_lora": true,
|
| 71 |
+
"gated_linear_unit": true,
|
| 72 |
+
"hc_eps": 1e-06,
|
| 73 |
+
"hc_mult": 4,
|
| 74 |
+
"hc_sinkhorn_iters": 20,
|
| 75 |
+
"hca_rope_type": "yarn",
|
| 76 |
+
"head_dim": 512,
|
| 77 |
+
"hidden_act": "situ",
|
| 78 |
+
"hidden_size": 4096,
|
| 79 |
+
"hybrid_mla_attention": "mqa_dsa",
|
| 80 |
+
"hybrid_mla_kv_lora_rank": 512,
|
| 81 |
+
"hybrid_mla_num_attention_heads": 64,
|
| 82 |
+
"hybrid_mla_num_key_value_heads": 64,
|
| 83 |
+
"hybrid_mla_q_lora_rank": 1024,
|
| 84 |
+
"hybrid_mla_qk_nope_head_dim": 192,
|
| 85 |
+
"hybrid_mla_qk_rope_head_dim": 64,
|
| 86 |
+
"hybrid_mla_v_head_dim": 256,
|
| 87 |
+
"index_head_dim": 128,
|
| 88 |
+
"index_n_heads": 64,
|
| 89 |
+
"index_topk": 2048,
|
| 90 |
+
"intermediate_size": 14336,
|
| 91 |
+
"kv_lora_rank": 512,
|
| 92 |
+
"latent_moe_use_norm": true,
|
| 93 |
+
"max_position_embeddings": 1048576,
|
| 94 |
+
"model_type": "ernie5_5_moe",
|
| 95 |
+
"moe_group_experts": false,
|
| 96 |
+
"moe_intermediate_size": 2048,
|
| 97 |
+
"moe_latent_size": 2048,
|
| 98 |
+
"moe_layer_freq": 1,
|
| 99 |
+
"moe_shared_expert_gate": false,
|
| 100 |
+
"moe_split_feature_routing": true,
|
| 101 |
+
"moe_token_dispatcher_type": "deepep",
|
| 102 |
+
"mqa_split_kv_b_proj": true,
|
| 103 |
+
"mtp_shared_last_layer": true,
|
| 104 |
+
"multimax": "lm_head",
|
| 105 |
+
"n_group": 1,
|
| 106 |
+
"n_routed_experts": 512,
|
| 107 |
+
"n_shared_experts": 1,
|
| 108 |
+
"norm_topk_prob": true,
|
| 109 |
+
"num_attention_heads": 64,
|
| 110 |
+
"num_experts_per_tok": 10,
|
| 111 |
+
"num_hidden_layers": 43,
|
| 112 |
+
"num_key_value_heads": 1,
|
| 113 |
+
"num_nextn_predict_layers": 0,
|
| 114 |
+
"o_groups": 8,
|
| 115 |
+
"o_lora_rank": 1024,
|
| 116 |
+
"pad_token_id": 0,
|
| 117 |
+
"q_lora_rank": 1024,
|
| 118 |
+
"qk_nope_head_dim": 448,
|
| 119 |
+
"qk_norm_type": "per_head",
|
| 120 |
+
"qk_pos_emb_head_dim": 64,
|
| 121 |
+
"qk_rope_head_dim": 64,
|
| 122 |
+
"rms_norm_eps": 1e-06,
|
| 123 |
+
"rope_interleave": true,
|
| 124 |
+
"rope_scaling": {
|
| 125 |
+
"beta_fast": 32,
|
| 126 |
+
"beta_slow": 1,
|
| 127 |
+
"factor": 16,
|
| 128 |
+
"original_max_position_embeddings": 65536,
|
| 129 |
+
"type": "yarn"
|
| 130 |
+
},
|
| 131 |
+
"rope_theta": 8000000,
|
| 132 |
+
"rope_type": "rope",
|
| 133 |
+
"rotary_base": 8000000,
|
| 134 |
+
"rotary_percent": 1.0,
|
| 135 |
+
"routed_scaling_factor": 3.0,
|
| 136 |
+
"routed_scaling_factor_learnable": true,
|
| 137 |
+
"scoring_func": "sigmoid",
|
| 138 |
+
"sliding_window": 128,
|
| 139 |
+
"tie_word_embeddings": false,
|
| 140 |
+
"topk_group": 1,
|
| 141 |
+
"topk_method": "noaux_tc",
|
| 142 |
+
"torch_dtype": "bfloat16",
|
| 143 |
+
"transformers_version": "4.46.1",
|
| 144 |
+
"use_attn_merger": true,
|
| 145 |
+
"use_bias": false,
|
| 146 |
+
"use_cache": true,
|
| 147 |
+
"use_dense_mtp": false,
|
| 148 |
+
"use_fast_hadamard": true,
|
| 149 |
+
"use_gated_attn": true,
|
| 150 |
+
"use_mla": false,
|
| 151 |
+
"use_qk_norm": true,
|
| 152 |
+
"use_vha_attention": true,
|
| 153 |
+
"v_head_dim": 512,
|
| 154 |
+
"vocab_size": 201216,
|
| 155 |
+
"quantization_config": {
|
| 156 |
+
"activation_scheme": "dynamic",
|
| 157 |
+
"fmt": "e4m3",
|
| 158 |
+
"quant_method": "fp8",
|
| 159 |
+
"expert_dtype": "mxfp4",
|
| 160 |
+
"scale_fmt": "ue8m0",
|
| 161 |
+
"weight_block_size": [
|
| 162 |
+
128,
|
| 163 |
+
128
|
| 164 |
+
]
|
| 165 |
+
}
|
| 166 |
+
}
|
decoding_ernie.py
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Completion parsing for the existing ERNIE protocol.
|
| 2 |
+
|
| 3 |
+
Token-ID input preserves the distinction between ordinary marker-looking text
|
| 4 |
+
and real control IDs. String-only input cannot recover that distinction.
|
| 5 |
+
The legacy parameter format has no type/escaping field: ambiguous values are
|
| 6 |
+
rejected unless a tool schema resolves them or raw-string mode is requested.
|
| 7 |
+
"""
|
| 8 |
+
|
| 9 |
+
from __future__ import annotations
|
| 10 |
+
|
| 11 |
+
import itertools
|
| 12 |
+
import json
|
| 13 |
+
import re
|
| 14 |
+
import uuid
|
| 15 |
+
from dataclasses import dataclass
|
| 16 |
+
|
| 17 |
+
from .encoding_ernie import CALL, CALL_END, END, MASK, START, THINK, THINK_END, RenderedChat
|
| 18 |
+
|
| 19 |
+
_MARKERS = (THINK, THINK_END, CALL, CALL_END, END, MASK, START)
|
| 20 |
+
_MARKER_RE = re.compile("|".join(re.escape(s) for s in _MARKERS))
|
| 21 |
+
_INVOKE = re.compile(r'<invoke\s+name="([^"]+)">')
|
| 22 |
+
_PARAMETER = re.compile(r'<parameter\s+name="([^"]+)">')
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
class CompletionParseError(ValueError):
|
| 26 |
+
"""Malformed, truncated, or inherently ambiguous completion."""
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
class AmbiguousArgumentsError(CompletionParseError):
|
| 30 |
+
"""The legacy wire format does not uniquely identify argument types."""
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
@dataclass(frozen=True)
|
| 34 |
+
class _Document:
|
| 35 |
+
text: str
|
| 36 |
+
markers: tuple[tuple[int, str], ...]
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
def _from_text(text: str) -> _Document:
|
| 40 |
+
return _Document(text, tuple((m.start(), m.group()) for m in _MARKER_RE.finditer(text)))
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def _from_ids(token_ids, tokenizer) -> _Document:
|
| 44 |
+
marker_ids = {tokenizer.convert_tokens_to_ids(s): s for s in _MARKERS}
|
| 45 |
+
if None in marker_ids or len(marker_ids) != len(_MARKERS):
|
| 46 |
+
raise CompletionParseError("Tokenizer does not contain the ERNIE protocol markers")
|
| 47 |
+
text = []
|
| 48 |
+
markers = []
|
| 49 |
+
ordinary = []
|
| 50 |
+
length = 0
|
| 51 |
+
|
| 52 |
+
def flush():
|
| 53 |
+
nonlocal length
|
| 54 |
+
if ordinary:
|
| 55 |
+
value = tokenizer.decode(ordinary, skip_special_tokens=False, clean_up_tokenization_spaces=False)
|
| 56 |
+
text.append(value)
|
| 57 |
+
length += len(value)
|
| 58 |
+
ordinary.clear()
|
| 59 |
+
|
| 60 |
+
for token_id in token_ids:
|
| 61 |
+
if token_id in marker_ids:
|
| 62 |
+
flush()
|
| 63 |
+
marker = marker_ids[token_id]
|
| 64 |
+
markers.append((length, marker))
|
| 65 |
+
text.append(marker)
|
| 66 |
+
length += len(marker)
|
| 67 |
+
else:
|
| 68 |
+
ordinary.append(token_id)
|
| 69 |
+
flush()
|
| 70 |
+
return _Document("".join(text), tuple(markers))
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
def _argument_candidates(raw):
|
| 74 |
+
values = [raw]
|
| 75 |
+
try:
|
| 76 |
+
parsed = json.loads(raw, parse_constant=lambda x: (_ for _ in ()).throw(ValueError(x)))
|
| 77 |
+
except (ValueError, TypeError):
|
| 78 |
+
return values
|
| 79 |
+
# String parameters are emitted raw by the encoder; literal quotes belong
|
| 80 |
+
# to the string. Only non-string JSON creates a second interpretation.
|
| 81 |
+
if not isinstance(parsed, str):
|
| 82 |
+
values.append(parsed)
|
| 83 |
+
return values
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
def _resolve_arguments(name, raw, tools, argument_mode):
|
| 87 |
+
if argument_mode == "raw":
|
| 88 |
+
return dict(raw)
|
| 89 |
+
schema = None
|
| 90 |
+
if tools is not None:
|
| 91 |
+
found = False
|
| 92 |
+
for tool in tools:
|
| 93 |
+
function = tool.get("function", tool)
|
| 94 |
+
if function.get("name") == name:
|
| 95 |
+
schema = function.get("parameters", {})
|
| 96 |
+
found = True
|
| 97 |
+
break
|
| 98 |
+
if not found:
|
| 99 |
+
raise CompletionParseError(f"Generated unknown tool {name!r}")
|
| 100 |
+
candidates = [_argument_candidates(value) for value in raw.values()]
|
| 101 |
+
possibilities = 1
|
| 102 |
+
for values in candidates:
|
| 103 |
+
possibilities *= len(values)
|
| 104 |
+
# Filter each property first; this makes ordinary schemas linear instead
|
| 105 |
+
# of exploring 2**N combinations of string-vs-number interpretations.
|
| 106 |
+
validator = None
|
| 107 |
+
if schema is not None:
|
| 108 |
+
from jsonschema.validators import validator_for
|
| 109 |
+
|
| 110 |
+
cls = validator_for(schema)
|
| 111 |
+
cls.check_schema(schema)
|
| 112 |
+
validator = cls(schema)
|
| 113 |
+
properties = schema.get("properties", {}) if isinstance(schema, dict) else {}
|
| 114 |
+
for i, key in enumerate(raw):
|
| 115 |
+
prop = properties.get(key)
|
| 116 |
+
if prop is not None:
|
| 117 |
+
candidates[i] = [v for v in candidates[i] if validator.evolve(schema=prop).is_valid(v)]
|
| 118 |
+
possibilities = 1
|
| 119 |
+
for values in candidates:
|
| 120 |
+
possibilities *= len(values)
|
| 121 |
+
if possibilities > 256:
|
| 122 |
+
raise AmbiguousArgumentsError("Too many unresolved argument types; provide a more specific tool schema")
|
| 123 |
+
valid = []
|
| 124 |
+
for values in itertools.product(*candidates):
|
| 125 |
+
candidate = dict(zip(raw, values))
|
| 126 |
+
if validator is None or validator.is_valid(candidate):
|
| 127 |
+
valid.append(candidate)
|
| 128 |
+
if len(valid) > 1:
|
| 129 |
+
raise AmbiguousArgumentsError(
|
| 130 |
+
f"Tool {name!r} has ambiguous string/JSON argument types; "
|
| 131 |
+
"provide an unambiguous schema or use argument_mode='raw'"
|
| 132 |
+
)
|
| 133 |
+
if not valid:
|
| 134 |
+
raise CompletionParseError(f"Arguments for tool {name!r} do not match its schema")
|
| 135 |
+
return valid[0]
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
def _parse_calls(text, tools, argument_mode):
|
| 139 |
+
calls = []
|
| 140 |
+
i = 0
|
| 141 |
+
|
| 142 |
+
def skip_space(position):
|
| 143 |
+
return re.compile(r"\s*").match(text, position).end()
|
| 144 |
+
|
| 145 |
+
while (i := skip_space(i)) < len(text):
|
| 146 |
+
match = _INVOKE.match(text, i)
|
| 147 |
+
if match is None:
|
| 148 |
+
raise CompletionParseError(f"Expected invoke tag at tool block offset {i}")
|
| 149 |
+
name = match.group(1)
|
| 150 |
+
i = match.end()
|
| 151 |
+
arguments = {}
|
| 152 |
+
while True:
|
| 153 |
+
i = skip_space(i)
|
| 154 |
+
if text.startswith("</invoke>", i):
|
| 155 |
+
i += len("</invoke>")
|
| 156 |
+
break
|
| 157 |
+
match = _PARAMETER.match(text, i)
|
| 158 |
+
if match is None:
|
| 159 |
+
raise CompletionParseError(f"Expected parameter or closing invoke at tool block offset {i}")
|
| 160 |
+
key = match.group(1)
|
| 161 |
+
if key in arguments:
|
| 162 |
+
raise CompletionParseError(f"Duplicate parameter {key!r}")
|
| 163 |
+
end = text.find("</parameter>", match.end())
|
| 164 |
+
if end < 0:
|
| 165 |
+
raise CompletionParseError(f"Missing closing parameter tag for {key!r}")
|
| 166 |
+
arguments[key] = text[match.end():end]
|
| 167 |
+
i = end + len("</parameter>")
|
| 168 |
+
values = _resolve_arguments(name, arguments, tools, argument_mode)
|
| 169 |
+
calls.append({
|
| 170 |
+
"id": "call_" + uuid.uuid4().hex,
|
| 171 |
+
"type": "function",
|
| 172 |
+
"function": {"name": name, "arguments": json.dumps(values, ensure_ascii=False, allow_nan=False)},
|
| 173 |
+
})
|
| 174 |
+
if not calls:
|
| 175 |
+
raise CompletionParseError("Empty tool-call block")
|
| 176 |
+
return calls
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
def _parse_document(document, tools, argument_mode, allow_incomplete):
|
| 180 |
+
text = document.text
|
| 181 |
+
markers = list(document.markers)
|
| 182 |
+
reasoning = ""
|
| 183 |
+
content = ""
|
| 184 |
+
calls = []
|
| 185 |
+
pending = ""
|
| 186 |
+
i = 0
|
| 187 |
+
terminated = False
|
| 188 |
+
|
| 189 |
+
def next_marker(position):
|
| 190 |
+
return next(((at, marker) for at, marker in markers if at >= position), (len(text), None))
|
| 191 |
+
|
| 192 |
+
at, marker = next_marker(0)
|
| 193 |
+
if at == 0 and marker == THINK:
|
| 194 |
+
i = len(THINK)
|
| 195 |
+
at, marker = next_marker(i)
|
| 196 |
+
reasoning = text[i:at]
|
| 197 |
+
if marker is None:
|
| 198 |
+
if not allow_incomplete:
|
| 199 |
+
raise CompletionParseError("Missing closing think tag")
|
| 200 |
+
return dict(role="assistant", reasoning_content=reasoning, content="", tool_calls=[],
|
| 201 |
+
complete=False, raw_text=text, unparsed_tool_text="")
|
| 202 |
+
if marker != THINK_END:
|
| 203 |
+
raise CompletionParseError(f"Expected closing think tag, found {marker}")
|
| 204 |
+
i = at + len(THINK_END)
|
| 205 |
+
at, marker = next_marker(i)
|
| 206 |
+
content = text[i:at]
|
| 207 |
+
i = at
|
| 208 |
+
if marker == CALL:
|
| 209 |
+
body_start = i + len(CALL)
|
| 210 |
+
at, marker = next_marker(body_start)
|
| 211 |
+
if marker is None and allow_incomplete:
|
| 212 |
+
pending = text[body_start:]
|
| 213 |
+
i = len(text)
|
| 214 |
+
elif marker != CALL_END:
|
| 215 |
+
raise CompletionParseError("Missing closing tool-call tag or unexpected control token inside tools")
|
| 216 |
+
else:
|
| 217 |
+
calls = _parse_calls(text[body_start:at], tools, argument_mode)
|
| 218 |
+
i = at + len(CALL_END)
|
| 219 |
+
at, marker = next_marker(i)
|
| 220 |
+
if text[i:at].strip():
|
| 221 |
+
raise CompletionParseError("Unexpected text after the tool-call block")
|
| 222 |
+
i = at
|
| 223 |
+
if marker in (END, MASK):
|
| 224 |
+
terminated = True
|
| 225 |
+
i = at + len(marker)
|
| 226 |
+
if text[i:].strip():
|
| 227 |
+
raise CompletionParseError("Unexpected text after assistant end")
|
| 228 |
+
elif marker is not None:
|
| 229 |
+
raise CompletionParseError(f"Unexpected control marker {marker}")
|
| 230 |
+
if not terminated and not allow_incomplete:
|
| 231 |
+
raise CompletionParseError("Missing assistant end token; pass allow_incomplete=True for truncated output")
|
| 232 |
+
return dict(
|
| 233 |
+
role="assistant", reasoning_content=reasoning, content=content, tool_calls=calls,
|
| 234 |
+
complete=terminated, raw_text=text, unparsed_tool_text=pending,
|
| 235 |
+
)
|
| 236 |
+
|
| 237 |
+
|
| 238 |
+
def parse_completion(
|
| 239 |
+
completion,
|
| 240 |
+
*,
|
| 241 |
+
tokenizer=None,
|
| 242 |
+
rendered: RenderedChat | None = None,
|
| 243 |
+
tools=None,
|
| 244 |
+
argument_mode="schema",
|
| 245 |
+
allow_incomplete=False,
|
| 246 |
+
):
|
| 247 |
+
"""Parse newly generated assistant output, optionally restoring its prefill.
|
| 248 |
+
|
| 249 |
+
Pass generated IDs plus tokenizer for source-preserving decoding. Do not
|
| 250 |
+
pass the whole prompt+completion sequence. `rendered` is the result of
|
| 251 |
+
render_chat(..., add_generation_prompt=True). String input is supported
|
| 252 |
+
for legacy servers, but marker-looking literal text is ambiguous there.
|
| 253 |
+
|
| 254 |
+
Default argument_mode='schema' refuses unresolved type ambiguity. 'raw'
|
| 255 |
+
returns every tool parameter as a string, for inspection only.
|
| 256 |
+
"""
|
| 257 |
+
if argument_mode not in ("schema", "raw"):
|
| 258 |
+
raise ValueError("argument_mode must be 'schema' or 'raw'")
|
| 259 |
+
if rendered is not None and not rendered.has_generation_prompt:
|
| 260 |
+
raise ValueError("rendered must have add_generation_prompt=True")
|
| 261 |
+
prefix = rendered.generation_prefix if rendered is not None else ()
|
| 262 |
+
if isinstance(completion, str):
|
| 263 |
+
prefix_text = "".join(s.text for s in prefix)
|
| 264 |
+
document = _from_text(prefix_text + completion)
|
| 265 |
+
else:
|
| 266 |
+
if tokenizer is None:
|
| 267 |
+
raise ValueError("Token-ID completion parsing requires tokenizer")
|
| 268 |
+
ids = completion.tolist() if hasattr(completion, "tolist") else list(completion)
|
| 269 |
+
if any(not isinstance(i, int) or isinstance(i, bool) or i < 0 or i >= len(tokenizer) for i in ids):
|
| 270 |
+
raise ValueError("completion must be a one-dimensional sequence of valid token IDs")
|
| 271 |
+
while ids and ids[-1] == tokenizer.pad_token_id:
|
| 272 |
+
ids.pop()
|
| 273 |
+
prefix_ids = tokenizer.encode_segments(prefix) if prefix else []
|
| 274 |
+
document = _from_ids(prefix_ids + ids, tokenizer)
|
| 275 |
+
return _parse_document(document, tools, argument_mode, allow_incomplete)
|
encoding_ernie.py
ADDED
|
@@ -0,0 +1,377 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Pure Python renderer for ERNIE m200k v2p1 / chatv2p3.
|
| 2 |
+
|
| 3 |
+
No Jinja or Transformers dependency. Caller text is always ordinary text;
|
| 4 |
+
only literals introduced by this renderer can activate added-token matching.
|
| 5 |
+
The reference template's whitespace, paired think tags, and media counters
|
| 6 |
+
(including its leading-system double count) are intentionally preserved.
|
| 7 |
+
"""
|
| 8 |
+
|
| 9 |
+
from __future__ import annotations
|
| 10 |
+
|
| 11 |
+
import copy
|
| 12 |
+
import json
|
| 13 |
+
import uuid
|
| 14 |
+
from dataclasses import dataclass, replace
|
| 15 |
+
from typing import Any, Iterable
|
| 16 |
+
|
| 17 |
+
MASK = "<|ERNIE_MASK|>"
|
| 18 |
+
START = "<|ernie:im_start|>"
|
| 19 |
+
END = "<|ernie:im_end|>"
|
| 20 |
+
THINK = "<ernie:think>"
|
| 21 |
+
THINK_END = "</ernie:think>"
|
| 22 |
+
CALL = "<ernie:tool_call>"
|
| 23 |
+
CALL_END = "</ernie:tool_call>"
|
| 24 |
+
OUTPUT = "<ernie:tool_output>"
|
| 25 |
+
OUTPUT_END = "</ernie:tool_output>"
|
| 26 |
+
MISSING = object()
|
| 27 |
+
REASONING_EFFORTS = ("low", "medium", "high")
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
@dataclass(frozen=True)
|
| 31 |
+
class EncodeSegment:
|
| 32 |
+
"""A text span plus whether it may activate added-token matching."""
|
| 33 |
+
text: str
|
| 34 |
+
allow_special: bool = False
|
| 35 |
+
# Historical assistant body, including its END, but excluding role header.
|
| 36 |
+
assistant: bool = False
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
@dataclass(frozen=True)
|
| 40 |
+
class RenderedChat:
|
| 41 |
+
"""A fully rendered chat as encode segments plus its generation prefix."""
|
| 42 |
+
segments: tuple[EncodeSegment, ...]
|
| 43 |
+
# Exact assistant body already supplied by add_generation_prompt.
|
| 44 |
+
generation_prefix: tuple[EncodeSegment, ...] = ()
|
| 45 |
+
has_generation_prompt: bool = False
|
| 46 |
+
|
| 47 |
+
@property
|
| 48 |
+
def text(self) -> str:
|
| 49 |
+
"""Concatenate all segments into the rendered chat text."""
|
| 50 |
+
return segments_to_text(self.segments)
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
def segments_to_text(segments: Iterable[EncodeSegment]) -> str:
|
| 54 |
+
"""Join the text of every segment into a single string."""
|
| 55 |
+
return "".join(segment.text for segment in segments)
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def _control(text: str) -> EncodeSegment:
|
| 59 |
+
return EncodeSegment(text, True)
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
def _text(text: str) -> EncodeSegment:
|
| 63 |
+
if not isinstance(text, str):
|
| 64 |
+
raise TypeError(f"Expected text, got {type(text).__name__}")
|
| 65 |
+
return EncodeSegment(text)
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def _compact(segments: Iterable[EncodeSegment]) -> list[EncodeSegment]:
|
| 69 |
+
"""Merge metadata-equivalent neighbors in linear time."""
|
| 70 |
+
result = []
|
| 71 |
+
parts: list[str] = []
|
| 72 |
+
previous = None
|
| 73 |
+
for segment in segments:
|
| 74 |
+
if not segment.text:
|
| 75 |
+
continue
|
| 76 |
+
metadata = (segment.allow_special, segment.assistant)
|
| 77 |
+
if previous is not None and metadata != previous:
|
| 78 |
+
result.append(EncodeSegment("".join(parts), *previous))
|
| 79 |
+
parts = []
|
| 80 |
+
parts.append(segment.text)
|
| 81 |
+
previous = metadata
|
| 82 |
+
if previous is not None:
|
| 83 |
+
result.append(EncodeSegment("".join(parts), *previous))
|
| 84 |
+
return result
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
def _slice(segments: Iterable[EncodeSegment], start: int, end: int) -> list[EncodeSegment]:
|
| 88 |
+
result = []
|
| 89 |
+
offset = 0
|
| 90 |
+
for segment in segments:
|
| 91 |
+
stop = offset + len(segment.text)
|
| 92 |
+
if stop > start and offset < end:
|
| 93 |
+
result.append(replace(segment, text=segment.text[max(0, start - offset):end - offset]))
|
| 94 |
+
offset = stop
|
| 95 |
+
if offset >= end:
|
| 96 |
+
break
|
| 97 |
+
return result
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
def _strip_newlines(segments: list[EncodeSegment]) -> list[EncodeSegment]:
|
| 101 |
+
text = segments_to_text(segments)
|
| 102 |
+
return _slice(segments, len(text) - len(text.lstrip("\n")), len(text.rstrip("\n")))
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
def _json(value: Any, sort_keys: bool = True) -> str:
|
| 106 |
+
# Like the Transformers Jinja sandbox's tojson (no HTML escaping), but sorts keys by default.
|
| 107 |
+
return json.dumps(value, ensure_ascii=False, sort_keys=sort_keys)
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
def _validate_messages(messages: Any) -> None:
|
| 111 |
+
if not isinstance(messages, (list, tuple)) or not messages:
|
| 112 |
+
raise ValueError("messages must be a non-empty list/tuple of message dictionaries")
|
| 113 |
+
for i, message in enumerate(messages):
|
| 114 |
+
if not isinstance(message, dict):
|
| 115 |
+
raise TypeError(f"messages[{i}] must be a dictionary")
|
| 116 |
+
if message.get("role") not in ("system", "user", "assistant", "tool"):
|
| 117 |
+
raise ValueError(f"Unsupported role at messages[{i}]: {message.get('role')!r}")
|
| 118 |
+
content = message.get("content")
|
| 119 |
+
if isinstance(content, (list, tuple)):
|
| 120 |
+
for block in content:
|
| 121 |
+
if not isinstance(block, dict):
|
| 122 |
+
raise TypeError(f"Content blocks at messages[{i}] must be dictionaries")
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
class _Renderer:
|
| 126 |
+
def __init__(self, *, tools, enable_thinking, reasoning_effort, options, sort_keys=True):
|
| 127 |
+
self.tools = tools or []
|
| 128 |
+
self.sort_keys = sort_keys
|
| 129 |
+
self.options = options or {}
|
| 130 |
+
if not isinstance(self.options, dict):
|
| 131 |
+
raise TypeError("options must be a dictionary")
|
| 132 |
+
self.thinking_off = (
|
| 133 |
+
self.options.get("thinking_mode") in ("close", "false")
|
| 134 |
+
or enable_thinking in (False, 0) # Preserve Jinja equality, including 0.
|
| 135 |
+
or enable_thinking == "false"
|
| 136 |
+
)
|
| 137 |
+
self.effort = reasoning_effort
|
| 138 |
+
self.counts = {"image": 0, "video": 0, "audio": 0}
|
| 139 |
+
|
| 140 |
+
def content(self, content, role="user", has_reasoning=False):
|
| 141 |
+
"""Render one message's content blocks into encode segments."""
|
| 142 |
+
if isinstance(content, str):
|
| 143 |
+
return [_text(content)]
|
| 144 |
+
if not isinstance(content, (list, tuple)):
|
| 145 |
+
return []
|
| 146 |
+
out = []
|
| 147 |
+
for item in content:
|
| 148 |
+
kind = item.get("type")
|
| 149 |
+
if kind == "text":
|
| 150 |
+
value = item.get("text", "")
|
| 151 |
+
# Jinja prints explicit None, unlike an absent text field.
|
| 152 |
+
out.append(_text(str(value)))
|
| 153 |
+
elif kind in ("image_url", "video_url", "audio_url"):
|
| 154 |
+
media = kind.removesuffix("_url")
|
| 155 |
+
self.counts[media] += 1
|
| 156 |
+
placeholder = f"<{media}_start><|{media}@placeholder|><{media}_end>"
|
| 157 |
+
if media == "image":
|
| 158 |
+
prefix = " " if role == "assistant" and has_reasoning else f" Picture {self.counts[media]}:"
|
| 159 |
+
elif media == "video":
|
| 160 |
+
prefix = f" Video {self.counts[media]}:"
|
| 161 |
+
elif role == "user":
|
| 162 |
+
prefix = f" Audio {self.counts[media]}:"
|
| 163 |
+
elif role == "assistant":
|
| 164 |
+
prefix = " "
|
| 165 |
+
else:
|
| 166 |
+
continue
|
| 167 |
+
out.append(_control(prefix + placeholder))
|
| 168 |
+
if media == "video":
|
| 169 |
+
subtitles = (item.get("video_url") or {}).get("subtitles")
|
| 170 |
+
if subtitles:
|
| 171 |
+
out.append(_control(" <Start of Audio Content>:"))
|
| 172 |
+
for subtitle, start, end in subtitles:
|
| 173 |
+
out.extend([_control(f"[{start:.1f},{end:.1f}]"), _text(str(subtitle))])
|
| 174 |
+
out.append(_control("<End of Audio Content> "))
|
| 175 |
+
# Unknown content block types are omitted by the original template.
|
| 176 |
+
return out
|
| 177 |
+
|
| 178 |
+
def assistant(self, message, content):
|
| 179 |
+
"""Render an assistant turn, including think tags and tool calls."""
|
| 180 |
+
reasoning = message.get("thoughts")
|
| 181 |
+
if not isinstance(reasoning, str):
|
| 182 |
+
reasoning = message.get("reasoning_content")
|
| 183 |
+
if isinstance(reasoning, str):
|
| 184 |
+
reasoning_segments = [_text(reasoning)]
|
| 185 |
+
else:
|
| 186 |
+
text = segments_to_text(content)
|
| 187 |
+
if THINK_END in text:
|
| 188 |
+
first = text.index(THINK_END)
|
| 189 |
+
start = text.rfind(THINK, 0, first)
|
| 190 |
+
reasoning_segments = _slice(content, start + len(THINK) if start >= 0 else 0, first)
|
| 191 |
+
content = _slice(content, text.rindex(THINK_END) + len(THINK_END), len(text))
|
| 192 |
+
else:
|
| 193 |
+
reasoning_segments = []
|
| 194 |
+
body = [_control(THINK)]
|
| 195 |
+
if not self.thinking_off and segments_to_text(reasoning_segments).strip():
|
| 196 |
+
body.extend(reasoning_segments)
|
| 197 |
+
body.append(_control(THINK_END))
|
| 198 |
+
body.extend(content)
|
| 199 |
+
calls = message.get("tool_calls")
|
| 200 |
+
if calls:
|
| 201 |
+
body.append(_control(CALL + "\n"))
|
| 202 |
+
for call in calls:
|
| 203 |
+
function = call.get("function") or call
|
| 204 |
+
body.extend([_control('<invoke name="'), _text(function["name"]), _control('">')])
|
| 205 |
+
arguments = function.get("arguments")
|
| 206 |
+
if isinstance(arguments, str):
|
| 207 |
+
arguments = json.loads(arguments)
|
| 208 |
+
if not isinstance(arguments, dict):
|
| 209 |
+
raise TypeError("tool call arguments must be a JSON object or its JSON string")
|
| 210 |
+
for key in sorted(arguments) if self.sort_keys else arguments:
|
| 211 |
+
value = arguments[key]
|
| 212 |
+
body.extend([
|
| 213 |
+
_control('<parameter name="'), _text(key), _control('">'),
|
| 214 |
+
_text(value if isinstance(value, str) else _json(value, self.sort_keys)),
|
| 215 |
+
_control("</parameter>"),
|
| 216 |
+
])
|
| 217 |
+
body.append(_control("</invoke>\n"))
|
| 218 |
+
body.append(_control(CALL_END))
|
| 219 |
+
body.append(_control(END))
|
| 220 |
+
return (
|
| 221 |
+
[_control(START + "assistant\n")]
|
| 222 |
+
+ [replace(s, assistant=True) for s in body]
|
| 223 |
+
+ [_control("\n")]
|
| 224 |
+
)
|
| 225 |
+
|
| 226 |
+
def messages(self, messages):
|
| 227 |
+
"""Render a message list into encode segments, role by role."""
|
| 228 |
+
out = []
|
| 229 |
+
for i, message in enumerate(messages):
|
| 230 |
+
role = message["role"]
|
| 231 |
+
# Preserve counter side effects even for a leading system message.
|
| 232 |
+
content = self.content(message.get("content"), role, "reasoning_content" in message)
|
| 233 |
+
if role == "user" or (role == "system" and i > 0):
|
| 234 |
+
out.extend([_control(START + role + "\n"), *content, _control(END + "\n")])
|
| 235 |
+
elif role == "assistant":
|
| 236 |
+
out.extend(self.assistant(message, content))
|
| 237 |
+
elif role == "tool":
|
| 238 |
+
if i == 0 or messages[i - 1]["role"] != "tool":
|
| 239 |
+
out.append(_control(START + "tool"))
|
| 240 |
+
out.extend([_control("\n" + OUTPUT), *content, _control(OUTPUT_END)])
|
| 241 |
+
if i == len(messages) - 1 or messages[i + 1]["role"] != "tool":
|
| 242 |
+
out.append(_control(END + "\n"))
|
| 243 |
+
return out
|
| 244 |
+
|
| 245 |
+
def generation_prefix(self):
|
| 246 |
+
"""Build the assistant generation prefix.
|
| 247 |
+
|
| 248 |
+
options.tool_choice is ignored: it is an inference parameter enforced by
|
| 249 |
+
constrained decoding on the serving side, not part of the prompt.
|
| 250 |
+
"""
|
| 251 |
+
return [_control(THINK + THINK_END if self.thinking_off else THINK)]
|
| 252 |
+
|
| 253 |
+
def render(self, messages, *, system_settings, agent_storage, examples, add_generation_prompt):
|
| 254 |
+
"""Render a full conversation, including system block and tools, to segments."""
|
| 255 |
+
out = [_control(MASK + START + "system\n")]
|
| 256 |
+
if messages[0]["role"] == "system" or system_settings or agent_storage or examples:
|
| 257 |
+
out.append(_control("<ernie:system_setting>"))
|
| 258 |
+
if system_settings:
|
| 259 |
+
out.extend([_control("\n"), _text(system_settings)])
|
| 260 |
+
if messages[0]["role"] == "system":
|
| 261 |
+
content = messages[0].get("content")
|
| 262 |
+
if isinstance(content, (str, list, tuple)):
|
| 263 |
+
out.extend([_control("\n"), *self.content(content)])
|
| 264 |
+
if agent_storage:
|
| 265 |
+
out.extend([
|
| 266 |
+
_control("\n【agent storage】记录额外的信息,包含但不限于用户画像、长期记忆内容等。\n"),
|
| 267 |
+
_text(agent_storage),
|
| 268 |
+
])
|
| 269 |
+
if examples and examples[0]:
|
| 270 |
+
out.append(_control("\n【行为例子】列举了一些情况下的行为逻辑供你参考。\n"))
|
| 271 |
+
for i, example in enumerate(reversed(examples)):
|
| 272 |
+
_validate_messages(example)
|
| 273 |
+
out.append(_control(("\n" if i else "") + f"[示例{i + 1}]\n"))
|
| 274 |
+
# Examples are prompt context, not training targets.
|
| 275 |
+
out.extend(replace(s, assistant=False) for s in _strip_newlines(self.messages(example)))
|
| 276 |
+
out.append(_control("\n</ernie:system_setting>\n"))
|
| 277 |
+
out.append(_control("<ernie:global_setting>"))
|
| 278 |
+
if not self.thinking_off:
|
| 279 |
+
effort = "high" if self.effort is MISSING else self.effort
|
| 280 |
+
if effort not in REASONING_EFFORTS:
|
| 281 |
+
raise ValueError(f"reasoning_effort must be one of {REASONING_EFFORTS}, got {effort!r}")
|
| 282 |
+
out.extend([_control("\nreasoning_effort="), _text(effort)])
|
| 283 |
+
parallel = self.options.get("parallel_tool_calls", MISSING)
|
| 284 |
+
if not (parallel in (False, 0) or parallel == "false") and self.tools:
|
| 285 |
+
out.append(_control("\nparallel_tool_calls=True"))
|
| 286 |
+
out.append(_control("\n</ernie:global_setting>"))
|
| 287 |
+
if self.tools:
|
| 288 |
+
out.extend([
|
| 289 |
+
_control("\n<ernie:tool_list>\n["),
|
| 290 |
+
_text(", ".join(_json(t, self.sort_keys) for t in self.tools)),
|
| 291 |
+
_control("]\n</ernie:tool_list>"),
|
| 292 |
+
])
|
| 293 |
+
out.append(_control(END + "\n"))
|
| 294 |
+
out.extend(_strip_newlines(self.messages(messages)))
|
| 295 |
+
prefix = self.generation_prefix() if add_generation_prompt else []
|
| 296 |
+
if add_generation_prompt:
|
| 297 |
+
out.extend([_control("\n" + START + "assistant\n"), *prefix])
|
| 298 |
+
return RenderedChat(tuple(_compact(out)), tuple(_compact(prefix)), bool(add_generation_prompt))
|
| 299 |
+
|
| 300 |
+
|
| 301 |
+
def render_chat(
|
| 302 |
+
messages,
|
| 303 |
+
tools=None,
|
| 304 |
+
*,
|
| 305 |
+
add_generation_prompt=True,
|
| 306 |
+
continue_final_message=False,
|
| 307 |
+
enable_thinking=None,
|
| 308 |
+
reasoning_effort=MISSING,
|
| 309 |
+
system_settings=None,
|
| 310 |
+
agent_storage=None,
|
| 311 |
+
examples=None,
|
| 312 |
+
options=None,
|
| 313 |
+
chat_template_kwargs=None,
|
| 314 |
+
sort_keys=True,
|
| 315 |
+
) -> RenderedChat:
|
| 316 |
+
"""Render one conversation without mutating input.
|
| 317 |
+
|
| 318 |
+
The standalone API defaults to a generation prompt, as direct rendering of
|
| 319 |
+
the original Jinja does. The HF adapter explicitly uses HF's default False.
|
| 320 |
+
sort_keys sorts the tool list and tool-call arguments by key, recursively.
|
| 321 |
+
Pass False to keep the caller's key order.
|
| 322 |
+
"""
|
| 323 |
+
_validate_messages(messages)
|
| 324 |
+
if tools is not None and (
|
| 325 |
+
not isinstance(tools, (list, tuple)) or any(not isinstance(t, dict) for t in tools)
|
| 326 |
+
):
|
| 327 |
+
raise TypeError("tools must be a list of tool schema dictionaries")
|
| 328 |
+
if chat_template_kwargs is not None:
|
| 329 |
+
if not isinstance(chat_template_kwargs, dict):
|
| 330 |
+
raise TypeError("chat_template_kwargs must be a dictionary")
|
| 331 |
+
if "options" in chat_template_kwargs:
|
| 332 |
+
options = chat_template_kwargs["options"]
|
| 333 |
+
if continue_final_message and add_generation_prompt:
|
| 334 |
+
raise ValueError("continue_final_message and add_generation_prompt cannot both be True")
|
| 335 |
+
marker = None
|
| 336 |
+
if continue_final_message:
|
| 337 |
+
# Match HF's continuation semantics even for inline think tags and a
|
| 338 |
+
# final text block followed by media. The marker is removed from segments
|
| 339 |
+
# before any tokenization and never changes the caller's message.
|
| 340 |
+
messages = copy.deepcopy(messages)
|
| 341 |
+
marker = "__ERNIE_CONTINUE_" + uuid.uuid4().hex + "__"
|
| 342 |
+
content = messages[-1].get("content")
|
| 343 |
+
if isinstance(content, str):
|
| 344 |
+
messages[-1]["content"] = content + marker
|
| 345 |
+
elif isinstance(content, (list, tuple)):
|
| 346 |
+
for block in reversed(content):
|
| 347 |
+
if "text" in block and isinstance(block["text"], str):
|
| 348 |
+
block["text"] += marker
|
| 349 |
+
break
|
| 350 |
+
else:
|
| 351 |
+
raise ValueError("continue_final_message requires a final text block")
|
| 352 |
+
else:
|
| 353 |
+
raise ValueError("continue_final_message requires string or text-block content")
|
| 354 |
+
renderer = _Renderer(
|
| 355 |
+
tools=tools, enable_thinking=enable_thinking,
|
| 356 |
+
reasoning_effort=reasoning_effort, options=options, sort_keys=sort_keys,
|
| 357 |
+
)
|
| 358 |
+
rendered = renderer.render(
|
| 359 |
+
messages, system_settings=system_settings, agent_storage=agent_storage,
|
| 360 |
+
examples=examples, add_generation_prompt=add_generation_prompt,
|
| 361 |
+
)
|
| 362 |
+
if marker is not None:
|
| 363 |
+
end = rendered.text.find(marker)
|
| 364 |
+
if end < 0:
|
| 365 |
+
raise ValueError("Final message content was removed by the protocol")
|
| 366 |
+
rendered = RenderedChat(tuple(_slice(rendered.segments, 0, end)))
|
| 367 |
+
return rendered
|
| 368 |
+
|
| 369 |
+
|
| 370 |
+
def build_chat_segments(messages, tools=None, **kwargs) -> list[EncodeSegment]:
|
| 371 |
+
"""Render a conversation and return its encode segments as a list."""
|
| 372 |
+
return list(render_chat(messages, tools, **kwargs).segments)
|
| 373 |
+
|
| 374 |
+
|
| 375 |
+
def encode_messages(messages, tools=None, **kwargs) -> str:
|
| 376 |
+
"""Text view only. Use the tokenizer's tokenize=True path for safe IDs."""
|
| 377 |
+
return render_chat(messages, tools, **kwargs).text
|
flashindexer/flashindexer.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:44fd87744c1546365eded8ca9131d6b4e0e250330a824b4a772daae949013fd2
|
| 3 |
+
size 3148112
|
generation_config.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"bos_token_id": 1,
|
| 4 |
+
"eos_token_id": [2, 8],
|
| 5 |
+
"pad_token_id": 0,
|
| 6 |
+
"do_sample": true,
|
| 7 |
+
"top_p": 0.95,
|
| 8 |
+
"temperature": 1.0,
|
| 9 |
+
"transformers_version": "4.57.6"
|
| 10 |
+
}
|
model-00001-of-00128.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a4560dca8132234c9a951481f5bc9081ed9d3efa4f298eb4b5f736fe99bc6a3b
|
| 3 |
+
size 1648361616
|
model-00002-of-00128.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d7c74e3699599b2c8fbffa01d24e1ee8f9b042dbb89af0ba86e8adbdad76f0fd
|
| 3 |
+
size 942980496
|
model-00003-of-00128.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:96415a874561bebabdd9385671211b0d78990af46cb35b2e8631d9ccc176ae74
|
| 3 |
+
size 1296981768
|
model-00004-of-00128.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6f522e988fc6f7070db8f5ddfdf54243d6f72919595ca44ef0a6d2c22421488a
|
| 3 |
+
size 1296981616
|
model-00005-of-00128.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4c0e4118d21e6ec64209984e9d7435f01423c0ab6d34e2a7353c1e89af0fee58
|
| 3 |
+
size 1294023008
|
model-00006-of-00128.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5105b72ea844376c37f41a96084d6a0a26d0eee1d44e076160fc0c78f44c3e0d
|
| 3 |
+
size 1296981776
|
model-00007-of-00128.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d2db383019848c20a4550ad05ffe869ed0973dd25b395c4dd12449b66911b7e2
|
| 3 |
+
size 1305147088
|
model-00008-of-00128.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d4c7791484b30785c1b18b7af3051d7569c89949683fd96ddfb3a39b5601873a
|
| 3 |
+
size 1288086016
|
model-00009-of-00128.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5281819a7a8d31cba0fe9439bdad47ff08550eea427f34f2a5602821bbfd6bfd
|
| 3 |
+
size 1294753272
|
model-00010-of-00128.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:dfa0b8dafad56f064bec988c0aba33a005c93849b479164aede0e4208538e201
|
| 3 |
+
size 1296251360
|
model-00011-of-00128.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e9713d4e534c488db94eeba1573824d99783cd27a27bda7769cf04b37ee7e318
|
| 3 |
+
size 1296981760
|
model-00012-of-00128.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3d646d13c4181c0f2c93c4f90dbdcb97c68e450946d96f17152d668538642cdc
|
| 3 |
+
size 1294753288
|
model-00013-of-00128.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:227bedb9dedc9b57db165d91db292378cd7f47154d517daf9d77080a68a6b261
|
| 3 |
+
size 1296251360
|
model-00014-of-00128.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8df3607d1a043f524301d411b25efdaadd18fe3f6d7fe18e819d5f7005752ab7
|
| 3 |
+
size 1296981768
|
model-00015-of-00128.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d0051937238741914a5377806c1dd15dea6b36f8497e9b0c2b1a3b340f7660c2
|
| 3 |
+
size 1296981752
|
model-00016-of-00128.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:85c85b2e94f2f36315773e498eb5299849a723c31a3f83e1d326a8980e3aa6d9
|
| 3 |
+
size 1294022880
|
model-00017-of-00128.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:18c121e543d67ba5cdb2740f62de67d357dd334034fb1d91e999ef99b0f3dfa3
|
| 3 |
+
size 1296981776
|
model-00018-of-00128.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2c746fe3ad69b91ba9e7ca6d94af2afaf84a4bffe3f4be8bbd53b8323a12e43e
|
| 3 |
+
size 1296981488
|
model-00019-of-00128.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e3bdc1fb84634ada273f2b67fea49de3ac1faa2bf362a8084825cc83efbf81e3
|
| 3 |
+
size 1296251632
|
model-00020-of-00128.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d4efc5290d66dac95e96c6e298b395c31313d6b49ccfd94270d00dfea84eccea
|
| 3 |
+
size 1294753272
|
model-00021-of-00128.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4fc562b33e1ea4c35500ec2d8bf6d6dae18cd0bd57b8423f8405fb48bb06dd15
|
| 3 |
+
size 1297433520
|
model-00022-of-00128.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0bbb0ca09e96bc11bccbc451badb0dea7bf9aad352c072ab6f0210a706fb9150
|
| 3 |
+
size 1294753280
|
model-00023-of-00128.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:54ebffa3f62a7996d8fae72a6af55712aacb569b3ead35a15d8c587d10065a6e
|
| 3 |
+
size 1296981768
|
model-00024-of-00128.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:69d3878a55caa7cfa2098ca89fa5b3fcac942544ae715e4f14bddc24195088d6
|
| 3 |
+
size 1296251360
|
model-00025-of-00128.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ff33031825504266fa8bc35f04f4738a6aa739e0f32c2b7bd64a8b2ef21efed6
|
| 3 |
+
size 1294753272
|
model-00026-of-00128.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4e992224425aa195b0dc9f0075b893c07777382c1977b960d2cbcecdd44fec35
|
| 3 |
+
size 1296981776
|
model-00027-of-00128.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:aa6c44760d5691de638d3e02bba0786274c7ded51b7b590a432968aa797d2347
|
| 3 |
+
size 1296251928
|
model-00028-of-00128.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0f172665143a0344a95926d665c2d46603838324841fa459605cad1679e5a4c9
|
| 3 |
+
size 1296982928
|
model-00029-of-00128.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7b9bb3cfffc47881b4fff9d75a6de669bc601447814b7be363cecc3bd238bf17
|
| 3 |
+
size 1294754296
|
model-00030-of-00128.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:085f5f868800ec6effaa24912109e6c14fc1978e1bb8593b1dc5401e9d4b7eab
|
| 3 |
+
size 1296252544
|
model-00031-of-00128.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6992c7130711479c093ab45af0ec70912601f986ac5092062c1c5e877f71d499
|
| 3 |
+
size 1296982944
|
model-00032-of-00128.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:70ef78d2d4656225e5958d50476b7a76a4336c28d5376fbd42bf55bcc9636090
|
| 3 |
+
size 1280499272
|
model-00033-of-00128.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b1063307627dfe09686b04384268616d988b00baffef1d2dc4618dbac4516fda
|
| 3 |
+
size 1310507544
|
model-00034-of-00128.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d37a9f3c531d7991c1c6d1a839185ba79bfcd02013e28212ddb06d49f5f211df
|
| 3 |
+
size 1296982928
|
model-00035-of-00128.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9c4c73b4f1d9db3897c1a8ab7ba94e2daf4e0ed5e0b4bbd5ce9b63b00d893e57
|
| 3 |
+
size 1296252416
|
model-00036-of-00128.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:80353c58502f9801893c530847c56d4dc03569087eb6fcd2a17def8c7022ae05
|
| 3 |
+
size 1294754440
|
model-00037-of-00128.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9b3f000de356ae3f225184fb5e310931b3545bda7df098ae5ccee288d02a4028
|
| 3 |
+
size 1296982928
|
model-00038-of-00128.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:464b5d49057ae7305e8a3bf8ddba8c21e927ea4e7bcde157b9aaf6b28e3fb998
|
| 3 |
+
size 1296252416
|
model-00039-of-00128.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9e3e21e2a4dca0e0a1cb72a142730bff2bfc89a0cbf9325efddc56c63404ff50
|
| 3 |
+
size 1296982928
|