Text Generation
Transformers
Safetensors
English
Chinese
spark2_5
llm
sparkx2_5
conversational
custom_code
Run this model with HF Jobs
Run XHToken/Spark-X2.6-4B-Base on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/XHToken/Spark-X2.6-4B-Base. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/XHToken/Spark-X2.6-4B-Base on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/XHToken/Spark-X2.6-4B-Base. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/XHToken/Spark-X2.6-4B-Base. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use XHToken/Spark-X2.6-4B-Base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use XHToken/Spark-X2.6-4B-Base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="XHToken/Spark-X2.6-4B-Base", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("XHToken/Spark-X2.6-4B-Base", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use XHToken/Spark-X2.6-4B-Base with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "XHToken/Spark-X2.6-4B-Base" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "XHToken/Spark-X2.6-4B-Base", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/XHToken/Spark-X2.6-4B-Base
- SGLang
How to use XHToken/Spark-X2.6-4B-Base 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 "XHToken/Spark-X2.6-4B-Base" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "XHToken/Spark-X2.6-4B-Base", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "XHToken/Spark-X2.6-4B-Base" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "XHToken/Spark-X2.6-4B-Base", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use XHToken/Spark-X2.6-4B-Base with Docker Model Runner:
docker model run hf.co/XHToken/Spark-X2.6-4B-Base
wzpeng2 commited on
Commit ·
192f54e
1
Parent(s): 04de861
upload files
Browse filesFiles changed (23)
- .gitattributes+3
- LICENSEAdded+202
- README.md+477
- chat_template.jinjaAdded+117
- config.jsonAdded+83
- configuration_spark.pyAdded+118
- generation_config.jsonAdded+14
- images/model-benchmark-comparison.svgAdded
- images/post_training_pipeline.svgAdded
- images/spark25-hybrid-architecture-light.pngAdded
- images/xhtoken-wechat.jpgAdded
- merges.txtAdded
- model-00001-of-00005.safetensorsAdded+3
- model-00002-of-00005.safetensorsAdded+3
- model-00003-of-00005.safetensorsAdded+3
- model-00004-of-00005.safetensorsAdded+3
- model-00005-of-00005.safetensorsAdded+3
- model.safetensors.index.jsonAdded+298
- modeling_spark.pyAdded+483
- special_tokens_map.jsonAdded+6
- tokenizer.jsonAdded
- tokenizer_config.jsonAdded+42
- vocab.jsonAdded
32 unmodified lines33343532 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -text32 unmodified lines33343536373832 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -text*.png filter=lfs diff=lfs merge=lfs -text*.jpg filter=lfs diff=lfs merge=lfs -text*.jpeg filter=lfs diff=lfs merge=lfs -text
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
"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.
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
"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.
"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).
"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.
"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."
"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.
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.
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.
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:
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
(c) 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
(d) 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.
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.
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.
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.
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.
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.
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.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
Copyright 2026 XHToken
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.123---license: apache-2.0---123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480---license: apache-2.0library_name: transformerspipeline_tag: text-generationtags:- llm- sparkx2_5- agentbase_model:- XHToken/Spark-X2.5-4B-Base---# Spark-X2.5<div align="center">[](https://join.slack.com/t/tokenspark/shared_invite/zt-432qf8l2f-5~dLyXv8uETr0P0UuC07nw)[](https://discord.gg/kTDE2Hg8aw)[](https://www.youtube.com/@SparkLLM)[](https://dev.to/sparkllm)[](https://bsky.app/profile/sparkllm.bsky.social)[](https://x.com/sparkllm)[](https://www.zhihu.com/people/zhiikz7qh7m)[](images/xhtoken-wechat.jpg)</div>> [!Note]> This repository contains model weights and configuration files for the post-trained model in the Hugging Face Transformers format.## IntroductionWe are introducing Spark-X2.5-4B and Spark-X2.5-1.7B, two compact, general-purpose language models designed to make capable AI more practical, efficient, and accessible. The models deliver strong performance across a broad range of everyday tasks—including conversation, writing, translation, reasoning, coding, tool use, and agentic workflows—achieving leading results among open-source models of comparable size. Spark-X2.5 combines an efficiency-oriented architecture with native context windows of up to 1M tokens, and support for more than 200 languages.**Technical Highlights**:- **Efficient Architecture and Native 1M-token Context**: The models use a hybrid attention architecture that combines one full-attention layer with three sliding-window attention layers. This design substantially reduces the computational overhead typically associated with long-context models while natively supporting a context window of up to 1M tokens.- **Strong Coding and Agent Capabilities**: The models are deeply integrated with popular agent harnesses, including Codex, Claude Code, OpenClaw, and Hermes. They deliver state-of-the-art performance among models of comparable size across everyday coding, agentic workflows, reasoning, and instruction-following tasks.- **Broad Hardware and Software Compatibility**: The models support a wide range of hardware platforms, including NVIDIA, Huawei, Hygon, HOUMO.AI, etc. It is compatible with leading inference frameworks such as vLLM, SGLang, llama.cpp, MLX, and can be deployed quickly through platforms including Ollama and LM Studio. The models can also be customized using popular fine-tuning frameworks such as LLaMA-Factory. Across multiple hardware platforms, they deliver superior TTFT, TOPT, and overall inference efficiency compared with similarly sized models.- **Advanced Training Algorithms**: The models were trained on Huawei Ascend clusters. Large-scale reinforcement learning and post-training techniques such as MOPD significantly enhance its reasoning, coding, agentic, and instruction-following capabilities.<p align="center"><img src="./images/model-benchmark-comparison.svg" alt="Spark-X2.5 benchmark comparison"></p>## Model OverviewFor agent tasks, balancing performance, inference speed, and cache usage has long been a key bottleneck limiting model performance. Spark-X2.5 systematically integrates and optimizes mature attention technologies, combining sliding-window attention (SWA) with a hybrid full-attention architecture. This approach leverages the strengths of both mechanisms while avoiding the limitations of relying on a single structure, achieving an effective balance among performance, inference efficiency, and KV-cache size—thereby improving its practicality and effectiveness across real-world deployment scenarios.<p align="center"><img src="./images/spark25-hybrid-architecture-light.png" alt="Spark-X2.5 hybrid architecture"></p>## Training MethodsSpark-X2.5 is pretrained on approximately 20 trillion tokens from a diverse corpus spanning web pages, books, academic publications, code, and encyclopedic materials. Particular attention is paid to data quality, domain coverage, and the sampling weights assigned to different data categories. Extensive data-mixture studies are conducted to determine an effective balance among mathematics, logic, code, and other high-value domains. This enables the models to acquire broad general knowledge while developing stronger capabilities in complex reasoning and code generation. Long-context capability is developed through a dedicated training stage comprising hundreds of billions of tokens, with sequence lengths extending to 1M tokens.Post-training begins with supervised fine-tuning on a carefully curated corpus. This stage establishes robust instruction following, structured generation, and task-completion, while providing a stable policy initialization for reinforcement learning. We subsequently apply large-scale reinforcement learning across several capability domains, including language understanding, reasoning, programming, tool-augmented agentic behavior, and instruction following. This process yields a set of domain-specialized teacher policies, whose complementary strengths are consolidated into a single deployable model through MOPD.<p align="center"><img src="./images/post_training_pipeline.svg" alt="Spark-X2.5 hybrid architecture"></p>## BenchmarksWe evaluate our models and compare them with leading on-device models of similar size across a broad range of tasks, including agent, code, math, general and knowledge.<div style="overflow-x: auto; width: 100%;"><table style="width: 100%; min-width: 1080px; border-collapse: collapse; text-align: center;"><colgroup><col style="width: 190px;"><col span="8" style="width: 110px;"></colgroup><thead><tr><th align="center">Benchmark</th><th align="center"><span style="white-space: nowrap;">Spark‑X2.5‑4B</span></th><th align="center"><span style="white-space: nowrap;">Spark‑X2.5‑1.7B</span></th><th align="center"><span style="white-space: nowrap;">Qwen3.5‑9B</span></th><th align="center"><span style="white-space: nowrap;">Qwen3.5‑4B</span></th><th align="center"><span style="white-space: nowrap;">Qwen3.5‑2B</span></th><th align="center"><span style="white-space: nowrap;">Gemma4‑12B</span></th><th align="center"><span style="white-space: nowrap;">Gemma4‑E4B</span></th><th align="center"><span style="white-space: nowrap;">Gemma4‑E2B</span></th></tr></thead><tbody><tr><th colspan="9" align="left">Agent</th></tr><tr><td align="center">BFCL‑V4</td><td align="center">65.1</td><td align="center">46.9</td><td align="center"><strong>66.1*</strong></td><td align="center">50.3*</td><td align="center">43.6*</td><td align="center">37.4</td><td align="center">36.9</td><td align="center">30.2</td></tr><tr><td align="center">τ²‑bench</td><td align="center">75.1</td><td align="center">65.3</td><td align="center">79.1*</td><td align="center"><strong>79.9*</strong></td><td align="center">48.8*</td><td align="center">69.0*</td><td align="center">42.2*</td><td align="center">24.5*</td></tr><tr><td align="center">τ³‑bench</td><td align="center"><strong>30.4</strong></td><td align="center">20.1</td><td align="center">9.3</td><td align="center">6.7</td><td align="center">4.1</td><td align="center">13.3</td><td align="center">10.1</td><td align="center">8.8</td></tr><tr><td align="center">MCP‑Atlas</td><td align="center"><strong>54.6</strong></td><td align="center">23.4</td><td align="center">47.4*</td><td align="center">40.8*</td><td align="center">14.8</td><td align="center">30.5*</td><td align="center">15.0*</td><td align="center">12.6</td></tr><tr><td align="center">MCP‑Mark</td><td align="center"><strong>14.2</strong></td><td align="center">2.3</td><td align="center">13.4</td><td align="center">12.5</td><td align="center">–</td><td align="center">–</td><td align="center">–</td><td align="center">–</td></tr><tr><td align="center"><span style="white-space: nowrap;">Workspace Bench</span></td><td align="center"><strong>31.2</strong></td><td align="center">18.9</td><td align="center">25.5</td><td align="center">21.3</td><td align="center">7.7</td><td align="center">–</td><td align="center">–</td><td align="center">–</td></tr><tr><td align="center">VitaBench2.0</td><td align="center"><strong>25.2</strong></td><td align="center">8.3</td><td align="center">15.6</td><td align="center">18.2</td><td align="center">5.2</td><td align="center">12.4</td><td align="center">4.8</td><td align="center">4.4</td></tr><tr><td align="center">BrowseComp</td><td align="center"><strong>40.9</strong></td><td align="center">29.7</td><td align="center">8.3</td><td align="center">14.3</td><td align="center">3.1</td><td align="center">10.0</td><td align="center">8.3</td><td align="center">3.7</td></tr><tr><th colspan="9" align="left">Code</th></tr><tr><td align="center"><span style="white-space: nowrap;">SWE‑Bench Pro</span></td><td align="center"><strong>44.4</strong></td><td align="center">10.4</td><td align="center">33.8*</td><td align="center">29.4*</td><td align="center">1.9</td><td align="center">21.9*</td><td align="center">4.0*</td><td align="center">–</td></tr><tr><td align="center"><span style="white-space: nowrap;">SWE‑Bench Verified</span></td><td align="center">41.6</td><td align="center">28.3</td><td align="center"><strong>53.1*</strong></td><td align="center">38.8*</td><td align="center">6.8</td><td align="center">44.2*</td><td align="center">14.0*</td><td align="center">–</td></tr><tr><td align="center"><span style="white-space: nowrap;">SWE‑Bench Multilingual</span></td><td align="center"><strong>53.3</strong></td><td align="center">23.3</td><td align="center">43.3</td><td align="center">27.7</td><td align="center">5.0</td><td align="center">32.5*</td><td align="center">–</td><td align="center">–</td></tr><tr><td align="center">SciCode</td><td align="center">34.7</td><td align="center">18.2</td><td align="center">32.7*</td><td align="center">24.0</td><td align="center">6.0</td><td align="center"><strong>39.8</strong></td><td align="center">27.5</td><td align="center">20.5</td></tr><tr><th colspan="9" align="left">Math</th></tr><tr><td align="center"><span style="white-space: nowrap;">Gaokao 2026</span></td><td align="center">133.4</td><td align="center">114.8</td><td align="center"><strong>135.5</strong></td><td align="center">130.3</td><td align="center">94.0</td><td align="center">130.6</td><td align="center">102.4</td><td align="center">81.8</td></tr><tr><td align="center"><span style="white-space: nowrap;">AIME 2026</span></td><td align="center"><strong>90.7</strong></td><td align="center">69.4</td><td align="center">88.2</td><td align="center">83.0</td><td align="center">30.8</td><td align="center">82.1*</td><td align="center">42.5*</td><td align="center">37.5*</td></tr><tr><td align="center"><span style="white-space: nowrap;">HMMT Feb 2026</span></td><td align="center"><strong>81.2</strong></td><td align="center">48.4</td><td align="center">70.8</td><td align="center">69.7</td><td align="center">21.5</td><td align="center">65.6</td><td align="center">34.2</td><td align="center">20.5</td></tr><tr><td align="center"><span style="white-space: nowrap;">IMO‑AnswerBench</span></td><td align="center"><strong>74.2</strong></td><td align="center">45.4</td><td align="center">69.8</td><td align="center">68.5</td><td align="center">–</td><td align="center">57.2</td><td align="center">26.9</td><td align="center">22.6</td></tr><tr><th colspan="9" align="left">General & Knowledge</th></tr><tr><td align="center">IFEval</td><td align="center">93.0</td><td align="center">89.5</td><td align="center">91.5*</td><td align="center">89.8*</td><td align="center">78.6*</td><td align="center"><strong>94.8</strong></td><td align="center">45.3</td><td align="center">34.8</td></tr><tr><td align="center">IFBench</td><td align="center"><strong>75.0</strong></td><td align="center">66.3</td><td align="center">64.5</td><td align="center">59.2</td><td align="center">41.3*</td><td align="center">73.5*</td><td align="center">44.0*</td><td align="center">22.7</td></tr><tr><td align="center">AA‑LCR</td><td align="center">56.3</td><td align="center">24.3</td><td align="center"><strong>63.0*</strong></td><td align="center">57.0*</td><td align="center">25.6*</td><td align="center">55.3*</td><td align="center">34.7</td><td align="center">18.3</td></tr><tr><td align="center">HLE</td><td align="center">12.3</td><td align="center">6.3</td><td align="center"><strong>14.3</strong></td><td align="center">8.6</td><td align="center">2.1</td><td align="center">13.1</td><td align="center">3.9</td><td align="center">2.5</td></tr><tr><td align="center">GPQA</td><td align="center">67.4</td><td align="center">43.8</td><td align="center"><strong>77.2</strong></td><td align="center">67.2</td><td align="center">44.6</td><td align="center">72.8</td><td align="center">54.5</td><td align="center">43.8</td></tr></tbody></table></div>- \* denotes reported results from publicly‑released model cards / papers and - denotes scores not yet available.- All evaluations are conducted in thinking mode. The recommended sampling parameters for Spark-X2.5 are temperature=1.0, top_p=0.95, and top_k=-1.- Gaokao 2026 consists of the five 2026 Chinese GAOKAO examinations (National I,National II, Beijing, Shanghai, Tianjin), each graded out of 150 points.## QuickstartThe examples below serve a local Spark-X2.5-4B checkpoint. Set `MODEL_PATH` to its absolute path before starting a container:```bashexport MODEL_PATH=/absolute/path/to/Spark-X2.5-4B```### SGLang#### Install SGLangUse the pre-built image that tracks the Spark-X2.5 runtime:##### For NVIDIA GPUs:```bashdocker pull lmsysorg/sglang:nightly-dev-cu13-20260827-20621aa1```##### For Ascend NPUs:```bash# A3 daily buildexport SGLANG_IMAGE=quay.io/ascend/sglang:main-cann9.0.0-a3# A2 daily build (use this instead on A2 hardware)export SGLANG_IMAGE=quay.io/ascend/sglang:main-cann9.0.0-910bdocker pull "$SGLANG_IMAGE"```#### Run InferenceThe following commands start an OpenAI-compatible API server configured for a maximum context length of 1,048,576 tokens. This setting requires sufficient device memory; reduce `--context-length` when necessary.#### Server##### NVIDIA GPU:```bashdocker run --rm -it \--gpus '"device=0"' \--ipc=host \-p 30000:30000 \-v "$MODEL_PATH:/root/Spark-X2.5-4B:ro" \lmsysorg/sglang:nightly-dev-cu13-20260827-20621aa1 \python -m sglang.launch_server \--model-path /root/Spark-X2.5-4B \--served-model-name spark2.5 \--tool-call-parser spark25 \--reasoning-parser qwen3 \--tp-size 1 \--mem-fraction-static 0.8 \--context-length 1048576 \--chat-template /root/Spark-X2.5-4B/chat_template.jinja \--host 0.0.0.0 \--port 30000```##### Ascend NPU:```bashdocker run -it --rm -e ASCEND_USE_FIA=1 --network=host --ipc=host --shm-size=16g \--device=/dev/davinci0 --device=/dev/davinci1 --device=/dev/davinci2 --device=/dev/davinci3 \--device=/dev/davinci4 --device=/dev/davinci5 --device=/dev/davinci6 --device=/dev/davinci7 \--device=/dev/davinci8 --device=/dev/davinci9 --device=/dev/davinci10 --device=/dev/davinci11 \--device=/dev/davinci12 --device=/dev/davinci13 --device=/dev/davinci14 --device=/dev/davinci15 \--device=/dev/davinci_manager \--device=/dev/devmm_svm \--device=/dev/hisi_hdc \--volume /usr/local/sbin:/usr/local/sbin \--volume /usr/local/Ascend/driver:/usr/local/Ascend/driver \--volume /usr/local/Ascend/firmware:/usr/local/Ascend/firmware \--volume /etc/ascend_install.info:/etc/ascend_install.info \--volume /var/queue_schedule:/var/queue_schedule \--volume ~/.cache/:/root/.cache/ \--volume "$MODEL_PATH:/root/Spark-X2.5-4B:ro" \--entrypoint=python \"$SGLANG_IMAGE" \-m sglang.launch_server \--model-path /root/Spark-X2.5-4B \--served-model-name spark2.5 \--tool-call-parser spark25 \--reasoning-parser qwen3 \--tp-size 1 \--mem-fraction-static 0.8 \--context-length 1048576 \--chat-template /root/Spark-X2.5-4B/chat_template.jinja \--host 0.0.0.0 \--port 30000```#### ClientThinking is enabled by default by both the chat template and the Qwen3 reasoning parser. To disable thinking for a specific request, set `"chat_template_kwargs": {"enable_thinking": false}`.```bashcurl -s http://localhost:30000/v1/chat/completions \-H "Content-Type: application/json" \-d '{"model": "spark2.5","messages": [{"role": "user","content": "What is the capital of Anhui Province?"}],"max_tokens": 131072,"temperature": 1,"top_k": -1,"top_p": 0.95,"repetition_penalty": 1,"presence_penalty": 0,"frequency_penalty": 0}'```### vLLM#### Deploy vLLMvLLM provides an official Docker image for NVIDIA GPU deployment:```bashdocker run --rm --gpus all \--ipc=host \-p 30000:30000 \-v "$MODEL_PATH:/models/Spark-X2.5-4B:ro" \vllm/vllm-openai:latest \--model /models/Spark-X2.5-4B \--port 30000 \--trust-remote-code \--served-model-name spark25 \--tensor-parallel-size 1 \--gpu-memory-utilization 0.7 \--enable-prefix-caching \--chat-template /models/Spark-X2.5-4B/chat_template.jinja```For Ascend NPUs, choose an official image for the fastest setup.##### Ascend A2:```bashexport IMAGE=quay.io/ascend/vllm-ascend:nightly-maindocker pull "$IMAGE"export DEVICE=/dev/davinci0export MODEL_CACHE="${HOME}/.cache"mkdir -p "$MODEL_CACHE"docker run --rm \--name vllm-ascend \--shm-size=1g \--device "$DEVICE" \--device /dev/davinci_manager \--device /dev/devmm_svm \--device /dev/hisi_hdc \-v /usr/local/dcmi:/usr/local/dcmi \-v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \-v /usr/local/Ascend/driver/lib64/:/usr/local/Ascend/driver/lib64/ \-v /usr/local/Ascend/driver/version.info:/usr/local/Ascend/driver/version.info \-v /etc/ascend_install.info:/etc/ascend_install.info \-v "$MODEL_CACHE:/root/.cache" \-p 8000:8000 \-it "$IMAGE" bash```##### Ascend A3:```bashexport IMAGE=quay.io/ascend/vllm-ascend:nightly-main-a3docker pull "$IMAGE"export DEVICE0=/dev/davinci0export DEVICE1=/dev/davinci1export MODEL_CACHE="${HOME}/.cache"mkdir -p "$MODEL_CACHE"docker run --rm \--name vllm-ascend \--shm-size=1g \--device "$DEVICE0" \--device "$DEVICE1" \--device /dev/davinci_manager \--device /dev/devmm_svm \--device /dev/hisi_hdc \-v /usr/local/dcmi:/usr/local/dcmi \-v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \-v /usr/local/Ascend/driver/lib64/:/usr/local/Ascend/driver/lib64/ \-v /usr/local/Ascend/driver/version.info:/usr/local/Ascend/driver/version.info \-v /etc/ascend_install.info:/etc/ascend_install.info \-v "$MODEL_CACHE:/root/.cache" \-p 8000:8000 \-it "$IMAGE" bash```##### Ascend 950DT:```bashexport IMAGE=quay.io/ascend/vllm-ascend:nightly-main-a5docker pull "$IMAGE"export MODEL_CACHE="${HOME}/.cache"mkdir -p "$MODEL_CACHE"docker run --rm \--name vllm-ascend \--net=host \--shm-size=1g \--device /dev/davinci0 \--device /dev/davinci_manager \--device /dev/devmm_svm \--device /dev/hisi_hdc \-v /usr/local/dcmi:/usr/local/dcmi \-v /usr/local/Ascend/driver/tools/hccn_tool:/usr/local/Ascend/driver/tools/hccn_tool \-v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \-v /usr/local/Ascend/driver/lib64/:/usr/local/Ascend/driver/lib64/ \-v /usr/local/Ascend/driver/version.info:/usr/local/Ascend/driver/version.info \-v /etc/ascend_install.info:/etc/ascend_install.info \-v "$MODEL_CACHE:/root/.cache" \-it "$IMAGE" bash```Install the Spark plugin inside the container:```bashpip install uvuv venv ~/spark2_5source ~/spark2_5/bin/activategit clone https://github.com/XHToken/Spark-plugin.gitcd ./Spark-pluginuv pip install .```#### Server```bashvllm serve "/models/Spark-X2.5-4B" \--port "30000" \--trust-remote-code \--served-model-name spark25 \--tensor-parallel-size 1 \--gpu-memory-utilization 0.7 \--enable-prefix-caching \--chat-template /models/Spark-X2.5-4B/chat_template.jinja```#### Client```bashcurl -s http://127.0.0.1:30000/v1/chat/completions \-H "Content-Type: application/json" \-d '{"model": "spark25","messages": [{"role": "user", "content": "What is the capital of Anhui Province?"}],"temperature": 1.0,"top_k": -1,"top_p": 0.95}'```### MLXSpark-MLX-LLM runs the original Spark-X2.5 Hugging Face checkpoints locally. It supports Apple silicon GPU, Linux CPU, and NVIDIA CUDA on Linux. No GGUF conversion is required.#### Installation```bashgit clone https://github.com/XHToken/Spark-MLX-LLM.gitcd Spark-MLX-LLMpython3 -m venv .venvsource .venv/bin/activate# Apple siliconpython -m pip install -e .# Linux CPUpython -m pip install -e '.[cpu]'# Linux with CUDA 12python -m pip install -e '.[cuda12]'# Linux with CUDA 13python -m pip install -e '.[cuda13]'```#### Run Inference```bashspark-mlx-generate \--device gpu \--dtype bfloat16 \--model XHToken/Spark-X2.5-4B \--prompt "What is the capital of Anhui Province?" \--max-tokens 512 \--temp 0```### llama.cpp> [!NOTE]> Native `spark2_5` support requires [llama.cpp](https://github.com/ggml-org/llama.cpp/) `b10828` or later.Run the model in the CLI:```bashllama cli -m /path/to/Spark-X2.5-4B-GGUF```Launch the OpenAI-compatible API server:```bashllama serve -m /path/to/Spark-X2.5-4B-GGUF```### Ollama[Download Ollama](https://ollama.com/download)> [!NOTE]> Native `spark2_5` support requires Ollama [`v0.34.1`](https://github.com/ollama/ollama/releases) or later.```bashollama run SparkLLM/Spark-X2.5-4B```### LM Studio[Download LM Studio](https://lmstudio.ai/download)> [!NOTE]> Native `spark2_5` support requires runtime version `2.34.0` or later.### Unsloth[Download Unsloth Studio](https://unsloth.ai/)> [!NOTE]> The latest Unsloth Studio supports native Spark-X2.5 GGUF inference.### Fine-TuningWe recommend using [Llama-Factory](https://github.com/XHToken/LlamaFactory) to fine-tune the model.## LicenseThe Spark-X2.5 model series is licensed under the [Apache 2.0 License](https://huggingface.co/XHToken/Spark-X2.5-4B/blob/main/LICENSE).## CitationIf you find our work helpful, feel free to give us a cite.```bibtex@misc{sparkx2.5,title = {Spark-X2.5 4B&1.7B: Pushing the Limits of Agentic Capabilities in On-Device Models},author = {SparkLLM Team},year = {2026}}```
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117{%- if not messages %} {{- raise_exception('No messages provided.') }}{%- endif %}{%- set enable_thinking = enable_thinking | default(true) %}{%- set reasoning_instructions = '' %}{%- if enable_thinking is true %} {%- set resolved_reasoning_effort = reasoning_effort|default('high') %} {%- if resolved_reasoning_effort not in ('high', 'low') %} {{- raise_exception('Unexpected reasoning effort ' ~ reasoning_effort ~ '. Supported types are high (default) and low.') }} {%- endif %} {%- set reasoning_instructions = '\n`thinking_effort` guides on how much to think in your thinking channel (not including the response channel), supported values include `low` and `high`.\nNow the system is invoked with `thinking_effort={resolved_reasoning_effort}`.'.format(resolved_reasoning_effort=resolved_reasoning_effort) %}{%- endif %}
{#- Render a string or a list of text blocks. -#}{%- macro render_content(content, context_name) %} {%- if content is string %} {{- content }} {%- elif content is none or content is undefined %} {{- '' }} {%- elif content is iterable and content is not mapping %} {%- for block in content %} {%- if block.type == 'text' %} {{- block.text }} {%- else %} {{- raise_exception('Unsupported ' ~ context_name ~ ' content block type: ' ~ (block.type | string)) }} {%- endif %} {%- endfor %} {%- else %} {{- raise_exception(context_name ~ ' content must be a string or a list of text blocks') }} {%- endif %}{%- endmacro %}
{#- Default system prompt -#}{%- set default_system = "you are a helpful assistant." + reasoning_instructions %}
{#- The first message-level system is placed in the initial system block. -#}{%- set ns = namespace(initial_system='') %}{%- if messages[0].role == "system" %} {%- set ns.initial_system = render_content(messages[0].content, 'system') %}{%- endif %}
{#- System block -#}{{- '<|start▁of▁sentence|><|System|>' + '\n' + default_system }}{%- if tools %} {{- '\n\n' + '## Tools' + '\n' + 'You have access to the following functions:' + '\n' + '<tools>' }} {%- for tool in tools %} {{- '\n' + (tool.function | tojson(separators=(',', ':'))) }} {%- endfor %} {{- '\n' + '</tools>' }}{%- endif %}{%- if ns.initial_system %} {{- '\n\n' + ns.initial_system }}{%- endif %}{{- '<|end▁of▁sentence|>'}}
{#- Conversation turns -#}{%- for message in messages %} {%- if message.role == "system" %} {#- The first system message was consumed by the initial block. -#} {%- if not loop.first %} {{- '<|start▁of▁sentence|><|System|>\n' + render_content(message.content, 'system') + '<|end▁of▁sentence|>' }} {%- endif %} {%- elif message.role == "user" %} {{- '<|start▁of▁sentence|><|User|>' + render_content(message.content, 'user') + '<|end▁of▁sentence|>' }} {%- elif message.role == "assistant" %} {%- set assistant_content = render_content(message.content, 'assistant') %} {%- if message.reasoning_content is defined and message.reasoning_content %} {%- set reasoning_content = message.reasoning_content %} {%- else %} {%- set reasoning_content = '' %} {%- endif %} {{- '<|start▁of▁sentence|><|Bot|>'}} {%- if reasoning_content %} {{- '<think>' + reasoning_content + '</think>'}} {%- else %} {{- '</think>' }} {%- endif %} {%- if assistant_content %} {{- assistant_content }} {%- endif %} {%- if message.tool_calls is defined and message.tool_calls is not none %} {%- for tool_call in message.tool_calls %} {%- if tool_call.function.arguments is not mapping %} {{- raise_exception('tool_call.function.arguments must be a dictionary; normalize JSON strings before apply_chat_template') }} {%- endif %} {%- set args = tool_call.function.arguments %} {{- '<tool_call>' + tool_call.function.name }} {%- for k, v in args.items() %} {{- '<arg_key>' ~ k ~ '</arg_key><arg_value>' ~ (v if v is string else v | tojson(separators=(', ', ': '))) ~ '</arg_value>' }} {%- endfor %} {{- '</tool_call>' }} {%- endfor %} {%- endif %} {{- '<|end▁of▁sentence|>' }} {%- elif message.role == "tool" %} {%- if loop.previtem is undefined or loop.previtem.role != "tool" %} {{- '<|start▁of▁sentence|><|Tool|>' }} {%- endif %} {{- '<tool_response>' ~ message.content ~ '</tool_response>' }} {%- if loop.nextitem is undefined or loop.nextitem.role != "tool" %} {{- '<|end▁of▁sentence|>' }} {%- endif %} {%- else %} {{- raise_exception('Unsupported message role: ' ~ message.role) }} {%- endif %}{%- endfor %}
{#- Generation prompt -#}{%- if add_generation_prompt %} {{- '<|start▁of▁sentence|><|Bot|>' }} {%- if enable_thinking is defined and enable_thinking %} {{- '<think>' }} {%- endif %} {%- if enable_thinking is defined and not enable_thinking %} {{- '</think>' }} {%- endif %}{%- endif %}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283{ "architectures": [ "Spark2_5ForCausalLM" ], "attention_bias": false, "attention_dropout": 0.0, "auto_map": { "AutoConfig": "configuration_spark.Spark2_5Config", "AutoModel": "modeling_spark.Spark2_5Model", "AutoModelForCausalLM": "modeling_spark.Spark2_5ForCausalLM" }, "bos_token_id": 0, "dtype": "bfloat16", "eos_token_id": 1, "gate_attn_act_mode": "sigmoid", "head_dim": 256, "headwise_attn_output_gate": true, "hidden_act": "gelu", "hidden_size": 2560, "initializer_range": 0.01976, "intermediate_size": 10240, "layer_types": [ "sliding_attention", "sliding_attention", "sliding_attention", "full_attention", "sliding_attention", "sliding_attention", "sliding_attention", "full_attention", "sliding_attention", "sliding_attention", "sliding_attention", "full_attention", "sliding_attention", "sliding_attention", "sliding_attention", "full_attention", "sliding_attention", "sliding_attention", "sliding_attention", "full_attention", "sliding_attention", "sliding_attention", "sliding_attention", "full_attention", "sliding_attention", "sliding_attention", "sliding_attention", "full_attention", "sliding_attention", "sliding_attention", "sliding_attention", "full_attention", "sliding_attention", "sliding_attention", "sliding_attention", "full_attention" ], "max_position_embeddings": 1048576, "mlp_bias": false, "model_type": "spark2_5", "num_attention_heads": 16, "num_hidden_layers": 36, "num_key_value_heads": 4, "pad_token_id": 2, "rms_norm_eps": 1e-06, "rope_parameters": { "full_attention": { "partial_rotary_factor": 0.25, "rope_theta": 5000000 }, "sliding_attention": { "partial_rotary_factor": 1.0, "rope_theta": 10000 } }, "sliding_window": 512, "tie_word_embeddings": true, "transformers_version": "4.57.1", "use_cache": true, "vocab_size": 131072}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118# coding=utf-8# Copyright 2026 The XHToken team and the HuggingFace Inc. team. All rights reserved.## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.
from transformers import PretrainedConfig
class Spark2_5Config(PretrainedConfig): model_type = "spark2_5" keys_to_ignore_at_inference = ["past_key_values"]
base_model_tp_plan = { "layers.*.self_attn.q_k_v_proj": "colwise", "layers.*.self_attn.g_proj": "colwise", "layers.*.self_attn.out_proj": "rowwise", "layers.*.mlp.gate_proj": "colwise", "layers.*.mlp.up_proj": "colwise", "layers.*.mlp.down_proj": "rowwise", } base_model_pp_plan = { "embedding": (["input_ids"], ["inputs_embeds"]), "layers": (["hidden_states", "attention_mask"], ["hidden_states"]), "norm": (["hidden_states"], ["hidden_states"]), }
def __init__( self, vocab_size=32000, hidden_size=4096, intermediate_size=11008, num_hidden_layers=32, num_attention_heads=32, num_key_value_heads=None, hidden_act="gelu", max_position_embeddings=2048, initializer_range=0.02, rms_norm_eps=1e-6, use_cache=True, pad_token_id=None, bos_token_id=1, eos_token_id=2, tie_word_embeddings=False, rope_parameters=None, attention_bias=False, attention_dropout=0.0, mlp_bias=False, head_dim=None, headwise_attn_output_gate=False, gate_attn_act_mode="sigmoid", sliding_window=None, layer_types=None, **kwargs, ): self.vocab_size = vocab_size self.max_position_embeddings = max_position_embeddings self.hidden_size = hidden_size self.intermediate_size = intermediate_size self.num_hidden_layers = num_hidden_layers self.num_attention_heads = num_attention_heads
if num_key_value_heads is None: num_key_value_heads = num_attention_heads if num_attention_heads % num_key_value_heads != 0: raise ValueError( f"num_attention_heads ({num_attention_heads}) must be divisible by num_key_value_heads ({num_key_value_heads})" ) self.num_key_value_heads = num_key_value_heads
self.hidden_act = hidden_act self.initializer_range = initializer_range self.rms_norm_eps = rms_norm_eps self.use_cache = use_cache self.attention_bias = attention_bias self.attention_dropout = attention_dropout self.mlp_bias = mlp_bias self.head_dim = head_dim if head_dim is not None else self.hidden_size // self.num_attention_heads self.headwise_attn_output_gate = headwise_attn_output_gate self.gate_attn_act_mode = gate_attn_act_mode self.sliding_window = sliding_window self.rope_parameters = rope_parameters
if layer_types is None: layer_types = ["full_attention"] * num_hidden_layers if len(layer_types) != num_hidden_layers: raise ValueError( f"layer_types length ({len(layer_types)}) must match num_hidden_layers ({num_hidden_layers})" ) self.layer_types = layer_types
super().__init__( pad_token_id=pad_token_id, bos_token_id=bos_token_id, eos_token_id=eos_token_id, tie_word_embeddings=tie_word_embeddings, **kwargs, )
def get_rope_theta(self, layer_type): params = self.rope_parameters.get(layer_type, {}) return params.get("rope_theta", 10000)
def get_partial_rotary_factor(self, layer_type): params = self.rope_parameters.get(layer_type, {}) return params.get("partial_rotary_factor", 1.0)
__all__ = ["Spark2_5Config"]1234567891011121314{ "bos_token_id": 0, "eos_token_id": 1, "pad_token_id": 2, "max_tokens": 1048576, "temperature": 1.0, "top_p": 0.95, "top_k": -1, "repetition_penalty": 1.0, "presence_penalty":0, "frequency_penalty":0, "do_sample": true, "transformers_version": "4.57.1"}123version https://git-lfs.github.com/spec/v1oid sha256:2408e76bc81043f5d0a3c1e6837e3f2555e7e384d43172c1c17ef8e4234ee669size 1982449560123version https://git-lfs.github.com/spec/v1oid sha256:5600d4719ee6896e461fffaa76250e9fb42fcea90f6240f25379723a23919ee8size 1993132424123version https://git-lfs.github.com/spec/v1oid sha256:63b9d64720e88494af8d1ed4bd4b37f162fc0c1dbceaf9aad3964ccba20ef3c8size 1993225080123version https://git-lfs.github.com/spec/v1oid sha256:84f4c5ce7144d4a7d51ab6895550df3ea311e635bc8b08d1f588e15f0f33d29esize 1993132448123version https://git-lfs.github.com/spec/v1oid sha256:72bd1352e56fb498c44e9822cae7742a000729a80c85a973e3830ea1b7c32f6dsize 262252896123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298{ "metadata": { "total_parameters": 4112079360, "total_size": 8224158720 }, "weight_map": { "model.embedding.weight": "model-00001-of-00005.safetensors", "model.layers.0.input_layernorm.weight": "model-00001-of-00005.safetensors", "model.layers.0.mlp.down_proj.weight": "model-00001-of-00005.safetensors", "model.layers.0.mlp.gate_proj.weight": "model-00001-of-00005.safetensors", "model.layers.0.mlp.up_proj.weight": "model-00001-of-00005.safetensors", "model.layers.0.post_attention_layernorm.weight": "model-00001-of-00005.safetensors", "model.layers.0.self_attn.g_proj.weight": "model-00001-of-00005.safetensors", "model.layers.0.self_attn.out_proj.weight": "model-00001-of-00005.safetensors", "model.layers.0.self_attn.q_k_v_proj.weight": "model-00001-of-00005.safetensors", "model.layers.1.input_layernorm.weight": "model-00001-of-00005.safetensors", "model.layers.1.mlp.down_proj.weight": "model-00001-of-00005.safetensors", "model.layers.1.mlp.gate_proj.weight": "model-00001-of-00005.safetensors", "model.layers.1.mlp.up_proj.weight": "model-00001-of-00005.safetensors", "model.layers.1.post_attention_layernorm.weight": "model-00001-of-00005.safetensors", "model.layers.1.self_attn.g_proj.weight": "model-00001-of-00005.safetensors", "model.layers.1.self_attn.out_proj.weight": "model-00001-of-00005.safetensors", "model.layers.1.self_attn.q_k_v_proj.weight": "model-00001-of-00005.safetensors", "model.layers.10.input_layernorm.weight": "model-00002-of-00005.safetensors", "model.layers.10.mlp.down_proj.weight": "model-00002-of-00005.safetensors", "model.layers.10.mlp.gate_proj.weight": "model-00002-of-00005.safetensors", "model.layers.10.mlp.up_proj.weight": "model-00002-of-00005.safetensors", "model.layers.10.post_attention_layernorm.weight": "model-00002-of-00005.safetensors", "model.layers.10.self_attn.g_proj.weight": "model-00002-of-00005.safetensors", "model.layers.10.self_attn.out_proj.weight": "model-00002-of-00005.safetensors", "model.layers.10.self_attn.q_k_v_proj.weight": "model-00002-of-00005.safetensors", "model.layers.11.input_layernorm.weight": "model-00002-of-00005.safetensors", "model.layers.11.mlp.down_proj.weight": "model-00002-of-00005.safetensors", "model.layers.11.mlp.gate_proj.weight": "model-00002-of-00005.safetensors", "model.layers.11.mlp.up_proj.weight": "model-00002-of-00005.safetensors", "model.layers.11.post_attention_layernorm.weight": "model-00002-of-00005.safetensors", "model.layers.11.self_attn.g_proj.weight": "model-00002-of-00005.safetensors", "model.layers.11.self_attn.out_proj.weight": "model-00002-of-00005.safetensors", "model.layers.11.self_attn.q_k_v_proj.weight": "model-00002-of-00005.safetensors", "model.layers.12.input_layernorm.weight": "model-00002-of-00005.safetensors", "model.layers.12.mlp.down_proj.weight": "model-00002-of-00005.safetensors", "model.layers.12.mlp.gate_proj.weight": "model-00002-of-00005.safetensors", "model.layers.12.mlp.up_proj.weight": "model-00002-of-00005.safetensors", "model.layers.12.post_attention_layernorm.weight": "model-00002-of-00005.safetensors", "model.layers.12.self_attn.g_proj.weight": "model-00002-of-00005.safetensors", "model.layers.12.self_attn.out_proj.weight": "model-00002-of-00005.safetensors", "model.layers.12.self_attn.q_k_v_proj.weight": "model-00002-of-00005.safetensors", "model.layers.13.input_layernorm.weight": "model-00002-of-00005.safetensors", "model.layers.13.mlp.down_proj.weight": "model-00002-of-00005.safetensors", "model.layers.13.mlp.gate_proj.weight": "model-00002-of-00005.safetensors", "model.layers.13.mlp.up_proj.weight": "model-00002-of-00005.safetensors", "model.layers.13.post_attention_layernorm.weight": "model-00002-of-00005.safetensors", "model.layers.13.self_attn.g_proj.weight": "model-00002-of-00005.safetensors", "model.layers.13.self_attn.out_proj.weight": "model-00002-of-00005.safetensors", "model.layers.13.self_attn.q_k_v_proj.weight": "model-00002-of-00005.safetensors", "model.layers.14.input_layernorm.weight": "model-00002-of-00005.safetensors", "model.layers.14.mlp.down_proj.weight": "model-00002-of-00005.safetensors", "model.layers.14.mlp.gate_proj.weight": "model-00002-of-00005.safetensors", "model.layers.14.mlp.up_proj.weight": "model-00002-of-00005.safetensors", "model.layers.14.post_attention_layernorm.weight": "model-00002-of-00005.safetensors", "model.layers.14.self_attn.g_proj.weight": "model-00002-of-00005.safetensors", "model.layers.14.self_attn.out_proj.weight": "model-00002-of-00005.safetensors", "model.layers.14.self_attn.q_k_v_proj.weight": "model-00002-of-00005.safetensors", "model.layers.15.input_layernorm.weight": "model-00003-of-00005.safetensors", "model.layers.15.mlp.down_proj.weight": "model-00003-of-00005.safetensors", "model.layers.15.mlp.gate_proj.weight": "model-00002-of-00005.safetensors", "model.layers.15.mlp.up_proj.weight": "model-00002-of-00005.safetensors", "model.layers.15.post_attention_layernorm.weight": "model-00003-of-00005.safetensors", "model.layers.15.self_attn.g_proj.weight": "model-00002-of-00005.safetensors", "model.layers.15.self_attn.out_proj.weight": "model-00002-of-00005.safetensors", "model.layers.15.self_attn.q_k_v_proj.weight": "model-00002-of-00005.safetensors", "model.layers.16.input_layernorm.weight": "model-00003-of-00005.safetensors", "model.layers.16.mlp.down_proj.weight": "model-00003-of-00005.safetensors", "model.layers.16.mlp.gate_proj.weight": "model-00003-of-00005.safetensors", "model.layers.16.mlp.up_proj.weight": "model-00003-of-00005.safetensors", "model.layers.16.post_attention_layernorm.weight": "model-00003-of-00005.safetensors", "model.layers.16.self_attn.g_proj.weight": "model-00003-of-00005.safetensors", "model.layers.16.self_attn.out_proj.weight": "model-00003-of-00005.safetensors", "model.layers.16.self_attn.q_k_v_proj.weight": "model-00003-of-00005.safetensors", "model.layers.17.input_layernorm.weight": "model-00003-of-00005.safetensors", "model.layers.17.mlp.down_proj.weight": "model-00003-of-00005.safetensors", "model.layers.17.mlp.gate_proj.weight": "model-00003-of-00005.safetensors", "model.layers.17.mlp.up_proj.weight": "model-00003-of-00005.safetensors", "model.layers.17.post_attention_layernorm.weight": "model-00003-of-00005.safetensors", "model.layers.17.self_attn.g_proj.weight": "model-00003-of-00005.safetensors", "model.layers.17.self_attn.out_proj.weight": "model-00003-of-00005.safetensors", "model.layers.17.self_attn.q_k_v_proj.weight": "model-00003-of-00005.safetensors", "model.layers.18.input_layernorm.weight": "model-00003-of-00005.safetensors", "model.layers.18.mlp.down_proj.weight": "model-00003-of-00005.safetensors", "model.layers.18.mlp.gate_proj.weight": "model-00003-of-00005.safetensors", "model.layers.18.mlp.up_proj.weight": "model-00003-of-00005.safetensors", "model.layers.18.post_attention_layernorm.weight": "model-00003-of-00005.safetensors", "model.layers.18.self_attn.g_proj.weight": "model-00003-of-00005.safetensors", "model.layers.18.self_attn.out_proj.weight": "model-00003-of-00005.safetensors", "model.layers.18.self_attn.q_k_v_proj.weight": "model-00003-of-00005.safetensors", "model.layers.19.input_layernorm.weight": "model-00003-of-00005.safetensors", "model.layers.19.mlp.down_proj.weight": "model-00003-of-00005.safetensors", "model.layers.19.mlp.gate_proj.weight": "model-00003-of-00005.safetensors", "model.layers.19.mlp.up_proj.weight": "model-00003-of-00005.safetensors", "model.layers.19.post_attention_layernorm.weight": "model-00003-of-00005.safetensors", "model.layers.19.self_attn.g_proj.weight": "model-00003-of-00005.safetensors", "model.layers.19.self_attn.out_proj.weight": "model-00003-of-00005.safetensors", "model.layers.19.self_attn.q_k_v_proj.weight": "model-00003-of-00005.safetensors", "model.layers.2.input_layernorm.weight": "model-00001-of-00005.safetensors", "model.layers.2.mlp.down_proj.weight": "model-00001-of-00005.safetensors", "model.layers.2.mlp.gate_proj.weight": "model-00001-of-00005.safetensors", "model.layers.2.mlp.up_proj.weight": "model-00001-of-00005.safetensors", "model.layers.2.post_attention_layernorm.weight": "model-00001-of-00005.safetensors", "model.layers.2.self_attn.g_proj.weight": "model-00001-of-00005.safetensors", "model.layers.2.self_attn.out_proj.weight": "model-00001-of-00005.safetensors", "model.layers.2.self_attn.q_k_v_proj.weight": "model-00001-of-00005.safetensors", "model.layers.20.input_layernorm.weight": "model-00003-of-00005.safetensors", "model.layers.20.mlp.down_proj.weight": "model-00003-of-00005.safetensors", "model.layers.20.mlp.gate_proj.weight": "model-00003-of-00005.safetensors", "model.layers.20.mlp.up_proj.weight": "model-00003-of-00005.safetensors", "model.layers.20.post_attention_layernorm.weight": "model-00003-of-00005.safetensors", "model.layers.20.self_attn.g_proj.weight": "model-00003-of-00005.safetensors", "model.layers.20.self_attn.out_proj.weight": "model-00003-of-00005.safetensors", "model.layers.20.self_attn.q_k_v_proj.weight": "model-00003-of-00005.safetensors", "model.layers.21.input_layernorm.weight": "model-00003-of-00005.safetensors", "model.layers.21.mlp.down_proj.weight": "model-00003-of-00005.safetensors", "model.layers.21.mlp.gate_proj.weight": "model-00003-of-00005.safetensors", "model.layers.21.mlp.up_proj.weight": "model-00003-of-00005.safetensors", "model.layers.21.post_attention_layernorm.weight": "model-00003-of-00005.safetensors", "model.layers.21.self_attn.g_proj.weight": "model-00003-of-00005.safetensors", "model.layers.21.self_attn.out_proj.weight": "model-00003-of-00005.safetensors", "model.layers.21.self_attn.q_k_v_proj.weight": "model-00003-of-00005.safetensors", "model.layers.22.input_layernorm.weight": "model-00003-of-00005.safetensors", "model.layers.22.mlp.down_proj.weight": "model-00003-of-00005.safetensors", "model.layers.22.mlp.gate_proj.weight": "model-00003-of-00005.safetensors", "model.layers.22.mlp.up_proj.weight": "model-00003-of-00005.safetensors", "model.layers.22.post_attention_layernorm.weight": "model-00003-of-00005.safetensors", "model.layers.22.self_attn.g_proj.weight": "model-00003-of-00005.safetensors", "model.layers.22.self_attn.out_proj.weight": "model-00003-of-00005.safetensors", "model.layers.22.self_attn.q_k_v_proj.weight": "model-00003-of-00005.safetensors", "model.layers.23.input_layernorm.weight": "model-00003-of-00005.safetensors", "model.layers.23.mlp.down_proj.weight": "model-00003-of-00005.safetensors", "model.layers.23.mlp.gate_proj.weight": "model-00003-of-00005.safetensors", "model.layers.23.mlp.up_proj.weight": "model-00003-of-00005.safetensors", "model.layers.23.post_attention_layernorm.weight": "model-00003-of-00005.safetensors", "model.layers.23.self_attn.g_proj.weight": "model-00003-of-00005.safetensors", "model.layers.23.self_attn.out_proj.weight": "model-00003-of-00005.safetensors", "model.layers.23.self_attn.q_k_v_proj.weight": "model-00003-of-00005.safetensors", "model.layers.24.input_layernorm.weight": "model-00003-of-00005.safetensors", "model.layers.24.mlp.down_proj.weight": "model-00003-of-00005.safetensors", "model.layers.24.mlp.gate_proj.weight": "model-00003-of-00005.safetensors", "model.layers.24.mlp.up_proj.weight": "model-00003-of-00005.safetensors", "model.layers.24.post_attention_layernorm.weight": "model-00003-of-00005.safetensors", "model.layers.24.self_attn.g_proj.weight": "model-00003-of-00005.safetensors", "model.layers.24.self_attn.out_proj.weight": "model-00003-of-00005.safetensors", "model.layers.24.self_attn.q_k_v_proj.weight": "model-00003-of-00005.safetensors", "model.layers.25.input_layernorm.weight": "model-00004-of-00005.safetensors", "model.layers.25.mlp.down_proj.weight": "model-00004-of-00005.safetensors", "model.layers.25.mlp.gate_proj.weight": "model-00004-of-00005.safetensors", "model.layers.25.mlp.up_proj.weight": "model-00004-of-00005.safetensors", "model.layers.25.post_attention_layernorm.weight": "model-00004-of-00005.safetensors", "model.layers.25.self_attn.g_proj.weight": "model-00003-of-00005.safetensors", "model.layers.25.self_attn.out_proj.weight": "model-00003-of-00005.safetensors", "model.layers.25.self_attn.q_k_v_proj.weight": "model-00003-of-00005.safetensors", "model.layers.26.input_layernorm.weight": "model-00004-of-00005.safetensors", "model.layers.26.mlp.down_proj.weight": "model-00004-of-00005.safetensors", "model.layers.26.mlp.gate_proj.weight": "model-00004-of-00005.safetensors", "model.layers.26.mlp.up_proj.weight": "model-00004-of-00005.safetensors", "model.layers.26.post_attention_layernorm.weight": "model-00004-of-00005.safetensors", "model.layers.26.self_attn.g_proj.weight": "model-00004-of-00005.safetensors", "model.layers.26.self_attn.out_proj.weight": "model-00004-of-00005.safetensors", "model.layers.26.self_attn.q_k_v_proj.weight": "model-00004-of-00005.safetensors", "model.layers.27.input_layernorm.weight": "model-00004-of-00005.safetensors", "model.layers.27.mlp.down_proj.weight": "model-00004-of-00005.safetensors", "model.layers.27.mlp.gate_proj.weight": "model-00004-of-00005.safetensors", "model.layers.27.mlp.up_proj.weight": "model-00004-of-00005.safetensors", "model.layers.27.post_attention_layernorm.weight": "model-00004-of-00005.safetensors", "model.layers.27.self_attn.g_proj.weight": "model-00004-of-00005.safetensors", "model.layers.27.self_attn.out_proj.weight": "model-00004-of-00005.safetensors", "model.layers.27.self_attn.q_k_v_proj.weight": "model-00004-of-00005.safetensors", "model.layers.28.input_layernorm.weight": "model-00004-of-00005.safetensors", "model.layers.28.mlp.down_proj.weight": "model-00004-of-00005.safetensors", "model.layers.28.mlp.gate_proj.weight": "model-00004-of-00005.safetensors", "model.layers.28.mlp.up_proj.weight": "model-00004-of-00005.safetensors", "model.layers.28.post_attention_layernorm.weight": "model-00004-of-00005.safetensors", "model.layers.28.self_attn.g_proj.weight": "model-00004-of-00005.safetensors", "model.layers.28.self_attn.out_proj.weight": "model-00004-of-00005.safetensors", "model.layers.28.self_attn.q_k_v_proj.weight": "model-00004-of-00005.safetensors", "model.layers.29.input_layernorm.weight": "model-00004-of-00005.safetensors", "model.layers.29.mlp.down_proj.weight": "model-00004-of-00005.safetensors", "model.layers.29.mlp.gate_proj.weight": "model-00004-of-00005.safetensors", "model.layers.29.mlp.up_proj.weight": "model-00004-of-00005.safetensors", "model.layers.29.post_attention_layernorm.weight": "model-00004-of-00005.safetensors", "model.layers.29.self_attn.g_proj.weight": "model-00004-of-00005.safetensors", "model.layers.29.self_attn.out_proj.weight": "model-00004-of-00005.safetensors", "model.layers.29.self_attn.q_k_v_proj.weight": "model-00004-of-00005.safetensors", "model.layers.3.input_layernorm.weight": "model-00001-of-00005.safetensors", "model.layers.3.mlp.down_proj.weight": "model-00001-of-00005.safetensors", "model.layers.3.mlp.gate_proj.weight": "model-00001-of-00005.safetensors", "model.layers.3.mlp.up_proj.weight": "model-00001-of-00005.safetensors", "model.layers.3.post_attention_layernorm.weight": "model-00001-of-00005.safetensors", "model.layers.3.self_attn.g_proj.weight": "model-00001-of-00005.safetensors", "model.layers.3.self_attn.out_proj.weight": "model-00001-of-00005.safetensors", "model.layers.3.self_attn.q_k_v_proj.weight": "model-00001-of-00005.safetensors", "model.layers.30.input_layernorm.weight": "model-00004-of-00005.safetensors", "model.layers.30.mlp.down_proj.weight": "model-00004-of-00005.safetensors", "model.layers.30.mlp.gate_proj.weight": "model-00004-of-00005.safetensors", "model.layers.30.mlp.up_proj.weight": "model-00004-of-00005.safetensors", "model.layers.30.post_attention_layernorm.weight": "model-00004-of-00005.safetensors", "model.layers.30.self_attn.g_proj.weight": "model-00004-of-00005.safetensors", "model.layers.30.self_attn.out_proj.weight": "model-00004-of-00005.safetensors", "model.layers.30.self_attn.q_k_v_proj.weight": "model-00004-of-00005.safetensors", "model.layers.31.input_layernorm.weight": "model-00004-of-00005.safetensors", "model.layers.31.mlp.down_proj.weight": "model-00004-of-00005.safetensors", "model.layers.31.mlp.gate_proj.weight": "model-00004-of-00005.safetensors", "model.layers.31.mlp.up_proj.weight": "model-00004-of-00005.safetensors", "model.layers.31.post_attention_layernorm.weight": "model-00004-of-00005.safetensors", "model.layers.31.self_attn.g_proj.weight": "model-00004-of-00005.safetensors", "model.layers.31.self_attn.out_proj.weight": "model-00004-of-00005.safetensors", "model.layers.31.self_attn.q_k_v_proj.weight": "model-00004-of-00005.safetensors", "model.layers.32.input_layernorm.weight": "model-00004-of-00005.safetensors", "model.layers.32.mlp.down_proj.weight": "model-00004-of-00005.safetensors", "model.layers.32.mlp.gate_proj.weight": "model-00004-of-00005.safetensors", "model.layers.32.mlp.up_proj.weight": "model-00004-of-00005.safetensors", "model.layers.32.post_attention_layernorm.weight": "model-00004-of-00005.safetensors", "model.layers.32.self_attn.g_proj.weight": "model-00004-of-00005.safetensors", "model.layers.32.self_attn.out_proj.weight": "model-00004-of-00005.safetensors", "model.layers.32.self_attn.q_k_v_proj.weight": "model-00004-of-00005.safetensors", "model.layers.33.input_layernorm.weight": "model-00004-of-00005.safetensors", "model.layers.33.mlp.down_proj.weight": "model-00004-of-00005.safetensors", "model.layers.33.mlp.gate_proj.weight": "model-00004-of-00005.safetensors", "model.layers.33.mlp.up_proj.weight": "model-00004-of-00005.safetensors", "model.layers.33.post_attention_layernorm.weight": "model-00004-of-00005.safetensors", "model.layers.33.self_attn.g_proj.weight": "model-00004-of-00005.safetensors", "model.layers.33.self_attn.out_proj.weight": "model-00004-of-00005.safetensors", "model.layers.33.self_attn.q_k_v_proj.weight": "model-00004-of-00005.safetensors", "model.layers.34.input_layernorm.weight": "model-00005-of-00005.safetensors", "model.layers.34.mlp.down_proj.weight": "model-00005-of-00005.safetensors", "model.layers.34.mlp.gate_proj.weight": "model-00004-of-00005.safetensors", "model.layers.34.mlp.up_proj.weight": "model-00004-of-00005.safetensors", "model.layers.34.post_attention_layernorm.weight": "model-00005-of-00005.safetensors", "model.layers.34.self_attn.g_proj.weight": "model-00004-of-00005.safetensors", "model.layers.34.self_attn.out_proj.weight": "model-00004-of-00005.safetensors", "model.layers.34.self_attn.q_k_v_proj.weight": "model-00004-of-00005.safetensors", "model.layers.35.input_layernorm.weight": "model-00005-of-00005.safetensors", "model.layers.35.mlp.down_proj.weight": "model-00005-of-00005.safetensors", "model.layers.35.mlp.gate_proj.weight": "model-00005-of-00005.safetensors", "model.layers.35.mlp.up_proj.weight": "model-00005-of-00005.safetensors", "model.layers.35.post_attention_layernorm.weight": "model-00005-of-00005.safetensors", "model.layers.35.self_attn.g_proj.weight": "model-00005-of-00005.safetensors", "model.layers.35.self_attn.out_proj.weight": "model-00005-of-00005.safetensors", "model.layers.35.self_attn.q_k_v_proj.weight": "model-00005-of-00005.safetensors", "model.layers.4.input_layernorm.weight": "model-00001-of-00005.safetensors", "model.layers.4.mlp.down_proj.weight": "model-00001-of-00005.safetensors", "model.layers.4.mlp.gate_proj.weight": "model-00001-of-00005.safetensors", "model.layers.4.mlp.up_proj.weight": "model-00001-of-00005.safetensors", "model.layers.4.post_attention_layernorm.weight": "model-00001-of-00005.safetensors", "model.layers.4.self_attn.g_proj.weight": "model-00001-of-00005.safetensors", "model.layers.4.self_attn.out_proj.weight": "model-00001-of-00005.safetensors", "model.layers.4.self_attn.q_k_v_proj.weight": "model-00001-of-00005.safetensors", "model.layers.5.input_layernorm.weight": "model-00001-of-00005.safetensors", "model.layers.5.mlp.down_proj.weight": "model-00001-of-00005.safetensors", "model.layers.5.mlp.gate_proj.weight": "model-00001-of-00005.safetensors", "model.layers.5.mlp.up_proj.weight": "model-00001-of-00005.safetensors", "model.layers.5.post_attention_layernorm.weight": "model-00001-of-00005.safetensors", "model.layers.5.self_attn.g_proj.weight": "model-00001-of-00005.safetensors", "model.layers.5.self_attn.out_proj.weight": "model-00001-of-00005.safetensors", "model.layers.5.self_attn.q_k_v_proj.weight": "model-00001-of-00005.safetensors", "model.layers.6.input_layernorm.weight": "model-00002-of-00005.safetensors", "model.layers.6.mlp.down_proj.weight": "model-00002-of-00005.safetensors", "model.layers.6.mlp.gate_proj.weight": "model-00002-of-00005.safetensors", "model.layers.6.mlp.up_proj.weight": "model-00002-of-00005.safetensors", "model.layers.6.post_attention_layernorm.weight": "model-00002-of-00005.safetensors", "model.layers.6.self_attn.g_proj.weight": "model-00001-of-00005.safetensors", "model.layers.6.self_attn.out_proj.weight": "model-00001-of-00005.safetensors", "model.layers.6.self_attn.q_k_v_proj.weight": "model-00001-of-00005.safetensors", "model.layers.7.input_layernorm.weight": "model-00002-of-00005.safetensors", "model.layers.7.mlp.down_proj.weight": "model-00002-of-00005.safetensors", "model.layers.7.mlp.gate_proj.weight": "model-00002-of-00005.safetensors", "model.layers.7.mlp.up_proj.weight": "model-00002-of-00005.safetensors", "model.layers.7.post_attention_layernorm.weight": "model-00002-of-00005.safetensors", "model.layers.7.self_attn.g_proj.weight": "model-00002-of-00005.safetensors", "model.layers.7.self_attn.out_proj.weight": "model-00002-of-00005.safetensors", "model.layers.7.self_attn.q_k_v_proj.weight": "model-00002-of-00005.safetensors", "model.layers.8.input_layernorm.weight": "model-00002-of-00005.safetensors", "model.layers.8.mlp.down_proj.weight": "model-00002-of-00005.safetensors", "model.layers.8.mlp.gate_proj.weight": "model-00002-of-00005.safetensors", "model.layers.8.mlp.up_proj.weight": "model-00002-of-00005.safetensors", "model.layers.8.post_attention_layernorm.weight": "model-00002-of-00005.safetensors", "model.layers.8.self_attn.g_proj.weight": "model-00002-of-00005.safetensors", "model.layers.8.self_attn.out_proj.weight": "model-00002-of-00005.safetensors", "model.layers.8.self_attn.q_k_v_proj.weight": "model-00002-of-00005.safetensors", "model.layers.9.input_layernorm.weight": "model-00002-of-00005.safetensors", "model.layers.9.mlp.down_proj.weight": "model-00002-of-00005.safetensors", "model.layers.9.mlp.gate_proj.weight": "model-00002-of-00005.safetensors", "model.layers.9.mlp.up_proj.weight": "model-00002-of-00005.safetensors", "model.layers.9.post_attention_layernorm.weight": "model-00002-of-00005.safetensors", "model.layers.9.self_attn.g_proj.weight": "model-00002-of-00005.safetensors", "model.layers.9.self_attn.out_proj.weight": "model-00002-of-00005.safetensors", "model.layers.9.self_attn.q_k_v_proj.weight": "model-00002-of-00005.safetensors", "model.norm.weight": "model-00005-of-00005.safetensors" }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483import math
import torchimport torch.nn.functional as Ffrom torch import nnfrom transformers.activations import ACT2FNfrom transformers.cache_utils import Cache, DynamicCachefrom transformers.generation import GenerationMixinfrom transformers.masking_utils import create_causal_mask, create_sliding_window_causal_maskfrom transformers.modeling_outputs import ( BaseModelOutputWithPast, CausalLMOutputWithPast,)from transformers.modeling_utils import PreTrainedModelfrom transformers.processing_utils import Unpackfrom transformers.pytorch_utils import ALL_LAYERNORM_LAYERSfrom transformers.utils import TransformersKwargs, can_return_tuple, logging
from .configuration_spark import Spark2_5Config
logger = logging.get_logger(__name__)
_CONFIG_FOR_DOC = "Spark2_5Config"
def rotate_half(x): x1 = x[..., : x.shape[-1] // 2] x2 = x[..., x.shape[-1] // 2 :] return torch.cat((-x2, x1), dim=-1)
def compute_rope_cos_sin(positions, head_dim, rope_theta, partial_rotary_factor=1.0, device="cpu"): rope_head_dim = int(head_dim * partial_rotary_factor) inv_freq = 1.0 / (rope_theta ** (torch.arange(0, rope_head_dim, 2, dtype=torch.int64).to(device="cpu", dtype=torch.float) / rope_head_dim)) inv_freq = inv_freq.to(device) t = positions.to(device=device, dtype=torch.float32) freqs = torch.outer(t, inv_freq) freqs = torch.cat([freqs, freqs], dim=-1) cos = freqs.cos() sin = freqs.sin() return cos, sin
def apply_rotary_pos_emb(x, cos, sin): rope_head_dim = cos.shape[-1] x_f32 = x.float() if x_f32.shape[-1] > rope_head_dim: x_rot = x_f32[..., :rope_head_dim] x_pass = x_f32[..., rope_head_dim:] c = cos.unsqueeze(0).unsqueeze(0) s = sin.unsqueeze(0).unsqueeze(0) x_rot = x_rot * c + rotate_half(x_rot) * s result = torch.cat([x_rot, x_pass], dim=-1) else: c = cos.unsqueeze(0).unsqueeze(0) s = sin.unsqueeze(0).unsqueeze(0) result = x_f32 * c + rotate_half(x_f32) * s return result.to(x.dtype)
def repeat_kv(hidden_states: torch.Tensor, n_rep: int) -> torch.Tensor: batch, num_key_value_heads, slen, head_dim = hidden_states.shape if n_rep == 1: return hidden_states hidden_states = hidden_states[:, :, None, :, :].expand(batch, num_key_value_heads, n_rep, slen, head_dim) return hidden_states.reshape(batch, num_key_value_heads * n_rep, slen, head_dim)
def eager_attention_forward( module: nn.Module, query: torch.Tensor, key: torch.Tensor, value: torch.Tensor, attention_mask: torch.Tensor | None = None, scaling: float | None = None, dropout: float = 0.0, **kwargs: Unpack[TransformersKwargs],): key = repeat_kv(key, module.num_key_value_groups) value = repeat_kv(value, module.num_key_value_groups)
if scaling is None: scaling = 1.0 / math.sqrt(query.shape[-1])
attn_weights = torch.matmul(query, key.transpose(2, 3)) * scaling if attention_mask is not None: causal_mask = attention_mask[:, :, :, : key.shape[-2]] attn_weights = attn_weights + causal_mask
attn_weights = attn_weights - attn_weights.max(dim=-1, keepdim=True).values attn_weights = F.softmax(attn_weights, dim=-1, dtype=torch.float32).to(query.dtype) attn_weights = nn.functional.dropout(attn_weights, p=dropout, training=module.training) attn_output = torch.matmul(attn_weights, value) return attn_output, attn_weights
class Spark2_5RMSNorm(nn.Module): def __init__(self, hidden_size, eps=1e-6): super().__init__() self.weight = nn.Parameter(torch.ones(hidden_size)) self.variance_epsilon = eps
def forward(self, hidden_states): input_dtype = hidden_states.dtype hidden_states = hidden_states.to(torch.float32) variance = hidden_states.pow(2).mean(-1, keepdim=True) hidden_states = hidden_states * torch.rsqrt(variance + self.variance_epsilon) return (self.weight.float() * hidden_states).to(input_dtype)
def extra_repr(self): return f"{tuple(self.weight.shape)}, eps={self.variance_epsilon}"
ALL_LAYERNORM_LAYERS.append(Spark2_5RMSNorm)
class Spark2_5MLP(nn.Module): def __init__(self, config): super().__init__() self.config = config self.hidden_size = config.hidden_size self.intermediate_size = config.intermediate_size self.gate_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=config.mlp_bias) self.up_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=config.mlp_bias) self.down_proj = nn.Linear(self.intermediate_size, self.hidden_size, bias=config.mlp_bias)
if config.hidden_act != "gelu": raise ValueError(f"只支持hidden_act='gelu',当前传入:{config.hidden_act}") self.act_fn = ACT2FN[config.hidden_act]
def forward(self, x): return self.down_proj(self.act_fn(self.gate_proj(x)) * self.up_proj(x))
class Spark2_5Attention(nn.Module): def __init__(self, config: Spark2_5Config, layer_idx: int | None = None): super().__init__() self.config = config self.layer_idx = layer_idx self.attention_dropout = config.attention_dropout self.hidden_size = config.hidden_size self.num_heads = config.num_attention_heads self.head_dim = config.head_dim self.num_key_value_heads = config.num_key_value_heads self.num_key_value_groups = self.num_heads // self.num_key_value_heads self.scaling = 1.0 / math.sqrt(self.head_dim) self.headwise_attn_output_gate = config.headwise_attn_output_gate self.gate_attn_act_mode = config.gate_attn_act_mode self.q_dim = self.num_heads * self.head_dim self.kv_dim = self.num_key_value_heads * self.head_dim
qkv_out_dim = self.q_dim + 2 * self.kv_dim self.q_k_v_proj = nn.Linear(self.hidden_size, qkv_out_dim, bias=config.attention_bias) self.g_proj = nn.Linear(self.hidden_size, self.num_heads, bias=config.attention_bias) if self.headwise_attn_output_gate else None self.out_proj = nn.Linear(self.num_heads * self.head_dim, self.hidden_size, bias=config.attention_bias) self.sliding_window = None
def forward( self, hidden_states: torch.Tensor, position_embeddings: tuple[torch.Tensor, torch.Tensor], attention_mask: torch.Tensor | None = None, past_key_values: Cache | None = None, cache_position: torch.LongTensor | None = None, **kwargs: Unpack[TransformersKwargs], ) -> tuple[torch.Tensor, torch.Tensor]: input_shape = hidden_states.shape[:-1] bsz, seq_len = input_shape
qkv = self.q_k_v_proj(hidden_states) q = qkv[..., :self.q_dim] k = qkv[..., self.q_dim:self.q_dim + self.kv_dim] v = qkv[..., self.q_dim + self.kv_dim:] gate_score = self.g_proj(hidden_states) if self.g_proj is not None else None
q = q.view(bsz, seq_len, self.num_heads, self.head_dim).transpose(1, 2) k = k.view(bsz, seq_len, self.num_key_value_heads, self.head_dim).transpose(1, 2) v = v.view(bsz, seq_len, self.num_key_value_heads, self.head_dim).transpose(1, 2) if gate_score is not None: gate_score = gate_score.view(bsz, seq_len, self.num_heads, 1).transpose(1, 2)
cos, sin = position_embeddings q = apply_rotary_pos_emb(q, cos, sin) k = apply_rotary_pos_emb(k, cos, sin)
if past_key_values is not None: cache_kwargs = {"sin": sin, "cos": cos, "cache_position": cache_position} k, v = past_key_values.update(k, v, self.layer_idx, cache_kwargs)
attn_output, attn_weights = eager_attention_forward( self, q, k, v, attention_mask=attention_mask, scaling=self.scaling, dropout=self.attention_dropout if self.training else 0.0, )
if gate_score is not None: if self.gate_attn_act_mode == "sigmoid": gate = torch.sigmoid(gate_score.float()) elif self.gate_attn_act_mode == "silu": gate = F.silu(gate_score.float()) else: raise ValueError(f"Unsupported gate_attn_act_mode: {self.gate_attn_act_mode}") gate = gate.to(attn_output.dtype) attn_output = attn_output * gate
attn_output = attn_output.transpose(1, 2).contiguous().view(bsz, seq_len, -1) attn_output = self.out_proj(attn_output)
return attn_output, attn_weights
class Spark2_5DecoderLayer(nn.Module): def __init__(self, config: Spark2_5Config, layer_idx: int): super().__init__() self.hidden_size = config.hidden_size
self.self_attn = Spark2_5Attention(config=config, layer_idx=layer_idx) self.mlp = Spark2_5MLP(config) self.input_layernorm = Spark2_5RMSNorm(config.hidden_size, eps=config.rms_norm_eps) self.post_attention_layernorm = Spark2_5RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
self.layer_type = config.layer_types[layer_idx] if layer_idx < len(config.layer_types) else "full_attention" if self.layer_type == "sliding_attention" and config.sliding_window is not None: self.self_attn.sliding_window = config.sliding_window else: self.self_attn.sliding_window = None self.self_attn.partial_rotary_factor = config.get_partial_rotary_factor(self.layer_type) def forward( self, hidden_states: torch.Tensor, position_embeddings: tuple[torch.Tensor, torch.Tensor], attention_mask: torch.Tensor | None = None, past_key_values: Cache | None = None, cache_position: torch.LongTensor | None = None, position_ids: torch.LongTensor | None = None, **kwargs: Unpack[TransformersKwargs] ) -> torch.Tensor:
residual = hidden_states hidden_states = self.input_layernorm(hidden_states) hidden_states = hidden_states.to(self.mlp.gate_proj.weight.dtype)
hidden_states, _ = self.self_attn( hidden_states=hidden_states, position_embeddings=position_embeddings, attention_mask=attention_mask, past_key_values=past_key_values, cache_position=cache_position, position_ids=position_ids, ) hidden_states = residual + hidden_states
residual = hidden_states hidden_states = self.post_attention_layernorm(hidden_states) hidden_states = hidden_states.to(self.mlp.gate_proj.weight.dtype)
hidden_states = self.mlp(hidden_states) hidden_states = residual + hidden_states
return hidden_states
class Spark2_5PreTrainedModel(PreTrainedModel): config_class = Spark2_5Config base_model_prefix = "model" supports_gradient_checkpointing = True _no_split_modules = ["Spark2_5DecoderLayer"] # noqa: RUF012 _skip_keys_device_placement = ["past_key_values"] # noqa: RUF012
def _init_weights(self, module): std = self.config.initializer_range if isinstance(module, nn.Linear): module.weight.data.normal_(mean=0.0, std=std) if module.bias is not None: module.bias.data.zero_() elif isinstance(module, nn.Embedding): module.weight.data.normal_(mean=0.0, std=std) if module.padding_idx is not None: module.weight.data[module.padding_idx].zero_()
class Spark2_5Model(Spark2_5PreTrainedModel): def __init__(self, config: Spark2_5Config): super().__init__(config) self.padding_idx = config.pad_token_id self.vocab_size = config.vocab_size
self.embedding = nn.Embedding(config.vocab_size, config.hidden_size, self.padding_idx) self.layers = nn.ModuleList( [Spark2_5DecoderLayer(config, layer_idx) for layer_idx in range(config.num_hidden_layers)] ) self.norm = Spark2_5RMSNorm(config.hidden_size, eps=config.rms_norm_eps) self.gradient_checkpointing = False self.has_sliding_layers = "sliding_attention" in config.layer_types
self.post_init()
def get_input_embeddings(self): return self.embedding
def set_input_embeddings(self, value): self.embedding = value def forward( self, input_ids: torch.LongTensor = None, attention_mask: torch.Tensor | None = None, position_ids: torch.LongTensor | None = None, past_key_values: Cache | list[torch.FloatTensor] | None = None, inputs_embeds: torch.FloatTensor | None = None, use_cache: bool | None = None, cache_position: torch.LongTensor | None = None, token_type_ids: torch.LongTensor | None = None, **kwargs: Unpack[TransformersKwargs], ) -> BaseModelOutputWithPast: use_cache = use_cache if use_cache is not None else self.config.use_cache if (input_ids is None) ^ (inputs_embeds is not None): raise ValueError( "You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one" )
if self.gradient_checkpointing and self.training and use_cache: logger.warning_once( "`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`." ) use_cache = False
if inputs_embeds is None: inputs_embeds = self.embedding(input_ids)
if use_cache and past_key_values is None: past_key_values = DynamicCache(config=self.config)
if cache_position is None: past_seen_tokens = past_key_values.get_seq_length() if past_key_values is not None else 0 cache_position = torch.arange( past_seen_tokens, past_seen_tokens + inputs_embeds.shape[1], device=inputs_embeds.device )
if position_ids is None: position_ids = cache_position.unsqueeze(0)
if not isinstance(attention_mask, dict): mask_kwargs = { "config": self.config, "input_embeds": inputs_embeds, "attention_mask": attention_mask, "cache_position": cache_position, "past_key_values": past_key_values, "position_ids": position_ids, } causal_mask_mapping = { "full_attention": create_causal_mask(**mask_kwargs), } if self.has_sliding_layers: causal_mask_mapping["sliding_attention"] = create_sliding_window_causal_mask(**mask_kwargs) else: causal_mask_mapping = attention_mask
hidden_states = inputs_embeds.float()
device = hidden_states.device dtype = self.embedding.weight.dtype
head_dim = self.config.head_dim rope_cache = {} for lt in set(self.config.layer_types): rope_theta = self.config.get_rope_theta(lt) prf = self.config.get_partial_rotary_factor(lt) cos, sin = compute_rope_cos_sin(cache_position, head_dim, rope_theta, partial_rotary_factor=prf, device=device) rope_cache[lt] = (cos, sin)
for decoder_layer in self.layers: layer_type = decoder_layer.layer_type position_embeddings = rope_cache.get(layer_type, rope_cache.get("full_attention")) layer_attention_mask = causal_mask_mapping.get(layer_type, causal_mask_mapping.get("full_attention"))
if self.gradient_checkpointing and self.training: layer_outputs = self._gradient_checkpointing_func( decoder_layer.__call__, hidden_states, position_embeddings, layer_attention_mask, ) hidden_states = layer_outputs[0] if isinstance(layer_outputs, tuple) else layer_outputs else: hidden_states = decoder_layer( hidden_states, position_embeddings=position_embeddings, attention_mask=layer_attention_mask, past_key_values=past_key_values, cache_position=cache_position, position_ids=position_ids, )
hidden_states = self.norm(hidden_states) hidden_states = hidden_states.to(dtype)
return BaseModelOutputWithPast( last_hidden_state=hidden_states, past_key_values=past_key_values if use_cache else None, )
class Spark2_5ForCausalLM(Spark2_5PreTrainedModel, GenerationMixin): _tied_weights_keys = ["lm_head.weight"] # noqa: RUF012
def __init__(self, config): super().__init__(config) self.model = Spark2_5Model(config) self.vocab_size = config.vocab_size self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False) self.post_init()
def get_input_embeddings(self): return self.model.embedding
def set_input_embeddings(self, value): self.model.embedding = value
def get_output_embeddings(self): return self.lm_head
def set_output_embeddings(self, new_embeddings): self.lm_head = new_embeddings
def set_decoder(self, decoder): self.model = decoder
def get_decoder(self): return self.model
@can_return_tuple def forward( self, input_ids: torch.LongTensor = None, attention_mask: torch.Tensor | None = None, position_ids: torch.LongTensor | None = None, past_key_values: Cache | list[torch.FloatTensor] | None = None, inputs_embeds: torch.FloatTensor | None = None, labels: torch.LongTensor | None = None, use_cache: bool | None = None, cache_position: torch.LongTensor | None = None, logits_to_keep: int = 0, token_type_ids: torch.LongTensor | None = None, **kwargs: Unpack[TransformersKwargs], ) -> CausalLMOutputWithPast: outputs: BaseModelOutputWithPast = self.model( input_ids=input_ids, attention_mask=attention_mask, position_ids=position_ids, past_key_values=past_key_values, inputs_embeds=inputs_embeds, use_cache=use_cache, cache_position=cache_position, )
hidden_states = outputs.last_hidden_state slice_indices = slice(-logits_to_keep, None) if isinstance(logits_to_keep, int) else logits_to_keep hidden_states = hidden_states[:, slice_indices, :]
if self.config.tie_word_embeddings: embed_weight = self.model.embedding.weight logits = F.linear(hidden_states, embed_weight) else: logits = self.lm_head(hidden_states)
loss = None if labels is not None: loss = self.loss_function(logits=logits, labels=labels, vocab_size=self.config.vocab_size, **kwargs)
return CausalLMOutputWithPast( loss=loss, logits=logits, past_key_values=outputs.past_key_values, hidden_states=outputs.hidden_states, attentions=outputs.attentions, )
__all__ = ["Spark2_5Config", "Spark2_5ForCausalLM", "Spark2_5Model"]123456{ "bos_token": "<|start▁of▁sentence|>", "eos_token": "<|end▁of▁sentence|>", "unk_token": "<unk>", "pad_token": "<|▁pad▁|>"}123456789101112131415161718192021222324252627282930313233343536373839404142{ "add_bos_token": false, "add_eos_token": false, "bos_token": { "__type": "AddedToken", "content": "<|start▁of▁sentence|>", "lstrip": false, "normalized": true, "rstrip": false, "single_word": false }, "clean_up_tokenization_spaces": false, "eos_token": { "__type": "AddedToken", "content": "<|end▁of▁sentence|>", "lstrip": false, "normalized": true, "rstrip": false, "single_word": false }, "legacy": true, "model_max_length": 131072, "pad_token": { "__type": "AddedToken", "content": "<|▁pad▁|>", "lstrip": false, "normalized": true, "rstrip": false, "single_word": false }, "sp_model_kwargs": {}, "unk_token": { "__type": "AddedToken", "content": "<unk>", "lstrip": false, "normalized": true, "rstrip": false, "single_word": false }, "tokenizer_class": "PreTrainedTokenizerFast", "chat_template": "{%- if not messages %}{{- raise_exception('No messages provided.') }}{%- endif %}{%- set enable_thinking = enable_thinking | default(true) %}{%- set reasoning_instructions = '' %}{%- if enable_thinking is true %}{%- set resolved_reasoning_effort = reasoning_effort|default('high') %}{%- if resolved_reasoning_effort not in ('high', 'low') %}{{- raise_exception('Unexpected reasoning effort ' ~ reasoning_effort ~ '. Supported types are high (default) and low.') }}{%- endif %}{%- set reasoning_instructions = '\n`thinking_effort` guides on how much to think in your thinking channel (not including the response channel), supported values include `low` and `high`.\nNow the system is invoked with `thinking_effort={resolved_reasoning_effort}`.'.format(resolved_reasoning_effort=resolved_reasoning_effort) %}{%- endif %}{#- Render a string or a list of text blocks. -#}{%- macro render_content(content, context_name) %}{%- if content is string %}{{- content }}{%- elif content is none or content is undefined %}{{- '' }}{%- elif content is iterable and content is not mapping %}{%- for block in content %}{%- if block.type == 'text' %}{{- block.text }}{%- else %}{{- raise_exception('Unsupported ' ~ context_name ~ ' content block type: ' ~ (block.type | string)) }}{%- endif %}{%- endfor %}{%- else %}{{- raise_exception(context_name ~ ' content must be a string or a list of text blocks') }}{%- endif %}{%- endmacro %}{#- Default system prompt -#}{%- set default_system = \"you are a helpful assistant.\" + reasoning_instructions %}{#- The first message-level system is placed in the initial system block. -#}{%- set ns = namespace(initial_system='') %}{%- if messages[0].role == \"system\" %}{%- set ns.initial_system = render_content(messages[0].content, 'system') %}{%- endif %}{#- System block -#}{{- '<|start▁of▁sentence|><|System|>' + '\n' + default_system }}{%- if tools %}{{- '\n\n' + '## Tools' + '\n' + 'You have access to the following functions:' + '\n' + '<tools>' }}{%- for tool in tools %}{{- '\n' + (tool.function | tojson(separators=(',', ':'))) }}{%- endfor %}{{- '\n' + '</tools>' }}{%- endif %}{%- if ns.initial_system %}{{- '\n\n' + ns.initial_system }}{%- endif %}{{- '<|end▁of▁sentence|>'}}{#- Conversation turns -#}{%- for message in messages %}{%- if message.role == \"system\" %}{#- The first system message was consumed by the initial block. -#}{%- if not loop.first %}{{- '<|start▁of▁sentence|><|System|>\n' + render_content(message.content, 'system') + '<|end▁of▁sentence|>' }}{%- endif %}{%- elif message.role == \"user\" %}{{- '<|start▁of▁sentence|><|User|>' + render_content(message.content, 'user') + '<|end▁of▁sentence|>' }}{%- elif message.role == \"assistant\" %}{%- set assistant_content = render_content(message.content, 'assistant') %}{%- if message.reasoning_content is defined and message.reasoning_content %}{%- set reasoning_content = message.reasoning_content %}{%- else %}{%- set reasoning_content = '' %}{%- endif %}{{- '<|start▁of▁sentence|><|Bot|>'}}{%- if reasoning_content %}{{- '<think>' + reasoning_content + '</think>'}}{%- else %}{{- '</think>' }}{%- endif %}{%- if assistant_content %}{{- assistant_content }}{%- endif %}{%- if message.tool_calls is defined and message.tool_calls is not none %}{%- for tool_call in message.tool_calls %}{%- if tool_call.function.arguments is not mapping %}{{- raise_exception('tool_call.function.arguments must be a dictionary; normalize JSON strings before apply_chat_template') }}{%- endif %}{%- set args = tool_call.function.arguments %}{{- '<tool_call>' + tool_call.function.name }}{%- for k, v in args.items() %}{{- '<arg_key>' ~ k ~ '</arg_key><arg_value>' ~ (v if v is string else v | tojson(separators=(', ', ': '))) ~ '</arg_value>' }}{%- endfor %}{{- '</tool_call>' }}{%- endfor %}{%- endif %}{{- '<|end▁of▁sentence|>' }}{%- elif message.role == \"tool\" %}{%- if loop.previtem is undefined or loop.previtem.role != \"tool\" %}{{- '<|start▁of▁sentence|><|Tool|>' }}{%- endif %}{{- '<tool_response>' ~ message.content ~ '</tool_response>' }}{%- if loop.nextitem is undefined or loop.nextitem.role != \"tool\" %}{{- '<|end▁of▁sentence|>' }}{%- endif %}{%- else %}{{- raise_exception('Unsupported message role: ' ~ message.role) }}{%- endif %}{%- endfor %}{#- Generation prompt -#}{%- if add_generation_prompt %}{{- '<|start▁of▁sentence|><|Bot|>' }}{%- if enable_thinking is defined and enable_thinking %}{{- '<think>' }}{%- endif %}{%- if enable_thinking is defined and not enable_thinking %}{{- '</think>' }}{%- endif %}{%- endif %}"}.gitattributes+3
LICENSEAdded+202
README.md+477
chat_template.jinjaAdded+117
config.jsonAdded+83
configuration_spark.pyAdded+118
generation_config.jsonAdded+14
images/model-benchmark-comparison.svgAdded
images/post_training_pipeline.svgAdded
images/spark25-hybrid-architecture-light.pngAdded

Large File Pointer Details
- SHA256: 5eddac6baf8e8460cc2a75b96070eff4074428674f3c33665bc2ff9479756bbd
- Pointer size: 131 Bytes
- Size of remote file: 429 kB
images/xhtoken-wechat.jpgAdded

Large File Pointer Details
- SHA256: 0c3fbd25c987237b383461fdaa96bf6881af615c23ba3baf19e51a7879354ddb
- Pointer size: 131 Bytes
- Size of remote file: 160 kB
merges.txtAdded
model-00001-of-00005.safetensorsAdded+3
model-00002-of-00005.safetensorsAdded+3
model-00003-of-00005.safetensorsAdded+3
model-00004-of-00005.safetensorsAdded+3
model-00005-of-00005.safetensorsAdded+3
model.safetensors.index.jsonAdded+298
modeling_spark.pyAdded+483
special_tokens_map.jsonAdded+6
tokenizer.jsonAdded
tokenizer_config.jsonAdded+42
vocab.jsonAdded