Instructions to use internlm/Intern-S2-Preview-397B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use internlm/Intern-S2-Preview-397B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="internlm/Intern-S2-Preview-397B", trust_remote_code=True) messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoModelForImageTextToText model = AutoModelForImageTextToText.from_pretrained("internlm/Intern-S2-Preview-397B", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use internlm/Intern-S2-Preview-397B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "internlm/Intern-S2-Preview-397B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "internlm/Intern-S2-Preview-397B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/internlm/Intern-S2-Preview-397B
- SGLang
How to use internlm/Intern-S2-Preview-397B 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 "internlm/Intern-S2-Preview-397B" \ --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": "internlm/Intern-S2-Preview-397B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'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 "internlm/Intern-S2-Preview-397B" \ --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": "internlm/Intern-S2-Preview-397B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use internlm/Intern-S2-Preview-397B with Docker Model Runner:
docker model run hf.co/internlm/Intern-S2-Preview-397B
Upload folder using huggingface_hub
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +4 -0
- LICENSE +197 -0
- README.md +515 -0
- chat_template.jinja +147 -0
- config.json +173 -0
- configuration_interns2_preview.py +434 -0
- deployment_guide.md +145 -0
- figs/general_tasks.png +3 -0
- figs/scientific_tasks.png +3 -0
- figs/title.png +3 -0
- generation_config.json +13 -0
- merges.txt +0 -0
- model-00001-of-00190.safetensors +3 -0
- model-00002-of-00190.safetensors +3 -0
- model-00003-of-00190.safetensors +3 -0
- model-00004-of-00190.safetensors +3 -0
- model-00005-of-00190.safetensors +3 -0
- model-00006-of-00190.safetensors +3 -0
- model-00007-of-00190.safetensors +3 -0
- model-00008-of-00190.safetensors +3 -0
- model-00009-of-00190.safetensors +3 -0
- model-00010-of-00190.safetensors +3 -0
- model-00011-of-00190.safetensors +3 -0
- model-00012-of-00190.safetensors +3 -0
- model-00013-of-00190.safetensors +3 -0
- model-00014-of-00190.safetensors +3 -0
- model-00015-of-00190.safetensors +3 -0
- model-00016-of-00190.safetensors +3 -0
- model-00017-of-00190.safetensors +3 -0
- model-00018-of-00190.safetensors +3 -0
- model-00019-of-00190.safetensors +3 -0
- model-00020-of-00190.safetensors +3 -0
- model-00021-of-00190.safetensors +3 -0
- model-00022-of-00190.safetensors +3 -0
- model-00023-of-00190.safetensors +3 -0
- model-00024-of-00190.safetensors +3 -0
- model-00025-of-00190.safetensors +3 -0
- model-00026-of-00190.safetensors +3 -0
- model-00027-of-00190.safetensors +3 -0
- model-00028-of-00190.safetensors +3 -0
- model-00029-of-00190.safetensors +3 -0
- model-00030-of-00190.safetensors +3 -0
- model-00031-of-00190.safetensors +3 -0
- model-00032-of-00190.safetensors +3 -0
- model-00033-of-00190.safetensors +3 -0
- model-00034-of-00190.safetensors +3 -0
- model-00035-of-00190.safetensors +3 -0
- model-00036-of-00190.safetensors +3 -0
- model-00037-of-00190.safetensors +3 -0
- model-00038-of-00190.safetensors +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,7 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
figs/general_tasks.png filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
figs/scientific_tasks.png filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
figs/title.png filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
LICENSE
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Apache License
|
| 2 |
+
Version 2.0, January 2004
|
| 3 |
+
http://www.apache.org/licenses/
|
| 4 |
+
|
| 5 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
| 6 |
+
|
| 7 |
+
1. Definitions.
|
| 8 |
+
|
| 9 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
| 10 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
| 11 |
+
|
| 12 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
| 13 |
+
the copyright owner that is granting the License.
|
| 14 |
+
|
| 15 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
| 16 |
+
other entities that control, are controlled by, or are under common
|
| 17 |
+
control with that entity. For the purposes of this definition,
|
| 18 |
+
"control" means (i) the power, direct or indirect, to cause the
|
| 19 |
+
direction or management of such entity, whether by contract or
|
| 20 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
| 21 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
| 22 |
+
|
| 23 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
| 24 |
+
exercising permissions granted by this License.
|
| 25 |
+
|
| 26 |
+
"Source" form shall mean the preferred form for making modifications,
|
| 27 |
+
including but not limited to software source code, documentation
|
| 28 |
+
source, and configuration files.
|
| 29 |
+
|
| 30 |
+
"Object" form shall mean any form resulting from mechanical
|
| 31 |
+
transformation or translation of a Source form, including but
|
| 32 |
+
not limited to compiled object code, generated documentation,
|
| 33 |
+
and conversions to other media types.
|
| 34 |
+
|
| 35 |
+
"Work" shall mean the work of authorship, whether in Source or
|
| 36 |
+
Object form, made available under the License, as indicated by a
|
| 37 |
+
copyright notice that is included in or attached to the work
|
| 38 |
+
(an example is provided in the Appendix below).
|
| 39 |
+
|
| 40 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
| 41 |
+
form, that is based on (or derived from) the Work and for which the
|
| 42 |
+
editorial revisions, annotations, elaborations, or other modifications
|
| 43 |
+
represent, as a whole, an original work of authorship. For the purposes
|
| 44 |
+
of this License, Derivative Works shall not include works that remain
|
| 45 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
| 46 |
+
the Work and Derivative Works thereof.
|
| 47 |
+
|
| 48 |
+
"Contribution" shall mean any work of authorship, including
|
| 49 |
+
the original version of the Work and any modifications or additions
|
| 50 |
+
to that Work or Derivative Works thereof, that is intentionally
|
| 51 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
| 52 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
| 53 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
| 54 |
+
means any form of electronic, verbal, or written communication sent
|
| 55 |
+
to the Licensor or its representatives, including but not limited to
|
| 56 |
+
communication on electronic mailing lists, source code control systems,
|
| 57 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
| 58 |
+
Licensor for the purpose of discussing and improving the Work, but
|
| 59 |
+
excluding communication that is conspicuously marked or otherwise
|
| 60 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
| 61 |
+
|
| 62 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
| 63 |
+
on behalf of whom a Contribution has been received by Licensor and
|
| 64 |
+
subsequently incorporated within the Work.
|
| 65 |
+
|
| 66 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
| 67 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 68 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 69 |
+
copyright license to reproduce, prepare Derivative Works of,
|
| 70 |
+
publicly display, publicly perform, sublicense, and distribute the
|
| 71 |
+
Work and such Derivative Works in Source or Object form.
|
| 72 |
+
|
| 73 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
| 74 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 75 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 76 |
+
(except as stated in this section) patent license to make, have made,
|
| 77 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
| 78 |
+
where such license applies only to those patent claims licensable
|
| 79 |
+
by such Contributor that are necessarily infringed by their
|
| 80 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
| 81 |
+
with the Work to which such Contribution(s) was submitted. If You
|
| 82 |
+
institute patent litigation against any entity (including a
|
| 83 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
| 84 |
+
or a Contribution incorporated within the Work constitutes direct
|
| 85 |
+
or contributory patent infringement, then any patent licenses
|
| 86 |
+
granted to You under this License for that Work shall terminate
|
| 87 |
+
as of the date such litigation is filed.
|
| 88 |
+
|
| 89 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
| 90 |
+
Work or Derivative Works thereof in any medium, with or without
|
| 91 |
+
modifications, and in Source or Object form, provided that You
|
| 92 |
+
meet the following conditions:
|
| 93 |
+
|
| 94 |
+
(a) You must give any other recipients of the Work or
|
| 95 |
+
Derivative Works a copy of this License; and
|
| 96 |
+
|
| 97 |
+
(b) You must cause any modified files to carry prominent notices
|
| 98 |
+
stating that You changed the files; and
|
| 99 |
+
|
| 100 |
+
(c) You must retain, in the Source form of any Derivative Works
|
| 101 |
+
that You distribute, all copyright, patent, trademark, and
|
| 102 |
+
attribution notices from the Source form of the Work,
|
| 103 |
+
excluding those notices that do not pertain to any part of
|
| 104 |
+
the Derivative Works; and
|
| 105 |
+
|
| 106 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
| 107 |
+
distribution, then any Derivative Works that You distribute must
|
| 108 |
+
include a readable copy of the attribution notices contained
|
| 109 |
+
within such NOTICE file, excluding those notices that do not
|
| 110 |
+
pertain to any part of the Derivative Works, in at least one
|
| 111 |
+
of the following places: within a NOTICE text file distributed
|
| 112 |
+
as part of the Derivative Works; within the Source form or
|
| 113 |
+
documentation, if provided along with the Derivative Works; or,
|
| 114 |
+
within a display generated by the Derivative Works, if and
|
| 115 |
+
wherever such third-party notices normally appear. The contents
|
| 116 |
+
of the NOTICE file are for informational purposes only and
|
| 117 |
+
do not modify the License. You may add Your own attribution
|
| 118 |
+
notices within Derivative Works that You distribute, alongside
|
| 119 |
+
or as an addendum to the NOTICE text from the Work, provided
|
| 120 |
+
that such additional attribution notices cannot be construed
|
| 121 |
+
as modifying the License.
|
| 122 |
+
|
| 123 |
+
You may add Your own copyright statement to Your modifications and
|
| 124 |
+
may provide additional or different license terms and conditions
|
| 125 |
+
for use, reproduction, or distribution of Your modifications, or
|
| 126 |
+
for any such Derivative Works as a whole, provided Your use,
|
| 127 |
+
reproduction, and distribution of the Work otherwise complies with
|
| 128 |
+
the conditions stated in this License.
|
| 129 |
+
|
| 130 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
| 131 |
+
any Contribution intentionally submitted for inclusion in the Work
|
| 132 |
+
by You to the Licensor shall be under the terms and conditions of
|
| 133 |
+
this License, without any additional terms or conditions.
|
| 134 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
| 135 |
+
the terms of any separate license agreement you may have executed
|
| 136 |
+
with Licensor regarding such Contributions.
|
| 137 |
+
|
| 138 |
+
6. Trademarks. This License does not grant permission to use the trade
|
| 139 |
+
names, trademarks, service marks, or product names of the Licensor,
|
| 140 |
+
except as required for reasonable and customary use in describing the
|
| 141 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
| 142 |
+
|
| 143 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
| 144 |
+
agreed to in writing, Licensor provides the Work (and each
|
| 145 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
| 146 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 147 |
+
implied, including, without limitation, any warranties or conditions
|
| 148 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
| 149 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
| 150 |
+
appropriateness of using or redistributing the Work and assume any
|
| 151 |
+
risks associated with Your exercise of permissions under this License.
|
| 152 |
+
|
| 153 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
| 154 |
+
whether in tort (including negligence), contract, or otherwise,
|
| 155 |
+
unless required by applicable law (such as deliberate and grossly
|
| 156 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
| 157 |
+
liable to You for damages, including any direct, indirect, special,
|
| 158 |
+
incidental, or consequential damages of any character arising as a
|
| 159 |
+
result of this License or out of the use or inability to use the
|
| 160 |
+
Work (including but not limited to damages for loss of goodwill,
|
| 161 |
+
work stoppage, computer failure or malfunction, or any and all
|
| 162 |
+
other commercial damages or losses), even if such Contributor
|
| 163 |
+
has been advised of the possibility of such damages.
|
| 164 |
+
|
| 165 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
| 166 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
| 167 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
| 168 |
+
or other liability obligations and/or rights consistent with this
|
| 169 |
+
License. However, in accepting such obligations, You may act only
|
| 170 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
| 171 |
+
of any other Contributor, and only if You agree to indemnify,
|
| 172 |
+
defend, and hold each Contributor harmless for any liability
|
| 173 |
+
incurred by, or claims asserted against, such Contributor by reason
|
| 174 |
+
of your accepting any such warranty or additional liability.
|
| 175 |
+
|
| 176 |
+
END OF TERMS AND CONDITIONS
|
| 177 |
+
|
| 178 |
+
APPENDIX: How to apply the Apache License to your work.
|
| 179 |
+
|
| 180 |
+
To apply the Apache License to your work, attach the following
|
| 181 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
| 182 |
+
replaced with your own identifying information. (Don't include
|
| 183 |
+
the brackets!) The text should be enclosed in the appropriate
|
| 184 |
+
comment syntax for the file format. We also recommend that a
|
| 185 |
+
file or class name and description of purpose be included on the
|
| 186 |
+
same "printed page" as the copyright notice for easier
|
| 187 |
+
identification within third-party archives.
|
| 188 |
+
Copyright 2025-2026 Shanghai AI Laboratory
|
| 189 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 190 |
+
you may not use this file except in compliance with the License.
|
| 191 |
+
You may obtain a copy of the License at
|
| 192 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 193 |
+
Unless required by applicable law or agreed to in writing, software
|
| 194 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 195 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 196 |
+
See the License for the specific language governing permissions and
|
| 197 |
+
limitations under the License.
|
README.md
CHANGED
|
@@ -1,3 +1,518 @@
|
|
| 1 |
---
|
|
|
|
| 2 |
license: apache-2.0
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
library_name: transformers
|
| 3 |
license: apache-2.0
|
| 4 |
+
license_link: https://huggingface.co/internlm/Intern-S2-Preview-397B/blob/main/LICENSE
|
| 5 |
+
pipeline_tag: image-text-to-text
|
| 6 |
---
|
| 7 |
+
|
| 8 |
+
## Intern-S2-Preview-397B
|
| 9 |
+
|
| 10 |
+
<div align="center">
|
| 11 |
+
<img src="./figs/title.png" />
|
| 12 |
+
|
| 13 |
+
<div> </div>
|
| 14 |
+
|
| 15 |
+
[💻Github Repo](https://github.com/InternLM/Intern-S1) • [🤗Model Collections](https://huggingface.co/collections/internlm/intern-s2) • [💬Online Chat](https://chat.intern-ai.org.cn/)
|
| 16 |
+
|
| 17 |
+
</div>
|
| 18 |
+
|
| 19 |
+
<p align="center">
|
| 20 |
+
👋 join us on <a href="https://discord.gg/xa29JuW87d" target="_blank">Discord</a> and <a href="https://cdn.vansin.top/intern-s1.jpg" target="_blank">WeChat</a>
|
| 21 |
+
</p>
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
## Introduction
|
| 26 |
+
|
| 27 |
+
We introduce **Intern-S2-Preview-397B**, our most capable multimodal foundation model for scientific intelligence and long-horizon agents. Building on Intern-S2-Preview-35B, this release scales along three critical dimensions: pre-training, reinforcement-learning task coverage, and interactive agent environments. By combining a new vision-language pre-training paradigm with large-scale multi-task reinforcement learning and long-horizon agent reinforcement learning, Intern-S2-Preview-397B delivers a step change in general reasoning, scientific problem solving, and agentic capabilities.
|
| 28 |
+
|
| 29 |
+
### Features
|
| 30 |
+
|
| 31 |
+
- **New Pre-training Paradigm.** Via visual pretraining, Intern-S2-Preview-397B learns directly from raw pages of scientific literature, jointly modeling symbolic semantics and visual relationships in a shared representation space without intermediate parsing. This preserves text-visual correspondence, strengthens spatial and visual reasoning, and improves data efficiency.
|
| 32 |
+
|
| 33 |
+
- **Scientific Modality Reasoning and Generation.** By scaling diverse scientific reinforcement-learning tasks across more than 20 domains and training them jointly, Intern-S2-Preview-397B achieves leading general-reasoning performance among open-source models and strong results in specialized scientific tasks such as biomolecular interaction design and material structure generation.
|
| 34 |
+
|
| 35 |
+
- **General & Scientific Long-Horizon Agents.** By connecting multiple agent frameworks to large-scale sandboxed environments for black-box agentic reinforcement learning, Intern-S2-Preview-397B improves generalization and raises the capability ceiling for long-horizon tasks in both general and scientific domains.
|
| 36 |
+
|
| 37 |
+
### Performance
|
| 38 |
+
|
| 39 |
+
We evaluate the Intern-S2-Preview-397B on various benchmarks, including general datasets and scientific datasets. We report the performance comparison with the recent VLMs and LLMs below.
|
| 40 |
+
|
| 41 |
+

|
| 42 |
+

|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
> **Note**: <u>Underline</u> means the best performance among open-sourced models, **Bold** indicates the best performance among all models.
|
| 47 |
+
|
| 48 |
+
We use the [OpenCompass](https://github.com/open-compass/OpenCompass/), [VLMEvalKit](https://github.com/open-compass/vlmevalkit), and [AgentCompass](https://github.com/open-compass/AgentCompass) to evaluate all models. For text reasoning benchmarks, Intern-S2-Preview-397B is evaluated with a maximum inference length of 256K tokens, while for multimodal benchmarks, it is evaluated with a maximum inference length of 64K tokens.
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
## Quick Start
|
| 52 |
+
|
| 53 |
+
### Sampling Parameters
|
| 54 |
+
|
| 55 |
+
We recommend using the following hyperparameters to ensure better results
|
| 56 |
+
|
| 57 |
+
```python
|
| 58 |
+
top_p = 0.95
|
| 59 |
+
top_k = 50
|
| 60 |
+
min_p = 0.0
|
| 61 |
+
temperature = 0.8
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
+
### Serving
|
| 65 |
+
|
| 66 |
+
Intern-S2-Preview-397B can be deployed using any of the following LLM inference frameworks:
|
| 67 |
+
|
| 68 |
+
- LMDeploy
|
| 69 |
+
- vLLM
|
| 70 |
+
- SGLang
|
| 71 |
+
|
| 72 |
+
Detailed deployment examples for these frameworks are available in the [Model Deployment Guide](./deployment_guide.md).
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
## Advanced Usage
|
| 76 |
+
|
| 77 |
+
### Tool Calling
|
| 78 |
+
|
| 79 |
+
Tool Calling lets the model extend its capabilities by invoking external tools and APIs. The example below shows how to use it to fetch the latest weather forecast via an OpenAI-compatible API (based on lmdeploy api server).
|
| 80 |
+
|
| 81 |
+
```python
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
from openai import OpenAI
|
| 85 |
+
import json
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
def get_current_temperature(location: str, unit: str = "celsius"):
|
| 89 |
+
"""Get current temperature at a location.
|
| 90 |
+
|
| 91 |
+
Args:
|
| 92 |
+
location: The location to get the temperature for, in the format "City, State, Country".
|
| 93 |
+
unit: The unit to return the temperature in. Defaults to "celsius". (choices: ["celsius", "fahrenheit"])
|
| 94 |
+
|
| 95 |
+
Returns:
|
| 96 |
+
the temperature, the location, and the unit in a dict
|
| 97 |
+
"""
|
| 98 |
+
return {
|
| 99 |
+
"temperature": 26.1,
|
| 100 |
+
"location": location,
|
| 101 |
+
"unit": unit,
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
def get_temperature_date(location: str, date: str, unit: str = "celsius"):
|
| 106 |
+
"""Get temperature at a location and date.
|
| 107 |
+
|
| 108 |
+
Args:
|
| 109 |
+
location: The location to get the temperature for, in the format "City, State, Country".
|
| 110 |
+
date: The date to get the temperature for, in the format "Year-Month-Day".
|
| 111 |
+
unit: The unit to return the temperature in. Defaults to "celsius". (choices: ["celsius", "fahrenheit"])
|
| 112 |
+
|
| 113 |
+
Returns:
|
| 114 |
+
the temperature, the location, the date and the unit in a dict
|
| 115 |
+
"""
|
| 116 |
+
return {
|
| 117 |
+
"temperature": 25.9,
|
| 118 |
+
"location": location,
|
| 119 |
+
"date": date,
|
| 120 |
+
"unit": unit,
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
def get_function_by_name(name):
|
| 124 |
+
if name == "get_current_temperature":
|
| 125 |
+
return get_current_temperature
|
| 126 |
+
if name == "get_temperature_date":
|
| 127 |
+
return get_temperature_date
|
| 128 |
+
|
| 129 |
+
tools = [{
|
| 130 |
+
'type': 'function',
|
| 131 |
+
'function': {
|
| 132 |
+
'name': 'get_current_temperature',
|
| 133 |
+
'description': 'Get current temperature at a location.',
|
| 134 |
+
'parameters': {
|
| 135 |
+
'type': 'object',
|
| 136 |
+
'properties': {
|
| 137 |
+
'location': {
|
| 138 |
+
'type': 'string',
|
| 139 |
+
'description': 'The location to get the temperature for, in the format \'City, State, Country\'.'
|
| 140 |
+
},
|
| 141 |
+
'unit': {
|
| 142 |
+
'type': 'string',
|
| 143 |
+
'enum': [
|
| 144 |
+
'celsius',
|
| 145 |
+
'fahrenheit'
|
| 146 |
+
],
|
| 147 |
+
'description': 'The unit to return the temperature in. Defaults to \'celsius\'.'
|
| 148 |
+
}
|
| 149 |
+
},
|
| 150 |
+
'required': [
|
| 151 |
+
'location'
|
| 152 |
+
]
|
| 153 |
+
}
|
| 154 |
+
}
|
| 155 |
+
}, {
|
| 156 |
+
'type': 'function',
|
| 157 |
+
'function': {
|
| 158 |
+
'name': 'get_temperature_date',
|
| 159 |
+
'description': 'Get temperature at a location and date.',
|
| 160 |
+
'parameters': {
|
| 161 |
+
'type': 'object',
|
| 162 |
+
'properties': {
|
| 163 |
+
'location': {
|
| 164 |
+
'type': 'string',
|
| 165 |
+
'description': 'The location to get the temperature for, in the format \'City, State, Country\'.'
|
| 166 |
+
},
|
| 167 |
+
'date': {
|
| 168 |
+
'type': 'string',
|
| 169 |
+
'description': 'The date to get the temperature for, in the format \'Year-Month-Day\'.'
|
| 170 |
+
},
|
| 171 |
+
'unit': {
|
| 172 |
+
'type': 'string',
|
| 173 |
+
'enum': [
|
| 174 |
+
'celsius',
|
| 175 |
+
'fahrenheit'
|
| 176 |
+
],
|
| 177 |
+
'description': 'The unit to return the temperature in. Defaults to \'celsius\'.'
|
| 178 |
+
}
|
| 179 |
+
},
|
| 180 |
+
'required': [
|
| 181 |
+
'location',
|
| 182 |
+
'date'
|
| 183 |
+
]
|
| 184 |
+
}
|
| 185 |
+
}
|
| 186 |
+
}]
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
|
| 190 |
+
messages = [
|
| 191 |
+
{'role': 'user', 'content': 'Today is 2024-11-14, What\'s the temperature in San Francisco now? How about tomorrow?'}
|
| 192 |
+
]
|
| 193 |
+
|
| 194 |
+
openai_api_key = "EMPTY"
|
| 195 |
+
openai_api_base = "http://0.0.0.0:23333/v1"
|
| 196 |
+
client = OpenAI(
|
| 197 |
+
api_key=openai_api_key,
|
| 198 |
+
base_url=openai_api_base,
|
| 199 |
+
)
|
| 200 |
+
model_name = client.models.list().data[0].id
|
| 201 |
+
response = client.chat.completions.create(
|
| 202 |
+
model=model_name,
|
| 203 |
+
messages=messages,
|
| 204 |
+
max_tokens=32768,
|
| 205 |
+
temperature=0.8,
|
| 206 |
+
top_p=0.95,
|
| 207 |
+
extra_body=dict(spaces_between_special_tokens=False),
|
| 208 |
+
tools=tools)
|
| 209 |
+
print(response.choices[0].message)
|
| 210 |
+
messages.append(response.choices[0].message)
|
| 211 |
+
|
| 212 |
+
for tool_call in response.choices[0].message.tool_calls:
|
| 213 |
+
tool_call_args = json.loads(tool_call.function.arguments)
|
| 214 |
+
tool_call_result = get_function_by_name(tool_call.function.name)(**tool_call_args)
|
| 215 |
+
tool_call_result = json.dumps(tool_call_result, ensure_ascii=False)
|
| 216 |
+
messages.append({
|
| 217 |
+
'role': 'tool',
|
| 218 |
+
'name': tool_call.function.name,
|
| 219 |
+
'content': tool_call_result,
|
| 220 |
+
'tool_call_id': tool_call.id
|
| 221 |
+
})
|
| 222 |
+
|
| 223 |
+
response = client.chat.completions.create(
|
| 224 |
+
model=model_name,
|
| 225 |
+
messages=messages,
|
| 226 |
+
temperature=0.8,
|
| 227 |
+
top_p=0.95,
|
| 228 |
+
extra_body=dict(spaces_between_special_tokens=False),
|
| 229 |
+
tools=tools)
|
| 230 |
+
print(response.choices[0].message)
|
| 231 |
+
```
|
| 232 |
+
|
| 233 |
+
### Switching Between Thinking and Non-Thinking Modes
|
| 234 |
+
|
| 235 |
+
Intern-S2-Preview-397B enables thinking mode by default, enhancing the model's reasoning capabilities to generate higher-quality responses. This feature can be disabled by setting `enable_thinking=False` in `tokenizer.apply_chat_template`
|
| 236 |
+
|
| 237 |
+
```python
|
| 238 |
+
text = tokenizer.apply_chat_template(
|
| 239 |
+
messages,
|
| 240 |
+
tokenize=False,
|
| 241 |
+
add_generation_prompt=True,
|
| 242 |
+
enable_thinking=False # think mode indicator
|
| 243 |
+
)
|
| 244 |
+
```
|
| 245 |
+
|
| 246 |
+
When serving Intern-S2-Preview-397B models, you can dynamically control the thinking mode by adjusting the `enable_thinking` parameter in your requests.
|
| 247 |
+
|
| 248 |
+
```python
|
| 249 |
+
from openai import OpenAI
|
| 250 |
+
import json
|
| 251 |
+
|
| 252 |
+
messages = [
|
| 253 |
+
{
|
| 254 |
+
'role': 'user',
|
| 255 |
+
'content': 'who are you'
|
| 256 |
+
}, {
|
| 257 |
+
'role': 'assistant',
|
| 258 |
+
'content': 'I am an AI'
|
| 259 |
+
}, {
|
| 260 |
+
'role': 'user',
|
| 261 |
+
'content': 'AGI is?'
|
| 262 |
+
}]
|
| 263 |
+
|
| 264 |
+
openai_api_key = "EMPTY"
|
| 265 |
+
openai_api_base = "http://0.0.0.0:23333/v1"
|
| 266 |
+
client = OpenAI(
|
| 267 |
+
api_key=openai_api_key,
|
| 268 |
+
base_url=openai_api_base,
|
| 269 |
+
)
|
| 270 |
+
model_name = client.models.list().data[0].id
|
| 271 |
+
|
| 272 |
+
response = client.chat.completions.create(
|
| 273 |
+
model=model_name,
|
| 274 |
+
messages=messages,
|
| 275 |
+
temperature=0.8,
|
| 276 |
+
top_p=0.95,
|
| 277 |
+
max_tokens=2048,
|
| 278 |
+
extra_body={
|
| 279 |
+
"chat_template_kwargs": {"enable_thinking": False}
|
| 280 |
+
}
|
| 281 |
+
)
|
| 282 |
+
print(json.dumps(response.model_dump(), indent=2, ensure_ascii=False))
|
| 283 |
+
```
|
| 284 |
+
|
| 285 |
+
> Note: We do not recommend disabling thinking mode for agentic tasks.
|
| 286 |
+
|
| 287 |
+
|
| 288 |
+
### Time Series Demo
|
| 289 |
+
|
| 290 |
+
Time series inference is currently only supported in LMDeploy. To get started, download and deploy Intern-S2-Preview-397B with LMDeploy by following the [Model Deployment Guide](./deployment_guide.md).
|
| 291 |
+
Below is an example of detecting earthquake events from a time series signal file. Additional data types and functionalities are also supported.
|
| 292 |
+
|
| 293 |
+
**Please note**: this demo is slightly different from the one in [Intern-S1-Pro](https://huggingface.co/internlm/Intern-S1-Pro#time-series-demo). The main difference is that in the messages content, you need to provide time_series_url first, followed by the text prompt. Please adapt your implementation based on this demo.
|
| 294 |
+
|
| 295 |
+
```
|
| 296 |
+
from openai import OpenAI
|
| 297 |
+
from lmdeploy.vl.utils import encode_time_series_base64
|
| 298 |
+
|
| 299 |
+
openai_api_key = "EMPTY"
|
| 300 |
+
openai_api_base = "http://0.0.0.0:8000/v1"
|
| 301 |
+
client = OpenAI(
|
| 302 |
+
api_key=openai_api_key,
|
| 303 |
+
base_url=openai_api_base,
|
| 304 |
+
)
|
| 305 |
+
model_name = client.models.list().data[0].id
|
| 306 |
+
|
| 307 |
+
|
| 308 |
+
def send_base64(file_path: str, sampling_rate: int = 100):
|
| 309 |
+
"""base64-encoded time-series data."""
|
| 310 |
+
|
| 311 |
+
# encode_time_series_base64 accepts local file paths and http urls,
|
| 312 |
+
# encoding time-series data (.npy, .csv, .wav, .mp3, .flac, etc.) into base64 strings.
|
| 313 |
+
base64_ts = encode_time_series_base64(file_path)
|
| 314 |
+
|
| 315 |
+
messages = [
|
| 316 |
+
{
|
| 317 |
+
"role": "user",
|
| 318 |
+
"content": [
|
| 319 |
+
{
|
| 320 |
+
"type": "time_series_url",
|
| 321 |
+
"time_series_url": {
|
| 322 |
+
"url": f"data:time_series/npy;base64,{base64_ts}",
|
| 323 |
+
"sampling_rate": sampling_rate
|
| 324 |
+
},
|
| 325 |
+
},
|
| 326 |
+
{
|
| 327 |
+
"type": "text",
|
| 328 |
+
"text": "Please determine whether an Earthquake event has occurred in the provided time-series data. If so, please specify the starting time point indices of the P-wave and S-wave in the event."
|
| 329 |
+
},
|
| 330 |
+
],
|
| 331 |
+
}
|
| 332 |
+
]
|
| 333 |
+
|
| 334 |
+
return client.chat.completions.create(
|
| 335 |
+
model=model_name,
|
| 336 |
+
messages=messages,
|
| 337 |
+
temperature=0,
|
| 338 |
+
max_tokens=200,
|
| 339 |
+
extra_body={
|
| 340 |
+
"chat_template_kwargs": {"enable_thinking": False}
|
| 341 |
+
}
|
| 342 |
+
)
|
| 343 |
+
|
| 344 |
+
|
| 345 |
+
def send_http_url(url: str, sampling_rate: int = 100):
|
| 346 |
+
"""http(s) url pointing to the time-series data."""
|
| 347 |
+
messages = [
|
| 348 |
+
{
|
| 349 |
+
"role": "user",
|
| 350 |
+
"content": [
|
| 351 |
+
{
|
| 352 |
+
"type": "time_series_url",
|
| 353 |
+
"time_series_url": {
|
| 354 |
+
"url": url,
|
| 355 |
+
"sampling_rate": sampling_rate
|
| 356 |
+
},
|
| 357 |
+
},
|
| 358 |
+
{
|
| 359 |
+
"type": "text",
|
| 360 |
+
"text": "Please determine whether an Earthquake event has occurred in the provided time-series data. If so, please specify the starting time point indices of the P-wave and S-wave in the event."
|
| 361 |
+
},
|
| 362 |
+
],
|
| 363 |
+
}
|
| 364 |
+
]
|
| 365 |
+
|
| 366 |
+
return client.chat.completions.create(
|
| 367 |
+
model=model_name,
|
| 368 |
+
messages=messages,
|
| 369 |
+
temperature=0,
|
| 370 |
+
max_tokens=200,
|
| 371 |
+
extra_body={
|
| 372 |
+
"chat_template_kwargs": {"enable_thinking": False}
|
| 373 |
+
}
|
| 374 |
+
)
|
| 375 |
+
|
| 376 |
+
|
| 377 |
+
def send_file_url(file_path: str, sampling_rate: int = 100):
|
| 378 |
+
"""file url pointing to the time-series data."""
|
| 379 |
+
messages = [
|
| 380 |
+
{
|
| 381 |
+
"role": "user",
|
| 382 |
+
"content": [
|
| 383 |
+
{
|
| 384 |
+
"type": "time_series_url",
|
| 385 |
+
"time_series_url": {
|
| 386 |
+
"url": f"file://{file_path}",
|
| 387 |
+
"sampling_rate": sampling_rate
|
| 388 |
+
},
|
| 389 |
+
},
|
| 390 |
+
{
|
| 391 |
+
"type": "text",
|
| 392 |
+
"text": "Please determine whether an Earthquake event has occurred in the provided time-series data. If so, please specify the starting time point indices of the P-wave and S-wave in the event."
|
| 393 |
+
},
|
| 394 |
+
],
|
| 395 |
+
}
|
| 396 |
+
]
|
| 397 |
+
|
| 398 |
+
return client.chat.completions.create(
|
| 399 |
+
model=model_name,
|
| 400 |
+
messages=messages,
|
| 401 |
+
temperature=0,
|
| 402 |
+
max_tokens=200,
|
| 403 |
+
extra_body={
|
| 404 |
+
"chat_template_kwargs": {"enable_thinking": False}
|
| 405 |
+
}
|
| 406 |
+
)
|
| 407 |
+
|
| 408 |
+
response = send_base64("./0092638_seism.npy")
|
| 409 |
+
# response = send_http_url("https://huggingface.co/internlm/Intern-S1-Pro/raw/main/0092638_seism.npy")
|
| 410 |
+
# response = send_file_url("./0092638_seism.npy")
|
| 411 |
+
|
| 412 |
+
print(response.choices[0].message)
|
| 413 |
+
|
| 414 |
+
```
|
| 415 |
+
|
| 416 |
+
## Agent Integration
|
| 417 |
+
|
| 418 |
+
Intern-S2-Preview-397B can be plugged into agent frameworks in two ways: connecting to a **self-hosted deployment**, or calling the **official InternLM API**. Below we cover both, with examples for agent frameworks (OpenClaw, Hermes, etc.) and for Claude Code.
|
| 419 |
+
|
| 420 |
+
### 1. Self-hosted Deployment (LMDeploy as an example)
|
| 421 |
+
|
| 422 |
+
First, serve the model with LMDeploy following the [Model Deployment Guide](./deployment_guide.md). The example below assumes the server is running at `http://0.0.0.0:23333`.
|
| 423 |
+
|
| 424 |
+
#### Connecting Agent Frameworks
|
| 425 |
+
|
| 426 |
+
Most agent frameworks (OpenClaw, Hermes, etc.) accept an OpenAI-compatible endpoint. Point them at the LMDeploy server base url `http://0.0.0.0:23333/v1`.
|
| 427 |
+
|
| 428 |
+
You can check the connection with the following command:
|
| 429 |
+
|
| 430 |
+
```bash
|
| 431 |
+
curl http://0.0.0.0:23333/v1/chat/completions \
|
| 432 |
+
-H "Content-Type: application/json" \
|
| 433 |
+
-H "Authorization: Bearer EMPTY" \
|
| 434 |
+
-d '{
|
| 435 |
+
"model": "internlm/Intern-S2-Preview-397B",
|
| 436 |
+
"messages": [
|
| 437 |
+
{"role": "user", "content": "Hello"}
|
| 438 |
+
],
|
| 439 |
+
"temperature": 0.8,
|
| 440 |
+
"top_p": 0.95
|
| 441 |
+
}'
|
| 442 |
+
```
|
| 443 |
+
|
| 444 |
+
Or you can configure your agent framework with the environment variables
|
| 445 |
+
|
| 446 |
+
```bash
|
| 447 |
+
export OPENAI_API_KEY=EMPTY
|
| 448 |
+
export OPENAI_BASE_URL=http://0.0.0.0:23333/v1
|
| 449 |
+
export OPENAI_MODEL=internlm/Intern-S2-Preview-397B
|
| 450 |
+
```
|
| 451 |
+
|
| 452 |
+
Remember to launch LMDeploy with `--tool-call-parser interns2-preview` so tool calls are parsed correctly.
|
| 453 |
+
|
| 454 |
+
#### Connecting Claude Code
|
| 455 |
+
|
| 456 |
+
LMDeploy exposes an Anthropic-compatible `/v1/messages` endpoint that Claude Code can talk to directly. Add the following to `~/.claude/settings.json`:
|
| 457 |
+
|
| 458 |
+
```json
|
| 459 |
+
{
|
| 460 |
+
"env": {
|
| 461 |
+
"ANTHROPIC_BASE_URL": "http://127.0.0.1:23333",
|
| 462 |
+
"ANTHROPIC_AUTH_TOKEN": "dummy",
|
| 463 |
+
"ANTHROPIC_MODEL": "internlm/Intern-S2-Preview-397B",
|
| 464 |
+
"ANTHROPIC_CUSTOM_MODEL_OPTION": "internlm/Intern-S2-Preview-397B"
|
| 465 |
+
}
|
| 466 |
+
}
|
| 467 |
+
```
|
| 468 |
+
|
| 469 |
+
For a full walkthrough (curl verification, model routing, troubleshooting), see [LMDeploy × Claude Code](https://lmdeploy.readthedocs.io/en/latest/intergration/claude_code.html).
|
| 470 |
+
|
| 471 |
+
### 2. Official Intern API
|
| 472 |
+
|
| 473 |
+
If you do not want to self-host, you can use the official Intern API. Register at [internlm.intern-ai.org.cn](https://internlm.intern-ai.org.cn/) and create an API token (`sk-xxxxxxxx`).
|
| 474 |
+
|
| 475 |
+
#### Connecting Agent Frameworks
|
| 476 |
+
|
| 477 |
+
The service is OpenAI-compatible, so any agent framework works. You can set the base url to `https://chat.intern-ai.org.cn/api/v1` and the model name to `intern-s2-preview` in the cli or config file.
|
| 478 |
+
|
| 479 |
+
You can check the connection with the following command:
|
| 480 |
+
|
| 481 |
+
```bash
|
| 482 |
+
curl https://chat.intern-ai.org.cn/api/v1/chat/completions \
|
| 483 |
+
-H "Content-Type: application/json" \
|
| 484 |
+
-H "Authorization: Bearer sk-xxxxxxxx" \
|
| 485 |
+
-d '{
|
| 486 |
+
"model": "intern-s2-preview",
|
| 487 |
+
"messages": [
|
| 488 |
+
{"role": "user", "content": "Hello"}
|
| 489 |
+
],
|
| 490 |
+
"temperature": 0.8,
|
| 491 |
+
"top_p": 0.95
|
| 492 |
+
}'
|
| 493 |
+
```
|
| 494 |
+
|
| 495 |
+
Refer to the [Intern API documentation](https://internlm.intern-ai.org.cn/api/document?lang=en) for the current endpoint, available model names, rate limits, and advanced parameters.
|
| 496 |
+
|
| 497 |
+
#### Connecting Claude Code
|
| 498 |
+
|
| 499 |
+
Claude Code can route to the official Intern API by pointing `ANTHROPIC_BASE_URL` at the Intern Anthropic-compatible gateway:
|
| 500 |
+
|
| 501 |
+
```json
|
| 502 |
+
{
|
| 503 |
+
"env": {
|
| 504 |
+
"ANTHROPIC_BASE_URL": "https://chat.intern-ai.org.cn",
|
| 505 |
+
"ANTHROPIC_AUTH_TOKEN": "your-api-token",
|
| 506 |
+
"ANTHROPIC_MODEL": "intern-s2-preview",
|
| 507 |
+
"ANTHROPIC_SMALL_FAST_MODEL": "intern-s2-preview"
|
| 508 |
+
}
|
| 509 |
+
}
|
| 510 |
+
```
|
| 511 |
+
|
| 512 |
+
Then start claude code with the following command:
|
| 513 |
+
|
| 514 |
+
```bash
|
| 515 |
+
claude --model intern-s2-preview
|
| 516 |
+
```
|
| 517 |
+
|
| 518 |
+
For step-by-step setup, see [Intern API × Claude Code Integration](https://internlm.intern-ai.org.cn/docEn/docs/Claude-Code-Integration).
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{%- set image_count = namespace(value=0) %}
|
| 2 |
+
{%- set video_count = namespace(value=0) %}
|
| 3 |
+
{%- macro render_content(content, do_vision_count, is_system_content=false) %}
|
| 4 |
+
{%- if content is string %}
|
| 5 |
+
{{- content }}
|
| 6 |
+
{%- elif content is iterable and content is not mapping %}
|
| 7 |
+
{%- for item in content %}
|
| 8 |
+
{%- if 'image' in item or 'image_url' in item or item.type == 'image' %}
|
| 9 |
+
{%- if is_system_content %}
|
| 10 |
+
{{- raise_exception('System message cannot contain images.') }}
|
| 11 |
+
{%- endif %}
|
| 12 |
+
{%- if do_vision_count %}
|
| 13 |
+
{%- set image_count.value = image_count.value + 1 %}
|
| 14 |
+
{%- endif %}
|
| 15 |
+
{%- if add_vision_id %}
|
| 16 |
+
{{- 'Picture ' ~ image_count.value ~ ': ' }}
|
| 17 |
+
{%- endif %}
|
| 18 |
+
{{- '<|vision_start|><|image_pad|><|vision_end|>' }}
|
| 19 |
+
{%- elif 'video' in item or item.type == 'video' %}
|
| 20 |
+
{%- if is_system_content %}
|
| 21 |
+
{{- raise_exception('System message cannot contain videos.') }}
|
| 22 |
+
{%- endif %}
|
| 23 |
+
{%- if do_vision_count %}
|
| 24 |
+
{%- set video_count.value = video_count.value + 1 %}
|
| 25 |
+
{%- endif %}
|
| 26 |
+
{%- if add_vision_id %}
|
| 27 |
+
{{- 'Video ' ~ video_count.value ~ ': ' }}
|
| 28 |
+
{%- endif %}
|
| 29 |
+
{{- '<|vision_start|><|video_pad|><|vision_end|>' }}
|
| 30 |
+
{%- elif 'text' in item %}
|
| 31 |
+
{{- item.text }}
|
| 32 |
+
{%- else %}
|
| 33 |
+
{{- raise_exception('Unexpected item type in content.') }}
|
| 34 |
+
{%- endif %}
|
| 35 |
+
{%- endfor %}
|
| 36 |
+
{%- elif content is none or content is undefined %}
|
| 37 |
+
{{- '' }}
|
| 38 |
+
{%- else %}
|
| 39 |
+
{{- raise_exception('Unexpected content type.') }}
|
| 40 |
+
{%- endif %}
|
| 41 |
+
{%- endmacro %}
|
| 42 |
+
{%- if not messages %}
|
| 43 |
+
{{- raise_exception('No messages provided.') }}
|
| 44 |
+
{%- endif %}
|
| 45 |
+
{%- if tools and tools is iterable and tools is not mapping %}
|
| 46 |
+
{{- '<|im_start|>system\n' }}
|
| 47 |
+
{{- "# Tools\n\nYou have access to the following functions:\n\n<tools>" }}
|
| 48 |
+
{%- for tool in tools %}
|
| 49 |
+
{{- "\n" }}
|
| 50 |
+
{{- tool | tojson }}
|
| 51 |
+
{%- endfor %}
|
| 52 |
+
{{- "\n</tools>" }}
|
| 53 |
+
{{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }}
|
| 54 |
+
{%- if messages[0].role == 'system' %}
|
| 55 |
+
{%- set content = render_content(messages[0].content, false, true)|trim %}
|
| 56 |
+
{%- if content %}
|
| 57 |
+
{{- '\n\n' + content }}
|
| 58 |
+
{%- endif %}
|
| 59 |
+
{%- endif %}
|
| 60 |
+
{{- '<|im_end|>\n' }}
|
| 61 |
+
{%- else %}
|
| 62 |
+
{%- if messages[0].role == 'system' %}
|
| 63 |
+
{%- set content = render_content(messages[0].content, false, true)|trim %}
|
| 64 |
+
{{- '<|im_start|>system\n' + content + '<|im_end|>\n' }}
|
| 65 |
+
{%- endif %}
|
| 66 |
+
{%- endif %}
|
| 67 |
+
{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
|
| 68 |
+
{%- for message in messages[::-1] %}
|
| 69 |
+
{%- set index = (messages|length - 1) - loop.index0 %}
|
| 70 |
+
{%- if ns.multi_step_tool and message.role == "user" %}
|
| 71 |
+
{%- set content = render_content(message.content, false)|trim %}
|
| 72 |
+
{%- if not(content.startswith('<tool_response>') and content.endswith('</tool_response>')) %}
|
| 73 |
+
{%- set ns.multi_step_tool = false %}
|
| 74 |
+
{%- set ns.last_query_index = index %}
|
| 75 |
+
{%- endif %}
|
| 76 |
+
{%- endif %}
|
| 77 |
+
{%- endfor %}
|
| 78 |
+
{%- for message in messages %}
|
| 79 |
+
{%- set content = render_content(message.content, true)|trim %}
|
| 80 |
+
{%- if message.role == "user" %}
|
| 81 |
+
{{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
|
| 82 |
+
{%- elif message.role == "assistant" %}
|
| 83 |
+
{%- set reasoning_content = '' %}
|
| 84 |
+
{%- if message.reasoning_content is string %}
|
| 85 |
+
{%- set reasoning_content = message.reasoning_content %}
|
| 86 |
+
{%- else %}
|
| 87 |
+
{%- if '</think>' in content %}
|
| 88 |
+
{%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
|
| 89 |
+
{%- set content = content.split('</think>')[-1].lstrip('\n') %}
|
| 90 |
+
{%- endif %}
|
| 91 |
+
{%- endif %}
|
| 92 |
+
{%- set reasoning_content = reasoning_content|trim %}
|
| 93 |
+
{%- if (clear_thinking is defined and not clear_thinking) or loop.index0 > ns.last_query_index %}
|
| 94 |
+
{{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content + '\n</think>\n\n' + content }}
|
| 95 |
+
{%- else %}
|
| 96 |
+
{{- '<|im_start|>' + message.role + '\n' + content }}
|
| 97 |
+
{%- endif %}
|
| 98 |
+
{%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}
|
| 99 |
+
{%- for tool_call in message.tool_calls %}
|
| 100 |
+
{%- if tool_call.function is defined %}
|
| 101 |
+
{%- set tool_call = tool_call.function %}
|
| 102 |
+
{%- endif %}
|
| 103 |
+
{%- if loop.first %}
|
| 104 |
+
{%- if content|trim %}
|
| 105 |
+
{{- '\n\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
|
| 106 |
+
{%- else %}
|
| 107 |
+
{{- '<tool_call>\n<function=' + tool_call.name + '>\n' }}
|
| 108 |
+
{%- endif %}
|
| 109 |
+
{%- else %}
|
| 110 |
+
{{- '\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
|
| 111 |
+
{%- endif %}
|
| 112 |
+
{%- if tool_call.arguments is defined %}
|
| 113 |
+
{%- for args_name, args_value in tool_call.arguments|items %}
|
| 114 |
+
{{- '<parameter=' + args_name + '>\n' }}
|
| 115 |
+
{%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %}
|
| 116 |
+
{{- args_value }}
|
| 117 |
+
{{- '\n</parameter>\n' }}
|
| 118 |
+
{%- endfor %}
|
| 119 |
+
{%- endif %}
|
| 120 |
+
{{- '</function>\n</tool_call>' }}
|
| 121 |
+
{%- endfor %}
|
| 122 |
+
{%- endif %}
|
| 123 |
+
{{- '<|im_end|>\n' }}
|
| 124 |
+
{%- elif message.role == "tool" %}
|
| 125 |
+
{%- if loop.previtem and loop.previtem.role != "tool" %}
|
| 126 |
+
{{- '<|im_start|>user' }}
|
| 127 |
+
{%- endif %}
|
| 128 |
+
{{- '\n<tool_response>\n' }}
|
| 129 |
+
{{- content }}
|
| 130 |
+
{{- '\n</tool_response>' }}
|
| 131 |
+
{%- if not loop.last and loop.nextitem.role != "tool" %}
|
| 132 |
+
{{- '<|im_end|>\n' }}
|
| 133 |
+
{%- elif loop.last %}
|
| 134 |
+
{{- '<|im_end|>\n' }}
|
| 135 |
+
{%- endif %}
|
| 136 |
+
{%- elif message.role != "system" %}
|
| 137 |
+
{{- raise_exception('Unexpected message role.') }}
|
| 138 |
+
{%- endif %}
|
| 139 |
+
{%- endfor %}
|
| 140 |
+
{%- if add_generation_prompt %}
|
| 141 |
+
{{- '<|im_start|>assistant\n' }}
|
| 142 |
+
{%- if enable_thinking is defined and enable_thinking is false %}
|
| 143 |
+
{{- '<think>\n\n</think>\n\n' }}
|
| 144 |
+
{%- else %}
|
| 145 |
+
{{- '<think>\n' }}
|
| 146 |
+
{%- endif %}
|
| 147 |
+
{%- endif %}
|
config.json
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"InternS2PreviewForConditionalGeneration"
|
| 4 |
+
],
|
| 5 |
+
"transformers_version": "5.2.0",
|
| 6 |
+
"auto_map": {
|
| 7 |
+
"AutoConfig": "configuration_interns2_preview.InternS2PreviewConfig",
|
| 8 |
+
"AutoModelForCausalLM": "modeling_interns2_preview.InternS2PreviewForCausalLM",
|
| 9 |
+
"AutoModel": "modeling_interns2_preview.InternS2PreviewModel",
|
| 10 |
+
"AutoModelForImageTextToText": "modeling_interns2_preview.InternS2PreviewForConditionalGeneration",
|
| 11 |
+
"AutoModelForMultimodalLM": "modeling_interns2_preview.InternS2PreviewForConditionalGeneration"
|
| 12 |
+
},
|
| 13 |
+
"model_type": "intern_s2_preview",
|
| 14 |
+
"image_token_id": 248056,
|
| 15 |
+
"text_config": {
|
| 16 |
+
"model_type": "qwen3_5_moe_text",
|
| 17 |
+
"attention_bias": false,
|
| 18 |
+
"attention_dropout": 0.0,
|
| 19 |
+
"attn_output_gate": true,
|
| 20 |
+
"dtype": "bfloat16",
|
| 21 |
+
"eos_token_id": 248044,
|
| 22 |
+
"full_attention_interval": 4,
|
| 23 |
+
"head_dim": 256,
|
| 24 |
+
"hidden_act": "silu",
|
| 25 |
+
"hidden_size": 4096,
|
| 26 |
+
"initializer_range": 0.02,
|
| 27 |
+
"layer_types": [
|
| 28 |
+
"linear_attention",
|
| 29 |
+
"linear_attention",
|
| 30 |
+
"linear_attention",
|
| 31 |
+
"full_attention",
|
| 32 |
+
"linear_attention",
|
| 33 |
+
"linear_attention",
|
| 34 |
+
"linear_attention",
|
| 35 |
+
"full_attention",
|
| 36 |
+
"linear_attention",
|
| 37 |
+
"linear_attention",
|
| 38 |
+
"linear_attention",
|
| 39 |
+
"full_attention",
|
| 40 |
+
"linear_attention",
|
| 41 |
+
"linear_attention",
|
| 42 |
+
"linear_attention",
|
| 43 |
+
"full_attention",
|
| 44 |
+
"linear_attention",
|
| 45 |
+
"linear_attention",
|
| 46 |
+
"linear_attention",
|
| 47 |
+
"full_attention",
|
| 48 |
+
"linear_attention",
|
| 49 |
+
"linear_attention",
|
| 50 |
+
"linear_attention",
|
| 51 |
+
"full_attention",
|
| 52 |
+
"linear_attention",
|
| 53 |
+
"linear_attention",
|
| 54 |
+
"linear_attention",
|
| 55 |
+
"full_attention",
|
| 56 |
+
"linear_attention",
|
| 57 |
+
"linear_attention",
|
| 58 |
+
"linear_attention",
|
| 59 |
+
"full_attention",
|
| 60 |
+
"linear_attention",
|
| 61 |
+
"linear_attention",
|
| 62 |
+
"linear_attention",
|
| 63 |
+
"full_attention",
|
| 64 |
+
"linear_attention",
|
| 65 |
+
"linear_attention",
|
| 66 |
+
"linear_attention",
|
| 67 |
+
"full_attention",
|
| 68 |
+
"linear_attention",
|
| 69 |
+
"linear_attention",
|
| 70 |
+
"linear_attention",
|
| 71 |
+
"full_attention",
|
| 72 |
+
"linear_attention",
|
| 73 |
+
"linear_attention",
|
| 74 |
+
"linear_attention",
|
| 75 |
+
"full_attention",
|
| 76 |
+
"linear_attention",
|
| 77 |
+
"linear_attention",
|
| 78 |
+
"linear_attention",
|
| 79 |
+
"full_attention",
|
| 80 |
+
"linear_attention",
|
| 81 |
+
"linear_attention",
|
| 82 |
+
"linear_attention",
|
| 83 |
+
"full_attention",
|
| 84 |
+
"linear_attention",
|
| 85 |
+
"linear_attention",
|
| 86 |
+
"linear_attention",
|
| 87 |
+
"full_attention"
|
| 88 |
+
],
|
| 89 |
+
"linear_conv_kernel_dim": 4,
|
| 90 |
+
"linear_key_head_dim": 128,
|
| 91 |
+
"linear_num_key_heads": 16,
|
| 92 |
+
"linear_num_value_heads": 64,
|
| 93 |
+
"linear_value_head_dim": 128,
|
| 94 |
+
"max_position_embeddings": 262144,
|
| 95 |
+
"mlp_only_layers": [],
|
| 96 |
+
"moe_intermediate_size": 1024,
|
| 97 |
+
"mtp_num_hidden_layers": 1,
|
| 98 |
+
"mtp_use_dedicated_embeddings": false,
|
| 99 |
+
"num_attention_heads": 32,
|
| 100 |
+
"num_experts": 512,
|
| 101 |
+
"num_experts_per_tok": 10,
|
| 102 |
+
"num_hidden_layers": 60,
|
| 103 |
+
"num_key_value_heads": 2,
|
| 104 |
+
"rms_norm_eps": 1e-06,
|
| 105 |
+
"router_aux_loss_coef": 0.001,
|
| 106 |
+
"shared_expert_intermediate_size": 1024,
|
| 107 |
+
"use_cache": true,
|
| 108 |
+
"vocab_size": 251392,
|
| 109 |
+
"mamba_ssm_dtype": "float32",
|
| 110 |
+
"rope_parameters": {
|
| 111 |
+
"mrope_interleaved": true,
|
| 112 |
+
"mrope_section": [
|
| 113 |
+
11,
|
| 114 |
+
11,
|
| 115 |
+
10
|
| 116 |
+
],
|
| 117 |
+
"rope_type": "default",
|
| 118 |
+
"rope_theta": 10000000,
|
| 119 |
+
"partial_rotary_factor": 0.25
|
| 120 |
+
},
|
| 121 |
+
"pad_token_id": null,
|
| 122 |
+
"bos_token_id": null,
|
| 123 |
+
"tie_word_embeddings": false,
|
| 124 |
+
"output_router_logits": false,
|
| 125 |
+
"partial_rotary_factor": 0.25
|
| 126 |
+
},
|
| 127 |
+
"tie_word_embeddings": false,
|
| 128 |
+
"video_token_id": 248057,
|
| 129 |
+
"vision_config": {
|
| 130 |
+
"model_type": "intern_s2_preview",
|
| 131 |
+
"deepstack_visual_indexes": [],
|
| 132 |
+
"depth": 27,
|
| 133 |
+
"hidden_act": "gelu_pytorch_tanh",
|
| 134 |
+
"hidden_size": 1152,
|
| 135 |
+
"in_channels": 3,
|
| 136 |
+
"initializer_range": 0.02,
|
| 137 |
+
"intermediate_size": 4304,
|
| 138 |
+
"num_heads": 16,
|
| 139 |
+
"num_position_embeddings": 2304,
|
| 140 |
+
"out_hidden_size": 4096,
|
| 141 |
+
"patch_size": 16,
|
| 142 |
+
"spatial_merge_size": 2,
|
| 143 |
+
"temporal_patch_size": 2
|
| 144 |
+
},
|
| 145 |
+
"vision_end_token_id": 248054,
|
| 146 |
+
"vision_start_token_id": 248053,
|
| 147 |
+
"ts_config": {
|
| 148 |
+
"auto_map": {
|
| 149 |
+
"AutoConfig": "configuration_interns2_preview.InternS2PreviewTimeSeriesConfig",
|
| 150 |
+
"AutoModel": "modeling_interns2_preview.InternS2PreviewTimeSeriesModel"
|
| 151 |
+
},
|
| 152 |
+
"model_type": "interns2_preview_time_series",
|
| 153 |
+
"activation_dropout": 0.0,
|
| 154 |
+
"activation_function": "gelu",
|
| 155 |
+
"attention_dropout": 0.0,
|
| 156 |
+
"d_model": 768,
|
| 157 |
+
"dropout": 0.0,
|
| 158 |
+
"encoder_attention_heads": 8,
|
| 159 |
+
"encoder_ffn_dim": 3072,
|
| 160 |
+
"encoder_layerdrop": 0.0,
|
| 161 |
+
"encoder_layers": 17,
|
| 162 |
+
"max_source_positions": 1500,
|
| 163 |
+
"num_mel_bins": 80,
|
| 164 |
+
"out_hidden_size": 2048,
|
| 165 |
+
"scale_embedding": false,
|
| 166 |
+
"ts_adapt_in_dim": 256,
|
| 167 |
+
"ts_adapt_out_dim": 1024,
|
| 168 |
+
"ts_hidden_dim": 1024
|
| 169 |
+
},
|
| 170 |
+
"ts_token_id": 248093,
|
| 171 |
+
"ts_start_id": 248091,
|
| 172 |
+
"ts_end_id": 248092
|
| 173 |
+
}
|
configuration_interns2_preview.py
ADDED
|
@@ -0,0 +1,434 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
|
| 2 |
+
# This file was automatically generated from src/transformers/models/interns2_preview/modular_interns2_preview.py.
|
| 3 |
+
# Do NOT edit this file manually as any edits will be overwritten by the generation of
|
| 4 |
+
# the file from the modular. If any change should be done, please apply the change to the
|
| 5 |
+
# modular_interns2_preview.py file directly. One of our CI enforces this.
|
| 6 |
+
# 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
|
| 7 |
+
# Copyright 2026 The Intern team, The Qwen Team and The HuggingFace Inc. team. All rights reserved.
|
| 8 |
+
#
|
| 9 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 10 |
+
# you may not use this file except in compliance with the License.
|
| 11 |
+
# You may obtain a copy of the License at
|
| 12 |
+
#
|
| 13 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 14 |
+
#
|
| 15 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 16 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 17 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 18 |
+
# See the License for the specific language governing permissions and
|
| 19 |
+
# limitations under the License.
|
| 20 |
+
from transformers.configuration_utils import PreTrainedConfig, layer_type_validation
|
| 21 |
+
from transformers.modeling_rope_utils import RopeParameters
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
class InternS2PreviewVisionConfig(PreTrainedConfig):
|
| 25 |
+
model_type = "intern_s2_preview"
|
| 26 |
+
base_config_key = "vision_config"
|
| 27 |
+
|
| 28 |
+
def __init__(
|
| 29 |
+
self,
|
| 30 |
+
depth=27,
|
| 31 |
+
hidden_size=1152,
|
| 32 |
+
hidden_act="gelu_pytorch_tanh",
|
| 33 |
+
intermediate_size=4304,
|
| 34 |
+
num_heads=16,
|
| 35 |
+
in_channels=3,
|
| 36 |
+
patch_size=16,
|
| 37 |
+
spatial_merge_size=2,
|
| 38 |
+
temporal_patch_size=2,
|
| 39 |
+
out_hidden_size=3584,
|
| 40 |
+
num_position_embeddings=2304,
|
| 41 |
+
initializer_range=0.02,
|
| 42 |
+
**kwargs,
|
| 43 |
+
):
|
| 44 |
+
super().__init__(**kwargs)
|
| 45 |
+
|
| 46 |
+
self.depth = depth
|
| 47 |
+
self.hidden_size = hidden_size
|
| 48 |
+
self.hidden_act = hidden_act
|
| 49 |
+
self.intermediate_size = intermediate_size
|
| 50 |
+
self.num_heads = num_heads
|
| 51 |
+
self.in_channels = in_channels
|
| 52 |
+
self.patch_size = patch_size
|
| 53 |
+
self.spatial_merge_size = spatial_merge_size
|
| 54 |
+
self.temporal_patch_size = temporal_patch_size
|
| 55 |
+
self.out_hidden_size = out_hidden_size
|
| 56 |
+
self.num_position_embeddings = num_position_embeddings
|
| 57 |
+
self.initializer_range = initializer_range
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
class InternS2PreviewTextConfig(PreTrainedConfig):
|
| 61 |
+
r"""
|
| 62 |
+
This is the configuration class to store the configuration of a [`InternS2PreviewTextModel`]. It is used to instantiate a
|
| 63 |
+
Qwen3.5-MoE model according to the specified arguments, defining the model architecture.
|
| 64 |
+
Instantiating a configuration with the defaults will yield a similar configuration to that of
|
| 65 |
+
Qwen3.5-35B-A3B-Instruct [Qwen/Qwen3.5-35B-A3B-Instruct](https://huggingface.co/Qwen/Qwen3.5-35B-A3B-Instruct).
|
| 66 |
+
|
| 67 |
+
Configuration objects inherit from [`PreTrainedConfig`] and can be used to control the model outputs. Read the
|
| 68 |
+
documentation from [`PreTrainedConfig`] for more information.
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
Args:
|
| 72 |
+
vocab_size (`int`, *optional*, defaults to 248320):
|
| 73 |
+
Vocabulary size of the model. Defines the number of different tokens that can be represented by the
|
| 74 |
+
`inputs_ids`.
|
| 75 |
+
hidden_size (`int`, *optional*, defaults to 2048):
|
| 76 |
+
Dimension of the hidden representations.
|
| 77 |
+
num_hidden_layers (`int`, *optional*, defaults to 40):
|
| 78 |
+
Number of hidden layers in the Transformer encoder.
|
| 79 |
+
num_attention_heads (`int`, *optional*, defaults to 16):
|
| 80 |
+
Number of attention heads for each attention layer in the Transformer encoder.
|
| 81 |
+
num_key_value_heads (`int`, *optional*, defaults to 2):
|
| 82 |
+
This is the number of key_value heads that should be used to implement Grouped Query Attention. If
|
| 83 |
+
`num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
|
| 84 |
+
`num_key_value_heads=1` the model will use Multi Query Attention (MQA) otherwise GQA is used. When
|
| 85 |
+
converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
|
| 86 |
+
by meanpooling all the original heads within that group. For more details checkout [this
|
| 87 |
+
paper](https://arxiv.org/pdf/2305.13245.pdf). If it is not specified, will default to `32`.
|
| 88 |
+
hidden_act (`str`, *optional*, defaults to `"silu"`):
|
| 89 |
+
The non-linear activation function in the decoder.
|
| 90 |
+
max_position_embeddings (`int`, *optional*, defaults to 32768):
|
| 91 |
+
The maximum sequence length that this model might ever be used with.
|
| 92 |
+
initializer_range (`float`, *optional*, defaults to 0.02):
|
| 93 |
+
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
|
| 94 |
+
rms_norm_eps (`float`, *optional*, defaults to 1e-06):
|
| 95 |
+
The epsilon used by the rms normalization layers.
|
| 96 |
+
use_cache (`bool`, *optional*, defaults to `True`):
|
| 97 |
+
Whether or not the model should return the last key/values attentions (not used by all models). Only
|
| 98 |
+
relevant if `config.is_decoder=True`.
|
| 99 |
+
tie_word_embeddings (`bool`, *optional*, defaults to `False`):
|
| 100 |
+
Whether the model's input and output word embeddings should be tied.
|
| 101 |
+
rope_parameters (`RopeParameters`, *optional*):
|
| 102 |
+
Dictionary containing the configuration parameters for the RoPE embeddings. The dictionary should contain
|
| 103 |
+
a value for `rope_theta` and optionally parameters used for scaling in case you want to use RoPE
|
| 104 |
+
with longer `max_position_embeddings`.
|
| 105 |
+
attention_bias (`bool`, *optional*, defaults to `False`):
|
| 106 |
+
Whether to use a bias in the query, key, value and output projection layers during self-attention.
|
| 107 |
+
attention_dropout (`float`, *optional*, defaults to 0.0):
|
| 108 |
+
The dropout ratio for the attention probabilities.
|
| 109 |
+
head_dim (`int`, *optional*, defaults to 256):
|
| 110 |
+
Projection weights dimension in multi-head attention.
|
| 111 |
+
linear_conv_kernel_dim (`int`, *optional*, defaults to 4):
|
| 112 |
+
Kernel size of the convolution used in linear attention layers.
|
| 113 |
+
linear_key_head_dim (`int`, *optional*, defaults to 128):
|
| 114 |
+
Dimension of each key head in linear attention.
|
| 115 |
+
linear_value_head_dim (`int`, *optional*, defaults to 128):
|
| 116 |
+
Dimension of each value head in linear attention.
|
| 117 |
+
linear_num_key_heads (`int`, *optional*, defaults to 16):
|
| 118 |
+
Number of key heads used in linear attention layers.
|
| 119 |
+
linear_num_value_heads (`int`, *optional*, defaults to 32):
|
| 120 |
+
Number of value heads used in linear attention layers.
|
| 121 |
+
moe_intermediate_size (`int`, *optional*, defaults to 512):
|
| 122 |
+
Intermediate size of the routed expert.
|
| 123 |
+
shared_expert_intermediate_size (`int`, *optional*, defaults to 512):
|
| 124 |
+
Intermediate size of the shared expert.
|
| 125 |
+
num_experts_per_tok (`int`, *optional*, defaults to 8):
|
| 126 |
+
Number of selected experts.
|
| 127 |
+
num_experts (`int`, *optional*, defaults to 256):
|
| 128 |
+
Number of routed experts.
|
| 129 |
+
output_router_logits (`bool`, *optional*, defaults to `False`):
|
| 130 |
+
Whether or not the router logits should be returned by the model. Enabling this will also
|
| 131 |
+
allow the model to output the auxiliary loss, including load balancing loss and router z-loss.
|
| 132 |
+
router_aux_loss_coef (`float`, *optional*, defaults to 0.001):
|
| 133 |
+
The aux loss factor for the total loss.
|
| 134 |
+
layer_types (`list[str]`, *optional*):
|
| 135 |
+
Types of each layer (attention or linear).
|
| 136 |
+
pad_token_id (`int`, *optional*):
|
| 137 |
+
Padding token id.
|
| 138 |
+
bos_token_id (`int`, *optional*):
|
| 139 |
+
Beginning of stream token id.
|
| 140 |
+
eos_token_id (`int`, *optional*):
|
| 141 |
+
End of stream token id.
|
| 142 |
+
|
| 143 |
+
```python
|
| 144 |
+
>>> from transformers import InternS2PreviewTextModel, InternS2PreviewTextConfig
|
| 145 |
+
|
| 146 |
+
>>> # Initializing a Qwen3.5-MoE style configuration
|
| 147 |
+
>>> configuration = InternS2PreviewTextConfig()
|
| 148 |
+
|
| 149 |
+
>>> # Initializing a model from the Qwen3.5-35B-A3B style configuration
|
| 150 |
+
>>> model = InternS2PreviewTextModel(configuration)
|
| 151 |
+
|
| 152 |
+
>>> # Accessing the model configuration
|
| 153 |
+
>>> configuration = model.config
|
| 154 |
+
```
|
| 155 |
+
"""
|
| 156 |
+
|
| 157 |
+
# NOTE: `model_type` is kept as `qwen3_5_moe_text` because transformers hardcodes weight-renaming logic keyed
|
| 158 |
+
# on model_type (e.g. `model_dtype`); reusing the parent's value ensures correct weight loading via
|
| 159 |
+
# `AutoModelForCausalLM.from_pretrained`.
|
| 160 |
+
model_type = "qwen3_5_moe_text"
|
| 161 |
+
keys_to_ignore_at_inference = ["past_key_values"]
|
| 162 |
+
|
| 163 |
+
base_model_tp_plan = {
|
| 164 |
+
"layers.*.self_attn.q_proj": "colwise",
|
| 165 |
+
"layers.*.self_attn.k_proj": "colwise",
|
| 166 |
+
"layers.*.self_attn.v_proj": "colwise",
|
| 167 |
+
"layers.*.self_attn.o_proj": "rowwise",
|
| 168 |
+
"layers.*.mlp.experts.gate_up_proj": "packed_colwise",
|
| 169 |
+
"layers.*.mlp.experts.down_proj": "rowwise",
|
| 170 |
+
"layers.*.mlp.shared_expert.gate_proj": "colwise",
|
| 171 |
+
"layers.*.mlp.shared_expert.up_proj": "colwise",
|
| 172 |
+
"layers.*.mlp.shared_expert.down_proj": "rowwise",
|
| 173 |
+
}
|
| 174 |
+
base_model_pp_plan = {
|
| 175 |
+
"embed_tokens": (["input_ids"], ["inputs_embeds"]),
|
| 176 |
+
"layers": (["hidden_states", "attention_mask"], ["hidden_states"]),
|
| 177 |
+
"norm": (["hidden_states"], ["hidden_states"]),
|
| 178 |
+
}
|
| 179 |
+
base_config_key = "text_config"
|
| 180 |
+
|
| 181 |
+
def __init__(
|
| 182 |
+
self,
|
| 183 |
+
vocab_size=248320,
|
| 184 |
+
hidden_size=2048,
|
| 185 |
+
num_hidden_layers=40,
|
| 186 |
+
num_attention_heads=16,
|
| 187 |
+
num_key_value_heads=2,
|
| 188 |
+
hidden_act="silu",
|
| 189 |
+
max_position_embeddings=32768,
|
| 190 |
+
initializer_range=0.02,
|
| 191 |
+
rms_norm_eps=1e-6,
|
| 192 |
+
use_cache=True,
|
| 193 |
+
tie_word_embeddings=False,
|
| 194 |
+
rope_parameters: RopeParameters | dict[str, RopeParameters] | None = None,
|
| 195 |
+
attention_bias=False,
|
| 196 |
+
attention_dropout=0.0,
|
| 197 |
+
head_dim=256,
|
| 198 |
+
linear_conv_kernel_dim=4,
|
| 199 |
+
linear_key_head_dim=128,
|
| 200 |
+
linear_value_head_dim=128,
|
| 201 |
+
linear_num_key_heads=16,
|
| 202 |
+
linear_num_value_heads=32,
|
| 203 |
+
moe_intermediate_size=512,
|
| 204 |
+
shared_expert_intermediate_size=512,
|
| 205 |
+
num_experts_per_tok=8,
|
| 206 |
+
num_experts=256,
|
| 207 |
+
output_router_logits=False,
|
| 208 |
+
router_aux_loss_coef=0.001,
|
| 209 |
+
layer_types=None,
|
| 210 |
+
pad_token_id: int | None = None,
|
| 211 |
+
bos_token_id: int | None = None,
|
| 212 |
+
eos_token_id: int | None = None,
|
| 213 |
+
**kwargs,
|
| 214 |
+
):
|
| 215 |
+
kwargs["ignore_keys_at_rope_validation"] = {"mrope_section", "mrope_interleaved"}
|
| 216 |
+
self.pad_token_id = pad_token_id
|
| 217 |
+
self.bos_token_id = bos_token_id
|
| 218 |
+
self.eos_token_id = eos_token_id
|
| 219 |
+
self.tie_word_embeddings = tie_word_embeddings
|
| 220 |
+
self.vocab_size = vocab_size
|
| 221 |
+
self.max_position_embeddings = max_position_embeddings
|
| 222 |
+
self.hidden_size = hidden_size
|
| 223 |
+
self.num_hidden_layers = num_hidden_layers
|
| 224 |
+
self.num_attention_heads = num_attention_heads
|
| 225 |
+
self.num_key_value_heads = num_key_value_heads
|
| 226 |
+
self.hidden_act = hidden_act
|
| 227 |
+
self.initializer_range = initializer_range
|
| 228 |
+
self.rms_norm_eps = rms_norm_eps
|
| 229 |
+
self.use_cache = use_cache
|
| 230 |
+
self.attention_bias = attention_bias
|
| 231 |
+
self.attention_dropout = attention_dropout
|
| 232 |
+
self.head_dim = head_dim
|
| 233 |
+
self.rope_parameters = rope_parameters
|
| 234 |
+
kwargs.setdefault("partial_rotary_factor", 0.25) # assign default for BC
|
| 235 |
+
|
| 236 |
+
self.layer_types = layer_types
|
| 237 |
+
if self.layer_types is None:
|
| 238 |
+
interval_pattern = kwargs.get("full_attention_interval", 4)
|
| 239 |
+
self.layer_types = [
|
| 240 |
+
"linear_attention" if bool((i + 1) % interval_pattern) else "full_attention"
|
| 241 |
+
for i in range(self.num_hidden_layers)
|
| 242 |
+
]
|
| 243 |
+
layer_type_validation(self.layer_types, self.num_hidden_layers)
|
| 244 |
+
|
| 245 |
+
# linear attention part
|
| 246 |
+
self.linear_conv_kernel_dim = linear_conv_kernel_dim
|
| 247 |
+
self.linear_key_head_dim = linear_key_head_dim
|
| 248 |
+
self.linear_value_head_dim = linear_value_head_dim
|
| 249 |
+
self.linear_num_key_heads = linear_num_key_heads
|
| 250 |
+
self.linear_num_value_heads = linear_num_value_heads
|
| 251 |
+
self.moe_intermediate_size = moe_intermediate_size
|
| 252 |
+
self.shared_expert_intermediate_size = shared_expert_intermediate_size
|
| 253 |
+
self.num_experts_per_tok = num_experts_per_tok
|
| 254 |
+
self.num_experts = num_experts
|
| 255 |
+
self.output_router_logits = output_router_logits
|
| 256 |
+
self.router_aux_loss_coef = router_aux_loss_coef
|
| 257 |
+
super().__init__(**kwargs)
|
| 258 |
+
|
| 259 |
+
|
| 260 |
+
class InternS2PreviewTimeSeriesConfig(PreTrainedConfig):
|
| 261 |
+
r"""
|
| 262 |
+
This is the configuration class to store the configuration of a [`InternS2PreviewTimeSeriesModel`]. It is used to instantiate a
|
| 263 |
+
InternS2PreviewTimeSeries model according to the specified arguments, defining the model architecture.
|
| 264 |
+
|
| 265 |
+
Args:
|
| 266 |
+
ts_adapt_in_dim (`int`, *optional*, defaults to 256):
|
| 267 |
+
The input dimension of the time series adapter.
|
| 268 |
+
ts_adapt_out_dim (`int`, *optional*, defaults to 1024):
|
| 269 |
+
The output dimension of the time series adapter.
|
| 270 |
+
ts_hidden_dim (`int`, *optional*, defaults to 1024):
|
| 271 |
+
The hidden dimension of the time series model.
|
| 272 |
+
ts_cnn_channels (`list[int]`, *optional*, defaults to [1, 32, 64, 128, 128]):
|
| 273 |
+
The channels of the time series CNN.
|
| 274 |
+
ts_cnn_kernel_sizes (`list[int]`, *optional*, defaults to [3, 5, 5, 5]):
|
| 275 |
+
The kernel sizes of the time series CNN.
|
| 276 |
+
ts_cnn_strides (`list[int]`, *optional*, defaults to [2, 4, 4, 5]):
|
| 277 |
+
The strides of the time series CNN.
|
| 278 |
+
ts_cnn_paddings (`list[int]`, *optional*, defaults to [1, 2, 2, 2]):
|
| 279 |
+
The paddings of the time series CNN.
|
| 280 |
+
ts_concat_subsampling_in_channels (`int`, *optional*, defaults to 128):
|
| 281 |
+
The input channels of the time series concat subsampling.
|
| 282 |
+
ts_concat_subsampling_concat_size (`int`, *optional*, defaults to 2):
|
| 283 |
+
The concat size of the time series concat subsampling.
|
| 284 |
+
**super_kwargs:
|
| 285 |
+
Additional keyword arguments passed along to the base class `WhisperConfig`.
|
| 286 |
+
"""
|
| 287 |
+
|
| 288 |
+
model_type = "interns2_preview_time_series"
|
| 289 |
+
base_config_key = "ts_config"
|
| 290 |
+
|
| 291 |
+
def __init__(
|
| 292 |
+
self,
|
| 293 |
+
activation_dropout: float = 0.0,
|
| 294 |
+
activation_function: str = "gelu",
|
| 295 |
+
attention_dropout: float = 0.0,
|
| 296 |
+
d_model: int = 768,
|
| 297 |
+
dropout: float = 0.0,
|
| 298 |
+
encoder_attention_heads: int = 8,
|
| 299 |
+
encoder_ffn_dim: int = 3072,
|
| 300 |
+
encoder_layerdrop: float = 0.0,
|
| 301 |
+
encoder_layers: int = 17,
|
| 302 |
+
max_source_positions: int = 1500,
|
| 303 |
+
num_mel_bins: int = 80,
|
| 304 |
+
out_hidden_size: int = 2048,
|
| 305 |
+
scale_embedding: bool = False,
|
| 306 |
+
ts_adapt_in_dim: int = 256,
|
| 307 |
+
ts_adapt_out_dim: int = 1024,
|
| 308 |
+
ts_hidden_dim: int = 1024,
|
| 309 |
+
**super_kwargs,
|
| 310 |
+
):
|
| 311 |
+
super().__init__(**super_kwargs)
|
| 312 |
+
|
| 313 |
+
self.auto_map = {
|
| 314 |
+
"AutoConfig": "configuration_interns2_preview.InternS2PreviewTimeSeriesConfig",
|
| 315 |
+
"AutoModel": "modeling_interns2_preview.InternS2PreviewTimeSeriesModel",
|
| 316 |
+
}
|
| 317 |
+
self.activation_dropout = activation_dropout
|
| 318 |
+
self.activation_function = activation_function
|
| 319 |
+
self.attention_dropout = attention_dropout
|
| 320 |
+
self.d_model = d_model
|
| 321 |
+
self.dropout = dropout
|
| 322 |
+
self.encoder_attention_heads = encoder_attention_heads
|
| 323 |
+
self.encoder_ffn_dim = encoder_ffn_dim
|
| 324 |
+
self.encoder_layerdrop = encoder_layerdrop
|
| 325 |
+
self.encoder_layers = encoder_layers
|
| 326 |
+
self.max_source_positions = max_source_positions
|
| 327 |
+
self.num_mel_bins = num_mel_bins
|
| 328 |
+
self.out_hidden_size = out_hidden_size
|
| 329 |
+
self.scale_embedding = scale_embedding
|
| 330 |
+
self.ts_adapt_in_dim = ts_adapt_in_dim
|
| 331 |
+
self.ts_adapt_out_dim = ts_adapt_out_dim
|
| 332 |
+
self.ts_hidden_dim = ts_hidden_dim
|
| 333 |
+
|
| 334 |
+
assert self.ts_adapt_out_dim == self.ts_hidden_dim, "ts_adapt_out_dim should be equal to ts_hidden_dim"
|
| 335 |
+
|
| 336 |
+
|
| 337 |
+
class InternS2PreviewConfig(PreTrainedConfig):
|
| 338 |
+
r"""
|
| 339 |
+
This is the configuration class to store the configuration of a [`InternS2PreviewModel`]. It is used to instantiate a
|
| 340 |
+
Qwen3.5-MoE model according to the specified arguments, defining the model architecture. Instantiating a configuration
|
| 341 |
+
with the defaults will yield a similar configuration to that of
|
| 342 |
+
Qwen3.5-35B-A3B-Instruct [Qwen/Qwen3.5-35B-A3B-Instruct](https://huggingface.co/Qwen/Qwen3.5-35B-A3B-Instruct).
|
| 343 |
+
|
| 344 |
+
Configuration objects inherit from [`PreTrainedConfig`] and can be used to control the model outputs. Read the
|
| 345 |
+
documentation from [`PreTrainedConfig`] for more information.
|
| 346 |
+
|
| 347 |
+
|
| 348 |
+
Args:
|
| 349 |
+
text_config (`Union[PreTrainedConfig, dict]`, *optional*, defaults to `Qwen3_5TextConfig`):
|
| 350 |
+
The config object or dictionary of the text backbone.
|
| 351 |
+
vision_config (`Union[PreTrainedConfig, dict]`, *optional*, defaults to `Qwen3_5VisionConfig`):
|
| 352 |
+
The config object or dictionary of the vision backbone.
|
| 353 |
+
image_token_id (`int`, *optional*, defaults to 248056):
|
| 354 |
+
The image token index to encode the image prompt.
|
| 355 |
+
video_token_id (`int`, *optional*, defaults to 248057):
|
| 356 |
+
The video token index to encode the image prompt.
|
| 357 |
+
vision_start_token_id (`int`, *optional*, defaults to 248053):
|
| 358 |
+
The start token index to encode the image prompt.
|
| 359 |
+
vision_end_token_id (`int`, *optional*, defaults to 248054):
|
| 360 |
+
The end token index to encode the image prompt.
|
| 361 |
+
tie_word_embeddings (`bool`, *optional*, defaults to `False`):
|
| 362 |
+
Whether to tie the word embeddings.
|
| 363 |
+
|
| 364 |
+
```python
|
| 365 |
+
>>> from transformers import InternS2PreviewForConditionalGeneration, InternS2PreviewConfig
|
| 366 |
+
|
| 367 |
+
>>> # Initializing a Qwen3.5-MoE style configuration
|
| 368 |
+
>>> configuration = InternS2PreviewConfig()
|
| 369 |
+
|
| 370 |
+
>>> # Initializing a model from the Qwen3.5-35B-A3B style configuration
|
| 371 |
+
>>> model = InternS2PreviewForConditionalGeneration(configuration)
|
| 372 |
+
|
| 373 |
+
>>> # Accessing the model configuration
|
| 374 |
+
>>> configuration = model.config
|
| 375 |
+
```"""
|
| 376 |
+
|
| 377 |
+
model_type = "intern_s2_preview"
|
| 378 |
+
sub_configs = {
|
| 379 |
+
"vision_config": InternS2PreviewVisionConfig,
|
| 380 |
+
"text_config": InternS2PreviewTextConfig,
|
| 381 |
+
"ts_config": InternS2PreviewTimeSeriesConfig,
|
| 382 |
+
}
|
| 383 |
+
keys_to_ignore_at_inference = ["past_key_values"]
|
| 384 |
+
|
| 385 |
+
def __init__(
|
| 386 |
+
self,
|
| 387 |
+
text_config=None,
|
| 388 |
+
vision_config=None,
|
| 389 |
+
image_token_id=248056,
|
| 390 |
+
video_token_id=248057,
|
| 391 |
+
vision_start_token_id=248053,
|
| 392 |
+
vision_end_token_id=248054,
|
| 393 |
+
tie_word_embeddings=False,
|
| 394 |
+
ts_config=None,
|
| 395 |
+
ts_token_id=248093,
|
| 396 |
+
ts_start_id=248091,
|
| 397 |
+
ts_end_id=248092,
|
| 398 |
+
**kwargs,
|
| 399 |
+
):
|
| 400 |
+
if isinstance(ts_config, dict):
|
| 401 |
+
self.ts_config = self.sub_configs["ts_config"](**ts_config)
|
| 402 |
+
elif ts_config is None:
|
| 403 |
+
self.ts_config = self.sub_configs["ts_config"]()
|
| 404 |
+
|
| 405 |
+
self.ts_token_id = ts_token_id
|
| 406 |
+
self.ts_start_id = ts_start_id
|
| 407 |
+
self.ts_end_id = ts_end_id
|
| 408 |
+
if isinstance(vision_config, dict):
|
| 409 |
+
self.vision_config = self.sub_configs["vision_config"](**vision_config)
|
| 410 |
+
elif vision_config is None:
|
| 411 |
+
self.vision_config = self.sub_configs["vision_config"]()
|
| 412 |
+
|
| 413 |
+
if isinstance(text_config, dict):
|
| 414 |
+
self.text_config = self.sub_configs["text_config"](**text_config)
|
| 415 |
+
elif text_config is None:
|
| 416 |
+
self.text_config = self.sub_configs["text_config"]()
|
| 417 |
+
|
| 418 |
+
self.image_token_id = image_token_id
|
| 419 |
+
self.video_token_id = video_token_id
|
| 420 |
+
self.vision_start_token_id = vision_start_token_id
|
| 421 |
+
self.vision_end_token_id = vision_end_token_id
|
| 422 |
+
self.tie_word_embeddings = tie_word_embeddings
|
| 423 |
+
super().__init__(**kwargs)
|
| 424 |
+
self.auto_map = {
|
| 425 |
+
"AutoConfig": "configuration_interns2_preview.InternS2PreviewConfig",
|
| 426 |
+
"AutoModelForCausalLM": "modeling_interns2_preview.InternS2PreviewForCausalLM",
|
| 427 |
+
"AutoModel": "modeling_interns2_preview.InternS2PreviewModel",
|
| 428 |
+
"AutoModelForImageTextToText": "modeling_interns2_preview.InternS2PreviewForConditionalGeneration",
|
| 429 |
+
"AutoModelForMultimodalLM": "modeling_interns2_preview.InternS2PreviewForConditionalGeneration",
|
| 430 |
+
}
|
| 431 |
+
self.architectures = ["InternS2PreviewForConditionalGeneration"]
|
| 432 |
+
|
| 433 |
+
|
| 434 |
+
__all__ = ["InternS2PreviewConfig", "InternS2PreviewTextConfig"]
|
deployment_guide.md
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Intern-S2-Preview-397B Deployment Guide
|
| 2 |
+
|
| 3 |
+
We recommend deploying the Intern-S2-Preview-397B model on H100 (x8) or H200 (x8) nodes. The next section provides deployment examples for the configurations listed below:
|
| 4 |
+
|
| 5 |
+
- Basic serving without MTP
|
| 6 |
+
- MTP speculative decoding
|
| 7 |
+
- Long-context inference with YaRN RoPE configuration
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
## LMDeploy (>=0.14.0)
|
| 11 |
+
|
| 12 |
+
- Basic Serving Without MTP
|
| 13 |
+
|
| 14 |
+
```bash
|
| 15 |
+
# proxy server
|
| 16 |
+
lmdeploy serve proxy --server-name ${proxy_server_ip} --server-port ${proxy_server_port}
|
| 17 |
+
|
| 18 |
+
# api_server
|
| 19 |
+
lmdeploy serve api_server \
|
| 20 |
+
internlm/Intern-S2-Preview-397B \
|
| 21 |
+
--trust-remote-code \
|
| 22 |
+
--backend pytorch \
|
| 23 |
+
--dp 4 \
|
| 24 |
+
--ep 8 \
|
| 25 |
+
--enable-prefix-caching \
|
| 26 |
+
--proxy-url http://${proxy_server_ip}:${proxy_server_port} \
|
| 27 |
+
--reasoning-parser default \
|
| 28 |
+
--tool-call-parser interns2-preview
|
| 29 |
+
```
|
| 30 |
+
|
| 31 |
+
- Serving With MTP
|
| 32 |
+
|
| 33 |
+
```bash
|
| 34 |
+
lmdeploy serve api_server \
|
| 35 |
+
internlm/Intern-S2-Preview-397B \
|
| 36 |
+
--trust-remote-code \
|
| 37 |
+
--backend pytorch \
|
| 38 |
+
--dp 4 \
|
| 39 |
+
--ep 8 \
|
| 40 |
+
--enable-prefix-caching \
|
| 41 |
+
--proxy-url http://${proxy_server_ip}:${proxy_server_port} \
|
| 42 |
+
--reasoning-parser default \
|
| 43 |
+
--tool-call-parser interns2-preview \
|
| 44 |
+
--speculative-algorithm qwen3_5_mtp \
|
| 45 |
+
--speculative-num-draft-tokens 4 \
|
| 46 |
+
--max-batch-size 256
|
| 47 |
+
```
|
| 48 |
+
|
| 49 |
+
- Long-Context Serving
|
| 50 |
+
|
| 51 |
+
For long-context inference, configure both `--session-len` and YaRN RoPE parameters. The following example uses a 512k context length:
|
| 52 |
+
|
| 53 |
+
```bash
|
| 54 |
+
lmdeploy serve api_server \
|
| 55 |
+
internlm/Intern-S2-Preview-397B \
|
| 56 |
+
--trust-remote-code \
|
| 57 |
+
--backend pytorch \
|
| 58 |
+
--dp 4 \
|
| 59 |
+
--ep 8 \
|
| 60 |
+
--enable-prefix-caching \
|
| 61 |
+
--reasoning-parser default \
|
| 62 |
+
--tool-call-parser interns2-preview \
|
| 63 |
+
--session-len 512000 \
|
| 64 |
+
--max-batch-size 64 \
|
| 65 |
+
--hf-overrides '{"text_config": {"rope_parameters": {"mrope_interleaved": true, "mrope_section": [11, 11, 10], "rope_type": "yarn", "rope_theta": 10000000, "partial_rotary_factor": 0.25, "factor": 4.0, "original_max_position_embeddings": 262144}}}'
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
## vLLM (>=v0.22.1)
|
| 69 |
+
|
| 70 |
+
- Basic Serving Without MTP
|
| 71 |
+
|
| 72 |
+
```bash
|
| 73 |
+
export VLLM_DEEP_GEMM_WARMUP=skip
|
| 74 |
+
export VLLM_USE_DEEP_GEMM=0
|
| 75 |
+
export VLLM_FLASHINFER_MOE_BACKEND=latency
|
| 76 |
+
|
| 77 |
+
vllm serve internlm/Intern-S2-Preview-397B \
|
| 78 |
+
--trust-remote-code \
|
| 79 |
+
--tensor-parallel-size 8 \
|
| 80 |
+
--enable-auto-tool-choice \
|
| 81 |
+
--tool-call-parser qwen3_coder \
|
| 82 |
+
--reasoning-parser qwen3 \
|
| 83 |
+
--mm-encoder-tp-mode data
|
| 84 |
+
```
|
| 85 |
+
|
| 86 |
+
- Serving With MTP
|
| 87 |
+
|
| 88 |
+
```bash
|
| 89 |
+
export VLLM_DEEP_GEMM_WARMUP=skip
|
| 90 |
+
export VLLM_USE_DEEP_GEMM=0
|
| 91 |
+
export VLLM_FLASHINFER_MOE_BACKEND=latency
|
| 92 |
+
|
| 93 |
+
vllm serve internlm/Intern-S2-Preview-397B \
|
| 94 |
+
--trust-remote-code \
|
| 95 |
+
--tensor-parallel-size 8 \
|
| 96 |
+
--enable-auto-tool-choice \
|
| 97 |
+
--tool-call-parser qwen3_coder \
|
| 98 |
+
--mm-encoder-tp-mode data \
|
| 99 |
+
--reasoning-parser qwen3 \
|
| 100 |
+
--speculative-config '{"method":"mtp","num_speculative_tokens":3}'
|
| 101 |
+
```
|
| 102 |
+
|
| 103 |
+
- Long-Context Serving
|
| 104 |
+
|
| 105 |
+
```bash
|
| 106 |
+
VLLM_ALLOW_LONG_MAX_MODEL_LEN=1 vllm serve internlm/Intern-S2-Preview-397B \
|
| 107 |
+
--tensor-parallel-size 8 \
|
| 108 |
+
--max-model-len 1010000 \
|
| 109 |
+
--reasoning-parser qwen3 \
|
| 110 |
+
--hf-overrides '{"text_config": {"rope_parameters": {"mrope_interleaved": true, "mrope_section": [11, 11, 10], "rope_type": "yarn", "rope_theta": 10000000, "partial_rotary_factor": 0.25, "factor": 4.0, "original_max_position_embeddings": 262144}}}'
|
| 111 |
+
```
|
| 112 |
+
|
| 113 |
+
## SGLang (>=v0.5.13)
|
| 114 |
+
|
| 115 |
+
- Basic Serving Without MTP
|
| 116 |
+
|
| 117 |
+
```bash
|
| 118 |
+
python3 -m sglang.launch_server \
|
| 119 |
+
--model-path internlm/Intern-S2-Preview-397B \
|
| 120 |
+
--trust-remote-code \
|
| 121 |
+
--tp-size 8 \
|
| 122 |
+
--mem-fraction-static 0.8 \
|
| 123 |
+
--enable-flashinfer-allreduce-fusion \
|
| 124 |
+
--reasoning-parser qwen3 \
|
| 125 |
+
--tool-call-parser qwen3_coder
|
| 126 |
+
```
|
| 127 |
+
|
| 128 |
+
- Serving With MTP
|
| 129 |
+
|
| 130 |
+
```bash
|
| 131 |
+
SGLANG_ENABLE_SPEC_V2=1 \
|
| 132 |
+
python3 -m sglang.launch_server \
|
| 133 |
+
--model-path internLM/Intern-S2-Preview-397B \
|
| 134 |
+
--trust-remote-code \
|
| 135 |
+
--tp-size 8 \
|
| 136 |
+
--reasoning-parser qwen3 \
|
| 137 |
+
--tool-call-parser qwen3_coder \
|
| 138 |
+
--mem-fraction-static 0.8 \
|
| 139 |
+
--mamba-scheduler-strategy extra_buffer \
|
| 140 |
+
--enable-flashinfer-allreduce-fusion \
|
| 141 |
+
--speculative-algo 'NEXTN' \
|
| 142 |
+
--speculative-eagle-topk 1 \
|
| 143 |
+
--speculative-num-steps 3 \
|
| 144 |
+
--speculative-num-draft-tokens 4
|
| 145 |
+
```
|
figs/general_tasks.png
ADDED
|
Git LFS Details
|
figs/scientific_tasks.png
ADDED
|
Git LFS Details
|
figs/title.png
ADDED
|
Git LFS Details
|
generation_config.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token_id": 248044,
|
| 3 |
+
"do_sample": true,
|
| 4 |
+
"eos_token_id": [
|
| 5 |
+
248046,
|
| 6 |
+
248044
|
| 7 |
+
],
|
| 8 |
+
"pad_token_id": 248044,
|
| 9 |
+
"temperature": 0.6,
|
| 10 |
+
"top_k": 20,
|
| 11 |
+
"top_p": 0.95,
|
| 12 |
+
"transformers_version": "4.57.0.dev0"
|
| 13 |
+
}
|
merges.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
model-00001-of-00190.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3285d7e540e05a592f4eac1bcef18c9671bea61e20229d38c0c28ebb00aeabf4
|
| 3 |
+
size 4295038192
|
model-00002-of-00190.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:32903fe80ebcc6f4843a509669ae41d4861615c971889aa61f5df35fc435e8a1
|
| 3 |
+
size 4295038280
|
model-00003-of-00190.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2110ee91e5a634706de2f9b0ee17be003c3a9399742a910afc7f737d39cb7dee
|
| 3 |
+
size 4295038752
|
model-00004-of-00190.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3a5c22f5342cd46617f10096296fd6607c78352e3d5fecbf9c1d635bd9d02c8c
|
| 3 |
+
size 4295038704
|
model-00005-of-00190.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4e2ef3c43298d42fb4fd26392430635bb0b40944652a81b4e8d7ac664137be0e
|
| 3 |
+
size 4295038728
|
model-00006-of-00190.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3d83ff685266d947a139ec1d369b91de516ba2ee3a6b9a813d24d6f78fc7c474
|
| 3 |
+
size 4295038752
|
model-00007-of-00190.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:938f820bd966f63a0cf753acd6e6a7e3c9bf269eff070378140220362e8319fd
|
| 3 |
+
size 4295038704
|
model-00008-of-00190.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5bf05ee2cb4180fe3937fed8579059b0898e63eb43420433188790db4004d15a
|
| 3 |
+
size 4295038728
|
model-00009-of-00190.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ab31d4602f63e4d465817d57f8fa7a38ac93ff8db87d8949d7c3cb5ad20a196d
|
| 3 |
+
size 4295038752
|
model-00010-of-00190.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4fa0d45652567c430429384b76970a96635e422177b92217926691db6d45febe
|
| 3 |
+
size 4295038704
|
model-00011-of-00190.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a5a4ab86574bbd5aa66764550f68d5ce748148d1f8f6eb04f137aa17ef7f0115
|
| 3 |
+
size 4295038728
|
model-00012-of-00190.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2d6c9671a6faf1899a2d7fa0954573784214a2b3036d2b17d429a4839c80ba97
|
| 3 |
+
size 1879077592
|
model-00013-of-00190.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c051f04a2ce19d73c0604fc5e104838b0b45fcd711b5709c201d17cecadeec78
|
| 3 |
+
size 4286686672
|
model-00014-of-00190.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a8076d7a604e92f324be555207cedcc5875b2ad78fb7b60b046e476cf90a0871
|
| 3 |
+
size 4239036360
|
model-00015-of-00190.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:95cd3abfac4392fb45d2c30e755596156def8bc3b066ee9f4fc0d51455e4f7bb
|
| 3 |
+
size 4208502728
|
model-00016-of-00190.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9a32969a2f846cea09803da807f45abfbad69ae5fa2d119b678c2623b1217e4d
|
| 3 |
+
size 4242057144
|
model-00017-of-00190.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f1fa91e359ffd91cc0dcbfb14000fae5618478e4573f75e2b85f82840e4da807
|
| 3 |
+
size 2672758192
|
model-00018-of-00190.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7343161d2271894a61c4a1e9c7f74fac82238b771136eb7e350848e0d911aba5
|
| 3 |
+
size 4286662776
|
model-00019-of-00190.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:56d74a12fff5a50fc87dd4278552399a677f80ddfa4a3eb22d1fe0334d7c527e
|
| 3 |
+
size 4295038368
|
model-00020-of-00190.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:44fa60c1263a7072e62b14df56700c1bd017826f5cbe497801ba1864a1e37790
|
| 3 |
+
size 4295038688
|
model-00021-of-00190.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d804cca276a07c23d03eaf08668b9a9e4d848df940e934b68464abaa3267d662
|
| 3 |
+
size 4295038880
|
model-00022-of-00190.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f2bb3ba2a28543c34720317c5b4d1e41e25b25a194980a72a8303876444c2b40
|
| 3 |
+
size 4295038880
|
model-00023-of-00190.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0b2382221eef8257709e970351e783bfd1e0ff2bd9d9713de6806074eec67137
|
| 3 |
+
size 4295038904
|
model-00024-of-00190.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:33d3e9e5decff697ee762d3907359ca3ac41e5ad38779d1da26666304ed35c0d
|
| 3 |
+
size 4295038880
|
model-00025-of-00190.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1823edd02b8cf428c78a1ad24510e6d851c00f8de651ba4993e41e5651bc1baa
|
| 3 |
+
size 4295038880
|
model-00026-of-00190.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0148fdd3b08f77ca3e3f9542b7e7bc0e74324f916f1c52b2266bb685c3610e07
|
| 3 |
+
size 4295038904
|
model-00027-of-00190.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3beec6d4bacab392be6778c5008742a2d2eb1d7a5add593977adeafc72a2b448
|
| 3 |
+
size 4295038880
|
model-00028-of-00190.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3358a900bc982810a7ebdc30fd11d8cc4bec062fb6d9edf17f9b88d7bc5f0288
|
| 3 |
+
size 4295038880
|
model-00029-of-00190.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bb53dbb80239bc914149bd58e325245fe80a4fc4524e6bc941b6df2e6eac9597
|
| 3 |
+
size 4295037176
|
model-00030-of-00190.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:31a340e801f3bbcd76d8b453e76b2dc12648127757bbfbb80ce83dd04e252544
|
| 3 |
+
size 4295038368
|
model-00031-of-00190.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:eeb7f8f3d4e193c13fd88d80adca4d17636db1b6e6c1de250345c73c96613195
|
| 3 |
+
size 4295038440
|
model-00032-of-00190.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7dd82bf47583c5a766a165ffb4958c65af7b31f21e8ce762b500e3bc0ee71610
|
| 3 |
+
size 4295038904
|
model-00033-of-00190.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fab735fd684d57db8b6244373c9ff5536485e1e839a85cda042a3634fc82e8ef
|
| 3 |
+
size 4295038880
|
model-00034-of-00190.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:24d600dc969e93d6190621419b1c62e553fba8b2dd6250a177444cd1bedaaddb
|
| 3 |
+
size 4295038880
|
model-00035-of-00190.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:26da13c3470070def0be89898bd7248ca840c37571ed99e12cecf10a87053af4
|
| 3 |
+
size 4295038904
|
model-00036-of-00190.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0faac133df5ea40d3c1dc102f207edcbeb372f749f1ffbe097f209b4c1ff11e0
|
| 3 |
+
size 4295038880
|
model-00037-of-00190.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d7430841a0efb6609f8f587bef70c7bf23d83c9f9cd2c55d8214a7154e6fdcc4
|
| 3 |
+
size 4295038880
|
model-00038-of-00190.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:28bbbee5fcb07dc021fc1e2b7518ae2d222b782f364d9eaf4e84aae986c19a87
|
| 3 |
+
size 4295038904
|