Image-Text-to-Text
Transformers
qwen3_5
embedding
multimodal
quantized
fp8
video-text-to-text
conversational
custom_code
Instructions to use Weidows/WeMM-Embedding-2B-FP8 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Weidows/WeMM-Embedding-2B-FP8 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="Weidows/WeMM-Embedding-2B-FP8", 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 AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("Weidows/WeMM-Embedding-2B-FP8", trust_remote_code=True) model = AutoModelForMultimodalLM.from_pretrained("Weidows/WeMM-Embedding-2B-FP8", trust_remote_code=True, device_map="auto") 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?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Weidows/WeMM-Embedding-2B-FP8 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Weidows/WeMM-Embedding-2B-FP8" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Weidows/WeMM-Embedding-2B-FP8", "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/Weidows/WeMM-Embedding-2B-FP8
- SGLang
How to use Weidows/WeMM-Embedding-2B-FP8 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 "Weidows/WeMM-Embedding-2B-FP8" \ --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": "Weidows/WeMM-Embedding-2B-FP8", "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 "Weidows/WeMM-Embedding-2B-FP8" \ --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": "Weidows/WeMM-Embedding-2B-FP8", "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 Weidows/WeMM-Embedding-2B-FP8 with Docker Model Runner:
docker model run hf.co/Weidows/WeMM-Embedding-2B-FP8
Upload folder using huggingface_hub
Browse files- .gitattributes +1 -0
- LICENSE +435 -0
- README.md +66 -0
- chat_template.jinja +154 -0
- config.json +113 -0
- config_sentence_transformers.json +11 -0
- embedding_chat_template.jinja +28 -0
- fp8_scales.json +1 -0
- model.fp8.safetensors +3 -0
- modeling_st_wemm.py +70 -0
- modeling_wemm_embedding.py +33 -0
- modules.json +8 -0
- patch_sglang_video.py +73 -0
- processor_config.json +60 -0
- sentence_bert_config.json +37 -0
- tokenizer.json +3 -0
- tokenizer_config.json +32 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ 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 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
LICENSE
ADDED
|
@@ -0,0 +1,435 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Tencent is pleased to support the open source community by making WeMM-Embedding-2B available.
|
| 2 |
+
|
| 3 |
+
Copyright (C) 2026 Tencent. All rights reserved.
|
| 4 |
+
|
| 5 |
+
The open-source software and/or models included in this distribution may have been modified by Tencent (“Tencent Modifications”). All Tencent Modifications are Copyright (C) Tencent.
|
| 6 |
+
|
| 7 |
+
WeMM-Embedding-2B is licensed under Apache-2.0, except for the third-party components listed below, which remain licensed under their respective original terms. WeMM-Embedding-2B does not impose any additional restrictions beyond those specified in the original licenses of these third-party components. Users are required to comply with all applicable terms and conditions of the original licenses and to ensure that the use of these third-party components conforms to all relevant laws and regulations.
|
| 8 |
+
|
| 9 |
+
For the avoidance of doubt, WeMM-Embedding-2B refers to code, parameters, and weights made publicly available by Tencent in accordance with Apache-2.0.
|
| 10 |
+
|
| 11 |
+
Terms of Apache-2.0:
|
| 12 |
+
--------------------------------------------------------------------
|
| 13 |
+
Apache License
|
| 14 |
+
Version 2.0, January 2004
|
| 15 |
+
http://www.apache.org/licenses/
|
| 16 |
+
|
| 17 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
| 18 |
+
|
| 19 |
+
1. Definitions.
|
| 20 |
+
|
| 21 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
| 22 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
| 23 |
+
|
| 24 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
| 25 |
+
the copyright owner that is granting the License.
|
| 26 |
+
|
| 27 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
| 28 |
+
other entities that control, are controlled by, or are under common
|
| 29 |
+
control with that entity. For the purposes of this definition,
|
| 30 |
+
"control" means (i) the power, direct or indirect, to cause the
|
| 31 |
+
direction or management of such entity, whether by contract or
|
| 32 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
| 33 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
| 34 |
+
|
| 35 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
| 36 |
+
exercising permissions granted by this License.
|
| 37 |
+
|
| 38 |
+
"Source" form shall mean the preferred form for making modifications,
|
| 39 |
+
including but not limited to software source code, documentation
|
| 40 |
+
source, and configuration files.
|
| 41 |
+
|
| 42 |
+
"Object" form shall mean any form resulting from mechanical
|
| 43 |
+
transformation or translation of a Source form, including but
|
| 44 |
+
not limited to compiled object code, generated documentation,
|
| 45 |
+
and conversions to other media types.
|
| 46 |
+
|
| 47 |
+
"Work" shall mean the work of authorship, whether in Source or
|
| 48 |
+
Object form, made available under the License, as indicated by a
|
| 49 |
+
copyright notice that is included in or attached to the work
|
| 50 |
+
(an example is provided in the Appendix below).
|
| 51 |
+
|
| 52 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
| 53 |
+
form, that is based on (or derived from) the Work and for which the
|
| 54 |
+
editorial revisions, annotations, elaborations, or other modifications
|
| 55 |
+
represent, as a whole, an original work of authorship. For the purposes
|
| 56 |
+
of this License, Derivative Works shall not include works that remain
|
| 57 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
| 58 |
+
the Work and Derivative Works thereof.
|
| 59 |
+
|
| 60 |
+
"Contribution" shall mean any work of authorship, including
|
| 61 |
+
the original version of the Work and any modifications or additions
|
| 62 |
+
to that Work or Derivative Works thereof, that is intentionally
|
| 63 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
| 64 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
| 65 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
| 66 |
+
means any form of electronic, verbal, or written communication sent
|
| 67 |
+
to the Licensor or its representatives, including but not limited to
|
| 68 |
+
communication on electronic mailing lists, source code control systems,
|
| 69 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
| 70 |
+
Licensor for the purpose of discussing and improving the Work, but
|
| 71 |
+
excluding communication that is conspicuously marked or otherwise
|
| 72 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
| 73 |
+
|
| 74 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
| 75 |
+
on behalf of whom a Contribution has been received by Licensor and
|
| 76 |
+
subsequently incorporated within the Work.
|
| 77 |
+
|
| 78 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
| 79 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 80 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 81 |
+
copyright license to reproduce, prepare Derivative Works of,
|
| 82 |
+
publicly display, publicly perform, sublicense, and distribute the
|
| 83 |
+
Work and such Derivative Works in Source or Object form.
|
| 84 |
+
|
| 85 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
| 86 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 87 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 88 |
+
(except as stated in this section) patent license to make, have made,
|
| 89 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
| 90 |
+
where such license applies only to those patent claims licensable
|
| 91 |
+
by such Contributor that are necessarily infringed by their
|
| 92 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
| 93 |
+
with the Work to which such Contribution(s) was submitted. If You
|
| 94 |
+
institute patent litigation against any entity (including a
|
| 95 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
| 96 |
+
or a Contribution incorporated within the Work constitutes direct
|
| 97 |
+
or contributory patent infringement, then any patent licenses
|
| 98 |
+
granted to You under this License for that Work shall terminate
|
| 99 |
+
as of the date such litigation is filed.
|
| 100 |
+
|
| 101 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
| 102 |
+
Work or Derivative Works thereof in any medium, with or without
|
| 103 |
+
modifications, and in Source or Object form, provided that You
|
| 104 |
+
meet the following conditions:
|
| 105 |
+
|
| 106 |
+
(a) You must give any other recipients of the Work or
|
| 107 |
+
Derivative Works a copy of this License; and
|
| 108 |
+
|
| 109 |
+
(b) You must cause any modified files to carry prominent notices
|
| 110 |
+
stating that You changed the files; and
|
| 111 |
+
|
| 112 |
+
(c) You must retain, in the Source form of any Derivative Works
|
| 113 |
+
that You distribute, all copyright, patent, trademark, and
|
| 114 |
+
attribution notices from the Source form of the Work,
|
| 115 |
+
excluding those notices that do not pertain to any part of
|
| 116 |
+
the Derivative Works; and
|
| 117 |
+
|
| 118 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
| 119 |
+
distribution, then any Derivative Works that You distribute must
|
| 120 |
+
include a readable copy of the attribution notices contained
|
| 121 |
+
within such NOTICE file, excluding those notices that do not
|
| 122 |
+
pertain to any part of the Derivative Works, in at least one
|
| 123 |
+
of the following places: within a NOTICE text file distributed
|
| 124 |
+
as part of the Derivative Works; within the Source form or
|
| 125 |
+
documentation, if provided along with the Derivative Works; or,
|
| 126 |
+
within a display generated by the Derivative Works, if and
|
| 127 |
+
wherever such third-party notices normally appear. The contents
|
| 128 |
+
of the NOTICE file are for informational purposes only and
|
| 129 |
+
do not modify the License. You may add Your own attribution
|
| 130 |
+
notices within Derivative Works that You distribute, alongside
|
| 131 |
+
or as an addendum to the NOTICE text from the Work, provided
|
| 132 |
+
that such additional attribution notices cannot be construed
|
| 133 |
+
as modifying the License.
|
| 134 |
+
|
| 135 |
+
You may add Your own copyright statement to Your modifications and
|
| 136 |
+
may provide additional or different license terms and conditions
|
| 137 |
+
for use, reproduction, or distribution of Your modifications, or
|
| 138 |
+
for any such Derivative Works as a whole, provided Your use,
|
| 139 |
+
reproduction, and distribution of the Work otherwise complies with
|
| 140 |
+
the conditions stated in this License.
|
| 141 |
+
|
| 142 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
| 143 |
+
any Contribution intentionally submitted for inclusion in the Work
|
| 144 |
+
by You to the Licensor shall be under the terms and conditions of
|
| 145 |
+
this License, without any additional terms or conditions.
|
| 146 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
| 147 |
+
the terms of any separate license agreement you may have executed
|
| 148 |
+
with Licensor regarding such Contributions.
|
| 149 |
+
|
| 150 |
+
6. Trademarks. This License does not grant permission to use the trade
|
| 151 |
+
names, trademarks, service marks, or product names of the Licensor,
|
| 152 |
+
except as required for reasonable and customary use in describing the
|
| 153 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
| 154 |
+
|
| 155 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
| 156 |
+
agreed to in writing, Licensor provides the Work (and each
|
| 157 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
| 158 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 159 |
+
implied, including, without limitation, any warranties or conditions
|
| 160 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
| 161 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
| 162 |
+
appropriateness of using or redistributing the Work and assume any
|
| 163 |
+
risks associated with Your exercise of permissions under this License.
|
| 164 |
+
|
| 165 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
| 166 |
+
whether in tort (including negligence), contract, or otherwise,
|
| 167 |
+
unless required by applicable law (such as deliberate and grossly
|
| 168 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
| 169 |
+
liable to You for damages, including any direct, indirect, special,
|
| 170 |
+
incidental, or consequential damages of any character arising as a
|
| 171 |
+
result of this License or out of the use or inability to use the
|
| 172 |
+
Work (including but not limited to damages for loss of goodwill,
|
| 173 |
+
work stoppage, computer failure or malfunction, or any and all
|
| 174 |
+
other commercial damages or losses), even if such Contributor
|
| 175 |
+
has been advised of the possibility of such damages.
|
| 176 |
+
|
| 177 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
| 178 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
| 179 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
| 180 |
+
or other liability obligations and/or rights consistent with this
|
| 181 |
+
License. However, in accepting such obligations, You may act only
|
| 182 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
| 183 |
+
of any other Contributor, and only if You agree to indemnify,
|
| 184 |
+
defend, and hold each Contributor harmless for any liability
|
| 185 |
+
incurred by, or claims asserted against, such Contributor by reason
|
| 186 |
+
of your accepting any such warranty or additional liability.
|
| 187 |
+
|
| 188 |
+
END OF TERMS AND CONDITIONS
|
| 189 |
+
|
| 190 |
+
APPENDIX: How to apply the Apache License to your work.
|
| 191 |
+
|
| 192 |
+
To apply the Apache License to your work, attach the following
|
| 193 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
| 194 |
+
replaced with your own identifying information. (Don't include
|
| 195 |
+
the brackets!) The text should be enclosed in the appropriate
|
| 196 |
+
comment syntax for the file format. We also recommend that a
|
| 197 |
+
file or class name and description of purpose be included on the
|
| 198 |
+
same "printed page" as the copyright notice for easier
|
| 199 |
+
identification within third-party archives.
|
| 200 |
+
|
| 201 |
+
Copyright [yyyy] [name of copyright owner]
|
| 202 |
+
|
| 203 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 204 |
+
you may not use this file except in compliance with the License.
|
| 205 |
+
You may obtain a copy of the License at
|
| 206 |
+
|
| 207 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 208 |
+
|
| 209 |
+
Unless required by applicable law or agreed to in writing, software
|
| 210 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 211 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 212 |
+
See the License for the specific language governing permissions and
|
| 213 |
+
limitations under the License.
|
| 214 |
+
|
| 215 |
+
|
| 216 |
+
Dependencies and Licenses:
|
| 217 |
+
|
| 218 |
+
This open-source project, WeMM-Embedding-2B, builds upon the following open-source models and/or software components, each of which remains licensed under its original license. Certain models or software may include modifications made by Tencent (“Tencent Modifications”), which are Copyright (C) Tencent.
|
| 219 |
+
|
| 220 |
+
In case you believe there have been errors in the attribution below, you may submit the concerns to us for review and correction.
|
| 221 |
+
|
| 222 |
+
|
| 223 |
+
Open Source Model Licensed under the Apache-2.0:
|
| 224 |
+
--------------------------------------------------------------------
|
| 225 |
+
1. Qwen3.5-2B
|
| 226 |
+
Copyright 2026 Alibaba Cloud
|
| 227 |
+
Please note this model has been modified by Tencent in this distribution.
|
| 228 |
+
|
| 229 |
+
|
| 230 |
+
|
| 231 |
+
Terms of the Apache-2.0:
|
| 232 |
+
--------------------------------------------------------------------
|
| 233 |
+
Apache License
|
| 234 |
+
Version 2.0, January 2004
|
| 235 |
+
http://www.apache.org/licenses/
|
| 236 |
+
|
| 237 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
| 238 |
+
|
| 239 |
+
1. Definitions.
|
| 240 |
+
|
| 241 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
| 242 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
| 243 |
+
|
| 244 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
| 245 |
+
the copyright owner that is granting the License.
|
| 246 |
+
|
| 247 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
| 248 |
+
other entities that control, are controlled by, or are under common
|
| 249 |
+
control with that entity. For the purposes of this definition,
|
| 250 |
+
"control" means (i) the power, direct or indirect, to cause the
|
| 251 |
+
direction or management of such entity, whether by contract or
|
| 252 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
| 253 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
| 254 |
+
|
| 255 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
| 256 |
+
exercising permissions granted by this License.
|
| 257 |
+
|
| 258 |
+
"Source" form shall mean the preferred form for making modifications,
|
| 259 |
+
including but not limited to software source code, documentation
|
| 260 |
+
source, and configuration files.
|
| 261 |
+
|
| 262 |
+
"Object" form shall mean any form resulting from mechanical
|
| 263 |
+
transformation or translation of a Source form, including but
|
| 264 |
+
not limited to compiled object code, generated documentation,
|
| 265 |
+
and conversions to other media types.
|
| 266 |
+
|
| 267 |
+
"Work" shall mean the work of authorship, whether in Source or
|
| 268 |
+
Object form, made available under the License, as indicated by a
|
| 269 |
+
copyright notice that is included in or attached to the work
|
| 270 |
+
(an example is provided in the Appendix below).
|
| 271 |
+
|
| 272 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
| 273 |
+
form, that is based on (or derived from) the Work and for which the
|
| 274 |
+
editorial revisions, annotations, elaborations, or other modifications
|
| 275 |
+
represent, as a whole, an original work of authorship. For the purposes
|
| 276 |
+
of this License, Derivative Works shall not include works that remain
|
| 277 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
| 278 |
+
the Work and Derivative Works thereof.
|
| 279 |
+
|
| 280 |
+
"Contribution" shall mean any work of authorship, including
|
| 281 |
+
the original version of the Work and any modifications or additions
|
| 282 |
+
to that Work or Derivative Works thereof, that is intentionally
|
| 283 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
| 284 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
| 285 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
| 286 |
+
means any form of electronic, verbal, or written communication sent
|
| 287 |
+
to the Licensor or its representatives, including but not limited to
|
| 288 |
+
communication on electronic mailing lists, source code control systems,
|
| 289 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
| 290 |
+
Licensor for the purpose of discussing and improving the Work, but
|
| 291 |
+
excluding communication that is conspicuously marked or otherwise
|
| 292 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
| 293 |
+
|
| 294 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
| 295 |
+
on behalf of whom a Contribution has been received by Licensor and
|
| 296 |
+
subsequently incorporated within the Work.
|
| 297 |
+
|
| 298 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
| 299 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 300 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 301 |
+
copyright license to reproduce, prepare Derivative Works of,
|
| 302 |
+
publicly display, publicly perform, sublicense, and distribute the
|
| 303 |
+
Work and such Derivative Works in Source or Object form.
|
| 304 |
+
|
| 305 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
| 306 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 307 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 308 |
+
(except as stated in this section) patent license to make, have made,
|
| 309 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
| 310 |
+
where such license applies only to those patent claims licensable
|
| 311 |
+
by such Contributor that are necessarily infringed by their
|
| 312 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
| 313 |
+
with the Work to which such Contribution(s) was submitted. If You
|
| 314 |
+
institute patent litigation against any entity (including a
|
| 315 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
| 316 |
+
or a Contribution incorporated within the Work constitutes direct
|
| 317 |
+
or contributory patent infringement, then any patent licenses
|
| 318 |
+
granted to You under this License for that Work shall terminate
|
| 319 |
+
as of the date such litigation is filed.
|
| 320 |
+
|
| 321 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
| 322 |
+
Work or Derivative Works thereof in any medium, with or without
|
| 323 |
+
modifications, and in Source or Object form, provided that You
|
| 324 |
+
meet the following conditions:
|
| 325 |
+
|
| 326 |
+
(a) You must give any other recipients of the Work or
|
| 327 |
+
Derivative Works a copy of this License; and
|
| 328 |
+
|
| 329 |
+
(b) You must cause any modified files to carry prominent notices
|
| 330 |
+
stating that You changed the files; and
|
| 331 |
+
|
| 332 |
+
(c) You must retain, in the Source form of any Derivative Works
|
| 333 |
+
that You distribute, all copyright, patent, trademark, and
|
| 334 |
+
attribution notices from the Source form of the Work,
|
| 335 |
+
excluding those notices that do not pertain to any part of
|
| 336 |
+
the Derivative Works; and
|
| 337 |
+
|
| 338 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
| 339 |
+
distribution, then any Derivative Works that You distribute must
|
| 340 |
+
include a readable copy of the attribution notices contained
|
| 341 |
+
within such NOTICE file, excluding those notices that do not
|
| 342 |
+
pertain to any part of the Derivative Works, in at least one
|
| 343 |
+
of the following places: within a NOTICE text file distributed
|
| 344 |
+
as part of the Derivative Works; within the Source form or
|
| 345 |
+
documentation, if provided along with the Derivative Works; or,
|
| 346 |
+
within a display generated by the Derivative Works, if and
|
| 347 |
+
wherever such third-party notices normally appear. The contents
|
| 348 |
+
of the NOTICE file are for informational purposes only and
|
| 349 |
+
do not modify the License. You may add Your own attribution
|
| 350 |
+
notices within Derivative Works that You distribute, alongside
|
| 351 |
+
or as an addendum to the NOTICE text from the Work, provided
|
| 352 |
+
that such additional attribution notices cannot be construed
|
| 353 |
+
as modifying the License.
|
| 354 |
+
|
| 355 |
+
You may add Your own copyright statement to Your modifications and
|
| 356 |
+
may provide additional or different license terms and conditions
|
| 357 |
+
for use, reproduction, or distribution of Your modifications, or
|
| 358 |
+
for any such Derivative Works as a whole, provided Your use,
|
| 359 |
+
reproduction, and distribution of the Work otherwise complies with
|
| 360 |
+
the conditions stated in this License.
|
| 361 |
+
|
| 362 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
| 363 |
+
any Contribution intentionally submitted for inclusion in the Work
|
| 364 |
+
by You to the Licensor shall be under the terms and conditions of
|
| 365 |
+
this License, without any additional terms or conditions.
|
| 366 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
| 367 |
+
the terms of any separate license agreement you may have executed
|
| 368 |
+
with Licensor regarding such Contributions.
|
| 369 |
+
|
| 370 |
+
6. Trademarks. This License does not grant permission to use the trade
|
| 371 |
+
names, trademarks, service marks, or product names of the Licensor,
|
| 372 |
+
except as required for reasonable and customary use in describing the
|
| 373 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
| 374 |
+
|
| 375 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
| 376 |
+
agreed to in writing, Licensor provides the Work (and each
|
| 377 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
| 378 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 379 |
+
implied, including, without limitation, any warranties or conditions
|
| 380 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
| 381 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
| 382 |
+
appropriateness of using or redistributing the Work and assume any
|
| 383 |
+
risks associated with Your exercise of permissions under this License.
|
| 384 |
+
|
| 385 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
| 386 |
+
whether in tort (including negligence), contract, or otherwise,
|
| 387 |
+
unless required by applicable law (such as deliberate and grossly
|
| 388 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
| 389 |
+
liable to You for damages, including any direct, indirect, special,
|
| 390 |
+
incidental, or consequential damages of any character arising as a
|
| 391 |
+
result of this License or out of the use or inability to use the
|
| 392 |
+
Work (including but not limited to damages for loss of goodwill,
|
| 393 |
+
work stoppage, computer failure or malfunction, or any and all
|
| 394 |
+
other commercial damages or losses), even if such Contributor
|
| 395 |
+
has been advised of the possibility of such damages.
|
| 396 |
+
|
| 397 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
| 398 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
| 399 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
| 400 |
+
or other liability obligations and/or rights consistent with this
|
| 401 |
+
License. However, in accepting such obligations, You may act only
|
| 402 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
| 403 |
+
of any other Contributor, and only if You agree to indemnify,
|
| 404 |
+
defend, and hold each Contributor harmless for any liability
|
| 405 |
+
incurred by, or claims asserted against, such Contributor by reason
|
| 406 |
+
of your accepting any such warranty or additional liability.
|
| 407 |
+
|
| 408 |
+
END OF TERMS AND CONDITIONS
|
| 409 |
+
|
| 410 |
+
APPENDIX: How to apply the Apache License to your work.
|
| 411 |
+
|
| 412 |
+
To apply the Apache License to your work, attach the following
|
| 413 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
| 414 |
+
replaced with your own identifying information. (Don't include
|
| 415 |
+
the brackets!) The text should be enclosed in the appropriate
|
| 416 |
+
comment syntax for the file format. We also recommend that a
|
| 417 |
+
file or class name and description of purpose be included on the
|
| 418 |
+
same "printed page" as the copyright notice for easier
|
| 419 |
+
identification within third-party archives.
|
| 420 |
+
|
| 421 |
+
Copyright [yyyy] [name of copyright owner]
|
| 422 |
+
|
| 423 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 424 |
+
you may not use this file except in compliance with the License.
|
| 425 |
+
You may obtain a copy of the License at
|
| 426 |
+
|
| 427 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 428 |
+
|
| 429 |
+
Unless required by applicable law or agreed to in writing, software
|
| 430 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 431 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 432 |
+
See the License for the specific language governing permissions and
|
| 433 |
+
limitations under the License.
|
| 434 |
+
|
| 435 |
+
|
README.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model: tencent/WeMM-Embedding-2B
|
| 3 |
+
license: apache-2.0
|
| 4 |
+
tags:
|
| 5 |
+
- embedding
|
| 6 |
+
- multimodal
|
| 7 |
+
- fp8
|
| 8 |
+
- qwen3_5
|
| 9 |
+
- image-text-to-text
|
| 10 |
+
- video-text-to-text
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# WeMM-Embedding-2B — FP8 Quantization
|
| 14 |
+
|
| 15 |
+
FP8 (8-bit float, E4M3) quantization of [tencent/WeMM-Embedding-2B](https://huggingface.co/tencent/WeMM-Embedding-2B), intended for vLLM / SGLang-class backends with FP8 support (RTX 4090 / Ada and newer have native FP8 tensor cores).
|
| 16 |
+
|
| 17 |
+
This is a **separate repo from the GGUF build** — GGUF targets llama.cpp; this FP8 build targets GPU inference servers.
|
| 18 |
+
|
| 19 |
+
## Files
|
| 20 |
+
|
| 21 |
+
- `model.fp8.safetensors` — weights stored as `float8_e4m3fn` (per-tensor scale).
|
| 22 |
+
- `fp8_scales.json` — per-layer dequant scale (layer name -> scalar).
|
| 23 |
+
- Supporting files (config, tokenizer, custom `WeMMEmbedding` modeling, chat templates) are mirrored from the base model so `AutoModel` can load it.
|
| 24 |
+
|
| 25 |
+
> Note: the saved weights are raw fp8 + scale. To run, dequantize at load time (fp8 -> bf16) or serve through a backend that natively consumes fp8. See Usage below.
|
| 26 |
+
|
| 27 |
+
## Evaluation (STS-B, same engine)
|
| 28 |
+
|
| 29 |
+
All numbers use the **same engine** (transformers / torch `AutoModel`) for both the BF16 baseline and the FP8 model, so Δρ is pure FP8 rounding error.
|
| 30 |
+
|
| 31 |
+
| Model | Bits/Weight | STS-B Spearman ρ | Δρ vs BF16 | Emb Cosine vs BF16 |
|
| 32 |
+
|---|---|---|---|---|
|
| 33 |
+
| BF16 | 16.00 | 0.8124 | — | — |
|
| 34 |
+
| FP8 (manual per-tensor E4M3) | 8.00 | 0.8114 | +0.12% | 0.9987 |
|
| 35 |
+
|
| 36 |
+
Metrics:
|
| 37 |
+
- **STS-B Spearman ρ**: rank correlation between model cosine similarities and human similarity scores (0-5). Higher is better.
|
| 38 |
+
- **Δρ vs BF16**: relative drop of ρ against the BF16 baseline. Negative = scored slightly above baseline (within noise).
|
| 39 |
+
- **Emb Cosine vs BF16**: mean cosine between each sentence embedding and its BF16 counterpart (space fidelity). 1.0 = identical.
|
| 40 |
+
|
| 41 |
+
Conclusion: FP8 causes negligible quality loss (Δρ = +0.12%, Emb Cosine = 0.999) on STS-B. This is the recommended format when serving on FP8-capable GPUs.
|
| 42 |
+
|
| 43 |
+
## Usage
|
| 44 |
+
|
| 45 |
+
### Dequantize to bf16 at load time (transformers)
|
| 46 |
+
|
| 47 |
+
```python
|
| 48 |
+
import torch, json, safetensors.torch as st
|
| 49 |
+
from transformers import AutoModel, AutoProcessor
|
| 50 |
+
|
| 51 |
+
sd = st.load_file("model.fp8.safetensors")
|
| 52 |
+
scales = json.load(open("fp8_scales.json"))
|
| 53 |
+
for k, s in scales.items(): # k like 'model.xxx.weight'
|
| 54 |
+
sd[k] = (sd[k].to(torch.float32) * s).to(torch.bfloat16) # dequant
|
| 55 |
+
# save a runnable bf16 copy, or load directly:
|
| 56 |
+
model = AutoModel.from_pretrained(".", trust_remote_code=True, dtype=torch.bfloat16)
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
### vLLM / SGLang
|
| 60 |
+
|
| 61 |
+
These backends expect a compressed-tensors / native fp8 checkpoint. The raw fp8+scale layout here is not yet wrapped for direct vLLM loading; repackaging into the backend's fp8 format (or quantizing the base model with the backend's own fp8 path) is required before serving. The quality numbers above already demonstrate the FP8 format itself is near-lossless.
|
| 62 |
+
|
| 63 |
+
## Notes
|
| 64 |
+
|
| 65 |
+
- FP8 was produced by **manual per-tensor fp8 (E4M3) quantization of all 285 Linear layers** (including the vision tower). `llmcompressor` oneshot did not actually quantize the qwen3_5 custom Linear layers, so the manual path is used for the reported numbers.
|
| 66 |
+
- The GGUF variants (Q8_0 / Q6_K / Q5_K_M / IQ4_XS / IQ3_M) live in a separate repo.
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
{%- if ns.multi_step_tool %}
|
| 79 |
+
{{- raise_exception('No user query found in messages.') }}
|
| 80 |
+
{%- endif %}
|
| 81 |
+
{%- for message in messages %}
|
| 82 |
+
{%- set content = render_content(message.content, true)|trim %}
|
| 83 |
+
{%- if message.role == "system" %}
|
| 84 |
+
{%- if not loop.first %}
|
| 85 |
+
{{- raise_exception('System message must be at the beginning.') }}
|
| 86 |
+
{%- endif %}
|
| 87 |
+
{%- elif message.role == "user" %}
|
| 88 |
+
{{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
|
| 89 |
+
{%- elif message.role == "assistant" %}
|
| 90 |
+
{%- set reasoning_content = '' %}
|
| 91 |
+
{%- if message.reasoning_content is string %}
|
| 92 |
+
{%- set reasoning_content = message.reasoning_content %}
|
| 93 |
+
{%- else %}
|
| 94 |
+
{%- if '</think>' in content %}
|
| 95 |
+
{%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
|
| 96 |
+
{%- set content = content.split('</think>')[-1].lstrip('\n') %}
|
| 97 |
+
{%- endif %}
|
| 98 |
+
{%- endif %}
|
| 99 |
+
{%- set reasoning_content = reasoning_content|trim %}
|
| 100 |
+
{%- if loop.index0 > ns.last_query_index %}
|
| 101 |
+
{{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content + '\n</think>\n\n' + content }}
|
| 102 |
+
{%- else %}
|
| 103 |
+
{{- '<|im_start|>' + message.role + '\n' + content }}
|
| 104 |
+
{%- endif %}
|
| 105 |
+
{%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}
|
| 106 |
+
{%- for tool_call in message.tool_calls %}
|
| 107 |
+
{%- if tool_call.function is defined %}
|
| 108 |
+
{%- set tool_call = tool_call.function %}
|
| 109 |
+
{%- endif %}
|
| 110 |
+
{%- if loop.first %}
|
| 111 |
+
{%- if content|trim %}
|
| 112 |
+
{{- '\n\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
|
| 113 |
+
{%- else %}
|
| 114 |
+
{{- '<tool_call>\n<function=' + tool_call.name + '>\n' }}
|
| 115 |
+
{%- endif %}
|
| 116 |
+
{%- else %}
|
| 117 |
+
{{- '\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
|
| 118 |
+
{%- endif %}
|
| 119 |
+
{%- if tool_call.arguments is defined %}
|
| 120 |
+
{%- for args_name, args_value in tool_call.arguments|items %}
|
| 121 |
+
{{- '<parameter=' + args_name + '>\n' }}
|
| 122 |
+
{%- 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 %}
|
| 123 |
+
{{- args_value }}
|
| 124 |
+
{{- '\n</parameter>\n' }}
|
| 125 |
+
{%- endfor %}
|
| 126 |
+
{%- endif %}
|
| 127 |
+
{{- '</function>\n</tool_call>' }}
|
| 128 |
+
{%- endfor %}
|
| 129 |
+
{%- endif %}
|
| 130 |
+
{{- '<|im_end|>\n' }}
|
| 131 |
+
{%- elif message.role == "tool" %}
|
| 132 |
+
{%- if loop.previtem and loop.previtem.role != "tool" %}
|
| 133 |
+
{{- '<|im_start|>user' }}
|
| 134 |
+
{%- endif %}
|
| 135 |
+
{{- '\n<tool_response>\n' }}
|
| 136 |
+
{{- content }}
|
| 137 |
+
{{- '\n</tool_response>' }}
|
| 138 |
+
{%- if not loop.last and loop.nextitem.role != "tool" %}
|
| 139 |
+
{{- '<|im_end|>\n' }}
|
| 140 |
+
{%- elif loop.last %}
|
| 141 |
+
{{- '<|im_end|>\n' }}
|
| 142 |
+
{%- endif %}
|
| 143 |
+
{%- else %}
|
| 144 |
+
{{- raise_exception('Unexpected message role.') }}
|
| 145 |
+
{%- endif %}
|
| 146 |
+
{%- endfor %}
|
| 147 |
+
{%- if add_generation_prompt %}
|
| 148 |
+
{{- '<|im_start|>assistant\n' }}
|
| 149 |
+
{%- if enable_thinking is defined and enable_thinking is true %}
|
| 150 |
+
{{- '<think>\n' }}
|
| 151 |
+
{%- else %}
|
| 152 |
+
{{- '<think>\n\n</think>\n\n' }}
|
| 153 |
+
{%- endif %}
|
| 154 |
+
{%- endif %}
|
config.json
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"Qwen3_5ForConditionalGeneration"
|
| 4 |
+
],
|
| 5 |
+
"dtype": "bfloat16",
|
| 6 |
+
"image_token_id": 248056,
|
| 7 |
+
"model_type": "qwen3_5",
|
| 8 |
+
"text_config": {
|
| 9 |
+
"attention_bias": false,
|
| 10 |
+
"attention_dropout": 0.0,
|
| 11 |
+
"attn_output_gate": true,
|
| 12 |
+
"bos_token_id": null,
|
| 13 |
+
"dtype": "bfloat16",
|
| 14 |
+
"eos_token_id": 248044,
|
| 15 |
+
"full_attention_interval": 4,
|
| 16 |
+
"head_dim": 256,
|
| 17 |
+
"hidden_act": "silu",
|
| 18 |
+
"hidden_size": 2048,
|
| 19 |
+
"initializer_range": 0.02,
|
| 20 |
+
"intermediate_size": 6144,
|
| 21 |
+
"layer_types": [
|
| 22 |
+
"linear_attention",
|
| 23 |
+
"linear_attention",
|
| 24 |
+
"linear_attention",
|
| 25 |
+
"full_attention",
|
| 26 |
+
"linear_attention",
|
| 27 |
+
"linear_attention",
|
| 28 |
+
"linear_attention",
|
| 29 |
+
"full_attention",
|
| 30 |
+
"linear_attention",
|
| 31 |
+
"linear_attention",
|
| 32 |
+
"linear_attention",
|
| 33 |
+
"full_attention",
|
| 34 |
+
"linear_attention",
|
| 35 |
+
"linear_attention",
|
| 36 |
+
"linear_attention",
|
| 37 |
+
"full_attention",
|
| 38 |
+
"linear_attention",
|
| 39 |
+
"linear_attention",
|
| 40 |
+
"linear_attention",
|
| 41 |
+
"full_attention",
|
| 42 |
+
"linear_attention",
|
| 43 |
+
"linear_attention",
|
| 44 |
+
"linear_attention",
|
| 45 |
+
"full_attention"
|
| 46 |
+
],
|
| 47 |
+
"linear_conv_kernel_dim": 4,
|
| 48 |
+
"linear_key_head_dim": 128,
|
| 49 |
+
"linear_num_key_heads": 16,
|
| 50 |
+
"linear_num_value_heads": 16,
|
| 51 |
+
"linear_value_head_dim": 128,
|
| 52 |
+
"mamba_ssm_dtype": "float32",
|
| 53 |
+
"max_position_embeddings": 262144,
|
| 54 |
+
"mlp_only_layers": [],
|
| 55 |
+
"model_type": "qwen3_5_text",
|
| 56 |
+
"mtp_num_hidden_layers": 1,
|
| 57 |
+
"mtp_use_dedicated_embeddings": false,
|
| 58 |
+
"num_attention_heads": 8,
|
| 59 |
+
"num_hidden_layers": 24,
|
| 60 |
+
"num_key_value_heads": 2,
|
| 61 |
+
"pad_token_id": null,
|
| 62 |
+
"partial_rotary_factor": 0.25,
|
| 63 |
+
"rms_norm_eps": 1e-06,
|
| 64 |
+
"rope_parameters": {
|
| 65 |
+
"mrope_interleaved": true,
|
| 66 |
+
"mrope_section": [
|
| 67 |
+
11,
|
| 68 |
+
11,
|
| 69 |
+
10
|
| 70 |
+
],
|
| 71 |
+
"partial_rotary_factor": 0.25,
|
| 72 |
+
"rope_theta": 10000000,
|
| 73 |
+
"rope_type": "default"
|
| 74 |
+
},
|
| 75 |
+
"tie_word_embeddings": false,
|
| 76 |
+
"use_cache": true,
|
| 77 |
+
"vocab_size": 248078
|
| 78 |
+
},
|
| 79 |
+
"tie_word_embeddings": false,
|
| 80 |
+
"transformers_version": "5.2.0",
|
| 81 |
+
"video_token_id": 248057,
|
| 82 |
+
"vision_config": {
|
| 83 |
+
"deepstack_visual_indexes": [],
|
| 84 |
+
"depth": 24,
|
| 85 |
+
"dtype": "bfloat16",
|
| 86 |
+
"hidden_act": "gelu_pytorch_tanh",
|
| 87 |
+
"hidden_size": 1024,
|
| 88 |
+
"in_channels": 3,
|
| 89 |
+
"initializer_range": 0.02,
|
| 90 |
+
"intermediate_size": 4096,
|
| 91 |
+
"model_type": "qwen3_5",
|
| 92 |
+
"num_heads": 16,
|
| 93 |
+
"num_position_embeddings": 2304,
|
| 94 |
+
"out_hidden_size": 2048,
|
| 95 |
+
"patch_size": 16,
|
| 96 |
+
"spatial_merge_size": 2,
|
| 97 |
+
"temporal_patch_size": 2
|
| 98 |
+
},
|
| 99 |
+
"vision_end_token_id": 248054,
|
| 100 |
+
"vision_start_token_id": 248053,
|
| 101 |
+
"auto_map": {
|
| 102 |
+
"AutoModel": "modeling_wemm_embedding.WeMMEmbedding",
|
| 103 |
+
"AutoModelForCausalLM": "modeling_wemm_embedding.WeMMEmbedding"
|
| 104 |
+
},
|
| 105 |
+
"matryoshka_dimensions": [
|
| 106 |
+
64,
|
| 107 |
+
128,
|
| 108 |
+
256,
|
| 109 |
+
512,
|
| 110 |
+
1024,
|
| 111 |
+
2048
|
| 112 |
+
]
|
| 113 |
+
}
|
config_sentence_transformers.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"__version__": {
|
| 3 |
+
"pytorch": "2.11.0+cu128",
|
| 4 |
+
"sentence_transformers": "5.7.0",
|
| 5 |
+
"transformers": "5.2.0"
|
| 6 |
+
},
|
| 7 |
+
"default_prompt_name": null,
|
| 8 |
+
"model_type": "SentenceTransformer",
|
| 9 |
+
"prompts": {},
|
| 10 |
+
"similarity_fn_name": "cosine"
|
| 11 |
+
}
|
embedding_chat_template.jinja
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{# Direct-tokenization template for vLLM 0.27 embedding requests.
|
| 2 |
+
Qwen's processor post-processor removes the role newline before images,
|
| 3 |
+
keeps it before text/video, and appends <embedding> without a preceding
|
| 4 |
+
newline. vLLM 0.27 adds each frame's vision boundaries itself, so video
|
| 5 |
+
uses a bare <video_pad> placeholder. #}
|
| 6 |
+
{%- for message in messages %}
|
| 7 |
+
{{- '<|im_start|>' + message.role }}
|
| 8 |
+
{%- if message.content is string %}
|
| 9 |
+
{{- '\n' + message.content }}
|
| 10 |
+
{%- else %}
|
| 11 |
+
{%- for item in message.content %}
|
| 12 |
+
{%- if item.type in ['image', 'image_url'] or 'image' in item or 'image_url' in item %}
|
| 13 |
+
{{- '<|vision_start|><|image_pad|><|vision_end|>' }}
|
| 14 |
+
{%- elif item.type in ['video', 'video_url'] or 'video' in item or 'video_url' in item %}
|
| 15 |
+
{{- '\n<|video_pad|>' }}
|
| 16 |
+
{%- elif item.type == 'text' or 'text' in item %}
|
| 17 |
+
{{- ('\n' if loop.first else '') + item.text }}
|
| 18 |
+
{%- else %}
|
| 19 |
+
{{- raise_exception('Unsupported embedding content type') }}
|
| 20 |
+
{%- endif %}
|
| 21 |
+
{%- endfor %}
|
| 22 |
+
{%- endif %}
|
| 23 |
+
{{- '<|im_end|>' }}
|
| 24 |
+
{%- if not loop.last %}
|
| 25 |
+
{{- '\n' }}
|
| 26 |
+
{%- endif %}
|
| 27 |
+
{%- endfor %}
|
| 28 |
+
{{- '<embedding>' }}
|
fp8_scales.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"model.visual.blocks.0.attn.qkv.weight": 0.0014299665344879031, "model.visual.blocks.0.attn.proj.weight": 0.0007890973938629031, "model.visual.blocks.0.mlp.linear_fc1.weight": 0.0006452288362197578, "model.visual.blocks.0.mlp.linear_fc2.weight": 0.0005841936799697578, "model.visual.blocks.1.attn.qkv.weight": 0.0011247907532379031, "model.visual.blocks.1.attn.proj.weight": 0.0007934570894576609, "model.visual.blocks.1.mlp.linear_fc1.weight": 0.0008588518830947578, "model.visual.blocks.1.mlp.linear_fc2.weight": 0.0013253348879516125, "model.visual.blocks.2.attn.qkv.weight": 0.0006757464143447578, "model.visual.blocks.2.attn.proj.weight": 0.0005711147096008062, "model.visual.blocks.2.mlp.linear_fc1.weight": 0.0007934570894576609, "model.visual.blocks.2.mlp.linear_fc2.weight": 0.0012991769472137094, "model.visual.blocks.3.attn.qkv.weight": 0.0005841936799697578, "model.visual.blocks.3.attn.proj.weight": 0.0006844656891189516, "model.visual.blocks.3.mlp.linear_fc1.weight": 0.0008283343049697578, "model.visual.blocks.3.mlp.linear_fc2.weight": 0.0012294225161895156, "model.visual.blocks.4.attn.qkv.weight": 0.00047302249004133046, "model.visual.blocks.4.attn.proj.weight": 0.0006670270813629031, "model.visual.blocks.4.mlp.linear_fc1.weight": 0.0006321498658508062, "model.visual.blocks.4.mlp.linear_fc2.weight": 0.0012991769472137094, "model.visual.blocks.5.attn.qkv.weight": 0.00054931640625, "model.visual.blocks.5.attn.proj.weight": 0.0004512242157943547, "model.visual.blocks.5.mlp.linear_fc1.weight": 0.00044250491191633046, "model.visual.blocks.5.mlp.linear_fc2.weight": 0.0010157994693145156, "model.visual.blocks.6.attn.qkv.weight": 0.0004141671524848789, "model.visual.blocks.6.attn.proj.weight": 0.00041634697117842734, "model.visual.blocks.6.mlp.linear_fc1.weight": 0.000579833984375, "model.visual.blocks.6.mlp.linear_fc2.weight": 0.0013253348879516125, "model.visual.blocks.7.attn.qkv.weight": 0.0005623953766189516, "model.visual.blocks.7.attn.proj.weight": 0.00026484898990020156, "model.visual.blocks.7.mlp.linear_fc1.weight": 0.0006277902284637094, "model.visual.blocks.7.mlp.linear_fc2.weight": 0.0005711147096008062, "model.visual.blocks.8.attn.qkv.weight": 0.0005078997346572578, "model.visual.blocks.8.attn.proj.weight": 0.0006321498658508062, "model.visual.blocks.8.mlp.linear_fc1.weight": 0.0006365095032379031, "model.visual.blocks.8.mlp.linear_fc2.weight": 0.0005514962831512094, "model.visual.blocks.9.attn.qkv.weight": 0.00047302249004133046, "model.visual.blocks.9.attn.proj.weight": 0.0002506801101844758, "model.visual.blocks.9.mlp.linear_fc1.weight": 0.0006103515625, "model.visual.blocks.9.mlp.linear_fc2.weight": 0.0006539481109939516, "model.visual.blocks.10.attn.qkv.weight": 0.0005209787050262094, "model.visual.blocks.10.attn.proj.weight": 0.0002659388992469758, "model.visual.blocks.10.mlp.linear_fc1.weight": 0.0006277902284637094, "model.visual.blocks.10.mlp.linear_fc2.weight": 0.0013863700442016125, "model.visual.blocks.11.attn.qkv.weight": 0.00039672854472883046, "model.visual.blocks.11.attn.proj.weight": 0.00022016253205947578, "model.visual.blocks.11.mlp.linear_fc1.weight": 0.0007324219332076609, "model.visual.blocks.11.mlp.linear_fc2.weight": 0.0012032645754516125, "model.visual.blocks.12.attn.qkv.weight": 0.0003574916336219758, "model.visual.blocks.12.attn.proj.weight": 0.00032479423680342734, "model.visual.blocks.12.mlp.linear_fc1.weight": 0.0009111677063629031, "model.visual.blocks.12.mlp.linear_fc2.weight": 0.0008980887942016125, "model.visual.blocks.13.attn.qkv.weight": 0.0003749302704818547, "model.visual.blocks.13.attn.proj.weight": 0.00023651124502066523, "model.visual.blocks.13.mlp.linear_fc1.weight": 0.0009286063723266125, "model.visual.blocks.13.mlp.linear_fc2.weight": 0.0007629395113326609, "model.visual.blocks.14.attn.qkv.weight": 0.0003444126923568547, "model.visual.blocks.14.attn.proj.weight": 0.0003596714814193547, "model.visual.blocks.14.mlp.linear_fc1.weight": 0.0003291539032943547, "model.visual.blocks.14.mlp.linear_fc2.weight": 0.0010027204407379031, "model.visual.blocks.15.attn.qkv.weight": 0.0003073556290473789, "model.visual.blocks.15.attn.proj.weight": 0.0003923688782379031, "model.visual.blocks.15.mlp.linear_fc1.weight": 0.00033569338847883046, "model.visual.blocks.15.mlp.linear_fc2.weight": 0.0009765625, "model.visual.blocks.16.attn.qkv.weight": 0.00042724612285383046, "model.visual.blocks.16.attn.proj.weight": 0.0002593994140625, "model.visual.blocks.16.mlp.linear_fc1.weight": 0.00032479423680342734, "model.visual.blocks.16.mlp.linear_fc2.weight": 0.0007716587861068547, "model.visual.blocks.17.attn.qkv.weight": 0.00026375908055342734, "model.visual.blocks.17.attn.proj.weight": 0.00044904439710080624, "model.visual.blocks.17.mlp.linear_fc1.weight": 0.0003378732071723789, "model.visual.blocks.17.mlp.linear_fc2.weight": 0.0006452288362197578, "model.visual.blocks.18.attn.qkv.weight": 0.0004926409455947578, "model.visual.blocks.18.attn.proj.weight": 0.00035095217754133046, "model.visual.blocks.18.mlp.linear_fc1.weight": 0.00033351354068145156, "model.visual.blocks.18.mlp.linear_fc2.weight": 0.0007106236298568547, "model.visual.blocks.19.attn.qkv.weight": 0.00029427665867842734, "model.visual.blocks.19.attn.proj.weight": 0.0002964564773719758, "model.visual.blocks.19.mlp.linear_fc1.weight": 0.0003749302704818547, "model.visual.blocks.19.mlp.linear_fc2.weight": 0.00036621096660383046, "model.visual.blocks.20.attn.qkv.weight": 0.0003008161438629031, "model.visual.blocks.20.attn.proj.weight": 0.00031825475161895156, "model.visual.blocks.20.mlp.linear_fc1.weight": 0.00033569338847883046, "model.visual.blocks.20.mlp.linear_fc2.weight": 0.0003422328445594758, "model.visual.blocks.21.attn.qkv.weight": 0.0003880092117469758, "model.visual.blocks.21.attn.proj.weight": 0.0003073556290473789, "model.visual.blocks.21.mlp.linear_fc1.weight": 0.0005754743469879031, "model.visual.blocks.21.mlp.linear_fc2.weight": 0.00046212333836592734, "model.visual.blocks.22.attn.qkv.weight": 0.00037057060399092734, "model.visual.blocks.22.attn.proj.weight": 0.00040980748599395156, "model.visual.blocks.22.mlp.linear_fc1.weight": 0.0005296979798004031, "model.visual.blocks.22.mlp.linear_fc2.weight": 0.00034005302586592734, "model.visual.blocks.23.attn.qkv.weight": 0.0003313337219879031, "model.visual.blocks.23.attn.proj.weight": 0.0005449567688629031, "model.visual.blocks.23.mlp.linear_fc1.weight": 0.0018920899601653218, "model.visual.blocks.23.mlp.linear_fc2.weight": 0.0015607562381774187, "model.visual.merger.linear_fc1.weight": 0.00021362306142691523, "model.visual.merger.linear_fc2.weight": 0.00044686454930342734, "model.language_model.layers.0.linear_attn.out_proj.weight": 0.0008762904908508062, "model.language_model.layers.0.linear_attn.in_proj_qkv.weight": 0.0008850098238326609, "model.language_model.layers.0.linear_attn.in_proj_z.weight": 0.0008283343049697578, "model.language_model.layers.0.linear_attn.in_proj_b.weight": 0.00027138847508467734, "model.language_model.layers.0.linear_attn.in_proj_a.weight": 0.0004926409455947578, "model.language_model.layers.0.mlp.gate_proj.weight": 0.0004228864563629031, "model.language_model.layers.0.mlp.up_proj.weight": 0.0002626691712066531, "model.language_model.layers.0.mlp.down_proj.weight": 0.0007324219332076609, "model.language_model.layers.1.linear_attn.out_proj.weight": 0.0010157994693145156, "model.language_model.layers.1.linear_attn.in_proj_qkv.weight": 0.0005711147096008062, "model.language_model.layers.1.linear_attn.in_proj_z.weight": 0.00044904439710080624, "model.language_model.layers.1.linear_attn.in_proj_b.weight": 0.0003422328445594758, "model.language_model.layers.1.linear_attn.in_proj_a.weight": 0.0005057199159637094, "model.language_model.layers.1.mlp.gate_proj.weight": 0.00031825475161895156, "model.language_model.layers.1.mlp.up_proj.weight": 0.0002692086563911289, "model.language_model.layers.1.mlp.down_proj.weight": 0.0006103515625, "model.language_model.layers.2.linear_attn.out_proj.weight": 0.0009111677063629031, "model.language_model.layers.2.linear_attn.in_proj_qkv.weight": 0.0005405971314758062, "model.language_model.layers.2.linear_attn.in_proj_z.weight": 0.00039454869693145156, "model.language_model.layers.2.linear_attn.in_proj_b.weight": 0.00033569338847883046, "model.language_model.layers.2.linear_attn.in_proj_a.weight": 0.0004359654267318547, "model.language_model.layers.2.mlp.gate_proj.weight": 0.00039454869693145156, "model.language_model.layers.2.mlp.up_proj.weight": 0.0003226144181098789, "model.language_model.layers.2.mlp.down_proj.weight": 0.0008196149719879031, "model.language_model.layers.3.self_attn.q_proj.weight": 0.0007280622376129031, "model.language_model.layers.3.self_attn.k_proj.weight": 0.00032479423680342734, "model.language_model.layers.3.self_attn.v_proj.weight": 0.0003073556290473789, "model.language_model.layers.3.self_attn.o_proj.weight": 0.0008588518830947578, "model.language_model.layers.3.mlp.gate_proj.weight": 0.0003531319962348789, "model.language_model.layers.3.mlp.up_proj.weight": 0.0002593994140625, "model.language_model.layers.3.mlp.down_proj.weight": 0.0007237026002258062, "model.language_model.layers.4.linear_attn.out_proj.weight": 0.0008850098238326609, "model.language_model.layers.4.linear_attn.in_proj_qkv.weight": 0.0006452288362197578, "model.language_model.layers.4.linear_attn.in_proj_z.weight": 0.00036403111880645156, "model.language_model.layers.4.linear_attn.in_proj_b.weight": 0.00028773717349395156, "model.language_model.layers.4.linear_attn.in_proj_a.weight": 0.0003880092117469758, "model.language_model.layers.4.mlp.gate_proj.weight": 0.0004599435196723789, "model.language_model.layers.4.mlp.up_proj.weight": 0.00022125245595816523, "model.language_model.layers.4.mlp.down_proj.weight": 0.0005558559205383062, "model.language_model.layers.5.linear_attn.out_proj.weight": 0.0009024484315887094, "model.language_model.layers.5.linear_attn.in_proj_qkv.weight": 0.0006888253847137094, "model.language_model.layers.5.linear_attn.in_proj_z.weight": 0.0003422328445594758, "model.language_model.layers.5.linear_attn.in_proj_b.weight": 0.00022997175983618945, "model.language_model.layers.5.linear_attn.in_proj_a.weight": 0.00033569338847883046, "model.language_model.layers.5.mlp.gate_proj.weight": 0.0002964564773719758, "model.language_model.layers.5.mlp.up_proj.weight": 0.00019073487783316523, "model.language_model.layers.5.mlp.down_proj.weight": 0.0005667550722137094, "model.language_model.layers.6.linear_attn.out_proj.weight": 0.0006844656891189516, "model.language_model.layers.6.linear_attn.in_proj_qkv.weight": 0.00047956197522580624, "model.language_model.layers.6.linear_attn.in_proj_z.weight": 0.0004359654267318547, "model.language_model.layers.6.linear_attn.in_proj_b.weight": 0.0003269740554969758, "model.language_model.layers.6.linear_attn.in_proj_a.weight": 0.00030953544774092734, "model.language_model.layers.6.mlp.gate_proj.weight": 0.0005209787050262094, "model.language_model.layers.6.mlp.up_proj.weight": 0.00021798271336592734, "model.language_model.layers.6.mlp.down_proj.weight": 0.0005340576171875, "model.language_model.layers.7.self_attn.q_proj.weight": 0.0005841936799697578, "model.language_model.layers.7.self_attn.k_proj.weight": 0.0002681187470443547, "model.language_model.layers.7.self_attn.v_proj.weight": 0.0003138951142318547, "model.language_model.layers.7.self_attn.o_proj.weight": 0.0005209787050262094, "model.language_model.layers.7.mlp.gate_proj.weight": 0.00041634697117842734, "model.language_model.layers.7.mlp.up_proj.weight": 0.00024087089695967734, "model.language_model.layers.7.mlp.down_proj.weight": 0.0006844656891189516, "model.language_model.layers.8.linear_attn.out_proj.weight": 0.0007978167268447578, "model.language_model.layers.8.linear_attn.in_proj_qkv.weight": 0.0005035400390625, "model.language_model.layers.8.linear_attn.in_proj_z.weight": 0.0004991804016754031, "model.language_model.layers.8.linear_attn.in_proj_b.weight": 0.00018419539264868945, "model.language_model.layers.8.linear_attn.in_proj_a.weight": 0.0002811976883094758, "model.language_model.layers.8.mlp.gate_proj.weight": 0.00034877232974395156, "model.language_model.layers.8.mlp.up_proj.weight": 0.00020381383365020156, "model.language_model.layers.8.mlp.down_proj.weight": 0.0006539481109939516, "model.language_model.layers.9.linear_attn.out_proj.weight": 0.0006757464143447578, "model.language_model.layers.9.linear_attn.in_proj_qkv.weight": 0.0006801060517318547, "model.language_model.layers.9.linear_attn.in_proj_z.weight": 0.00047084264224395156, "model.language_model.layers.9.linear_attn.in_proj_b.weight": 0.00022779192659072578, "model.language_model.layers.9.linear_attn.in_proj_a.weight": 0.0005929129547439516, "model.language_model.layers.9.mlp.gate_proj.weight": 0.0003749302704818547, "model.language_model.layers.9.mlp.up_proj.weight": 0.00021035331883467734, "model.language_model.layers.9.mlp.down_proj.weight": 0.0004032680008094758, "model.language_model.layers.10.linear_attn.out_proj.weight": 0.0006931850221008062, "model.language_model.layers.10.linear_attn.in_proj_qkv.weight": 0.0005471365875564516, "model.language_model.layers.10.linear_attn.in_proj_z.weight": 0.00033351354068145156, "model.language_model.layers.10.linear_attn.in_proj_b.weight": 0.00020926340948790312, "model.language_model.layers.10.linear_attn.in_proj_a.weight": 0.0002615792618598789, "model.language_model.layers.10.mlp.gate_proj.weight": 0.0003117152664344758, "model.language_model.layers.10.mlp.up_proj.weight": 0.0002768380509223789, "model.language_model.layers.10.mlp.down_proj.weight": 0.00046430318616330624, "model.language_model.layers.11.self_attn.q_proj.weight": 0.0005580357392318547, "model.language_model.layers.11.self_attn.k_proj.weight": 0.0003138951142318547, "model.language_model.layers.11.self_attn.v_proj.weight": 0.0003531319962348789, "model.language_model.layers.11.self_attn.o_proj.weight": 0.0005427769501693547, "model.language_model.layers.11.mlp.gate_proj.weight": 0.00037928990786895156, "model.language_model.layers.11.mlp.up_proj.weight": 0.0003073556290473789, "model.language_model.layers.11.mlp.down_proj.weight": 0.0005427769501693547, "model.language_model.layers.12.linear_attn.out_proj.weight": 0.0006670270813629031, "model.language_model.layers.12.linear_attn.in_proj_qkv.weight": 0.0006103515625, "model.language_model.layers.12.linear_attn.in_proj_z.weight": 0.0004032680008094758, "model.language_model.layers.12.linear_attn.in_proj_b.weight": 0.00017983574070967734, "model.language_model.layers.12.linear_attn.in_proj_a.weight": 0.00033351354068145156, "model.language_model.layers.12.mlp.gate_proj.weight": 0.0005318777984939516, "model.language_model.layers.12.mlp.up_proj.weight": 0.00025612968602217734, "model.language_model.layers.12.mlp.down_proj.weight": 0.0004207066376693547, "model.language_model.layers.13.linear_attn.out_proj.weight": 0.0007019043550826609, "model.language_model.layers.13.linear_attn.in_proj_qkv.weight": 0.0005057199159637094, "model.language_model.layers.13.linear_attn.in_proj_z.weight": 0.00040108818211592734, "model.language_model.layers.13.linear_attn.in_proj_b.weight": 0.00020708357624243945, "model.language_model.layers.13.linear_attn.in_proj_a.weight": 0.00033351354068145156, "model.language_model.layers.13.mlp.gate_proj.weight": 0.0004294259415473789, "model.language_model.layers.13.mlp.up_proj.weight": 0.0002692086563911289, "model.language_model.layers.13.mlp.down_proj.weight": 0.0005929129547439516, "model.language_model.layers.14.linear_attn.out_proj.weight": 0.0009329660097137094, "model.language_model.layers.14.linear_attn.in_proj_qkv.weight": 0.0007106236298568547, "model.language_model.layers.14.linear_attn.in_proj_z.weight": 0.00038582939305342734, "model.language_model.layers.14.linear_attn.in_proj_b.weight": 0.00024087089695967734, "model.language_model.layers.14.linear_attn.in_proj_a.weight": 0.00036403111880645156, "model.language_model.layers.14.mlp.gate_proj.weight": 0.0005929129547439516, "model.language_model.layers.14.mlp.up_proj.weight": 0.00030953544774092734, "model.language_model.layers.14.mlp.down_proj.weight": 0.0006234305328689516, "model.language_model.layers.15.self_attn.q_proj.weight": 0.0005929129547439516, "model.language_model.layers.15.self_attn.k_proj.weight": 0.0003836495743598789, "model.language_model.layers.15.self_attn.v_proj.weight": 0.0008719308534637094, "model.language_model.layers.15.self_attn.o_proj.weight": 0.00046430318616330624, "model.language_model.layers.15.mlp.gate_proj.weight": 0.0005667550722137094, "model.language_model.layers.15.mlp.up_proj.weight": 0.00040980748599395156, "model.language_model.layers.15.mlp.down_proj.weight": 0.00044904439710080624, "model.language_model.layers.16.linear_attn.out_proj.weight": 0.0007367815705947578, "model.language_model.layers.16.linear_attn.in_proj_qkv.weight": 0.0006234305328689516, "model.language_model.layers.16.linear_attn.in_proj_z.weight": 0.00035531181492842734, "model.language_model.layers.16.linear_attn.in_proj_b.weight": 0.0004512242157943547, "model.language_model.layers.16.linear_attn.in_proj_a.weight": 0.00033351354068145156, "model.language_model.layers.16.mlp.gate_proj.weight": 0.0005667550722137094, "model.language_model.layers.16.mlp.up_proj.weight": 0.00024850029149092734, "model.language_model.layers.16.mlp.down_proj.weight": 0.0007934570894576609, "model.language_model.layers.17.linear_attn.out_proj.weight": 0.0005885533173568547, "model.language_model.layers.17.linear_attn.in_proj_qkv.weight": 0.0008152553346008062, "model.language_model.layers.17.linear_attn.in_proj_z.weight": 0.0003008161438629031, "model.language_model.layers.17.linear_attn.in_proj_b.weight": 0.00025177001953125, "model.language_model.layers.17.linear_attn.in_proj_a.weight": 0.0004926409455947578, "model.language_model.layers.17.mlp.gate_proj.weight": 0.0008806501282379031, "model.language_model.layers.17.mlp.up_proj.weight": 0.0003073556290473789, "model.language_model.layers.17.mlp.down_proj.weight": 0.0005972726503387094, "model.language_model.layers.18.linear_attn.out_proj.weight": 0.0008893694612197578, "model.language_model.layers.18.linear_attn.in_proj_qkv.weight": 0.0006626674439758062, "model.language_model.layers.18.linear_attn.in_proj_z.weight": 0.0004686628235504031, "model.language_model.layers.18.linear_attn.in_proj_b.weight": 0.0003291539032943547, "model.language_model.layers.18.linear_attn.in_proj_a.weight": 0.0004228864563629031, "model.language_model.layers.18.mlp.gate_proj.weight": 0.0006147112580947578, "model.language_model.layers.18.mlp.up_proj.weight": 0.00022888185048941523, "model.language_model.layers.18.mlp.down_proj.weight": 0.0008457729127258062, "model.language_model.layers.19.self_attn.q_proj.weight": 0.00036403111880645156, "model.language_model.layers.19.self_attn.k_proj.weight": 0.00041198733379133046, "model.language_model.layers.19.self_attn.v_proj.weight": 0.001220703125, "model.language_model.layers.19.self_attn.o_proj.weight": 0.0007672991487197578, "model.language_model.layers.19.mlp.gate_proj.weight": 0.0007716587861068547, "model.language_model.layers.19.mlp.up_proj.weight": 0.0002768380509223789, "model.language_model.layers.19.mlp.down_proj.weight": 0.0008675712160766125, "model.language_model.layers.20.linear_attn.out_proj.weight": 0.0008937290986068547, "model.language_model.layers.20.linear_attn.in_proj_qkv.weight": 0.0008850098238326609, "model.language_model.layers.20.linear_attn.in_proj_z.weight": 0.0006103515625, "model.language_model.layers.20.linear_attn.in_proj_b.weight": 0.00036621096660383046, "model.language_model.layers.20.linear_attn.in_proj_a.weight": 0.0005449567688629031, "model.language_model.layers.20.mlp.gate_proj.weight": 0.0005929129547439516, "model.language_model.layers.20.mlp.up_proj.weight": 0.00032479423680342734, "model.language_model.layers.20.mlp.down_proj.weight": 0.0008283343049697578, "model.language_model.layers.21.linear_attn.out_proj.weight": 0.0007716587861068547, "model.language_model.layers.21.linear_attn.in_proj_qkv.weight": 0.0008675712160766125, "model.language_model.layers.21.linear_attn.in_proj_z.weight": 0.00047956197522580624, "model.language_model.layers.21.linear_attn.in_proj_b.weight": 0.0002692086563911289, "model.language_model.layers.21.linear_attn.in_proj_a.weight": 0.0005449567688629031, "model.language_model.layers.21.mlp.gate_proj.weight": 0.0008457729127258062, "model.language_model.layers.21.mlp.up_proj.weight": 0.0004512242157943547, "model.language_model.layers.21.mlp.down_proj.weight": 0.0006495884736068547, "model.language_model.layers.22.linear_attn.out_proj.weight": 0.0012468610657379031, "model.language_model.layers.22.linear_attn.in_proj_qkv.weight": 0.0009678432252258062, "model.language_model.layers.22.linear_attn.in_proj_z.weight": 0.0005667550722137094, "model.language_model.layers.22.linear_attn.in_proj_b.weight": 0.0004359654267318547, "model.language_model.layers.22.linear_attn.in_proj_a.weight": 0.0005623953766189516, "model.language_model.layers.22.mlp.gate_proj.weight": 0.0008893694612197578, "model.language_model.layers.22.mlp.up_proj.weight": 0.0003422328445594758, "model.language_model.layers.22.mlp.down_proj.weight": 0.0008588518830947578, "model.language_model.layers.23.self_attn.q_proj.weight": 0.0006757464143447578, "model.language_model.layers.23.self_attn.k_proj.weight": 0.00044250491191633046, "model.language_model.layers.23.self_attn.v_proj.weight": 0.0008196149719879031, "model.language_model.layers.23.self_attn.o_proj.weight": 0.0008283343049697578, "model.language_model.layers.23.mlp.gate_proj.weight": 0.0009547642548568547, "model.language_model.layers.23.mlp.up_proj.weight": 0.0005667550722137094, "model.language_model.layers.23.mlp.down_proj.weight": 0.0020490374881774187, "lm_head.weight": 0.00044032506411895156}
|
model.fp8.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:750b5b58f160fb405ead4fb21df9774a492aec5a4367c0d7484e8db2a0b7ade2
|
| 3 |
+
size 3233793676
|
modeling_st_wemm.py
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Sentence Transformers module for WeMM-Embedding.
|
| 2 |
+
|
| 3 |
+
Reproduces the `transformers` usage from the model card inside a Sentence Transformers
|
| 4 |
+
pipeline: vision inputs are prepared with `qwen_vl_utils.process_vision_info` and the
|
| 5 |
+
embedding is read from `WeMMEmbedding.embedding`, which pools the `<embedding>` position and
|
| 6 |
+
L2-normalizes. Everything else (batching, prompts, truncation, `encode_query` /
|
| 7 |
+
`encode_document`, similarity) comes from the stock `Transformer` module.
|
| 8 |
+
"""
|
| 9 |
+
|
| 10 |
+
from __future__ import annotations
|
| 11 |
+
|
| 12 |
+
import inspect
|
| 13 |
+
from typing import Any
|
| 14 |
+
|
| 15 |
+
from sentence_transformers.models import Transformer
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class WeMMTransformer(Transformer):
|
| 19 |
+
"""`Transformer` that prepares images and videos the way the model card's snippet does."""
|
| 20 |
+
|
| 21 |
+
def __init__(self, model_name_or_path: str, **kwargs: Any) -> None:
|
| 22 |
+
super().__init__(model_name_or_path, **kwargs)
|
| 23 |
+
vision_config = getattr(self.config, "vision_config", None)
|
| 24 |
+
self.image_patch_size = int(getattr(vision_config, "patch_size", 16))
|
| 25 |
+
|
| 26 |
+
# `embedding` hands its **kwargs to the inner model, so filtering on its own signature
|
| 27 |
+
# would drop `pixel_values`. Filter on the inner model's parameters instead, plus the
|
| 28 |
+
# processor's input names for anything the model only accepts as **kwargs.
|
| 29 |
+
inner_model = getattr(self.model, "model", self.model)
|
| 30 |
+
signature = set(inspect.signature(inner_model.forward).parameters)
|
| 31 |
+
signature |= set(getattr(self.processor, "model_input_names", ()))
|
| 32 |
+
for modality_params in self.modality_config.values():
|
| 33 |
+
method_name = modality_params["method"]
|
| 34 |
+
if method_name != "forward":
|
| 35 |
+
self._method_signature_cache.setdefault(method_name, signature)
|
| 36 |
+
|
| 37 |
+
def _apply_chat_template(
|
| 38 |
+
self,
|
| 39 |
+
messages: list[list[dict[str, Any]]],
|
| 40 |
+
modality_kwargs: dict[str, dict[str, Any]],
|
| 41 |
+
common_kwargs: dict[str, Any],
|
| 42 |
+
chat_template_kwargs: dict[str, Any],
|
| 43 |
+
) -> dict[str, Any]:
|
| 44 |
+
"""Render the chat template and prepare images / videos exactly as the model card does."""
|
| 45 |
+
from qwen_vl_utils import process_vision_info
|
| 46 |
+
|
| 47 |
+
chat_template_kwargs = {"add_generation_prompt": False, **chat_template_kwargs}
|
| 48 |
+
texts = [
|
| 49 |
+
self.processor.apply_chat_template(conversation, tokenize=False, **chat_template_kwargs)
|
| 50 |
+
for conversation in messages
|
| 51 |
+
]
|
| 52 |
+
images, videos, video_kwargs = process_vision_info(
|
| 53 |
+
[list(conversation) for conversation in messages],
|
| 54 |
+
image_patch_size=self.image_patch_size,
|
| 55 |
+
return_video_kwargs=True,
|
| 56 |
+
return_video_metadata=True,
|
| 57 |
+
)
|
| 58 |
+
if videos is not None:
|
| 59 |
+
videos, video_metadata = (list(part) for part in zip(*videos))
|
| 60 |
+
video_kwargs = {**video_kwargs, "video_metadata": video_metadata}
|
| 61 |
+
|
| 62 |
+
return self.processor(
|
| 63 |
+
text=texts,
|
| 64 |
+
images=images,
|
| 65 |
+
videos=videos,
|
| 66 |
+
text_kwargs=modality_kwargs["text"],
|
| 67 |
+
images_kwargs=modality_kwargs["image"],
|
| 68 |
+
videos_kwargs={**modality_kwargs["video"], **video_kwargs},
|
| 69 |
+
common_kwargs=common_kwargs,
|
| 70 |
+
)
|
modeling_wemm_embedding.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
import torch.nn.functional as F
|
| 3 |
+
from transformers import Qwen3_5ForConditionalGeneration
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
class WeMMEmbedding(Qwen3_5ForConditionalGeneration):
|
| 7 |
+
def embedding(self, input_ids=None, attention_mask=None, **kwargs):
|
| 8 |
+
# transformers < 5.15 reuses the rope_deltas cached by the previous multimodal
|
| 9 |
+
# forward for a text-only one, which shifts its position ids.
|
| 10 |
+
self.model.rope_deltas = None
|
| 11 |
+
|
| 12 |
+
outputs = self.model(
|
| 13 |
+
input_ids=input_ids,
|
| 14 |
+
attention_mask=attention_mask,
|
| 15 |
+
**kwargs
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
last_hidden_state = outputs.last_hidden_state
|
| 19 |
+
|
| 20 |
+
if attention_mask is not None:
|
| 21 |
+
eos_positions = attention_mask.sum(dim=1) - 1
|
| 22 |
+
else:
|
| 23 |
+
eos_positions = torch.full((last_hidden_state.shape[0],), last_hidden_state.shape[1] - 1, device=last_hidden_state.device)
|
| 24 |
+
|
| 25 |
+
eos_positions = eos_positions.clamp(min=0)
|
| 26 |
+
|
| 27 |
+
batch_indices = torch.arange(last_hidden_state.size(0), device=last_hidden_state.device)
|
| 28 |
+
|
| 29 |
+
embeddings = last_hidden_state[batch_indices, eos_positions]
|
| 30 |
+
|
| 31 |
+
embeddings = F.normalize(embeddings, dim=-1)
|
| 32 |
+
|
| 33 |
+
return embeddings
|
modules.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
{
|
| 3 |
+
"idx": 0,
|
| 4 |
+
"name": "0",
|
| 5 |
+
"path": "",
|
| 6 |
+
"type": "modeling_st_wemm.WeMMTransformer"
|
| 7 |
+
}
|
| 8 |
+
]
|
patch_sglang_video.py
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Align SGLang 0.5.9 video preprocessing with WeMM-Embedding."""
|
| 3 |
+
|
| 4 |
+
import importlib.metadata
|
| 5 |
+
import py_compile
|
| 6 |
+
import shutil
|
| 7 |
+
from pathlib import Path
|
| 8 |
+
|
| 9 |
+
import sglang
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
EXPECTED_VERSION = "0.5.9"
|
| 13 |
+
REPLACEMENTS = (
|
| 14 |
+
(
|
| 15 |
+
"IMAGE_FACTOR = 28",
|
| 16 |
+
"IMAGE_FACTOR = 32 # patch_size=16 * spatial_merge_size=2",
|
| 17 |
+
),
|
| 18 |
+
(
|
| 19 |
+
" idx = np.linspace(0, total_frames - 1, num=nframes, dtype=np.int64)",
|
| 20 |
+
" idx = torch.linspace(0, total_frames - 1, nframes).round().long().cpu().numpy()",
|
| 21 |
+
),
|
| 22 |
+
(
|
| 23 |
+
""" video = torchvision.transforms.functional.resize(
|
| 24 |
+
video,
|
| 25 |
+
[resized_height, resized_width],
|
| 26 |
+
interpolation=InterpolationMode.BILINEAR,
|
| 27 |
+
)
|
| 28 |
+
""",
|
| 29 |
+
""" video = torchvision.transforms.functional.resize(
|
| 30 |
+
video,
|
| 31 |
+
[resized_height, resized_width],
|
| 32 |
+
interpolation=InterpolationMode.BICUBIC,
|
| 33 |
+
antialias=True,
|
| 34 |
+
).float()
|
| 35 |
+
""",
|
| 36 |
+
),
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def main() -> None:
|
| 41 |
+
version = importlib.metadata.version("sglang")
|
| 42 |
+
if version != EXPECTED_VERSION:
|
| 43 |
+
raise RuntimeError(f"Expected sglang=={EXPECTED_VERSION}, found {version}")
|
| 44 |
+
|
| 45 |
+
path = (
|
| 46 |
+
Path(sglang.__file__).resolve().parent
|
| 47 |
+
/ "srt"
|
| 48 |
+
/ "multimodal"
|
| 49 |
+
/ "processors"
|
| 50 |
+
/ "qwen_vl.py"
|
| 51 |
+
)
|
| 52 |
+
text = path.read_text(encoding="utf-8")
|
| 53 |
+
if all(new in text for _, new in REPLACEMENTS):
|
| 54 |
+
print("SGLang video preprocessing is ready.")
|
| 55 |
+
return
|
| 56 |
+
|
| 57 |
+
updated = text
|
| 58 |
+
for old, new in REPLACEMENTS:
|
| 59 |
+
if updated.count(old) != 1:
|
| 60 |
+
raise RuntimeError(f"Unexpected SGLang source: {old.splitlines()[0]}")
|
| 61 |
+
updated = updated.replace(old, new, 1)
|
| 62 |
+
|
| 63 |
+
backup = path.with_suffix(path.suffix + ".original")
|
| 64 |
+
if not backup.exists():
|
| 65 |
+
shutil.copy2(path, backup)
|
| 66 |
+
path.write_text(updated, encoding="utf-8")
|
| 67 |
+
py_compile.compile(str(path), doraise=True)
|
| 68 |
+
print("SGLang video preprocessing is ready.")
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
if __name__ == "__main__":
|
| 72 |
+
main()
|
| 73 |
+
|
processor_config.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"image_processor": {
|
| 3 |
+
"do_convert_rgb": true,
|
| 4 |
+
"do_normalize": true,
|
| 5 |
+
"do_rescale": true,
|
| 6 |
+
"do_resize": true,
|
| 7 |
+
"image_mean": [
|
| 8 |
+
0.5,
|
| 9 |
+
0.5,
|
| 10 |
+
0.5
|
| 11 |
+
],
|
| 12 |
+
"image_processor_type": "Qwen2VLImageProcessor",
|
| 13 |
+
"image_std": [
|
| 14 |
+
0.5,
|
| 15 |
+
0.5,
|
| 16 |
+
0.5
|
| 17 |
+
],
|
| 18 |
+
"merge_size": 2,
|
| 19 |
+
"patch_size": 16,
|
| 20 |
+
"resample": 3,
|
| 21 |
+
"rescale_factor": 0.00392156862745098,
|
| 22 |
+
"size": {
|
| 23 |
+
"longest_edge": 16777216,
|
| 24 |
+
"shortest_edge": 65536
|
| 25 |
+
},
|
| 26 |
+
"temporal_patch_size": 2
|
| 27 |
+
},
|
| 28 |
+
"processor_class": "Qwen3VLProcessor",
|
| 29 |
+
"video_processor": {
|
| 30 |
+
"do_convert_rgb": true,
|
| 31 |
+
"do_normalize": true,
|
| 32 |
+
"do_rescale": true,
|
| 33 |
+
"do_resize": true,
|
| 34 |
+
"do_sample_frames": true,
|
| 35 |
+
"fps": 2,
|
| 36 |
+
"image_mean": [
|
| 37 |
+
0.5,
|
| 38 |
+
0.5,
|
| 39 |
+
0.5
|
| 40 |
+
],
|
| 41 |
+
"image_std": [
|
| 42 |
+
0.5,
|
| 43 |
+
0.5,
|
| 44 |
+
0.5
|
| 45 |
+
],
|
| 46 |
+
"max_frames": 768,
|
| 47 |
+
"merge_size": 2,
|
| 48 |
+
"min_frames": 4,
|
| 49 |
+
"patch_size": 16,
|
| 50 |
+
"resample": 3,
|
| 51 |
+
"rescale_factor": 0.00392156862745098,
|
| 52 |
+
"return_metadata": false,
|
| 53 |
+
"size": {
|
| 54 |
+
"longest_edge": 234881024,
|
| 55 |
+
"shortest_edge": 4096
|
| 56 |
+
},
|
| 57 |
+
"temporal_patch_size": 2,
|
| 58 |
+
"video_processor_type": "Qwen3VLVideoProcessor"
|
| 59 |
+
}
|
| 60 |
+
}
|
sentence_bert_config.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"transformer_task": "feature-extraction",
|
| 3 |
+
"modality_config": {
|
| 4 |
+
"text": {
|
| 5 |
+
"method": "embedding",
|
| 6 |
+
"method_output_name": null
|
| 7 |
+
},
|
| 8 |
+
"image": {
|
| 9 |
+
"method": "embedding",
|
| 10 |
+
"method_output_name": null
|
| 11 |
+
},
|
| 12 |
+
"video": {
|
| 13 |
+
"method": "embedding",
|
| 14 |
+
"method_output_name": null
|
| 15 |
+
},
|
| 16 |
+
"image+text": {
|
| 17 |
+
"method": "embedding",
|
| 18 |
+
"method_output_name": null
|
| 19 |
+
},
|
| 20 |
+
"text+video": {
|
| 21 |
+
"method": "embedding",
|
| 22 |
+
"method_output_name": null
|
| 23 |
+
},
|
| 24 |
+
"message": {
|
| 25 |
+
"method": "embedding",
|
| 26 |
+
"method_output_name": null,
|
| 27 |
+
"format": "structured"
|
| 28 |
+
}
|
| 29 |
+
},
|
| 30 |
+
"module_output_name": "sentence_embedding",
|
| 31 |
+
"processing_kwargs": {
|
| 32 |
+
"chat_template": {
|
| 33 |
+
"chat_template": "sentence_transformers"
|
| 34 |
+
}
|
| 35 |
+
},
|
| 36 |
+
"unpad_inputs": false
|
| 37 |
+
}
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:40e444c744512f423da4c8443c47c21e22ff76056ba4e9796a81c04c13a9daf0
|
| 3 |
+
size 19990378
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": false,
|
| 3 |
+
"audio_bos_token": "<|audio_start|>",
|
| 4 |
+
"audio_eos_token": "<|audio_end|>",
|
| 5 |
+
"audio_token": "<|audio_pad|>",
|
| 6 |
+
"backend": "tokenizers",
|
| 7 |
+
"bos_token": null,
|
| 8 |
+
"clean_up_tokenization_spaces": false,
|
| 9 |
+
"eos_token": "<|endoftext|>",
|
| 10 |
+
"errors": "replace",
|
| 11 |
+
"image_token": "<|image_pad|>",
|
| 12 |
+
"is_local": true,
|
| 13 |
+
"model_max_length": 262144,
|
| 14 |
+
"model_specific_special_tokens": {
|
| 15 |
+
"audio_bos_token": "<|audio_start|>",
|
| 16 |
+
"audio_eos_token": "<|audio_end|>",
|
| 17 |
+
"audio_token": "<|audio_pad|>",
|
| 18 |
+
"image_token": "<|image_pad|>",
|
| 19 |
+
"video_token": "<|video_pad|>",
|
| 20 |
+
"vision_bos_token": "<|vision_start|>",
|
| 21 |
+
"vision_eos_token": "<|vision_end|>"
|
| 22 |
+
},
|
| 23 |
+
"pad_token": "<|endoftext|>",
|
| 24 |
+
"pretokenize_regex": "(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\\r\\n\\p{L}\\p{N}]?[\\p{L}\\p{M}]+|\\p{N}| ?[^\\s\\p{L}\\p{M}\\p{N}]+[\\r\\n]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+",
|
| 25 |
+
"processor_class": "Qwen3VLProcessor",
|
| 26 |
+
"split_special_tokens": false,
|
| 27 |
+
"tokenizer_class": "PreTrainedTokenizerFast",
|
| 28 |
+
"unk_token": null,
|
| 29 |
+
"video_token": "<|video_pad|>",
|
| 30 |
+
"vision_bos_token": "<|vision_start|>",
|
| 31 |
+
"vision_eos_token": "<|vision_end|>"
|
| 32 |
+
}
|