Text Ranking
Transformers
Safetensors
sentence-transformers
multilingual
llama_nemotron_vl_rerank
feature-extraction
reranker
cross-encoder
visual-document-retrieval
question-answering retrieval
multimodal reranking
semantic-search
rag
custom_code
modelopt
Instructions to use nvidia/llama-nemotron-rerank-vl-1b-v2-fp8 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nvidia/llama-nemotron-rerank-vl-1b-v2-fp8 with Transformers:
# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("nvidia/llama-nemotron-rerank-vl-1b-v2-fp8", trust_remote_code=True, device_map="auto") - sentence-transformers
How to use nvidia/llama-nemotron-rerank-vl-1b-v2-fp8 with sentence-transformers:
from sentence_transformers import CrossEncoder model = CrossEncoder("nvidia/llama-nemotron-rerank-vl-1b-v2-fp8", trust_remote_code=True) query = "Which planet is known as the Red Planet?" passages = [ "Venus is often called Earth's twin because of its similar size and proximity.", "Mars, known for its reddish appearance, is often referred to as the Red Planet.", "Jupiter, the largest planet in our solar system, has a prominent red spot.", "Saturn, famous for its rings, is sometimes mistaken for the Red Planet." ] scores = model.predict([(query, passage) for passage in passages]) print(scores) - Notebooks
- Google Colab
- Kaggle
Commit ·
a306061
1
Parent(s): 36c3562
Add quantized checkpoint weights (#1)
Browse files- Add quantized checkpoint weights (3d74eb775cce5d533ec4c40226952598c3fb6f37)
- Add model card README.md (b9a2130af10fbd8bc4d8412b1bcd72f1dae04b4e)
- .gitattributes +1 -0
- LICENSE +243 -0
- README.md +414 -0
- THIRD_PARTY_NOTICES.md +306 -0
- chat_template.jinja +93 -0
- config.json +154 -0
- configuration_llama_nemotron_vl.py +165 -0
- hf_quant_config.json +28 -0
- model.safetensors +3 -0
- modeling_llama_nemotron_vl.py +712 -0
- processing_llama_nemotron_vl.py +554 -0
- processor_config.json +15 -0
- special_tokens_map.json +23 -0
- tokenizer.json +3 -0
- tokenizer_config.json +2165 -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,243 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
All binary model files are licensed under NVIDIA Open Model License Agreement.
|
| 2 |
+
All source code files are licensed under the Apache 2.0 License.
|
| 3 |
+
|
| 4 |
+
------------
|
| 5 |
+
NVIDIA Open Model License Agreement
|
| 6 |
+
Last Modified: October 24, 2025
|
| 7 |
+
https://www.nvidia.com/en-us/agreements/enterprise-software/nvidia-open-model-license/
|
| 8 |
+
|
| 9 |
+
This NVIDIA Open Model License Agreement (the “Agreement”) is a legal agreement between the Legal Entity You represent, or if no entity is identified, You and NVIDIA Corporation and its Affiliates (“NVIDIA”) and governs Your use of the Models that NVIDIA provides to You under this Agreement. NVIDIA and You are each a “party” and collectively the “parties.”
|
| 10 |
+
|
| 11 |
+
NVIDIA models released under this Agreement are intended to be used permissively and enable the further development of AI technologies. Subject to the terms of this Agreement, NVIDIA confirms that:
|
| 12 |
+
|
| 13 |
+
- Models are commercially usable.
|
| 14 |
+
- You are free to create and distribute Derivative Models.
|
| 15 |
+
- NVIDIA does not claim ownership to any outputs generated using the Models or Derivative Models.
|
| 16 |
+
By using, reproducing, modifying, distributing, performing or displaying any portion or element of the Model or Derivative Model, or otherwise accepting the terms of this Agreement, you agree to be bound by this Agreement.
|
| 17 |
+
|
| 18 |
+
1. Definitions. The following definitions apply to this Agreement:
|
| 19 |
+
|
| 20 |
+
1.1 "Derivative Model" means all (a) modifications to the Model, (b) works based on the Model, and (c) any other derivative works of the Model. An output is not a Derivative Model.
|
| 21 |
+
|
| 22 |
+
1.2 "Legal Entity" means the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of fifty percent (50%) or more of the outstanding shares, or (c) beneficial ownership of such entity.
|
| 23 |
+
|
| 24 |
+
1.3 “Model” means the machine learning model, software, checkpoints, learnt weights, algorithms, parameters, configuration files and documentation shared under this Agreement.
|
| 25 |
+
|
| 26 |
+
1.4 "NVIDIA Cosmos Model" means a multimodal Model shared under this Agreement
|
| 27 |
+
|
| 28 |
+
1.5 "Special-Purpose Model" means a Model that is only competent in a narrow set of purpose-specific tasks and should not be used for unintended or general-purpose applications
|
| 29 |
+
|
| 30 |
+
1.6 “You” or “Your” means an individual or Legal Entity exercising permissions granted by this Agreement.
|
| 31 |
+
|
| 32 |
+
2. Conditions for Use, License Grant, AI Ethics and IP Ownership.
|
| 33 |
+
|
| 34 |
+
2.1 Conditions for Use. The Model and any Derivative Model are subject to additional terms as described in Section 2 and Section 3 of this Agreement and govern Your use. If You institute copyright or patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Model or a Derivative Model constitutes direct or contributory copyright or patent infringement, then any licenses granted to You under this Agreement for that Model or Derivative Model will terminate as of the date such litigation is filed. If You bypass, disable, reduce the efficacy of, or circumvent any technical limitation, safety guardrail or associated safety guardrail hyperparameter, encryption, security, digital rights management, or authentication mechanism (collectively “Guardrail”) contained in the Model without a substantially similar Guardrail appropriate for your use case, your rights under this Agreement will automatically terminate. NVIDIA may indicate in relevant documentation that a Model is a Special-Purpose Model. NVIDIA may update this Agreement to comply with legal and regulatory requirements at any time and You agree to either comply with any updated license or cease Your copying, use, and distribution of the Model and any Derivative Model.
|
| 35 |
+
|
| 36 |
+
2.2 License Grant. The rights granted herein are explicitly conditioned on Your full compliance with the terms of this Agreement. Subject to the terms and conditions of this Agreement, NVIDIA hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, revocable (as stated in Section 2.1) license to publicly perform, publicly display, reproduce, use, create derivative works of, make, have made, sell, offer for sale, distribute (through multiple tiers of distribution) and import the Model.
|
| 37 |
+
|
| 38 |
+
2.3 AI Ethics. Use of the Models under the Agreement must be consistent with NVIDIA’s Trustworthy AI terms found at https://www.nvidia.com/en-us/agreements/trustworthy-ai/terms/.
|
| 39 |
+
|
| 40 |
+
2.4 NVIDIA owns the Model and any Derivative Models created by NVIDIA. Subject to NVIDIA’s underlying ownership rights in the Model or its Derivative Models, You are and will be the owner of Your Derivative Models. NVIDIA claims no ownership rights in outputs. You are responsible for outputs and their subsequent uses. Except as expressly granted in this Agreement, (a) NVIDIA reserves all rights, interests and remedies in connection with the Model and (b) no other license or right is granted to you by implication, estoppel or otherwise.
|
| 41 |
+
|
| 42 |
+
3. Redistribution. You may reproduce and distribute copies of the Model or Derivative Models thereof in any medium, with or without modifications, provided that You meet the following conditions:
|
| 43 |
+
|
| 44 |
+
3.1 If you distribute the Model, You must give any other recipients of the Model a copy of this Agreement and include the following attribution notice within a “Notice” text file with such copies: “Licensed by NVIDIA Corporation under the NVIDIA Open Model License”;
|
| 45 |
+
|
| 46 |
+
3.2 If you distribute or make available a NVIDIA Cosmos Model, or a product or service (including an AI model) that contains or uses a NVIDIA Cosmos Model, use a NVIDIA Cosmos Model to create a Derivative Model, or use a NVIDIA Cosmos Model or its outputs to create, train, fine tune, or otherwise improve an AI model, you will include “Built on NVIDIA Cosmos” on a related website, user interface, blogpost, about page, or product documentation; and
|
| 47 |
+
|
| 48 |
+
3.3 You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Models as a whole, provided Your use, reproduction, and distribution of the Model otherwise complies with the conditions stated in this Agreement.
|
| 49 |
+
|
| 50 |
+
4. Separate Components. The Models may include or be distributed with components provided with separate legal notices or terms that accompany the components, such as an Open Source Software License or other third-party license. The components are subject to the applicable other licenses, including any proprietary notices, disclaimers, requirements and extended use rights; except that this Agreement will prevail regarding the use of third-party Open Source Software License, unless a third-party Open Source Software License requires its license terms to prevail. “Open Source Software License” means any software, data or documentation subject to any license identified as an open source license by the Open Source Initiative (https://opensource.org), Free Software Foundation (https://www.fsf.org) or other similar open source organization or listed by the Software Package Data Exchange (SPDX) Workgroup under the Linux Foundation (https://www.spdx.org).
|
| 51 |
+
|
| 52 |
+
5. Trademarks. This Agreement does not grant permission to use the trade names, trademarks, service marks, or product names of NVIDIA, except as required for reasonable and customary use in describing the origin of the Model and reproducing the content of the “Notice” text file.
|
| 53 |
+
|
| 54 |
+
6. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, NVIDIA provides the Model on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for reviewing Model documentation, including any Special-Purpose Model limitations, and determining the appropriateness of using or redistributing the Model, Derivative Models and outputs. You assume any risks associated with Your exercise of permissions under this Agreement.
|
| 55 |
+
|
| 56 |
+
7. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, will NVIDIA be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this Agreement or out of the use or inability to use the Model, Derivative Models or outputs (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if NVIDIA has been advised of the possibility of such damages.
|
| 57 |
+
|
| 58 |
+
8. Indemnity. You will indemnify and hold harmless NVIDIA from and against any claim by any third party arising out of or related to your use or distribution of the Model, Derivative Models or outputs.
|
| 59 |
+
|
| 60 |
+
9. Feedback. NVIDIA appreciates your feedback, and You agree that NVIDIA may use it without restriction or compensation to You.
|
| 61 |
+
|
| 62 |
+
10. Governing Law. This Agreement will be governed in all respects by the laws of the United States and the laws of the State of Delaware, without regard to conflict of laws principles or the United Nations Convention on Contracts for the International Sale of Goods. The state and federal courts residing in Santa Clara County, California will have exclusive jurisdiction over any dispute or claim arising out of or related to this Agreement, and the parties irrevocably consent to personal jurisdiction and venue in those courts; except that, either party may apply for injunctive remedies or an equivalent type of urgent legal relief in any jurisdiction.
|
| 63 |
+
|
| 64 |
+
11. Trade and Compliance. You agree to comply with all applicable export, import, trade and economic sanctions laws and regulations, as amended, including without limitation U.S. Export Administration Regulations and Office of Foreign Assets Control regulations. These laws include restrictions on destinations, end-users and end-use.
|
| 65 |
+
|
| 66 |
+
Version Release Date: October 24, 2025
|
| 67 |
+
|
| 68 |
+
-----------------
|
| 69 |
+
Apache License
|
| 70 |
+
Version 2.0, January 2004
|
| 71 |
+
http://www.apache.org/licenses/
|
| 72 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
| 73 |
+
1. Definitions.
|
| 74 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
| 75 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
| 76 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
| 77 |
+
the copyright owner that is granting the License.
|
| 78 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
| 79 |
+
other entities that control, are controlled by, or are under common
|
| 80 |
+
control with that entity. For the purposes of this definition,
|
| 81 |
+
"control" means (i) the power, direct or indirect, to cause the
|
| 82 |
+
direction or management of such entity, whether by contract or
|
| 83 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
| 84 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
| 85 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
| 86 |
+
exercising permissions granted by this License.
|
| 87 |
+
"Source" form shall mean the preferred form for making modifications,
|
| 88 |
+
including but not limited to software source code, documentation
|
| 89 |
+
source, and configuration files.
|
| 90 |
+
"Object" form shall mean any form resulting from mechanical
|
| 91 |
+
transformation or translation of a Source form, including but
|
| 92 |
+
not limited to compiled object code, generated documentation,
|
| 93 |
+
and conversions to other media types.
|
| 94 |
+
"Work" shall mean the work of authorship, whether in Source or
|
| 95 |
+
Object form, made available under the License, as indicated by a
|
| 96 |
+
copyright notice that is included in or attached to the work
|
| 97 |
+
(an example is provided in the Appendix below).
|
| 98 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
| 99 |
+
form, that is based on (or derived from) the Work and for which the
|
| 100 |
+
editorial revisions, annotations, elaborations, or other modifications
|
| 101 |
+
represent, as a whole, an original work of authorship. For the purposes
|
| 102 |
+
of this License, Derivative Works shall not include works that remain
|
| 103 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
| 104 |
+
the Work and Derivative Works thereof.
|
| 105 |
+
"Contribution" shall mean any work of authorship, including
|
| 106 |
+
the original version of the Work and any modifications or additions
|
| 107 |
+
to that Work or Derivative Works thereof, that is intentionally
|
| 108 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
| 109 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
| 110 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
| 111 |
+
means any form of electronic, verbal, or written communication sent
|
| 112 |
+
to the Licensor or its representatives, including but not limited to
|
| 113 |
+
communication on electronic mailing lists, source code control systems,
|
| 114 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
| 115 |
+
Licensor for the purpose of discussing and improving the Work, but
|
| 116 |
+
excluding communication that is conspicuously marked or otherwise
|
| 117 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
| 118 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
| 119 |
+
on behalf of whom a Contribution has been received by Licensor and
|
| 120 |
+
subsequently incorporated within the Work.
|
| 121 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
| 122 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 123 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 124 |
+
copyright license to reproduce, prepare Derivative Works of,
|
| 125 |
+
publicly display, publicly perform, sublicense, and distribute the
|
| 126 |
+
Work and such Derivative Works in Source or Object form.
|
| 127 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
| 128 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 129 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 130 |
+
(except as stated in this section) patent license to make, have made,
|
| 131 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
| 132 |
+
where such license applies only to those patent claims licensable
|
| 133 |
+
by such Contributor that are necessarily infringed by their
|
| 134 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
| 135 |
+
with the Work to which such Contribution(s) was submitted. If You
|
| 136 |
+
institute patent litigation against any entity (including a
|
| 137 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
| 138 |
+
or a Contribution incorporated within the Work constitutes direct
|
| 139 |
+
or contributory patent infringement, then any patent licenses
|
| 140 |
+
granted to You under this License for that Work shall terminate
|
| 141 |
+
as of the date such litigation is filed.
|
| 142 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
| 143 |
+
Work or Derivative Works thereof in any medium, with or without
|
| 144 |
+
modifications, and in Source or Object form, provided that You
|
| 145 |
+
meet the following conditions:
|
| 146 |
+
(a) You must give any other recipients of the Work or
|
| 147 |
+
Derivative Works a copy of this License; and
|
| 148 |
+
(b) You must cause any modified files to carry prominent notices
|
| 149 |
+
stating that You changed the files; and
|
| 150 |
+
(c) You must retain, in the Source form of any Derivative Works
|
| 151 |
+
that You distribute, all copyright, patent, trademark, and
|
| 152 |
+
attribution notices from the Source form of the Work,
|
| 153 |
+
excluding those notices that do not pertain to any part of
|
| 154 |
+
the Derivative Works; and
|
| 155 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
| 156 |
+
distribution, then any Derivative Works that You distribute must
|
| 157 |
+
include a readable copy of the attribution notices contained
|
| 158 |
+
within such NOTICE file, excluding those notices that do not
|
| 159 |
+
pertain to any part of the Derivative Works, in at least one
|
| 160 |
+
of the following places: within a NOTICE text file distributed
|
| 161 |
+
as part of the Derivative Works; within the Source form or
|
| 162 |
+
documentation, if provided along with the Derivative Works; or,
|
| 163 |
+
within a display generated by the Derivative Works, if and
|
| 164 |
+
wherever such third-party notices normally appear. The contents
|
| 165 |
+
of the NOTICE file are for informational purposes only and
|
| 166 |
+
do not modify the License. You may add Your own attribution
|
| 167 |
+
notices within Derivative Works that You distribute, alongside
|
| 168 |
+
or as an addendum to the NOTICE text from the Work, provided
|
| 169 |
+
that such additional attribution notices cannot be construed
|
| 170 |
+
as modifying the License.
|
| 171 |
+
You may add Your own copyright statement to Your modifications and
|
| 172 |
+
may provide additional or different license terms and conditions
|
| 173 |
+
for use, reproduction, or distribution of Your modifications, or
|
| 174 |
+
for any such Derivative Works as a whole, provided Your use,
|
| 175 |
+
reproduction, and distribution of the Work otherwise complies with
|
| 176 |
+
the conditions stated in this License.
|
| 177 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
| 178 |
+
any Contribution intentionally submitted for inclusion in the Work
|
| 179 |
+
by You to the Licensor shall be under the terms and conditions of
|
| 180 |
+
this License, without any additional terms or conditions.
|
| 181 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
| 182 |
+
the terms of any separate license agreement you may have executed
|
| 183 |
+
with Licensor regarding such Contributions.
|
| 184 |
+
6. Trademarks. This License does not grant permission to use the trade
|
| 185 |
+
names, trademarks, service marks, or product names of the Licensor,
|
| 186 |
+
except as required for reasonable and customary use in describing the
|
| 187 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
| 188 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
| 189 |
+
agreed to in writing, Licensor provides the Work (and each
|
| 190 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
| 191 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 192 |
+
implied, including, without limitation, any warranties or conditions
|
| 193 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
| 194 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
| 195 |
+
appropriateness of using or redistributing the Work and assume any
|
| 196 |
+
risks associated with Your exercise of permissions under this License.
|
| 197 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
| 198 |
+
whether in tort (including negligence), contract, or otherwise,
|
| 199 |
+
unless required by applicable law (such as deliberate and grossly
|
| 200 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
| 201 |
+
liable to You for damages, including any direct, indirect, special,
|
| 202 |
+
incidental, or consequential damages of any character arising as a
|
| 203 |
+
result of this License or out of the use or inability to use the
|
| 204 |
+
Work (including but not limited to damages for loss of goodwill,
|
| 205 |
+
work stoppage, computer failure or malfunction, or any and all
|
| 206 |
+
other commercial damages or losses), even if such Contributor
|
| 207 |
+
has been advised of the possibility of such damages.
|
| 208 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
| 209 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
| 210 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
| 211 |
+
or other liability obligations and/or rights consistent with this
|
| 212 |
+
License. However, in accepting such obligations, You may act only
|
| 213 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
| 214 |
+
of any other Contributor, and only if You agree to indemnify,
|
| 215 |
+
defend, and hold each Contributor harmless for any liability
|
| 216 |
+
incurred by, or claims asserted against, such Contributor by reason
|
| 217 |
+
of your accepting any such warranty or additional liability.
|
| 218 |
+
END OF TERMS AND CONDITIONS
|
| 219 |
+
APPENDIX: How to apply the Apache License to your work.
|
| 220 |
+
To apply the Apache License to your work, attach the following
|
| 221 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
| 222 |
+
replaced with your own identifying information. (Don't include
|
| 223 |
+
the brackets!) The text should be enclosed in the appropriate
|
| 224 |
+
comment syntax for the file format. We also recommend that a
|
| 225 |
+
file or class name and description of purpose be included on the
|
| 226 |
+
same "printed page" as the copyright notice for easier
|
| 227 |
+
identification within third-party archives.
|
| 228 |
+
|
| 229 |
+
Copyright [yyyy] [name of copyright owner]
|
| 230 |
+
|
| 231 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 232 |
+
you may not use this file except in compliance with the License.
|
| 233 |
+
You may obtain a copy of the License at
|
| 234 |
+
|
| 235 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 236 |
+
|
| 237 |
+
Unless required by applicable law or agreed to in writing, software
|
| 238 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 239 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 240 |
+
See the License for the specific language governing permissions and
|
| 241 |
+
limitations under the License.
|
| 242 |
+
|
| 243 |
+
|
README.md
ADDED
|
@@ -0,0 +1,414 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: other
|
| 3 |
+
license_name: nvidia-open-model-license
|
| 4 |
+
license_link: >-
|
| 5 |
+
https://www.nvidia.com/en-us/agreements/enterprise-software/nvidia-open-model-license/
|
| 6 |
+
tags:
|
| 7 |
+
- reranker
|
| 8 |
+
- cross-encoder
|
| 9 |
+
- visual-document-retrieval
|
| 10 |
+
- question-answering retrieval
|
| 11 |
+
- multimodal reranking
|
| 12 |
+
- semantic-search
|
| 13 |
+
- rag
|
| 14 |
+
- transformers
|
| 15 |
+
- sentence-transformers
|
| 16 |
+
pipeline_tag: text-ranking
|
| 17 |
+
language:
|
| 18 |
+
- multilingual
|
| 19 |
+
library_name: transformers
|
| 20 |
+
---
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
## **Model Overview**
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
### Description:
|
| 27 |
+
|
| 28 |
+
The NVIDIA `llama-nemotron-rerank-vl-1b-v2-fp8` is the quantized version of the [NVIDIA llama-nemotron-rerank-vl-1b-v2](https://huggingface.co/nvidia/llama-nemotron-rerank-vl-1b-v2/tree/9c20c4ae) which is developed for multimodal question-answering retrieval. For more information, please check [here](https://huggingface.co/nvidia/llama-nemotron-rerank-vl-1b-v2/tree/9c20c4ae). The NVIDIA `llama-nemotron-rerank-vl-1b-v2-fp8` model is quantized with [TensorRT Model Optimizer](https://github.com/NVIDIA/TensorRT-Model-Optimizer).
|
| 29 |
+
|
| 30 |
+
For this quantization checkpoint we quantize only the language portion of the model, llama-3-1B. All other parts including vision encoder (SigLIP 400M) and the binary classification head are not quantized and are left in default bf-16 or fp-32 precision.
|
| 31 |
+
|
| 32 |
+
This model is ready for commercial use. <br>
|
| 33 |
+
|
| 34 |
+
### License/Terms of Use:
|
| 35 |
+
|
| 36 |
+
The use of this model is governed by the [NVIDIA Open Model License Agreement](https://www.nvidia.com/en-us/agreements/enterprise-software/nvidia-open-model-license/) and the use of the post-processing scripts are licensed under [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt). Additional Information: [Llama 3.2 Community Model License Agreement](https://www.llama.com/llama3_2/license/). Built with Llama. |
|
| 37 |
+
|
| 38 |
+
### Deployment Geography:
|
| 39 |
+
Global <br>
|
| 40 |
+
|
| 41 |
+
### Use Case: <br>
|
| 42 |
+
The llama-nemotron-rerank-vl-1b-v2-fp8 is suitable for users who want to build a multimodal question-and-answer application over a large corpus, leveraging the latest dense retrieval technology.
|
| 43 |
+
|
| 44 |
+
The input of the model is a query combined with a text or image document and the output is a float representing the relevance score (logit) reflecting how strongly it predicts that the passage or document contains the information relevant to the query. Multiple documents could be passed with a single query for batched processing, in this case the output contains a logit per document.
|
| 45 |
+
|
| 46 |
+
The rerank model is a cross-encoder that supports context in textual format (e.g. the query or the OCR text of a page or a section of a document) or the image of a document page.
|
| 47 |
+
|
| 48 |
+
Typically, the embedding model is used first to embed (vectorize) the whole corpus (document images or text chunks), and embeddings are stored in a vector database associated to its raw content (image or text). Then at inference time, the embedding model is used to embed the query and pick closest documents based on the cosine similarity of document and query embeddings. Finally, the rerank model is used on the query and top selections from the embedding model to improve the selection document relevance scores with better context information.
|
| 49 |
+
|
| 50 |
+
### Release Date
|
| 51 |
+
Hugging Face 07/28/2026 via https://huggingface.co/nvidia/llama-nemotron-rerank-vl-1b-v2-fp8
|
| 52 |
+
|
| 53 |
+
## Model Architecture:
|
| 54 |
+
|
| 55 |
+
**Architecture Type:** Transformer<br>
|
| 56 |
+
**Network Architecture:** : Eagle VLM architecture with SigLIP 2 400M vision encoder and [llama-nemotron-rerank-1b-v2](https://huggingface.co/nvidia/llama-nemotron-rerank-1b-v2) model as language model. <br>
|
| 57 |
+
|
| 58 |
+
The llama-nemotron-rerank-vl-1b-v2 is a cross-encoder model with approximately 1.7B parameters. It is a fine-tuned version of an NVIDIA Eagle-family model, which consists of the SigLIP 2 400M vision encoder and the Llama 3.2 1B language model. The final embedding output by the decoder is aggregated using a mean pooling strategy, and a binary classification head is fine-tuned for the ranking task. The CrossEntropy loss is used to maximize the likelihood of (visual) documents containing information to answer the question and minimize the likelihood for (negative) documents that do not contain information to answer the question.
|
| 59 |
+
|
| 60 |
+
The vision-language model reranker incorporates key innovations from NVIDIA, including [Eagle 2 work](https://arxiv.org/abs/2501.14818) which uses a tiling-based VLM architecture, and [nemoretriever-parse](https://build.nvidia.com/nvidia/nemoretriever-parse). The Eagle 2 architecture, available on [Hugging Face](https://huggingface.co/collections/nvidia/eagle-2-6764ba887fa1ef387f7df067), significantly enhances multimodal understanding through its dynamic tiling and mixture of vision encoders design. It particularly improves performance on tasks that involve high-resolution images and complex visual content.
|
| 61 |
+
|
| 62 |
+
**Number of model parameters:**
|
| 63 |
+
- Llama 3.2 1B language model: 1.23 B (Transformer parameters: 973 M, Token embedding parameters: 262 M)
|
| 64 |
+
- SigLip 2 image encoder: 428.77 M
|
| 65 |
+
|
| 66 |
+
## Input(s): <br>
|
| 67 |
+
**Input Type(s):** Image, Text<br>
|
| 68 |
+
|
| 69 |
+
**Input Format(s):** <br>
|
| 70 |
+
- Image: Red, Green, Blue (RGB) <br>
|
| 71 |
+
- Text: String <br>
|
| 72 |
+
|
| 73 |
+
**Input Parameters:**
|
| 74 |
+
- Image: Two-Dimensional (2D) <br>
|
| 75 |
+
- Text: One-Dimensional (1D) <br>
|
| 76 |
+
|
| 77 |
+
**Other Properties Related to Input:** <br>
|
| 78 |
+
|
| 79 |
+
The model was fine-tuned exclusively on image data, using max_input_tiles = 4 and the maximum context length of 2048 tokens. For evaluation, it was tested on image-only, image+text, and text-only inputs, with max_input_tiles = 6 and the maximum context length of 10240 tokens. Inputs exceeding the maximum length are truncated. <br>
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
## Output(s)
|
| 83 |
+
|
| 84 |
+
**Output Type(s):** Floats <br>
|
| 85 |
+
|
| 86 |
+
**Output Format(s):** List of Floats <br>
|
| 87 |
+
|
| 88 |
+
**Output Parameters:** One-Dimensional (1D) <br>
|
| 89 |
+
|
| 90 |
+
**Other Properties Related to Output:** Each value corresponds to a raw logit. Users can choose to apply a Sigmoid activation function to the logits to convert them into probabilities during model usage.
|
| 91 |
+
|
| 92 |
+
Our AI models are designed and/or optimized to run on NVIDIA GPU-accelerated systems. By leveraging NVIDIA’s hardware (e.g. GPU cores) and software frameworks (e.g., CUDA libraries), the model achieves faster training and inference times compared to CPU-only solutions. <br>
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
## vLLM Usage
|
| 96 |
+
|
| 97 |
+
The model can be served with [vLLM](https://github.com/vllm-project/vllm) for high-throughput reranking. A chat template **must** be provided via `--chat-template` to correctly apply the `question:` / `passage:` prefixes based on the message role — without it, the prompt template is not applied and results will be incorrect.
|
| 98 |
+
|
| 99 |
+
See the [vLLM documentation](https://docs.vllm.ai/en/stable/models/pooling_models/specific_models/#llama-nemotron-multimodal) for full details.
|
| 100 |
+
|
| 101 |
+
### Online Serving
|
| 102 |
+
|
| 103 |
+
Create the score template file and start the server:
|
| 104 |
+
```bash
|
| 105 |
+
cat > nemotron-rerank-vl.jinja << 'JINJA'
|
| 106 |
+
{%- set query_msg = (messages | selectattr("role", "equalto", "query") | list | first) -%}
|
| 107 |
+
{%- set doc_msg = (messages | selectattr("role", "equalto", "document") | list | first) -%}
|
| 108 |
+
{%- set q = query_msg["content"] -%}
|
| 109 |
+
{%- set d = doc_msg["content"] -%}
|
| 110 |
+
{# If the doc contains <image> anywhere, hoist a single <image> to the front #}
|
| 111 |
+
{%- set has_image = ("<image>" in d) -%}
|
| 112 |
+
{%- set d_clean = d | replace("<image>", "") -%}
|
| 113 |
+
{%- set q_clean = q | replace("<image>", "") -%}
|
| 114 |
+
{%- if has_image -%}<image>{{ " " }}{%- endif -%}
|
| 115 |
+
question:{{ q_clean }}{{ " " }}
|
| 116 |
+
{{ " " }}
|
| 117 |
+
{{ " " }}passage:{{ d_clean }}
|
| 118 |
+
JINJA
|
| 119 |
+
|
| 120 |
+
vllm serve nvidia/llama-nemotron-rerank-vl-1b-v2-fp8 \
|
| 121 |
+
--runner pooling \
|
| 122 |
+
--trust-remote-code \
|
| 123 |
+
--max-model-len 10240 \
|
| 124 |
+
--chat-template nemotron-rerank-vl.jinja
|
| 125 |
+
```
|
| 126 |
+
|
| 127 |
+
Note: Use `--max-model-len 10240` to support all modalities including image+text. A smaller value like `2048` can be used if only processing image-only or text-only inputs.
|
| 128 |
+
|
| 129 |
+
The chat template uses the message `role` to combine the correct prefixes: set `role` to `"query"` for queries (prepends `question:`) and `"document"` for passages (prepends `passage:`).
|
| 130 |
+
|
| 131 |
+
Send a rerank request:
|
| 132 |
+
```python
|
| 133 |
+
import requests
|
| 134 |
+
|
| 135 |
+
url = "http://localhost:8000/v1/rerank"
|
| 136 |
+
|
| 137 |
+
# Text-only reranking
|
| 138 |
+
response = requests.post(url, json={
|
| 139 |
+
"model": "nvidia/llama-nemotron-rerank-vl-1b-v2-fp8",
|
| 140 |
+
"query": "How is AI improving the intelligence and capabilities of robots?",
|
| 141 |
+
"documents": [
|
| 142 |
+
"AI enables robots to perceive, plan, and act autonomously.",
|
| 143 |
+
"A biological foundation model designed to analyze DNA, RNA, and protein sequences.",
|
| 144 |
+
],
|
| 145 |
+
})
|
| 146 |
+
print(response.json())
|
| 147 |
+
|
| 148 |
+
# Image document reranking
|
| 149 |
+
response = requests.post(url, json={
|
| 150 |
+
"model": "nvidia/llama-nemotron-rerank-vl-1b-v2-fp8",
|
| 151 |
+
"query": "How is AI improving the intelligence and capabilities of robots?",
|
| 152 |
+
"documents": [
|
| 153 |
+
{"content": [{"type": "image_url", "image_url": {"url": "https://example.com/page.png"}}]},
|
| 154 |
+
{"content": [
|
| 155 |
+
{"type": "text", "text": "AI enables robots to perceive, plan, and act autonomously."},
|
| 156 |
+
{"type": "image_url", "image_url": {"url": "https://example.com/page2.png"}},
|
| 157 |
+
]},
|
| 158 |
+
],
|
| 159 |
+
})
|
| 160 |
+
print(response.json())
|
| 161 |
+
```
|
| 162 |
+
|
| 163 |
+
### Offline / In-Process
|
| 164 |
+
|
| 165 |
+
```python
|
| 166 |
+
from vllm import LLM
|
| 167 |
+
|
| 168 |
+
SCORE_TEMPLATE = """\
|
| 169 |
+
{%- set query_msg = (messages | selectattr('role', 'equalto', 'query') | list | first) -%}
|
| 170 |
+
{%- set doc_msg = (messages | selectattr('role', 'equalto', 'document') | list | first) -%}
|
| 171 |
+
{%- set q = query_msg['content'] -%}
|
| 172 |
+
{%- set d = doc_msg['content'] -%}
|
| 173 |
+
{%- set has_image = ("<image>" in d) -%}
|
| 174 |
+
{%- set d_clean = d | replace("<image>", "") -%}
|
| 175 |
+
{%- set q_clean = q | replace("<image>", "") -%}
|
| 176 |
+
{%- if has_image -%}<image>{{ " " }}{%- endif -%}
|
| 177 |
+
question:{{ q_clean }}{{ " " }}
|
| 178 |
+
{{ " " }}
|
| 179 |
+
{{ " " }}passage:{{ d_clean }}"""
|
| 180 |
+
|
| 181 |
+
llm = LLM(
|
| 182 |
+
model="nvidia/llama-nemotron-rerank-vl-1b-v2-fp8",
|
| 183 |
+
runner="pooling",
|
| 184 |
+
max_model_len=10240,
|
| 185 |
+
trust_remote_code=True,
|
| 186 |
+
)
|
| 187 |
+
|
| 188 |
+
query = "How is AI improving the intelligence and capabilities of robots?"
|
| 189 |
+
documents = [
|
| 190 |
+
"AI enables robots to perceive, plan, and act autonomously.",
|
| 191 |
+
"A biological foundation model designed to analyze DNA, RNA, and protein sequences.",
|
| 192 |
+
]
|
| 193 |
+
|
| 194 |
+
# Text-only scoring
|
| 195 |
+
outputs = llm.score(query, documents, chat_template=SCORE_TEMPLATE)
|
| 196 |
+
for doc, output in zip(documents, outputs):
|
| 197 |
+
print(f"Score: {output.outputs.score:.4f} | {doc}")
|
| 198 |
+
|
| 199 |
+
# Image document scoring
|
| 200 |
+
outputs = llm.score(
|
| 201 |
+
query,
|
| 202 |
+
[
|
| 203 |
+
{"content": [{"type": "image_url", "image_url": {"url": "https://example.com/page.png"}}]},
|
| 204 |
+
{"content": [
|
| 205 |
+
{"type": "text", "text": "AI enables robots to perceive, plan, and act autonomously."},
|
| 206 |
+
{"type": "image_url", "image_url": {"url": "https://example.com/page2.png"}},
|
| 207 |
+
]},
|
| 208 |
+
],
|
| 209 |
+
chat_template=SCORE_TEMPLATE,
|
| 210 |
+
)
|
| 211 |
+
for output in outputs:
|
| 212 |
+
print(f"Score: {output.outputs.score:.4f}")
|
| 213 |
+
```
|
| 214 |
+
|
| 215 |
+
|
| 216 |
+
## Software Integration:
|
| 217 |
+
|
| 218 |
+
**Runtime Engine(s)**: vLLM<br>
|
| 219 |
+
**Supported Hardware Microarchitecture Compatibility**: NVIDIA Blackwell, NVIDIA Hopper, NVIDIA Lovelace <br>
|
| 220 |
+
**Preferred/Supported Operating System(s):** Linux<br>
|
| 221 |
+
|
| 222 |
+
The integration of foundation and fine-tuned models into AI systems requires additional testing using use-case-specific data to ensure safe and effective deployment. Following the V-model methodology, iterative testing and validation at both unit and system levels are essential to mitigate risks, meet technical and functional requirements, and ensure compliance with safety and ethical standards before deployment. <br>
|
| 223 |
+
|
| 224 |
+
|
| 225 |
+
## Model Version(s):
|
| 226 |
+
`llama-nemotron-rerank-vl-1b-v2-fp8`<br>
|
| 227 |
+
The model is quantized with nvidia-modelopt v0.43.0
|
| 228 |
+
|
| 229 |
+
## Post Training Quantization:
|
| 230 |
+
|
| 231 |
+
This model was obtained by quantizing the weights and activations of [nvidia/llama-nemotron-rerank-vl-1b-v2](https://huggingface.co/nvidia/llama-nemotron-rerank-vl-1b-v2/tree/9c20c4ae) to FP8 data type, ready for inference with vLLM
|
| 232 |
+
|
| 233 |
+
## Training, Testing, and Evaluation Datasets:
|
| 234 |
+
|
| 235 |
+
### Dataset Overview
|
| 236 |
+
|
| 237 |
+
This checkpoint is an FP8 post-training-quantized derivative of [nvidia/llama-nemotron-rerank-vl-1b-v2](https://huggingface.co/nvidia/llama-nemotron-rerank-vl-1b-v2/tree/9c20c4ae). No additional supervised training or fine-tuning data was used to create this FP8 checkpoint.
|
| 238 |
+
|
| 239 |
+
For this FP8 release, data was used for two purposes: post-training quantization calibration and evaluation. The [cnn_dailymail](https://huggingface.co/datasets/abisee/cnn_dailymail) dataset was used for FP8 quantization calibration.
|
| 240 |
+
|
| 241 |
+
The FP8 checkpoint was produced by applying post-training quantization to the BF16 parent model using NVIDIA TensorRT Model Optimizer. Calibration samples were converted into model inputs and used to estimate quantization parameters for weights and activations. This calibration process did not involve supervised training, fine-tuning, or modification of the model objective.
|
| 242 |
+
|
| 243 |
+
## Calibration dataset
|
| 244 |
+
|
| 245 |
+
* Link: [cnn_dailymail](https://huggingface.co/datasets/abisee/cnn_dailymail)
|
| 246 |
+
**Data Collection Method by dataset** <br>
|
| 247 |
+
* Automated <br>
|
| 248 |
+
|
| 249 |
+
**Labeling Method by dataset** <br>
|
| 250 |
+
* Automated <br>
|
| 251 |
+
|
| 252 |
+
**Properties:** <br>
|
| 253 |
+
* The cnn_dailymail dataset is an English-language dataset containing just over 300k unique news articles as written by journalists at CNN and the Daily Mail. 512 samples from the train split were used for calibration. <br>
|
| 254 |
+
|
| 255 |
+
## Training Dataset
|
| 256 |
+
|
| 257 |
+
### Data Modality:
|
| 258 |
+
|
| 259 |
+
* Image <br>
|
| 260 |
+
|
| 261 |
+
### Training Data Size:
|
| 262 |
+
|
| 263 |
+
**Image Training Data Size** <br>
|
| 264 |
+
|
| 265 |
+
* Undisclosed <br>
|
| 266 |
+
|
| 267 |
+
**Data Collection Method by dataset** <br>
|
| 268 |
+
* Not Applicable <br>
|
| 269 |
+
|
| 270 |
+
**Labeling Method by dataset** <br>
|
| 271 |
+
* Not Applicable <br>
|
| 272 |
+
|
| 273 |
+
**Properties:** <br>
|
| 274 |
+
* Not Applicable <br>
|
| 275 |
+
|
| 276 |
+
## Evaluation Dataset
|
| 277 |
+
|
| 278 |
+
In this section, we compare the performance of quantized model **llama-nemotron-rerank-vl-1b-v2-fp8** with baseline implementation **llama-nemotron-rerank-vl-1b-v2**. We applied the ranking model to the candidates retrieved from the `llama-nemotron-embed-vl-1b-v2` model.
|
| 279 |
+
|
| 280 |
+
ViDoRe V3, KoViDoRe, and ZhViDoRe (an internal Chinese visual document) retrieval benchmark were used to evaluate ranking quality relative to the BF16 baseline model. Evaluation inputs were formatted as text-only, image-only, and image-plus-text examples to compare retrieval accuracy between the FP8 checkpoint and the BF16 baseline.
|
| 281 |
+
|
| 282 |
+
We evaluate the embedding + reranking pipeline on a set of evaluation benchmarks. Both the baseline BF16 and the quantized FP8 checkpoints were provided with the same candidates retrieved from `llama-nemotron-embed-vl-1b-v2` BF16 model. Top 20 candidates were selected based on cosine similarity of embeddings, then rerank model was used to score relevancy of those top-20 documents and compute recall of top 5 scoring documents.
|
| 283 |
+
|
| 284 |
+
In each configuration, the embedding modality matched the reranking modality (e.g., text-only reranking used text-only embeddings, image-only reranking used image-only embeddings, and image-plus-text reranking used image-plus-text embeddings).
|
| 285 |
+
|
| 286 |
+
<table>
|
| 287 |
+
<caption><b><em>FP8 model accuracy relative to baseline BF16 model, on Visual Document Retrieval benchmarks. Chinese: ZhViDoRe (internal); Korean: KoViDoRe; English/French: ViDoRe V3.</em></b></caption>
|
| 288 |
+
<thead>
|
| 289 |
+
<tr>
|
| 290 |
+
<th></th>
|
| 291 |
+
<th colspan="3">Dataset</th>
|
| 292 |
+
</tr></thead>
|
| 293 |
+
<tbody>
|
| 294 |
+
<tr>
|
| 295 |
+
<td>Modality</td>
|
| 296 |
+
<td>All</td>
|
| 297 |
+
<td>Chinese/Korean</td>
|
| 298 |
+
<td>English/French</td>
|
| 299 |
+
</tr>
|
| 300 |
+
<tr>
|
| 301 |
+
<td>image+text</td>
|
| 302 |
+
<td>99.53%</td>
|
| 303 |
+
<td>100.28%</td>
|
| 304 |
+
<td>99.34%</td>
|
| 305 |
+
</tr>
|
| 306 |
+
<tr>
|
| 307 |
+
<td>image</td>
|
| 308 |
+
<td>99.68%</td>
|
| 309 |
+
<td> - </td>
|
| 310 |
+
<td>99.68%</td>
|
| 311 |
+
</tr>
|
| 312 |
+
<tr>
|
| 313 |
+
<td>text</td>
|
| 314 |
+
<td>99.03%</td>
|
| 315 |
+
<td>98.88%</td>
|
| 316 |
+
<td>99.07%</td>
|
| 317 |
+
</tr>
|
| 318 |
+
</tbody>
|
| 319 |
+
</table>
|
| 320 |
+
|
| 321 |
+
Note that the model does not have Chinese/Korean language support for image-only inputs.
|
| 322 |
+
|
| 323 |
+
**Data Collection Method by dataset** <br>
|
| 324 |
+
* Hybrid: Automated, Human, Synthetic <br>
|
| 325 |
+
|
| 326 |
+
**Labeling Method by dataset:** <br>
|
| 327 |
+
* Hybrid: Automated, Human, Synthetic <br>
|
| 328 |
+
|
| 329 |
+
**Properties** <br>
|
| 330 |
+
* ZhViDoRe comprises 922 queries, KoViDoRe comprises 706 queries, and ViDoRe V3 comprises 14,514 queries. More details on ViDoRe benchmarks can be found on their Hugging Face [page](https://huggingface.co/vidore).
|
| 331 |
+
|
| 332 |
+
## Inference
|
| 333 |
+
|
| 334 |
+
**Acceleration Engine:** [vLLM](https://vllm.ai/) <br>
|
| 335 |
+
**Test Hardware:** <br>
|
| 336 |
+
* NVIDIA Hopper (H100 SXM) <br>
|
| 337 |
+
|
| 338 |
+
|
| 339 |
+
## **Ethical Considerations**
|
| 340 |
+
|
| 341 |
+
NVIDIA believes Trustworthy AI is a shared responsibility and we have established policies and practices to enable development for a wide array of AI applications. Developers should work with their supporting model team to ensure this model meets requirements for the relevant industry and use case and addresses unforeseen product misuse. <br>
|
| 342 |
+
|
| 343 |
+
Please make sure you have proper rights and permissions for all input image content; if image includes people, personal health information, or intellectual property, the image or video generated will not blur or maintain proportions of image subjects included. <br>
|
| 344 |
+
|
| 345 |
+
For more detailed information on ethical considerations for this model, please see the Explainability, Bias, Safety & Security, and Privacy sections.
|
| 346 |
+
|
| 347 |
+
Please report model quality, risk, security vulnerabilities or NVIDIA AI Concerns [here](https://www.nvidia.com/en-us/support/submit-security-vulnerability/).
|
| 348 |
+
|
| 349 |
+
## Citation
|
| 350 |
+
```
|
| 351 |
+
@inproceedings{moreira2025_nvretriever,
|
| 352 |
+
author = {Moreira, Gabriel de Souza P. and Osmulski, Radek and Xu, Mengyao and Ak, Ronay and Schifferer, Benedikt and Oldridge, Even},
|
| 353 |
+
title = {Improving Text Embedding Models with Positive-aware Hard-negative Mining},
|
| 354 |
+
year = {2025},
|
| 355 |
+
isbn = {9798400720406},
|
| 356 |
+
publisher = {Association for Computing Machinery},
|
| 357 |
+
address = {New York, NY, USA},
|
| 358 |
+
url = {https://doi.org/10.1145/3746252.3761254},
|
| 359 |
+
doi = {10.1145/3746252.3761254},
|
| 360 |
+
pages = {2169–2178},
|
| 361 |
+
numpages = {10},
|
| 362 |
+
keywords = {contrastive learning, distillation, embedding models, hard-negative mining, rag, text retrieval, transformers},
|
| 363 |
+
location = {Seoul, Republic of Korea},
|
| 364 |
+
series = {CIKM '25}
|
| 365 |
+
}
|
| 366 |
+
```
|
| 367 |
+
|
| 368 |
+
## Bias
|
| 369 |
+
|
| 370 |
+
| Field | Response |
|
| 371 |
+
| ----- | ----- |
|
| 372 |
+
| Participation considerations from adversely impacted groups [protected classes](https://www.senate.ca.gov/content/protected-classes) in model design and testing | None |
|
| 373 |
+
| Measures taken to mitigate against unwanted bias | None |
|
| 374 |
+
| Bias Metric (If Measured) | None |
|
| 375 |
+
|
| 376 |
+
## Explainability
|
| 377 |
+
|
| 378 |
+
| Field | Response |
|
| 379 |
+
| ----- | ----- |
|
| 380 |
+
| Intended Application & Domain: | Passage or document ranking for question and answer retrieval. |
|
| 381 |
+
| Model Type: | Transformer cross-encoder. |
|
| 382 |
+
| Intended User: | Generative AI developers working with conversational AI models. This is suitable for users building question-answering applications over large multimodal corpora and aiming to improve retrieval performance by reranking a set of candidate documents for a given question. The corpus may include visually rich document images (e.g., pages with text, figures, tables, charts, or infographics) and/or text extracted from documents. |
|
| 383 |
+
| Output: | List of Floats (Score/Logit indicating if a passage/document relevant to a question). |
|
| 384 |
+
| Describe how the model works: | The model outputs a relevance score (logit) reflecting how strongly it predicts that the passage or document contains the information required to answer the question. |
|
| 385 |
+
| Technical Limitations: | The model's max sequence length is 10240. Longer text inputs should be truncated. |
|
| 386 |
+
| Name the adversely impacted groups this has been tested to deliver comparable outcomes regardless of: | N/A |
|
| 387 |
+
| Verified to have met prescribed NVIDIA quality standards: | Yes |
|
| 388 |
+
| Performance Metrics: | Accuracy, Throughput, and Latency. |
|
| 389 |
+
| Potential Known Risks: | This model does not always guarantee to provide a meaningful ranking of document(s) for a given query. |
|
| 390 |
+
| Licensing & Terms of Use: | The use of this model is governed by the [NVIDIA Open Model License Agreement](https://www.nvidia.com/en-us/agreements/enterprise-software/nvidia-open-model-license/) and the use of the post-processing scripts are licensed under [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt). Additional Information: [Llama 3.2 Community Model License Agreement](https://www.llama.com/llama3_2/license/). Built with Llama. |
|
| 391 |
+
|
| 392 |
+
## Privacy
|
| 393 |
+
|
| 394 |
+
| Field | Response |
|
| 395 |
+
| ----- | ----- |
|
| 396 |
+
| Generatable or reverse engineerable personal data? | No |
|
| 397 |
+
| Personal data used to create this model? | None Known |
|
| 398 |
+
| Was consent obtained for any personal data used? | Not Applicable |
|
| 399 |
+
| How often is dataset reviewed? | Dataset is initially reviewed upon addition, and subsequent reviews are conducted as needed or upon request for changes. |
|
| 400 |
+
| Is there provenance for all datasets used in training? | Yes |
|
| 401 |
+
| Does data labeling (annotation, metadata) comply with privacy laws? | Yes |
|
| 402 |
+
| Is data compliant with data subject requests for data correction or removal, if such a request was made? | No, not possible with externally-sourced data. |
|
| 403 |
+
| Was data from user interactions with the AI model (e.g. user input and prompts) used to train the model? | No |
|
| 404 |
+
| Was consent obtained for any personal data used? | Not Applicable |
|
| 405 |
+
| Applicable Privacy Policy | https://www.nvidia.com/en-us/about-nvidia/privacy-policy/ |
|
| 406 |
+
|
| 407 |
+
## Safety & Security
|
| 408 |
+
|
| 409 |
+
| Field | Response |
|
| 410 |
+
| ----- | ----- |
|
| 411 |
+
| Model Application(s): | Document Reranking for Retrieval. User queries can be text and documents can be text, document page images, charts, tables, and infographics. |
|
| 412 |
+
| Describe the physical safety impact (if present). | Not Applicable |
|
| 413 |
+
| Use Case Restrictions: | The use of this model is governed by the [NVIDIA Open Model License Agreement](https://www.nvidia.com/en-us/agreements/enterprise-software/nvidia-open-model-license/) and the use of the post-processing scripts are licensed under [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt). Additional Information: [Llama 3.2 Community Model License Agreement](https://www.llama.com/llama3_2/license/). Built with Llama. |
|
| 414 |
+
| Model and dataset restrictions: | The Principle of least privilege (PoLP) is applied limiting access for dataset generation and model development. Restrictions enforce dataset access during training, and dataset license constraints adhered to. |
|
THIRD_PARTY_NOTICES.md
ADDED
|
@@ -0,0 +1,306 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Copyright "Hugging Face, Inc." - Apache License 2.0
|
| 2 |
+
License Text([https://github.com/huggingface/transformers/blob/main/LICENSE](https://github.com/huggingface/transformers/blob/main/LICENSE))
|
| 3 |
+
|
| 4 |
+
This notice applies to **transformers**.
|
| 5 |
+
|
| 6 |
+
Copyright 2018- The Hugging Face team. All rights reserved.
|
| 7 |
+
|
| 8 |
+
Apache License
|
| 9 |
+
Version 2.0, January 2004
|
| 10 |
+
http://www.apache.org/licenses/
|
| 11 |
+
|
| 12 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
| 13 |
+
|
| 14 |
+
1. Definitions.
|
| 15 |
+
|
| 16 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
| 17 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
| 18 |
+
|
| 19 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
| 20 |
+
the copyright owner that is granting the License.
|
| 21 |
+
|
| 22 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
| 23 |
+
other entities that control, are controlled by, or are under common
|
| 24 |
+
control with that entity. For the purposes of this definition,
|
| 25 |
+
"control" means (i) the power, direct or indirect, to cause the
|
| 26 |
+
direction or management of such entity, whether by contract or
|
| 27 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
| 28 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
| 29 |
+
|
| 30 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
| 31 |
+
exercising permissions granted by this License.
|
| 32 |
+
|
| 33 |
+
"Source" form shall mean the preferred form for making modifications,
|
| 34 |
+
including but not limited to software source code, documentation
|
| 35 |
+
source, and configuration files.
|
| 36 |
+
|
| 37 |
+
"Object" form shall mean any form resulting from mechanical
|
| 38 |
+
transformation or translation of a Source form, including but
|
| 39 |
+
not limited to compiled object code, generated documentation,
|
| 40 |
+
and conversions to other media types.
|
| 41 |
+
|
| 42 |
+
"Work" shall mean the work of authorship, whether in Source or
|
| 43 |
+
Object form, made available under the License, as indicated by a
|
| 44 |
+
copyright notice that is included in or attached to the work
|
| 45 |
+
(an example is provided in the Appendix below).
|
| 46 |
+
|
| 47 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
| 48 |
+
form, that is based on (or derived from) the Work and for which the
|
| 49 |
+
editorial revisions, annotations, elaborations, or other modifications
|
| 50 |
+
represent, as a whole, an original work of authorship. For the purposes
|
| 51 |
+
of this License, Derivative Works shall not include works that remain
|
| 52 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
| 53 |
+
the Work and Derivative Works thereof.
|
| 54 |
+
|
| 55 |
+
"Contribution" shall mean any work of authorship, including
|
| 56 |
+
the original version of the Work and any modifications or additions
|
| 57 |
+
to that Work or Derivative Works thereof, that is intentionally
|
| 58 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
| 59 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
| 60 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
| 61 |
+
means any form of electronic, verbal, or written communication sent
|
| 62 |
+
to the Licensor or its representatives, including but not limited to
|
| 63 |
+
communication on electronic mailing lists, source code control systems,
|
| 64 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
| 65 |
+
Licensor for the purpose of discussing and improving the Work, but
|
| 66 |
+
excluding communication that is conspicuously marked or otherwise
|
| 67 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
| 68 |
+
|
| 69 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
| 70 |
+
on behalf of whom a Contribution has been received by Licensor and
|
| 71 |
+
subsequently incorporated within the Work.
|
| 72 |
+
|
| 73 |
+
2. Grant of Copyright 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 |
+
copyright license to reproduce, prepare Derivative Works of,
|
| 77 |
+
publicly display, publicly perform, sublicense, and distribute the
|
| 78 |
+
Work and such Derivative Works in Source or Object form.
|
| 79 |
+
|
| 80 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
| 81 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 82 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 83 |
+
(except as stated in this section) patent license to make, have made,
|
| 84 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
| 85 |
+
where such license applies only to those patent claims licensable
|
| 86 |
+
by such Contributor that are necessarily infringed by their
|
| 87 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
| 88 |
+
with the Work to which such Contribution(s) was submitted. If You
|
| 89 |
+
institute patent litigation against any entity (including a
|
| 90 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
| 91 |
+
or a Contribution incorporated within the Work constitutes direct
|
| 92 |
+
or contributory patent infringement, then any patent licenses
|
| 93 |
+
granted to You under this License for that Work shall terminate
|
| 94 |
+
as of the date such litigation is filed.
|
| 95 |
+
|
| 96 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
| 97 |
+
Work or Derivative Works thereof in any medium, with or without
|
| 98 |
+
modifications, and in Source or Object form, provided that You
|
| 99 |
+
meet the following conditions:
|
| 100 |
+
|
| 101 |
+
(a) You must give any other recipients of the Work or
|
| 102 |
+
Derivative Works a copy of this License; and
|
| 103 |
+
|
| 104 |
+
(b) You must cause any modified files to carry prominent notices
|
| 105 |
+
stating that You changed the files; and
|
| 106 |
+
|
| 107 |
+
(c) You must retain, in the Source form of any Derivative Works
|
| 108 |
+
that You distribute, all copyright, patent, trademark, and
|
| 109 |
+
attribution notices from the Source form of the Work,
|
| 110 |
+
excluding those notices that do not pertain to any part of
|
| 111 |
+
the Derivative Works; and
|
| 112 |
+
|
| 113 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
| 114 |
+
distribution, then any Derivative Works that You distribute must
|
| 115 |
+
include a readable copy of the attribution notices contained
|
| 116 |
+
within such NOTICE file, excluding those notices that do not
|
| 117 |
+
pertain to any part of the Derivative Works, in at least one
|
| 118 |
+
of the following places: within a NOTICE text file distributed
|
| 119 |
+
as part of the Derivative Works; within the Source form or
|
| 120 |
+
documentation, if provided along with the Derivative Works; or,
|
| 121 |
+
within a display generated by the Derivative Works, if and
|
| 122 |
+
wherever such third-party notices normally appear. The contents
|
| 123 |
+
of the NOTICE file are for informational purposes only and
|
| 124 |
+
do not modify the License. You may add Your own attribution
|
| 125 |
+
notices within Derivative Works that You distribute, alongside
|
| 126 |
+
or as an addendum to the NOTICE text from the Work, provided
|
| 127 |
+
that such additional attribution notices cannot be construed
|
| 128 |
+
as modifying the License.
|
| 129 |
+
|
| 130 |
+
You may add Your own copyright statement to Your modifications and
|
| 131 |
+
may provide additional or different license terms and conditions
|
| 132 |
+
for use, reproduction, or distribution of Your modifications, or
|
| 133 |
+
for any such Derivative Works as a whole, provided Your use,
|
| 134 |
+
reproduction, and distribution of the Work otherwise complies with
|
| 135 |
+
the conditions stated in this License.
|
| 136 |
+
|
| 137 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
| 138 |
+
any Contribution intentionally submitted for inclusion in the Work
|
| 139 |
+
by You to the Licensor shall be under the terms and conditions of
|
| 140 |
+
this License, without any additional terms or conditions.
|
| 141 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
| 142 |
+
the terms of any separate license agreement you may have executed
|
| 143 |
+
with Licensor regarding such Contributions.
|
| 144 |
+
|
| 145 |
+
6. Trademarks. This License does not grant permission to use the trade
|
| 146 |
+
names, trademarks, service marks, or product names of the Licensor,
|
| 147 |
+
except as required for reasonable and customary use in describing the
|
| 148 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
| 149 |
+
|
| 150 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
| 151 |
+
agreed to in writing, Licensor provides the Work (and each
|
| 152 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
| 153 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 154 |
+
implied, including, without limitation, any warranties or conditions
|
| 155 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
| 156 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
| 157 |
+
appropriateness of using or redistributing the Work and assume any
|
| 158 |
+
risks associated with Your exercise of permissions under this License.
|
| 159 |
+
|
| 160 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
| 161 |
+
whether in tort (including negligence), contract, or otherwise,
|
| 162 |
+
unless required by applicable law (such as deliberate and grossly
|
| 163 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
| 164 |
+
liable to You for damages, including any direct, indirect, special,
|
| 165 |
+
incidental, or consequential damages of any character arising as a
|
| 166 |
+
result of this License or out of the use or inability to use the
|
| 167 |
+
Work (including but not limited to damages for loss of goodwill,
|
| 168 |
+
work stoppage, computer failure or malfunction, or any and all
|
| 169 |
+
other commercial damages or losses), even if such Contributor
|
| 170 |
+
has been advised of the possibility of such damages.
|
| 171 |
+
|
| 172 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
| 173 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
| 174 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
| 175 |
+
or other liability obligations and/or rights consistent with this
|
| 176 |
+
License. However, in accepting such obligations, You may act only
|
| 177 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
| 178 |
+
of any other Contributor, and only if You agree to indemnify,
|
| 179 |
+
defend, and hold each Contributor harmless for any liability
|
| 180 |
+
incurred by, or claims asserted against, such Contributor by reason
|
| 181 |
+
of your accepting any such warranty or additional liability.
|
| 182 |
+
|
| 183 |
+
END OF TERMS AND CONDITIONS
|
| 184 |
+
|
| 185 |
+
-----
|
| 186 |
+
|
| 187 |
+
Copyright "Secret Labs AB, Fredrik Lundh, Alex Clark and contributors" - Pillow License
|
| 188 |
+
License Text([https://github.com/python-pillow/Pillow/blob/main/LICENSE](https://www.google.com/search?q=https://github.com/python-pillow/Pillow/blob/main/LICENSE))
|
| 189 |
+
|
| 190 |
+
This notice applies to **PIL (Pillow)**.
|
| 191 |
+
|
| 192 |
+
The Python Imaging Library (PIL) is
|
| 193 |
+
Copyright (c) 1997-2011 by Secret Labs AB
|
| 194 |
+
Copyright (c) 1995-2011 by Fredrik Lundh
|
| 195 |
+
Copyright (c) 2010-2023 by Alex Clark and contributors
|
| 196 |
+
|
| 197 |
+
Like PIL, Pillow is licensed under the open source HPND License:
|
| 198 |
+
|
| 199 |
+
By obtaining, using, and/or copying this software and/or its
|
| 200 |
+
associated documentation, you agree that you have read, understood,
|
| 201 |
+
and will comply with the following terms and conditions:
|
| 202 |
+
|
| 203 |
+
Permission to use, copy, modify, and distribute this software and
|
| 204 |
+
its associated documentation for any purpose and without fee is
|
| 205 |
+
hereby granted, provided that the above copyright notice appears in
|
| 206 |
+
all copies, and that both that copyright notice and this permission
|
| 207 |
+
notice appear in supporting documentation, and that the name of
|
| 208 |
+
Secret Labs AB or the author not be used in advertising or publicity
|
| 209 |
+
pertaining to distribution of the software without specific, written
|
| 210 |
+
prior permission.
|
| 211 |
+
|
| 212 |
+
SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
|
| 213 |
+
TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT-
|
| 214 |
+
ABILITY AND FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR
|
| 215 |
+
BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
|
| 216 |
+
DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 217 |
+
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 218 |
+
ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 219 |
+
OF THIS SOFTWARE.
|
| 220 |
+
|
| 221 |
+
-----
|
| 222 |
+
|
| 223 |
+
Copyright "PyTorch Contributors" - BSD-style License
|
| 224 |
+
License Text([https://github.com/pytorch/pytorch/blob/main/LICENSE](https://www.google.com/search?q=https://github.com/pytorch/pytorch/blob/main/LICENSE))
|
| 225 |
+
|
| 226 |
+
This notice applies to **torch** and **torchvision**.
|
| 227 |
+
|
| 228 |
+
Copyright (c) 2016- Facebook, Inc. (Adam Paszke)
|
| 229 |
+
Copyright (c) 2014- Facebook, Inc. (Soumith Chintala)
|
| 230 |
+
Copyright (c) 2011-2014 Idiap Research Institute (Ronan Collobert)
|
| 231 |
+
Copyright (c) 2012-2014 DeepMind Technologies (Koray Kavukcuoglu)
|
| 232 |
+
Copyright (c) 2011-2012 NEC Laboratories America (Clement Farabet)
|
| 233 |
+
Copyright (c) 2011-2013 New York University (Antoine Bordes)
|
| 234 |
+
Copyright (c) 2012-2013 University of Montreal (Pascal Vincent)
|
| 235 |
+
Copyright (c) 2014- Google Inc.
|
| 236 |
+
Copyright (c) 2015- Twitter, Inc.
|
| 237 |
+
Copyright (c) 2015- Intel Corporation
|
| 238 |
+
Copyright (c) 2015- AMD Inc.
|
| 239 |
+
Copyright (c) 2016- Baidu, Inc.
|
| 240 |
+
Copyright (c) 2016- Microsoft Corporation
|
| 241 |
+
Copyright (c) 2017- Amazon.com, Inc.
|
| 242 |
+
Copyright (c) 2018- Facebook AI Research
|
| 243 |
+
Copyright (c) 2019- fast.ai, Inc.
|
| 244 |
+
Copyright (c) 2022- PyTorch Contributors
|
| 245 |
+
All rights reserved.
|
| 246 |
+
|
| 247 |
+
Redistribution and use in source and binary forms, with or without
|
| 248 |
+
modification, are permitted provided that the following conditions are met:
|
| 249 |
+
|
| 250 |
+
* Redistributions of source code must retain the above copyright notice, this
|
| 251 |
+
list of conditions and the following disclaimer.
|
| 252 |
+
|
| 253 |
+
* Redistributions in binary form must reproduce the above copyright notice,
|
| 254 |
+
this list of conditions and the following disclaimer in the documentation
|
| 255 |
+
and/or other materials provided with the distribution.
|
| 256 |
+
|
| 257 |
+
* Neither the name of Facebook Inc. nor the names of its contributors may be
|
| 258 |
+
used to endorse or promote products derived from this software without
|
| 259 |
+
specific prior written permission.
|
| 260 |
+
|
| 261 |
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
| 262 |
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
| 263 |
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
| 264 |
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
| 265 |
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
| 266 |
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
| 267 |
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
| 268 |
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
| 269 |
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 270 |
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 271 |
+
|
| 272 |
+
-----
|
| 273 |
+
|
| 274 |
+
Copyright "Tri Dao" - BSD 3-Clause License
|
| 275 |
+
License Text([https://github.com/Dao-AILab/flash-attention/blob/main/LICENSE](https://github.com/Dao-AILab/flash-attention/blob/main/LICENSE))
|
| 276 |
+
|
| 277 |
+
This notice applies to **flash-attention**.
|
| 278 |
+
|
| 279 |
+
Copyright (c) 2022, Tri Dao.
|
| 280 |
+
All rights reserved.
|
| 281 |
+
|
| 282 |
+
Redistribution and use in source and binary forms, with or without
|
| 283 |
+
modification, are permitted provided that the following conditions are
|
| 284 |
+
met:
|
| 285 |
+
|
| 286 |
+
* Redistributions of source code must retain the above copyright notice, this
|
| 287 |
+
list of conditions and the following disclaimer.
|
| 288 |
+
|
| 289 |
+
* Redistributions in binary form must reproduce the above copyright notice,
|
| 290 |
+
this list of conditions and the following disclaimer in the documentation
|
| 291 |
+
and/or other materials provided with the distribution.
|
| 292 |
+
|
| 293 |
+
* Neither the name of the copyright holder nor the names of its
|
| 294 |
+
contributors may be used to endorse or promote products derived from
|
| 295 |
+
this software without specific prior written permission.
|
| 296 |
+
|
| 297 |
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
| 298 |
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
| 299 |
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
| 300 |
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
| 301 |
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
| 302 |
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
| 303 |
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
| 304 |
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
| 305 |
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 306 |
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{{- bos_token }}
|
| 2 |
+
{%- if custom_tools is defined %}
|
| 3 |
+
{%- set tools = custom_tools %}
|
| 4 |
+
{%- endif %}
|
| 5 |
+
{%- if not tools_in_user_message is defined %}
|
| 6 |
+
{%- set tools_in_user_message = true %}
|
| 7 |
+
{%- endif %}
|
| 8 |
+
{%- if not date_string is defined %}
|
| 9 |
+
{%- if strftime_now is defined %}
|
| 10 |
+
{%- set date_string = strftime_now("%d %b %Y") %}
|
| 11 |
+
{%- else %}
|
| 12 |
+
{%- set date_string = "26 Jul 2024" %}
|
| 13 |
+
{%- endif %}
|
| 14 |
+
{%- endif %}
|
| 15 |
+
{%- if not tools is defined %}
|
| 16 |
+
{%- set tools = none %}
|
| 17 |
+
{%- endif %}
|
| 18 |
+
|
| 19 |
+
{#- This block extracts the system message, so we can slot it into the right place. #}
|
| 20 |
+
{%- if messages[0]['role'] == 'system' %}
|
| 21 |
+
{%- set system_message = messages[0]['content']|trim %}
|
| 22 |
+
{%- set messages = messages[1:] %}
|
| 23 |
+
{%- else %}
|
| 24 |
+
{%- set system_message = "" %}
|
| 25 |
+
{%- endif %}
|
| 26 |
+
|
| 27 |
+
{#- System message #}
|
| 28 |
+
{{- "<|start_header_id|>system<|end_header_id|>\n\n" }}
|
| 29 |
+
{%- if tools is not none %}
|
| 30 |
+
{{- "Environment: ipython\n" }}
|
| 31 |
+
{%- endif %}
|
| 32 |
+
{{- "Cutting Knowledge Date: December 2023\n" }}
|
| 33 |
+
{{- "Today Date: " + date_string + "\n\n" }}
|
| 34 |
+
{%- if tools is not none and not tools_in_user_message %}
|
| 35 |
+
{{- "You have access to the following functions. To call a function, please respond with JSON for a function call." }}
|
| 36 |
+
{{- 'Respond in the format {"name": function name, "parameters": dictionary of argument name and its value}.' }}
|
| 37 |
+
{{- "Do not use variables.\n\n" }}
|
| 38 |
+
{%- for t in tools %}
|
| 39 |
+
{{- t | tojson(indent=4) }}
|
| 40 |
+
{{- "\n\n" }}
|
| 41 |
+
{%- endfor %}
|
| 42 |
+
{%- endif %}
|
| 43 |
+
{{- system_message }}
|
| 44 |
+
{{- "<|eot_id|>" }}
|
| 45 |
+
|
| 46 |
+
{#- Custom tools are passed in a user message with some extra guidance #}
|
| 47 |
+
{%- if tools_in_user_message and not tools is none %}
|
| 48 |
+
{#- Extract the first user message so we can plug it in here #}
|
| 49 |
+
{%- if messages | length != 0 %}
|
| 50 |
+
{%- set first_user_message = messages[0]['content']|trim %}
|
| 51 |
+
{%- set messages = messages[1:] %}
|
| 52 |
+
{%- else %}
|
| 53 |
+
{{- raise_exception("Cannot put tools in the first user message when there's no first user message!") }}
|
| 54 |
+
{%- endif %}
|
| 55 |
+
{{- '<|start_header_id|>user<|end_header_id|>\n\n' -}}
|
| 56 |
+
{{- "Given the following functions, please respond with a JSON for a function call " }}
|
| 57 |
+
{{- "with its proper arguments that best answers the given prompt.\n\n" }}
|
| 58 |
+
{{- 'Respond in the format {"name": function name, "parameters": dictionary of argument name and its value}.' }}
|
| 59 |
+
{{- "Do not use variables.\n\n" }}
|
| 60 |
+
{%- for t in tools %}
|
| 61 |
+
{{- t | tojson(indent=4) }}
|
| 62 |
+
{{- "\n\n" }}
|
| 63 |
+
{%- endfor %}
|
| 64 |
+
{{- first_user_message + "<|eot_id|>"}}
|
| 65 |
+
{%- endif %}
|
| 66 |
+
|
| 67 |
+
{%- for message in messages %}
|
| 68 |
+
{%- if not (message.role == 'ipython' or message.role == 'tool' or 'tool_calls' in message) %}
|
| 69 |
+
{{- '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n'+ message['content'] | trim + '<|eot_id|>' }}
|
| 70 |
+
{%- elif 'tool_calls' in message %}
|
| 71 |
+
{%- if not message.tool_calls|length == 1 %}
|
| 72 |
+
{{- raise_exception("This model only supports single tool-calls at once!") }}
|
| 73 |
+
{%- endif %}
|
| 74 |
+
{%- set tool_call = message.tool_calls[0].function %}
|
| 75 |
+
{{- '<|start_header_id|>assistant<|end_header_id|>\n\n' -}}
|
| 76 |
+
{{- '{"name": "' + tool_call.name + '", ' }}
|
| 77 |
+
{{- '"parameters": ' }}
|
| 78 |
+
{{- tool_call.arguments | tojson }}
|
| 79 |
+
{{- "}" }}
|
| 80 |
+
{{- "<|eot_id|>" }}
|
| 81 |
+
{%- elif message.role == "tool" or message.role == "ipython" %}
|
| 82 |
+
{{- "<|start_header_id|>ipython<|end_header_id|>\n\n" }}
|
| 83 |
+
{%- if message.content is mapping or message.content is iterable %}
|
| 84 |
+
{{- message.content | tojson }}
|
| 85 |
+
{%- else %}
|
| 86 |
+
{{- message.content }}
|
| 87 |
+
{%- endif %}
|
| 88 |
+
{{- "<|eot_id|>" }}
|
| 89 |
+
{%- endif %}
|
| 90 |
+
{%- endfor %}
|
| 91 |
+
{%- if add_generation_prompt %}
|
| 92 |
+
{{- '<|start_header_id|>assistant<|end_header_id|>\n\n' }}
|
| 93 |
+
{%- endif %}
|
config.json
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"LlamaNemotronVLForSequenceClassification"
|
| 4 |
+
],
|
| 5 |
+
"auto_map": {
|
| 6 |
+
"AutoConfig": "configuration_llama_nemotron_vl.LlamaNemotronVLForSequenceClassificationConfig",
|
| 7 |
+
"AutoModel": "modeling_llama_nemotron_vl.LlamaNemotronVLForSequenceClassification",
|
| 8 |
+
"AutoModelForSequenceClassification": "modeling_llama_nemotron_vl.LlamaNemotronVLForSequenceClassification"
|
| 9 |
+
},
|
| 10 |
+
"bidirectional_attention": false,
|
| 11 |
+
"downsample_ratio": 0.5,
|
| 12 |
+
"dtype": "bfloat16",
|
| 13 |
+
"dynamic_image_size": true,
|
| 14 |
+
"force_image_size": 512,
|
| 15 |
+
"has_no_defaults_at_init": true,
|
| 16 |
+
"id2label": {
|
| 17 |
+
"0": "LABEL_0"
|
| 18 |
+
},
|
| 19 |
+
"img_context_token_id": 128258,
|
| 20 |
+
"is_composition": true,
|
| 21 |
+
"keep_aspect_ratio": false,
|
| 22 |
+
"label2id": {
|
| 23 |
+
"LABEL_0": 0
|
| 24 |
+
},
|
| 25 |
+
"llm_config": {
|
| 26 |
+
"_attn_implementation_autoset": true,
|
| 27 |
+
"architectures": [
|
| 28 |
+
"LlamaBidirectionalForSequenceClassification"
|
| 29 |
+
],
|
| 30 |
+
"attention_bias": false,
|
| 31 |
+
"attention_dropout": 0.0,
|
| 32 |
+
"bos_token_id": 128000,
|
| 33 |
+
"dtype": "bfloat16",
|
| 34 |
+
"eos_token_id": 128001,
|
| 35 |
+
"head_dim": 64,
|
| 36 |
+
"hidden_act": "silu",
|
| 37 |
+
"hidden_size": 2048,
|
| 38 |
+
"id2label": {
|
| 39 |
+
"0": "LABEL_0"
|
| 40 |
+
},
|
| 41 |
+
"initializer_range": 0.02,
|
| 42 |
+
"intermediate_size": 8192,
|
| 43 |
+
"label2id": {
|
| 44 |
+
"LABEL_0": 0
|
| 45 |
+
},
|
| 46 |
+
"max_position_embeddings": 131072,
|
| 47 |
+
"mlp_bias": false,
|
| 48 |
+
"model_type": "llama_bidirec",
|
| 49 |
+
"num_attention_heads": 32,
|
| 50 |
+
"num_hidden_layers": 16,
|
| 51 |
+
"num_key_value_heads": 8,
|
| 52 |
+
"pad_token_id": 128001,
|
| 53 |
+
"pooling": "avg",
|
| 54 |
+
"pretraining_tp": 1,
|
| 55 |
+
"rms_norm_eps": 1e-05,
|
| 56 |
+
"rope_scaling": {
|
| 57 |
+
"factor": 32.0,
|
| 58 |
+
"high_freq_factor": 4.0,
|
| 59 |
+
"low_freq_factor": 1.0,
|
| 60 |
+
"original_max_position_embeddings": 8192,
|
| 61 |
+
"rope_type": "llama3"
|
| 62 |
+
},
|
| 63 |
+
"rope_theta": 500000.0,
|
| 64 |
+
"tie_word_embeddings": true,
|
| 65 |
+
"use_cache": true,
|
| 66 |
+
"vocab_size": 128267
|
| 67 |
+
},
|
| 68 |
+
"loss_version": "efficient_v2_cp_head",
|
| 69 |
+
"max_dynamic_patch": 12,
|
| 70 |
+
"max_input_tiles": 4,
|
| 71 |
+
"min_dynamic_patch": 1,
|
| 72 |
+
"mlp_checkpoint": false,
|
| 73 |
+
"model_type": "llama_nemotron_vl_rerank",
|
| 74 |
+
"modelopt_quantization_config": {
|
| 75 |
+
"component": "text",
|
| 76 |
+
"modelopt_quantized": true,
|
| 77 |
+
"quant_type": "fp8"
|
| 78 |
+
},
|
| 79 |
+
"p_max_length": 10240,
|
| 80 |
+
"pad2square": false,
|
| 81 |
+
"pad_token_id": 128004,
|
| 82 |
+
"passage_prefix": "passage:",
|
| 83 |
+
"pooling": "avg",
|
| 84 |
+
"pre_feature_reduction": false,
|
| 85 |
+
"prompt_template": "v1",
|
| 86 |
+
"ps_version": "v2",
|
| 87 |
+
"q_max_length": 512,
|
| 88 |
+
"query_prefix": "query:",
|
| 89 |
+
"select_layer": -1,
|
| 90 |
+
"template": "bidirectional-llama-retriever",
|
| 91 |
+
"transformers_version": "4.57.6",
|
| 92 |
+
"use_backbone_lora": 0,
|
| 93 |
+
"use_llm_lora": 0,
|
| 94 |
+
"use_thumbnail": true,
|
| 95 |
+
"vision_config": {
|
| 96 |
+
"_attn_implementation_autoset": true,
|
| 97 |
+
"attention_dropout": 0.0,
|
| 98 |
+
"drop_path_rate": 0.1,
|
| 99 |
+
"dtype": "bfloat16",
|
| 100 |
+
"hidden_act": "gelu_pytorch_tanh",
|
| 101 |
+
"hidden_size": 1152,
|
| 102 |
+
"image_size": 512,
|
| 103 |
+
"intermediate_size": 4304,
|
| 104 |
+
"layer_norm_eps": 1e-06,
|
| 105 |
+
"model_type": "siglip_vision_model",
|
| 106 |
+
"num_attention_heads": 16,
|
| 107 |
+
"num_channels": 3,
|
| 108 |
+
"num_hidden_layers": 27,
|
| 109 |
+
"patch_size": 16
|
| 110 |
+
},
|
| 111 |
+
"vocab_size": 128267,
|
| 112 |
+
"quantization_config": {
|
| 113 |
+
"config_groups": {
|
| 114 |
+
"group_0": {
|
| 115 |
+
"input_activations": {
|
| 116 |
+
"dynamic": false,
|
| 117 |
+
"num_bits": 8,
|
| 118 |
+
"type": "float"
|
| 119 |
+
},
|
| 120 |
+
"weights": {
|
| 121 |
+
"dynamic": false,
|
| 122 |
+
"num_bits": 8,
|
| 123 |
+
"type": "float"
|
| 124 |
+
},
|
| 125 |
+
"targets": [
|
| 126 |
+
"Linear"
|
| 127 |
+
]
|
| 128 |
+
}
|
| 129 |
+
},
|
| 130 |
+
"ignore": [
|
| 131 |
+
"model.mlp1*",
|
| 132 |
+
"model.vision_model*",
|
| 133 |
+
"*embed_tokens*",
|
| 134 |
+
"score*",
|
| 135 |
+
"model.score*",
|
| 136 |
+
"language_model.score*",
|
| 137 |
+
"model.language_model.score*",
|
| 138 |
+
"classifier*",
|
| 139 |
+
"model.classifier*",
|
| 140 |
+
"language_model.classifier*",
|
| 141 |
+
"model.language_model.classifier*",
|
| 142 |
+
"lm_head*",
|
| 143 |
+
"model.lm_head*",
|
| 144 |
+
"language_model.lm_head*",
|
| 145 |
+
"model.language_model.lm_head*"
|
| 146 |
+
],
|
| 147 |
+
"quant_algo": "FP8",
|
| 148 |
+
"producer": {
|
| 149 |
+
"name": "modelopt",
|
| 150 |
+
"version": "0.43.0"
|
| 151 |
+
},
|
| 152 |
+
"quant_method": "modelopt"
|
| 153 |
+
}
|
| 154 |
+
}
|
configuration_llama_nemotron_vl.py
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
| 2 |
+
# SPDX-License-Identifier: Apache-2.0.
|
| 3 |
+
|
| 4 |
+
from typing import Optional
|
| 5 |
+
|
| 6 |
+
from transformers.configuration_utils import PretrainedConfig
|
| 7 |
+
from transformers.models.llama.configuration_llama import LlamaConfig
|
| 8 |
+
from transformers.models.siglip.configuration_siglip import SiglipVisionConfig
|
| 9 |
+
from transformers.utils import logging
|
| 10 |
+
|
| 11 |
+
logger = logging.get_logger(__name__)
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
# ============================================================================
|
| 15 |
+
# Bidirectional LLaMA Configuration
|
| 16 |
+
# ============================================================================
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class LlamaBidirectionalConfig(LlamaConfig):
|
| 20 |
+
"""Configuration for bidirectional (non-causal) LLaMA model."""
|
| 21 |
+
|
| 22 |
+
model_type = "llama_bidirec"
|
| 23 |
+
|
| 24 |
+
def __init__(
|
| 25 |
+
self,
|
| 26 |
+
pooling="avg",
|
| 27 |
+
temperature=1.0,
|
| 28 |
+
**kwargs,
|
| 29 |
+
):
|
| 30 |
+
self.pooling = pooling
|
| 31 |
+
self.temperature = temperature
|
| 32 |
+
super().__init__(**kwargs)
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
# ============================================================================
|
| 36 |
+
# LlamaNemotronVL Configuration Classes
|
| 37 |
+
# ============================================================================
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
class LlamaNemotronVLConfig(PretrainedConfig):
|
| 41 |
+
"""
|
| 42 |
+
Base configuration for vision-language models combining vision and language components.
|
| 43 |
+
|
| 44 |
+
This serves as the foundation for LlamaNemotronVL configurations.
|
| 45 |
+
"""
|
| 46 |
+
|
| 47 |
+
model_type = "llama_nemotron_vl"
|
| 48 |
+
is_composition = True
|
| 49 |
+
# is_composition was renamed to has_no_defaults_at_init in transformers 4.52.1
|
| 50 |
+
# In PR https://github.com/huggingface/transformers/pull/36263
|
| 51 |
+
has_no_defaults_at_init = True
|
| 52 |
+
# Declare sub-configs so transformers can propagate per-backbone attn_implementation
|
| 53 |
+
# e.g. from_pretrained(attn_implementation={"vision_config": "sdpa", "llm_config": "flash_attention_2"})
|
| 54 |
+
sub_configs = {"vision_config": SiglipVisionConfig, "llm_config": LlamaBidirectionalConfig}
|
| 55 |
+
|
| 56 |
+
def __init__(
|
| 57 |
+
self,
|
| 58 |
+
# Vision-language parameters
|
| 59 |
+
vision_config=None,
|
| 60 |
+
llm_config=None,
|
| 61 |
+
use_backbone_lora=0,
|
| 62 |
+
use_llm_lora=0,
|
| 63 |
+
select_layer=-1,
|
| 64 |
+
force_image_size=None,
|
| 65 |
+
downsample_ratio=0.5,
|
| 66 |
+
template=None,
|
| 67 |
+
dynamic_image_size=False,
|
| 68 |
+
use_thumbnail=False,
|
| 69 |
+
min_dynamic_patch=1,
|
| 70 |
+
max_dynamic_patch=6,
|
| 71 |
+
mlp_checkpoint=True,
|
| 72 |
+
pre_feature_reduction=False,
|
| 73 |
+
keep_aspect_ratio=False,
|
| 74 |
+
vocab_size=-1,
|
| 75 |
+
q_max_length: Optional[int] = 512,
|
| 76 |
+
p_max_length: Optional[int] = 10240,
|
| 77 |
+
query_prefix: str = "query:",
|
| 78 |
+
passage_prefix: str = "passage:",
|
| 79 |
+
pooling: str = "last",
|
| 80 |
+
bidirectional_attention: bool = False,
|
| 81 |
+
max_input_tiles: int = 2,
|
| 82 |
+
img_context_token_id: int = 128258, # tokenizer.convert_tokens_to_ids("<IMG_CONTEXT>")
|
| 83 |
+
**kwargs,
|
| 84 |
+
):
|
| 85 |
+
# Initialize vision config
|
| 86 |
+
if vision_config is None:
|
| 87 |
+
vision_config = {}
|
| 88 |
+
logger.info(
|
| 89 |
+
"vision_config is None. Initializing Vision Encoders with default values."
|
| 90 |
+
)
|
| 91 |
+
else:
|
| 92 |
+
if vision_config["model_type"] == "siglip_vision_model":
|
| 93 |
+
self.vision_config = SiglipVisionConfig(**vision_config)
|
| 94 |
+
else:
|
| 95 |
+
raise ValueError(
|
| 96 |
+
"Unsupported model_type: {}".format(vision_config["model_type"])
|
| 97 |
+
)
|
| 98 |
+
|
| 99 |
+
# Initialize LLM config
|
| 100 |
+
if llm_config is None:
|
| 101 |
+
llm_config = {}
|
| 102 |
+
logger.info(
|
| 103 |
+
"llm_config is None. Initializing the LLM config with default values"
|
| 104 |
+
)
|
| 105 |
+
else:
|
| 106 |
+
if llm_config["architectures"][0] in {
|
| 107 |
+
"LlamaBidirectionalModel",
|
| 108 |
+
"LlamaBidirectionalForSequenceClassification",
|
| 109 |
+
}:
|
| 110 |
+
self.llm_config = LlamaBidirectionalConfig(**llm_config)
|
| 111 |
+
else:
|
| 112 |
+
raise ValueError(
|
| 113 |
+
"Unsupported architecture: {}".format(
|
| 114 |
+
llm_config["architectures"][0]
|
| 115 |
+
)
|
| 116 |
+
)
|
| 117 |
+
self.vocab_size = self.llm_config.vocab_size
|
| 118 |
+
|
| 119 |
+
# Vision-language parameters
|
| 120 |
+
self.use_backbone_lora = use_backbone_lora
|
| 121 |
+
self.use_llm_lora = use_llm_lora
|
| 122 |
+
self.select_layer = select_layer
|
| 123 |
+
self.force_image_size = force_image_size
|
| 124 |
+
self.downsample_ratio = downsample_ratio
|
| 125 |
+
self.template = template
|
| 126 |
+
self.dynamic_image_size = dynamic_image_size
|
| 127 |
+
self.use_thumbnail = use_thumbnail
|
| 128 |
+
self.min_dynamic_patch = min_dynamic_patch
|
| 129 |
+
self.max_dynamic_patch = max_dynamic_patch
|
| 130 |
+
self.mlp_checkpoint = mlp_checkpoint
|
| 131 |
+
self.pre_feature_reduction = pre_feature_reduction
|
| 132 |
+
self.keep_aspect_ratio = keep_aspect_ratio
|
| 133 |
+
|
| 134 |
+
# Reranking-specific parameters
|
| 135 |
+
self.q_max_length = q_max_length
|
| 136 |
+
self.p_max_length = p_max_length
|
| 137 |
+
self.query_prefix = query_prefix
|
| 138 |
+
self.passage_prefix = passage_prefix
|
| 139 |
+
self.pooling = pooling
|
| 140 |
+
self.bidirectional_attention = bidirectional_attention
|
| 141 |
+
self.img_context_token_id = img_context_token_id
|
| 142 |
+
self.max_input_tiles = max_input_tiles
|
| 143 |
+
|
| 144 |
+
super().__init__(**kwargs)
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
class LlamaNemotronVLForSequenceClassificationConfig(LlamaNemotronVLConfig):
|
| 148 |
+
"""
|
| 149 |
+
Configuration class for LlamaNemotron VL sequence classification model.
|
| 150 |
+
|
| 151 |
+
This configuration extends LlamaNemotronVLConfig with parameters specific to
|
| 152 |
+
sequence classification tasks (reranking).
|
| 153 |
+
"""
|
| 154 |
+
|
| 155 |
+
model_type = "llama_nemotron_vl_rerank"
|
| 156 |
+
|
| 157 |
+
def __init__(
|
| 158 |
+
self,
|
| 159 |
+
temperature: float = 1.0,
|
| 160 |
+
prompt_template: str = None,
|
| 161 |
+
**kwargs,
|
| 162 |
+
):
|
| 163 |
+
self.temperature = temperature
|
| 164 |
+
self.prompt_template = prompt_template
|
| 165 |
+
super().__init__(**kwargs)
|
hf_quant_config.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"producer": {
|
| 3 |
+
"name": "modelopt",
|
| 4 |
+
"version": "0.43.0"
|
| 5 |
+
},
|
| 6 |
+
"quantization": {
|
| 7 |
+
"quant_algo": "FP8",
|
| 8 |
+
"kv_cache_quant_algo": null,
|
| 9 |
+
"exclude_modules": [
|
| 10 |
+
"model.mlp1*",
|
| 11 |
+
"model.vision_model*",
|
| 12 |
+
"*embed_tokens*",
|
| 13 |
+
"score*",
|
| 14 |
+
"model.score*",
|
| 15 |
+
"language_model.score*",
|
| 16 |
+
"model.language_model.score*",
|
| 17 |
+
"classifier*",
|
| 18 |
+
"model.classifier*",
|
| 19 |
+
"language_model.classifier*",
|
| 20 |
+
"model.language_model.classifier*",
|
| 21 |
+
"lm_head*",
|
| 22 |
+
"model.lm_head*",
|
| 23 |
+
"language_model.lm_head*",
|
| 24 |
+
"model.language_model.lm_head*"
|
| 25 |
+
]
|
| 26 |
+
},
|
| 27 |
+
"quant_method": "modelopt"
|
| 28 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f700e0f51118e1c325d4b4fdbc5edfe0defefa1b1f39435c39c70aaf570ee2fb
|
| 3 |
+
size 2383548640
|
modeling_llama_nemotron_vl.py
ADDED
|
@@ -0,0 +1,712 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
| 2 |
+
# SPDX-License-Identifier: Apache-2.0.
|
| 3 |
+
|
| 4 |
+
import inspect
|
| 5 |
+
import math
|
| 6 |
+
from typing import List, Optional, Tuple, Union, Any, Dict
|
| 7 |
+
|
| 8 |
+
import torch
|
| 9 |
+
import torch.nn as nn
|
| 10 |
+
import transformers
|
| 11 |
+
from torch.nn import CrossEntropyLoss, BCEWithLogitsLoss, MSELoss
|
| 12 |
+
from transformers import AutoProcessor, PreTrainedModel
|
| 13 |
+
from transformers.cache_utils import Cache, DynamicCache
|
| 14 |
+
from transformers.modeling_outputs import (
|
| 15 |
+
BaseModelOutputWithPast,
|
| 16 |
+
CausalLMOutputWithPast,
|
| 17 |
+
SequenceClassifierOutputWithPast,
|
| 18 |
+
)
|
| 19 |
+
from transformers.models.llama.modeling_llama import (
|
| 20 |
+
LlamaDecoderLayer,
|
| 21 |
+
LlamaModel,
|
| 22 |
+
LlamaPreTrainedModel,
|
| 23 |
+
)
|
| 24 |
+
from transformers.models.siglip.modeling_siglip import SiglipVisionModel
|
| 25 |
+
from transformers.utils import logging
|
| 26 |
+
|
| 27 |
+
from .configuration_llama_nemotron_vl import (
|
| 28 |
+
LlamaBidirectionalConfig,
|
| 29 |
+
LlamaNemotronVLConfig,
|
| 30 |
+
LlamaNemotronVLForSequenceClassificationConfig,
|
| 31 |
+
)
|
| 32 |
+
from .processing_llama_nemotron_vl import LlamaNemotronVLRerankProcessor
|
| 33 |
+
|
| 34 |
+
logger = logging.get_logger(__name__)
|
| 35 |
+
|
| 36 |
+
# Check if native create_bidirectional_mask exists (transformers >= 5.0)
|
| 37 |
+
try:
|
| 38 |
+
from transformers.masking_utils import create_bidirectional_mask
|
| 39 |
+
|
| 40 |
+
_HAS_NATIVE_BIDIRECTIONAL_MASK = True
|
| 41 |
+
except ImportError:
|
| 42 |
+
from transformers.modeling_attn_mask_utils import _prepare_4d_attention_mask
|
| 43 |
+
|
| 44 |
+
_HAS_NATIVE_BIDIRECTIONAL_MASK = False
|
| 45 |
+
|
| 46 |
+
# Detect API differences via introspection
|
| 47 |
+
_decoder_forward_params = inspect.signature(LlamaDecoderLayer.forward).parameters
|
| 48 |
+
_dynamic_cache_init_params = inspect.signature(DynamicCache.__init__).parameters
|
| 49 |
+
|
| 50 |
+
# past_key_value (singular) in < 4.56, past_key_values (plural) in >= 4.56
|
| 51 |
+
_USE_PLURAL_CACHE_PARAM = "past_key_values" in _decoder_forward_params
|
| 52 |
+
# DynamicCache accepts config parameter in >= 4.56
|
| 53 |
+
_DYNAMIC_CACHE_ACCEPTS_CONFIG = "config" in _dynamic_cache_init_params
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
def pool(
|
| 57 |
+
last_hidden_states: torch.Tensor, attention_mask: torch.Tensor, pool_type: str
|
| 58 |
+
) -> torch.Tensor:
|
| 59 |
+
last_hidden = last_hidden_states.masked_fill(~attention_mask[..., None].bool(), 0.0)
|
| 60 |
+
|
| 61 |
+
if pool_type == "avg":
|
| 62 |
+
emb = last_hidden.sum(dim=1) / attention_mask.sum(dim=1)[..., None]
|
| 63 |
+
elif pool_type == "weighted_avg":
|
| 64 |
+
emb = last_hidden.sum(dim=1)
|
| 65 |
+
elif pool_type == "cls":
|
| 66 |
+
emb = last_hidden[:, 0]
|
| 67 |
+
elif pool_type == "last":
|
| 68 |
+
left_padding = attention_mask[:, -1].sum() == attention_mask.shape[0]
|
| 69 |
+
if left_padding:
|
| 70 |
+
emb = last_hidden[:, -1]
|
| 71 |
+
else:
|
| 72 |
+
sequence_lengths = attention_mask.sum(dim=1) - 1
|
| 73 |
+
batch_size = last_hidden.shape[0]
|
| 74 |
+
emb = last_hidden[
|
| 75 |
+
torch.arange(batch_size, device=last_hidden.device), sequence_lengths
|
| 76 |
+
]
|
| 77 |
+
elif pool_type == "cls_last":
|
| 78 |
+
emb = last_hidden[:, 0]
|
| 79 |
+
elif pool_type == "colbert":
|
| 80 |
+
emb = last_hidden
|
| 81 |
+
else:
|
| 82 |
+
raise ValueError(f"pool_type {pool_type} not supported")
|
| 83 |
+
|
| 84 |
+
return emb
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
# ============================================================================
|
| 88 |
+
# Bidirectional LLaMA Model
|
| 89 |
+
# ============================================================================
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
class LlamaBidirectionalModel(LlamaModel):
|
| 93 |
+
"""
|
| 94 |
+
LlamaModel modified to use bidirectional (non-causal) attention.
|
| 95 |
+
|
| 96 |
+
Supports transformers 4.44+ through 5.x with a unified forward() implementation.
|
| 97 |
+
"""
|
| 98 |
+
|
| 99 |
+
config_class = LlamaBidirectionalConfig
|
| 100 |
+
|
| 101 |
+
def __init__(self, config: LlamaBidirectionalConfig):
|
| 102 |
+
super().__init__(config)
|
| 103 |
+
for layer in self.layers:
|
| 104 |
+
layer.self_attn.is_causal = False
|
| 105 |
+
|
| 106 |
+
def _create_bidirectional_mask(
|
| 107 |
+
self,
|
| 108 |
+
input_embeds: torch.Tensor,
|
| 109 |
+
attention_mask: torch.Tensor | None,
|
| 110 |
+
) -> torch.Tensor | None:
|
| 111 |
+
if attention_mask is None:
|
| 112 |
+
return None
|
| 113 |
+
|
| 114 |
+
if _HAS_NATIVE_BIDIRECTIONAL_MASK:
|
| 115 |
+
return create_bidirectional_mask(
|
| 116 |
+
self.config,
|
| 117 |
+
input_embeds,
|
| 118 |
+
attention_mask=attention_mask,
|
| 119 |
+
)
|
| 120 |
+
|
| 121 |
+
# Fallback for transformers < 5.0
|
| 122 |
+
if getattr(self.config, "_attn_implementation", None) == "flash_attention_2":
|
| 123 |
+
has_masked_tokens = (attention_mask == 0).any()
|
| 124 |
+
return attention_mask if has_masked_tokens else None
|
| 125 |
+
|
| 126 |
+
return _prepare_4d_attention_mask(attention_mask, input_embeds.dtype)
|
| 127 |
+
|
| 128 |
+
def forward(
|
| 129 |
+
self,
|
| 130 |
+
input_ids: torch.LongTensor | None = None,
|
| 131 |
+
attention_mask: torch.Tensor | None = None,
|
| 132 |
+
position_ids: torch.LongTensor | None = None,
|
| 133 |
+
past_key_values: Cache | None = None,
|
| 134 |
+
inputs_embeds: torch.FloatTensor | None = None,
|
| 135 |
+
cache_position: torch.LongTensor | None = None,
|
| 136 |
+
use_cache: bool | None = None,
|
| 137 |
+
output_hidden_states: bool | None = None,
|
| 138 |
+
**kwargs,
|
| 139 |
+
) -> BaseModelOutputWithPast:
|
| 140 |
+
if (input_ids is None) ^ (inputs_embeds is not None):
|
| 141 |
+
raise ValueError(
|
| 142 |
+
"You must specify exactly one of input_ids or inputs_embeds"
|
| 143 |
+
)
|
| 144 |
+
|
| 145 |
+
if inputs_embeds is None:
|
| 146 |
+
inputs_embeds = self.embed_tokens(input_ids)
|
| 147 |
+
|
| 148 |
+
# Initialize cache if needed
|
| 149 |
+
if use_cache and past_key_values is None:
|
| 150 |
+
if _DYNAMIC_CACHE_ACCEPTS_CONFIG:
|
| 151 |
+
past_key_values = DynamicCache(config=self.config)
|
| 152 |
+
else:
|
| 153 |
+
past_key_values = DynamicCache()
|
| 154 |
+
|
| 155 |
+
if cache_position is None:
|
| 156 |
+
past_seen_tokens = (
|
| 157 |
+
past_key_values.get_seq_length() if past_key_values is not None else 0
|
| 158 |
+
)
|
| 159 |
+
cache_position = torch.arange(
|
| 160 |
+
past_seen_tokens,
|
| 161 |
+
past_seen_tokens + inputs_embeds.shape[1],
|
| 162 |
+
device=inputs_embeds.device,
|
| 163 |
+
)
|
| 164 |
+
|
| 165 |
+
if position_ids is None:
|
| 166 |
+
position_ids = cache_position.unsqueeze(0)
|
| 167 |
+
|
| 168 |
+
bidirectional_mask = self._create_bidirectional_mask(
|
| 169 |
+
inputs_embeds, attention_mask
|
| 170 |
+
)
|
| 171 |
+
|
| 172 |
+
hidden_states = inputs_embeds
|
| 173 |
+
position_embeddings = self.rotary_emb(hidden_states, position_ids)
|
| 174 |
+
|
| 175 |
+
all_hidden_states = () if output_hidden_states else None
|
| 176 |
+
|
| 177 |
+
# Build decoder layer kwargs with correct cache parameter name
|
| 178 |
+
layer_kwargs = {
|
| 179 |
+
"attention_mask": bidirectional_mask,
|
| 180 |
+
"position_ids": position_ids,
|
| 181 |
+
"use_cache": use_cache,
|
| 182 |
+
"cache_position": cache_position,
|
| 183 |
+
"position_embeddings": position_embeddings,
|
| 184 |
+
}
|
| 185 |
+
if _USE_PLURAL_CACHE_PARAM:
|
| 186 |
+
layer_kwargs["past_key_values"] = past_key_values
|
| 187 |
+
else:
|
| 188 |
+
layer_kwargs["past_key_value"] = past_key_values
|
| 189 |
+
|
| 190 |
+
for decoder_layer in self.layers[: self.config.num_hidden_layers]:
|
| 191 |
+
if output_hidden_states:
|
| 192 |
+
all_hidden_states += (hidden_states,)
|
| 193 |
+
|
| 194 |
+
layer_outputs = decoder_layer(hidden_states, **layer_kwargs)
|
| 195 |
+
|
| 196 |
+
# Decoder returns tuple in < 4.54, tensor in >= 4.54
|
| 197 |
+
if isinstance(layer_outputs, tuple):
|
| 198 |
+
hidden_states = layer_outputs[0]
|
| 199 |
+
else:
|
| 200 |
+
hidden_states = layer_outputs
|
| 201 |
+
|
| 202 |
+
hidden_states = self.norm(hidden_states)
|
| 203 |
+
|
| 204 |
+
if output_hidden_states:
|
| 205 |
+
all_hidden_states += (hidden_states,)
|
| 206 |
+
|
| 207 |
+
return BaseModelOutputWithPast(
|
| 208 |
+
last_hidden_state=hidden_states,
|
| 209 |
+
past_key_values=past_key_values,
|
| 210 |
+
hidden_states=all_hidden_states,
|
| 211 |
+
)
|
| 212 |
+
|
| 213 |
+
|
| 214 |
+
class LlamaBidirectionalForSequenceClassification(LlamaPreTrainedModel):
|
| 215 |
+
config_class = LlamaBidirectionalConfig
|
| 216 |
+
|
| 217 |
+
def __init__(self, config):
|
| 218 |
+
super().__init__(config)
|
| 219 |
+
self.num_labels = config.num_labels
|
| 220 |
+
self.score = nn.Linear(config.hidden_size, self.num_labels, bias=False)
|
| 221 |
+
self.model = LlamaBidirectionalModel(config)
|
| 222 |
+
|
| 223 |
+
# Initialize weights and apply final processing
|
| 224 |
+
self.post_init()
|
| 225 |
+
|
| 226 |
+
def forward(
|
| 227 |
+
self,
|
| 228 |
+
input_ids: Optional[torch.LongTensor] = None,
|
| 229 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 230 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 231 |
+
past_key_values: Optional[Union[Cache, List[torch.FloatTensor]]] = None,
|
| 232 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 233 |
+
labels: Optional[torch.LongTensor] = None,
|
| 234 |
+
use_cache: Optional[bool] = None,
|
| 235 |
+
output_attentions: Optional[bool] = None,
|
| 236 |
+
output_hidden_states: Optional[bool] = None,
|
| 237 |
+
return_dict: Optional[bool] = None,
|
| 238 |
+
**kwargs,
|
| 239 |
+
) -> Union[Tuple, SequenceClassifierOutputWithPast]:
|
| 240 |
+
r"""
|
| 241 |
+
labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
|
| 242 |
+
Labels for computing the sequence classification/regression loss.
|
| 243 |
+
"""
|
| 244 |
+
return_dict = (
|
| 245 |
+
return_dict if return_dict is not None else self.config.use_return_dict
|
| 246 |
+
)
|
| 247 |
+
|
| 248 |
+
transformer_outputs = self.model(
|
| 249 |
+
input_ids,
|
| 250 |
+
attention_mask=attention_mask,
|
| 251 |
+
position_ids=position_ids,
|
| 252 |
+
past_key_values=past_key_values,
|
| 253 |
+
inputs_embeds=inputs_embeds,
|
| 254 |
+
use_cache=use_cache,
|
| 255 |
+
output_attentions=output_attentions,
|
| 256 |
+
output_hidden_states=output_hidden_states,
|
| 257 |
+
return_dict=return_dict,
|
| 258 |
+
**kwargs,
|
| 259 |
+
)
|
| 260 |
+
hidden_states = transformer_outputs[0]
|
| 261 |
+
|
| 262 |
+
pooled_hidden_states = pool(
|
| 263 |
+
last_hidden_states=hidden_states,
|
| 264 |
+
attention_mask=attention_mask,
|
| 265 |
+
pool_type=self.config.pooling,
|
| 266 |
+
)
|
| 267 |
+
|
| 268 |
+
pooled_logits = self.score(pooled_hidden_states)
|
| 269 |
+
pooled_logits = pooled_logits / self.config.temperature
|
| 270 |
+
|
| 271 |
+
loss = None
|
| 272 |
+
if labels is not None:
|
| 273 |
+
labels = labels.to(pooled_logits.device)
|
| 274 |
+
if self.config.problem_type is None:
|
| 275 |
+
if self.num_labels == 1:
|
| 276 |
+
self.config.problem_type = "regression"
|
| 277 |
+
elif self.num_labels > 1 and (
|
| 278 |
+
labels.dtype == torch.long or labels.dtype == torch.int
|
| 279 |
+
):
|
| 280 |
+
self.config.problem_type = "single_label_classification"
|
| 281 |
+
else:
|
| 282 |
+
self.config.problem_type = "multi_label_classification"
|
| 283 |
+
|
| 284 |
+
if self.config.problem_type == "regression":
|
| 285 |
+
loss_fct = MSELoss()
|
| 286 |
+
if self.num_labels == 1:
|
| 287 |
+
loss = loss_fct(pooled_logits.squeeze(), labels.squeeze())
|
| 288 |
+
else:
|
| 289 |
+
loss = loss_fct(pooled_logits, labels)
|
| 290 |
+
elif self.config.problem_type == "single_label_classification":
|
| 291 |
+
loss_fct = CrossEntropyLoss()
|
| 292 |
+
loss = loss_fct(
|
| 293 |
+
pooled_logits.view(-1, self.num_labels), labels.view(-1)
|
| 294 |
+
)
|
| 295 |
+
elif self.config.problem_type == "multi_label_classification":
|
| 296 |
+
loss_fct = BCEWithLogitsLoss()
|
| 297 |
+
loss = loss_fct(pooled_logits, labels)
|
| 298 |
+
|
| 299 |
+
if not return_dict:
|
| 300 |
+
output = (pooled_logits,) + transformer_outputs[1:]
|
| 301 |
+
return ((loss,) + output) if loss is not None else output
|
| 302 |
+
|
| 303 |
+
return SequenceClassifierOutputWithPast(
|
| 304 |
+
loss=loss,
|
| 305 |
+
logits=pooled_logits,
|
| 306 |
+
past_key_values=transformer_outputs.past_key_values,
|
| 307 |
+
hidden_states=transformer_outputs.hidden_states,
|
| 308 |
+
attentions=transformer_outputs.attentions,
|
| 309 |
+
)
|
| 310 |
+
|
| 311 |
+
|
| 312 |
+
# ============================================================================
|
| 313 |
+
# LlamaNemotronVL Model Classes
|
| 314 |
+
# ============================================================================
|
| 315 |
+
|
| 316 |
+
|
| 317 |
+
class LlamaNemotronVLModel(PreTrainedModel):
|
| 318 |
+
"""
|
| 319 |
+
LlamaNemotron VL model for vision-language reranking.
|
| 320 |
+
|
| 321 |
+
Combines a vision encoder (SigLIP) with a bidirectional language model (LLaMA)
|
| 322 |
+
for cross-modal reranking tasks.
|
| 323 |
+
"""
|
| 324 |
+
|
| 325 |
+
config_class = LlamaNemotronVLConfig
|
| 326 |
+
main_input_name = "pixel_values"
|
| 327 |
+
_no_split_modules = ["LlamaDecoderLayer"]
|
| 328 |
+
_supports_flash_attn_2 = True # transformers < 4.54
|
| 329 |
+
_supports_flash_attn = True # transformers >= 4.54
|
| 330 |
+
_supports_sdpa = True
|
| 331 |
+
|
| 332 |
+
def __init__(
|
| 333 |
+
self,
|
| 334 |
+
config: LlamaNemotronVLConfig,
|
| 335 |
+
vision_model: Optional[PreTrainedModel] = None,
|
| 336 |
+
language_model: Optional[PreTrainedModel] = None,
|
| 337 |
+
):
|
| 338 |
+
super().__init__(config)
|
| 339 |
+
|
| 340 |
+
# Propagate attn_implementation to sub-configs for transformers < 4.56
|
| 341 |
+
# which lacks set_attn_implementation. In 4.56+, set_attn_implementation
|
| 342 |
+
# handles this automatically using the sub_configs declared on the config class.
|
| 343 |
+
if not hasattr(PreTrainedModel, "set_attn_implementation"):
|
| 344 |
+
parent_attn = getattr(config, "_attn_implementation", None)
|
| 345 |
+
if parent_attn is not None:
|
| 346 |
+
for sub_config in (config.vision_config, config.llm_config):
|
| 347 |
+
if getattr(sub_config, "_attn_implementation_autoset", False):
|
| 348 |
+
sub_config._attn_implementation = parent_attn
|
| 349 |
+
sub_config._attn_implementation_autoset = False
|
| 350 |
+
|
| 351 |
+
# Calculate image token count
|
| 352 |
+
image_size = config.force_image_size or config.vision_config.image_size
|
| 353 |
+
if hasattr(config.vision_config, "grid_size"):
|
| 354 |
+
grid_size = config.vision_config.grid_size
|
| 355 |
+
self.patch_size = 14
|
| 356 |
+
self.num_image_token = int((grid_size * config.downsample_ratio) ** 2)
|
| 357 |
+
else:
|
| 358 |
+
patch_size = config.vision_config.patch_size
|
| 359 |
+
self.patch_size = patch_size
|
| 360 |
+
self.num_image_token = int(
|
| 361 |
+
(image_size // patch_size) ** 2 * (config.downsample_ratio**2)
|
| 362 |
+
)
|
| 363 |
+
|
| 364 |
+
self.select_layer = config.select_layer
|
| 365 |
+
self.template = config.template
|
| 366 |
+
self.downsample_ratio = config.downsample_ratio
|
| 367 |
+
|
| 368 |
+
logger.info(f"num_image_token: {self.num_image_token}")
|
| 369 |
+
if vision_model is not None:
|
| 370 |
+
self.vision_model = vision_model
|
| 371 |
+
else:
|
| 372 |
+
if config.vision_config.model_type == "siglip_vision_model":
|
| 373 |
+
self.vision_model = SiglipVisionModel(config.vision_config)
|
| 374 |
+
else:
|
| 375 |
+
raise NotImplementedError(
|
| 376 |
+
f"Unsupported vision model type: {config.vision_config.model_type}"
|
| 377 |
+
)
|
| 378 |
+
|
| 379 |
+
if language_model is not None:
|
| 380 |
+
self.language_model = language_model
|
| 381 |
+
else:
|
| 382 |
+
if config.llm_config.architectures[0] in (
|
| 383 |
+
"LlamaBidirectionalModel",
|
| 384 |
+
"LlamaBidirectionalForSequenceClassification",
|
| 385 |
+
):
|
| 386 |
+
self.language_model = LlamaBidirectionalModel(config.llm_config)
|
| 387 |
+
else:
|
| 388 |
+
raise NotImplementedError(
|
| 389 |
+
f"{config.llm_config.architectures[0]} is not implemented."
|
| 390 |
+
)
|
| 391 |
+
|
| 392 |
+
# Vision-to-language projection
|
| 393 |
+
vit_hidden_size = config.vision_config.hidden_size
|
| 394 |
+
llm_hidden_size = config.llm_config.hidden_size
|
| 395 |
+
self.mlp1 = nn.Sequential(
|
| 396 |
+
nn.LayerNorm(vit_hidden_size * int(1 / self.downsample_ratio) ** 2),
|
| 397 |
+
nn.Linear(
|
| 398 |
+
vit_hidden_size * int(1 / self.downsample_ratio) ** 2,
|
| 399 |
+
llm_hidden_size,
|
| 400 |
+
),
|
| 401 |
+
nn.GELU(),
|
| 402 |
+
nn.Linear(llm_hidden_size, llm_hidden_size),
|
| 403 |
+
)
|
| 404 |
+
self.img_context_token_id = None
|
| 405 |
+
|
| 406 |
+
# Initialize processor
|
| 407 |
+
self.processor = AutoProcessor.from_pretrained(
|
| 408 |
+
config.name_or_path, trust_remote_code=True
|
| 409 |
+
)
|
| 410 |
+
|
| 411 |
+
self.post_init()
|
| 412 |
+
|
| 413 |
+
# transformers 4.54.0-4.55.x have a bug in the flash attention
|
| 414 |
+
# infrastructure where a parameter name mismatch ('implementation' vs
|
| 415 |
+
# 'attn_implementation') in _flash_attention_forward causes FA3 pad/unpad
|
| 416 |
+
# functions to be used with FA2 attention kernels, producing nondeterministic
|
| 417 |
+
# and numerically different results for batched vision+text sequences.
|
| 418 |
+
# This was fixed in 4.56.0.
|
| 419 |
+
from packaging.version import Version
|
| 420 |
+
|
| 421 |
+
_tv = Version(transformers.__version__)
|
| 422 |
+
if Version("4.54.0") <= _tv < Version("4.56.0"):
|
| 423 |
+
raise RuntimeError(
|
| 424 |
+
f"transformers {transformers.__version__} is not supported by this model. "
|
| 425 |
+
f"Versions 4.54.0-4.55.x have a flash attention bug that produces "
|
| 426 |
+
f"nondeterministic and incorrect image embeddings. "
|
| 427 |
+
f"Please use transformers <=4.53.x or >=4.56.0."
|
| 428 |
+
)
|
| 429 |
+
|
| 430 |
+
def forward(
|
| 431 |
+
self,
|
| 432 |
+
pixel_values: torch.FloatTensor = None,
|
| 433 |
+
input_ids: torch.LongTensor = None,
|
| 434 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 435 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 436 |
+
image_flags: Optional[torch.LongTensor] = None,
|
| 437 |
+
past_key_values: Optional[List[torch.FloatTensor]] = None,
|
| 438 |
+
labels: Optional[torch.LongTensor] = None,
|
| 439 |
+
use_cache: Optional[bool] = None,
|
| 440 |
+
output_attentions: Optional[bool] = None,
|
| 441 |
+
output_hidden_states: Optional[bool] = None,
|
| 442 |
+
return_dict: Optional[bool] = None,
|
| 443 |
+
num_patches_list: Optional[List[torch.Tensor]] = None,
|
| 444 |
+
) -> Union[Tuple, CausalLMOutputWithPast]:
|
| 445 |
+
return_dict = (
|
| 446 |
+
return_dict if return_dict is not None else self.config.use_return_dict
|
| 447 |
+
)
|
| 448 |
+
|
| 449 |
+
# Get text embeddings
|
| 450 |
+
input_embeds = self.language_model.get_input_embeddings()(input_ids)
|
| 451 |
+
|
| 452 |
+
# Process and inject vision embeddings if present
|
| 453 |
+
if pixel_values is not None:
|
| 454 |
+
if image_flags is None:
|
| 455 |
+
image_flags = torch.ones(pixel_values.shape[0])
|
| 456 |
+
image_flags = image_flags.squeeze(-1)
|
| 457 |
+
vit_embeds = self.extract_feature(pixel_values).to(
|
| 458 |
+
device=input_embeds.device
|
| 459 |
+
)
|
| 460 |
+
|
| 461 |
+
if not isinstance(image_flags, list):
|
| 462 |
+
image_flags = image_flags.squeeze(-1)
|
| 463 |
+
vit_embeds = vit_embeds[image_flags == 1]
|
| 464 |
+
|
| 465 |
+
# Inject vision tokens into text embeddings
|
| 466 |
+
B, N, C = input_embeds.shape
|
| 467 |
+
input_embeds = input_embeds.reshape(B * N, C)
|
| 468 |
+
input_ids = input_ids.reshape(B * N)
|
| 469 |
+
selected = (input_ids == self.config.img_context_token_id).to(input_embeds.device)
|
| 470 |
+
try:
|
| 471 |
+
input_embeds[selected] = input_embeds[
|
| 472 |
+
selected
|
| 473 |
+
] * 0.0 + vit_embeds.reshape(-1, C)
|
| 474 |
+
except Exception as e:
|
| 475 |
+
vit_embeds = vit_embeds.reshape(-1, C)
|
| 476 |
+
print(
|
| 477 |
+
f"warning: {e}, input_embeds[selected].shape={input_embeds[selected].shape}, "
|
| 478 |
+
f"vit_embeds.shape={vit_embeds.shape}"
|
| 479 |
+
)
|
| 480 |
+
n_token = selected.sum()
|
| 481 |
+
input_embeds[selected] = (
|
| 482 |
+
input_embeds[selected] * 0.0 + vit_embeds[:n_token]
|
| 483 |
+
)
|
| 484 |
+
|
| 485 |
+
input_embeds = input_embeds.reshape(B, N, C)
|
| 486 |
+
|
| 487 |
+
# Forward through language model
|
| 488 |
+
outputs = self.language_model(
|
| 489 |
+
inputs_embeds=input_embeds,
|
| 490 |
+
attention_mask=attention_mask,
|
| 491 |
+
position_ids=position_ids,
|
| 492 |
+
past_key_values=past_key_values,
|
| 493 |
+
use_cache=use_cache,
|
| 494 |
+
output_attentions=output_attentions,
|
| 495 |
+
output_hidden_states=output_hidden_states,
|
| 496 |
+
)
|
| 497 |
+
logits = None
|
| 498 |
+
loss = None
|
| 499 |
+
|
| 500 |
+
if hasattr(outputs, "logits"):
|
| 501 |
+
logits = outputs.logits
|
| 502 |
+
if labels is not None:
|
| 503 |
+
# Shift so that tokens < n predict n
|
| 504 |
+
shift_logits = logits[..., :-1, :].contiguous()
|
| 505 |
+
shift_labels = labels[..., 1:].contiguous()
|
| 506 |
+
# Flatten the tokens
|
| 507 |
+
loss_fct = CrossEntropyLoss()
|
| 508 |
+
shift_logits = shift_logits.view(
|
| 509 |
+
-1, self.language_model.config.vocab_size
|
| 510 |
+
)
|
| 511 |
+
shift_labels = shift_labels.view(-1)
|
| 512 |
+
# Enable model parallelism
|
| 513 |
+
shift_labels = shift_labels.to(shift_logits.device)
|
| 514 |
+
loss = loss_fct(shift_logits, shift_labels)
|
| 515 |
+
|
| 516 |
+
if not return_dict:
|
| 517 |
+
output = (logits,) + outputs[1:]
|
| 518 |
+
return (loss,) + output if loss is not None else output
|
| 519 |
+
|
| 520 |
+
return CausalLMOutputWithPast(
|
| 521 |
+
loss=loss,
|
| 522 |
+
logits=logits,
|
| 523 |
+
past_key_values=outputs.past_key_values,
|
| 524 |
+
hidden_states=outputs.hidden_states,
|
| 525 |
+
attentions=outputs.attentions,
|
| 526 |
+
)
|
| 527 |
+
|
| 528 |
+
def pixel_shuffle(self, x, scale_factor=0.5):
|
| 529 |
+
n, w, h, c = x.shape
|
| 530 |
+
# N, W, H, C --> N, W, H * scale, C // scale
|
| 531 |
+
x = x.view(n, w, int(h * scale_factor), int(c / scale_factor))
|
| 532 |
+
# N, W, H * scale, C // scale --> N, H * scale, W, C // scale
|
| 533 |
+
x = x.permute(0, 2, 1, 3).contiguous()
|
| 534 |
+
# N, H * scale, W, C // scale --> N, H * scale, W * scale, C // (scale ** 2)
|
| 535 |
+
x = x.view(
|
| 536 |
+
n,
|
| 537 |
+
int(h * scale_factor),
|
| 538 |
+
int(w * scale_factor),
|
| 539 |
+
int(c / (scale_factor * scale_factor)),
|
| 540 |
+
)
|
| 541 |
+
x = x.permute(0, 2, 1, 3).contiguous()
|
| 542 |
+
return x
|
| 543 |
+
|
| 544 |
+
def extract_feature(self, pixel_values):
|
| 545 |
+
"""Extract and project vision features to language model space."""
|
| 546 |
+
# Extract features from vision encoder
|
| 547 |
+
if self.select_layer == -1:
|
| 548 |
+
vit_embeds = self.vision_model(
|
| 549 |
+
pixel_values=pixel_values, output_hidden_states=False, return_dict=True
|
| 550 |
+
)
|
| 551 |
+
if hasattr(vit_embeds, "last_hidden_state"):
|
| 552 |
+
vit_embeds = vit_embeds.last_hidden_state
|
| 553 |
+
else:
|
| 554 |
+
vit_embeds = self.vision_model(
|
| 555 |
+
pixel_values=pixel_values, output_hidden_states=True, return_dict=True
|
| 556 |
+
).hidden_states[self.select_layer]
|
| 557 |
+
|
| 558 |
+
# Remove CLS token if not using SigLIP
|
| 559 |
+
if not isinstance(self.vision_model, SiglipVisionModel):
|
| 560 |
+
vit_embeds = vit_embeds[:, 1:, :]
|
| 561 |
+
|
| 562 |
+
# Apply pixel shuffle and MLP projection
|
| 563 |
+
_, n, c = vit_embeds.shape
|
| 564 |
+
h = w = int(n**0.5)
|
| 565 |
+
vit_embeds = vit_embeds.reshape(-1, h, w, c)
|
| 566 |
+
vit_embeds = self.pixel_shuffle(vit_embeds, scale_factor=self.downsample_ratio)
|
| 567 |
+
_, h_s, w_s, c_s = vit_embeds.shape
|
| 568 |
+
vit_embeds = vit_embeds.reshape(-1, h_s * w_s, c_s)
|
| 569 |
+
vit_embeds = self.mlp1(vit_embeds)
|
| 570 |
+
|
| 571 |
+
return vit_embeds
|
| 572 |
+
|
| 573 |
+
def build_collator(self, tokenizer, **kwargs):
|
| 574 |
+
return self.processor
|
| 575 |
+
|
| 576 |
+
def post_loss(self, loss, inputs):
|
| 577 |
+
# Add Dummy Gradients for Vision Encoder to ensure multi-GPU synchronization
|
| 578 |
+
if "pixel_values" in inputs and inputs["pixel_values"] is None:
|
| 579 |
+
dummy_pixels = torch.zeros(
|
| 580 |
+
1, 3, 512, 512, device=loss.device, dtype=self.vision_model.dtype
|
| 581 |
+
)
|
| 582 |
+
dummy_output = self.extract_feature(dummy_pixels)
|
| 583 |
+
loss = loss + dummy_output.sum() * 0.0
|
| 584 |
+
return loss
|
| 585 |
+
|
| 586 |
+
|
| 587 |
+
class CrossEncoderHead(nn.Linear):
|
| 588 |
+
"""Classification head for cross-encoder."""
|
| 589 |
+
|
| 590 |
+
pass
|
| 591 |
+
|
| 592 |
+
|
| 593 |
+
class LlamaNemotronVLForSequenceClassification(PreTrainedModel):
|
| 594 |
+
"""LlamaNemotron VL model for sequence classification (reranking)."""
|
| 595 |
+
|
| 596 |
+
config_class = LlamaNemotronVLForSequenceClassificationConfig
|
| 597 |
+
base_model_prefix = "model"
|
| 598 |
+
_supports_flash_attn_2 = True
|
| 599 |
+
_supports_flash_attn = True
|
| 600 |
+
_supports_sdpa = True
|
| 601 |
+
_no_split_modules = ["LlamaNemotronVLModel"]
|
| 602 |
+
|
| 603 |
+
def __init__(self, config, **kwargs):
|
| 604 |
+
super().__init__(config, **kwargs)
|
| 605 |
+
self.num_labels = config.num_labels
|
| 606 |
+
|
| 607 |
+
self.add_module("model", LlamaNemotronVLModel(config))
|
| 608 |
+
|
| 609 |
+
score = CrossEncoderHead(
|
| 610 |
+
config.llm_config.hidden_size,
|
| 611 |
+
self.num_labels,
|
| 612 |
+
bias=False,
|
| 613 |
+
dtype=torch.float32,
|
| 614 |
+
)
|
| 615 |
+
self.add_module("score", score)
|
| 616 |
+
|
| 617 |
+
# Initialize weights and apply final processing
|
| 618 |
+
self.post_init()
|
| 619 |
+
|
| 620 |
+
def _init_weights(self, module):
|
| 621 |
+
super()._init_weights(module)
|
| 622 |
+
if isinstance(module, CrossEncoderHead):
|
| 623 |
+
# Initialize cross-encoder head to avoid NaN/Inf loss
|
| 624 |
+
torch.nn.init.kaiming_uniform_(module.weight, a=math.sqrt(5))
|
| 625 |
+
|
| 626 |
+
def forward(
|
| 627 |
+
self,
|
| 628 |
+
pixel_values: torch.FloatTensor = None,
|
| 629 |
+
input_ids: torch.LongTensor = None,
|
| 630 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 631 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 632 |
+
image_flags: Optional[torch.LongTensor] = None,
|
| 633 |
+
past_key_values: Optional[List[torch.FloatTensor]] = None,
|
| 634 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 635 |
+
labels: Optional[torch.LongTensor] = None,
|
| 636 |
+
use_cache: Optional[bool] = None,
|
| 637 |
+
output_attentions: Optional[bool] = None,
|
| 638 |
+
output_hidden_states: Optional[bool] = None,
|
| 639 |
+
return_dict: Optional[bool] = None,
|
| 640 |
+
num_patches_list: Optional[List[torch.Tensor]] = None,
|
| 641 |
+
) -> Union[Tuple, SequenceClassifierOutputWithPast]:
|
| 642 |
+
r"""
|
| 643 |
+
labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
|
| 644 |
+
Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
|
| 645 |
+
config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss), If
|
| 646 |
+
`config.num_labels > 1` a classification loss is computed (Cross-Entropy).
|
| 647 |
+
"""
|
| 648 |
+
return_dict = (
|
| 649 |
+
return_dict if return_dict is not None else self.config.use_return_dict
|
| 650 |
+
)
|
| 651 |
+
|
| 652 |
+
transformer_outputs = self.model(
|
| 653 |
+
pixel_values=pixel_values,
|
| 654 |
+
input_ids=input_ids,
|
| 655 |
+
attention_mask=attention_mask,
|
| 656 |
+
position_ids=position_ids,
|
| 657 |
+
image_flags=image_flags,
|
| 658 |
+
past_key_values=past_key_values,
|
| 659 |
+
use_cache=use_cache,
|
| 660 |
+
output_attentions=output_attentions,
|
| 661 |
+
output_hidden_states=True,
|
| 662 |
+
return_dict=return_dict,
|
| 663 |
+
num_patches_list=num_patches_list,
|
| 664 |
+
)
|
| 665 |
+
|
| 666 |
+
hidden_states = transformer_outputs.hidden_states[-1]
|
| 667 |
+
|
| 668 |
+
pooled_hidden_states = pool(
|
| 669 |
+
last_hidden_states=hidden_states,
|
| 670 |
+
attention_mask=attention_mask,
|
| 671 |
+
pool_type=self.config.pooling,
|
| 672 |
+
)
|
| 673 |
+
|
| 674 |
+
pooled_logits = self.score(pooled_hidden_states.to(self.score.weight.dtype))
|
| 675 |
+
pooled_logits = pooled_logits / self.config.temperature
|
| 676 |
+
if torch.isnan(pooled_logits).any():
|
| 677 |
+
raise ValueError("NaN detected in pooled_logits!")
|
| 678 |
+
|
| 679 |
+
loss = None
|
| 680 |
+
|
| 681 |
+
if not return_dict:
|
| 682 |
+
output = (pooled_logits,) + transformer_outputs[1:]
|
| 683 |
+
return ((loss,) + output) if loss is not None else output
|
| 684 |
+
|
| 685 |
+
return SequenceClassifierOutputWithPast(
|
| 686 |
+
loss=loss,
|
| 687 |
+
logits=pooled_logits,
|
| 688 |
+
past_key_values=transformer_outputs.past_key_values,
|
| 689 |
+
hidden_states=transformer_outputs.hidden_states,
|
| 690 |
+
attentions=transformer_outputs.attentions,
|
| 691 |
+
)
|
| 692 |
+
|
| 693 |
+
def build_collator(self, tokenizer, **kwargs):
|
| 694 |
+
max_input_tiles = kwargs.pop("max_input_tiles", self.config.max_input_tiles)
|
| 695 |
+
prompt_template = kwargs.pop("prompt_template", self.config.prompt_template)
|
| 696 |
+
return LlamaNemotronVLRerankProcessor(
|
| 697 |
+
tokenizer=tokenizer,
|
| 698 |
+
max_input_tiles=max_input_tiles,
|
| 699 |
+
num_image_token=self.model.num_image_token,
|
| 700 |
+
prompt_template=prompt_template,
|
| 701 |
+
**kwargs,
|
| 702 |
+
)
|
| 703 |
+
|
| 704 |
+
def post_loss(self, loss, inputs):
|
| 705 |
+
# Add Dummy Gradients for Vision Encoder to ensure multi-GPU synchronization
|
| 706 |
+
if "pixel_values" in inputs and inputs["pixel_values"] is None:
|
| 707 |
+
dummy_pixels = torch.zeros(
|
| 708 |
+
1, 3, 512, 512, device=loss.device, dtype=self.model.vision_model.dtype
|
| 709 |
+
)
|
| 710 |
+
dummy_output = self.model.extract_feature(dummy_pixels)
|
| 711 |
+
loss = loss + dummy_output.sum() * 0.0
|
| 712 |
+
return loss
|
processing_llama_nemotron_vl.py
ADDED
|
@@ -0,0 +1,554 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
| 2 |
+
# SPDX-License-Identifier: Apache-2.0.
|
| 3 |
+
|
| 4 |
+
import base64
|
| 5 |
+
import os
|
| 6 |
+
from io import BytesIO
|
| 7 |
+
from typing import Any, Dict, List, Literal, Optional, Union, Tuple
|
| 8 |
+
import dataclasses
|
| 9 |
+
from dataclasses import field
|
| 10 |
+
|
| 11 |
+
import requests
|
| 12 |
+
import torch
|
| 13 |
+
import torchvision.transforms as T
|
| 14 |
+
from PIL import Image
|
| 15 |
+
from torchvision.transforms.functional import InterpolationMode
|
| 16 |
+
from transformers import ProcessorMixin
|
| 17 |
+
|
| 18 |
+
IMAGENET_MEAN = (0.485, 0.456, 0.406)
|
| 19 |
+
IMAGENET_STD = (0.229, 0.224, 0.225)
|
| 20 |
+
|
| 21 |
+
SIGLIP_MEAN = (0.5, 0.5, 0.5)
|
| 22 |
+
SIGLIP_STD = (0.5, 0.5, 0.5)
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
@dataclasses.dataclass
|
| 26 |
+
class Conversation:
|
| 27 |
+
"""Manages prompt construction with system messages and multi-turn dialogues."""
|
| 28 |
+
|
| 29 |
+
# System instruction prepended to prompts
|
| 30 |
+
system_message: str = ""
|
| 31 |
+
# Role identifiers for dialogue turns
|
| 32 |
+
roles: Tuple[str, str] = ("", "")
|
| 33 |
+
# Message history as (role, content) pairs
|
| 34 |
+
messages: List[List[str]] = field(default_factory=list)
|
| 35 |
+
# Separator token between messages
|
| 36 |
+
sep: str = ""
|
| 37 |
+
# Token IDs that trigger generation stopping
|
| 38 |
+
stop_token_ids: List[int] = None
|
| 39 |
+
|
| 40 |
+
def get_prompt(self) -> str:
|
| 41 |
+
"""Construct the formatted prompt string from system message and dialogue history."""
|
| 42 |
+
ret = self.system_message + self.sep
|
| 43 |
+
for role, message in self.messages:
|
| 44 |
+
if message:
|
| 45 |
+
ret += role + message + self.sep
|
| 46 |
+
else:
|
| 47 |
+
ret += role
|
| 48 |
+
return ret
|
| 49 |
+
|
| 50 |
+
def append_message(self, role: str, message: str):
|
| 51 |
+
"""Add a message turn to the dialogue history."""
|
| 52 |
+
self.messages.append([role, message])
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def get_conv_template(name: str) -> Conversation:
|
| 56 |
+
"""Initialize a conversation instance with default configuration."""
|
| 57 |
+
return Conversation(
|
| 58 |
+
stop_token_ids=[128259, 128001],
|
| 59 |
+
)
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
def load_image(image):
|
| 63 |
+
if isinstance(image, Image.Image):
|
| 64 |
+
return image
|
| 65 |
+
elif isinstance(image, str) and os.path.exists(image):
|
| 66 |
+
return Image.open(image)
|
| 67 |
+
elif isinstance(image, dict):
|
| 68 |
+
if "disk_path" in image:
|
| 69 |
+
return Image.open(image["disk_path"])
|
| 70 |
+
elif "base64" in image:
|
| 71 |
+
return Image.open(BytesIO(base64.b64decode(image["base64"])))
|
| 72 |
+
elif "url" in image:
|
| 73 |
+
response = requests.get(image["url"])
|
| 74 |
+
return Image.open(BytesIO(response.content))
|
| 75 |
+
elif "bytes" in image:
|
| 76 |
+
return Image.open(BytesIO(image["bytes"]))
|
| 77 |
+
else:
|
| 78 |
+
raise ValueError(f"Invalid image: {image}")
|
| 79 |
+
else:
|
| 80 |
+
raise ValueError(f"Invalid image: {image}")
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
def build_transform(input_size, norm_type="imagenet"):
|
| 84 |
+
if norm_type == "imagenet":
|
| 85 |
+
MEAN, STD = IMAGENET_MEAN, IMAGENET_STD
|
| 86 |
+
elif norm_type == "siglip":
|
| 87 |
+
MEAN, STD = SIGLIP_MEAN, SIGLIP_STD
|
| 88 |
+
|
| 89 |
+
transform = T.Compose(
|
| 90 |
+
[
|
| 91 |
+
T.Lambda(lambda img: img.convert("RGB") if img.mode != "RGB" else img),
|
| 92 |
+
T.Resize((input_size, input_size), interpolation=InterpolationMode.BICUBIC),
|
| 93 |
+
T.ToTensor(),
|
| 94 |
+
T.Normalize(mean=MEAN, std=STD),
|
| 95 |
+
]
|
| 96 |
+
)
|
| 97 |
+
return transform
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
def find_closest_aspect_ratio(aspect_ratio, target_ratios, width, height, image_size):
|
| 101 |
+
"""
|
| 102 |
+
previous version mainly foucs on ratio.
|
| 103 |
+
We also consider area ratio here.
|
| 104 |
+
"""
|
| 105 |
+
best_factor = float("-inf")
|
| 106 |
+
best_ratio = (1, 1)
|
| 107 |
+
area = width * height
|
| 108 |
+
for ratio in target_ratios:
|
| 109 |
+
target_aspect_ratio = ratio[0] / ratio[1]
|
| 110 |
+
area_ratio = (ratio[0] * ratio[1] * image_size * image_size) / area
|
| 111 |
+
# new area > 60% of original image area is enough.
|
| 112 |
+
factor_based_on_area_n_ratio = min(area_ratio, 0.6) * min(
|
| 113 |
+
target_aspect_ratio / aspect_ratio, aspect_ratio / target_aspect_ratio
|
| 114 |
+
)
|
| 115 |
+
|
| 116 |
+
if factor_based_on_area_n_ratio > best_factor:
|
| 117 |
+
best_factor = factor_based_on_area_n_ratio
|
| 118 |
+
best_ratio = ratio
|
| 119 |
+
|
| 120 |
+
return best_ratio
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
def dynamic_preprocess(
|
| 124 |
+
image, min_num=1, max_num=6, image_size=448, use_thumbnail=False
|
| 125 |
+
):
|
| 126 |
+
orig_width, orig_height = image.size
|
| 127 |
+
aspect_ratio = orig_width / orig_height
|
| 128 |
+
|
| 129 |
+
# calculate the existing image aspect ratio
|
| 130 |
+
target_ratios = set(
|
| 131 |
+
(i, j)
|
| 132 |
+
for n in range(min_num, max_num + 1)
|
| 133 |
+
for i in range(1, n + 1)
|
| 134 |
+
for j in range(1, n + 1)
|
| 135 |
+
if i * j <= max_num and i * j >= min_num
|
| 136 |
+
)
|
| 137 |
+
target_ratios = sorted(target_ratios, key=lambda x: x[0] * x[1])
|
| 138 |
+
|
| 139 |
+
# find the closest aspect ratio to the target
|
| 140 |
+
target_aspect_ratio = find_closest_aspect_ratio(
|
| 141 |
+
aspect_ratio, target_ratios, orig_width, orig_height, image_size
|
| 142 |
+
)
|
| 143 |
+
|
| 144 |
+
# calculate the target width and height
|
| 145 |
+
target_width = image_size * target_aspect_ratio[0]
|
| 146 |
+
target_height = image_size * target_aspect_ratio[1]
|
| 147 |
+
blocks = target_aspect_ratio[0] * target_aspect_ratio[1]
|
| 148 |
+
|
| 149 |
+
# resize the image
|
| 150 |
+
resized_img = image.resize((target_width, target_height))
|
| 151 |
+
processed_images = []
|
| 152 |
+
for i in range(blocks):
|
| 153 |
+
box = (
|
| 154 |
+
(i % (target_width // image_size)) * image_size,
|
| 155 |
+
(i // (target_width // image_size)) * image_size,
|
| 156 |
+
((i % (target_width // image_size)) + 1) * image_size,
|
| 157 |
+
((i // (target_width // image_size)) + 1) * image_size,
|
| 158 |
+
)
|
| 159 |
+
# split the image
|
| 160 |
+
split_img = resized_img.crop(box)
|
| 161 |
+
processed_images.append(split_img)
|
| 162 |
+
assert len(processed_images) == blocks
|
| 163 |
+
if use_thumbnail and len(processed_images) != 1:
|
| 164 |
+
thumbnail_img = image.resize((image_size, image_size))
|
| 165 |
+
processed_images.append(thumbnail_img)
|
| 166 |
+
return processed_images
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
class LlamaNemotronVLRerankProcessor(ProcessorMixin):
|
| 170 |
+
attributes = ["tokenizer"]
|
| 171 |
+
tokenizer_class = "AutoTokenizer"
|
| 172 |
+
|
| 173 |
+
def __init__(
|
| 174 |
+
self,
|
| 175 |
+
tokenizer: Any,
|
| 176 |
+
padding: Union[bool, str] = True,
|
| 177 |
+
rerank_max_length: Optional[int] = None,
|
| 178 |
+
pad_to_multiple_of: Optional[int] = None,
|
| 179 |
+
max_input_tiles: int = 2,
|
| 180 |
+
num_image_token: int = None,
|
| 181 |
+
prompt_template: str = None,
|
| 182 |
+
force_image_size: int = 512,
|
| 183 |
+
template: str = "bidirectional-llama-retriever",
|
| 184 |
+
dynamic_image_size: bool = True,
|
| 185 |
+
use_thumbnail: bool = True,
|
| 186 |
+
**kwargs,
|
| 187 |
+
):
|
| 188 |
+
self.padding = padding
|
| 189 |
+
self.rerank_max_length = rerank_max_length
|
| 190 |
+
self.pad_to_multiple_of = pad_to_multiple_of
|
| 191 |
+
|
| 192 |
+
tokenizer.padding_side = "left"
|
| 193 |
+
tokenizer.model_input_names = tokenizer.model_input_names + ["pixel_values"]
|
| 194 |
+
self.tokenizer = tokenizer
|
| 195 |
+
|
| 196 |
+
self.norm_type = "siglip"
|
| 197 |
+
self.image_size = force_image_size
|
| 198 |
+
self.max_input_tiles = max_input_tiles
|
| 199 |
+
self.num_image_token = num_image_token
|
| 200 |
+
self.system_message = ""
|
| 201 |
+
self.prompt_template = prompt_template
|
| 202 |
+
self.template = template
|
| 203 |
+
self.dynamic_image_size = dynamic_image_size
|
| 204 |
+
self.use_thumbnail = use_thumbnail
|
| 205 |
+
|
| 206 |
+
super().__init__(self.tokenizer)
|
| 207 |
+
|
| 208 |
+
def __call__(
|
| 209 |
+
self,
|
| 210 |
+
text: Optional[List] = None,
|
| 211 |
+
images: Optional[List[Any]] = None,
|
| 212 |
+
text_kwargs: Optional[Dict[str, Any]] = None,
|
| 213 |
+
images_kwargs: Optional[Dict[str, Any]] = None,
|
| 214 |
+
common_kwargs: Optional[Dict[str, Any]] = None,
|
| 215 |
+
**kwargs,
|
| 216 |
+
) -> Dict[str, Any]:
|
| 217 |
+
"""Process inputs for Sentence Transformers CrossEncoder compatibility.
|
| 218 |
+
|
| 219 |
+
For text-only pairs, ``text`` is a list of (query, document) tuples.
|
| 220 |
+
For image-based inputs, ``images`` contains document images alongside
|
| 221 |
+
``text`` containing the query strings.
|
| 222 |
+
|
| 223 |
+
Args:
|
| 224 |
+
text: List of text strings or list of (query, document) tuples.
|
| 225 |
+
images: Optional list of PIL Images for document pages.
|
| 226 |
+
text_kwargs: Keyword arguments for text processing.
|
| 227 |
+
images_kwargs: Keyword arguments for image processing (unused).
|
| 228 |
+
common_kwargs: Common keyword arguments (e.g. return_tensors).
|
| 229 |
+
"""
|
| 230 |
+
text_kwargs = text_kwargs or {}
|
| 231 |
+
common_kwargs = common_kwargs or {}
|
| 232 |
+
tokenizer_kwargs = {**common_kwargs, **text_kwargs}
|
| 233 |
+
return_tensors = tokenizer_kwargs.pop("return_tensors", "pt")
|
| 234 |
+
padding = tokenizer_kwargs.pop("padding", self.padding)
|
| 235 |
+
truncation = tokenizer_kwargs.pop("truncation", True)
|
| 236 |
+
|
| 237 |
+
if text is not None and len(text) > 0 and isinstance(text[0], (tuple, list)):
|
| 238 |
+
# Text pairs from CrossEncoder: [("query1", "doc1"), ("query2", "doc2")]
|
| 239 |
+
formatted = [
|
| 240 |
+
self.prompt_template_question_passage(q, d) if self.prompt_template == "v1"
|
| 241 |
+
else f"{q} \n {d}"
|
| 242 |
+
for q, d in text
|
| 243 |
+
]
|
| 244 |
+
doc_images = [None] * len(text)
|
| 245 |
+
elif images is not None:
|
| 246 |
+
# Image documents with optional text
|
| 247 |
+
formatted = [
|
| 248 |
+
self.prompt_template_question_passage("", t) if self.prompt_template == "v1"
|
| 249 |
+
else t
|
| 250 |
+
for t in (text or [""] * len(images))
|
| 251 |
+
]
|
| 252 |
+
doc_images = images
|
| 253 |
+
else:
|
| 254 |
+
# Plain text (fallback)
|
| 255 |
+
formatted = text or []
|
| 256 |
+
doc_images = [None] * len(formatted)
|
| 257 |
+
|
| 258 |
+
documents = [
|
| 259 |
+
{"image": img if img is not None else "", "text": t}
|
| 260 |
+
for img, t in zip(doc_images, formatted)
|
| 261 |
+
]
|
| 262 |
+
return self.process_query_documents(
|
| 263 |
+
documents,
|
| 264 |
+
return_tensors=return_tensors,
|
| 265 |
+
padding=padding,
|
| 266 |
+
truncation=truncation,
|
| 267 |
+
)
|
| 268 |
+
|
| 269 |
+
def apply_chat_template(
|
| 270 |
+
self,
|
| 271 |
+
messages: List,
|
| 272 |
+
tokenize: bool = True,
|
| 273 |
+
return_dict: bool = True,
|
| 274 |
+
text_kwargs: Optional[Dict[str, Any]] = None,
|
| 275 |
+
images_kwargs: Optional[Dict[str, Any]] = None,
|
| 276 |
+
audio_kwargs: Optional[Dict[str, Any]] = None,
|
| 277 |
+
videos_kwargs: Optional[Dict[str, Any]] = None,
|
| 278 |
+
common_kwargs: Optional[Dict[str, Any]] = None,
|
| 279 |
+
**kwargs,
|
| 280 |
+
) -> Dict[str, Any]:
|
| 281 |
+
"""Process chat-formatted messages for multimodal CrossEncoder pairs.
|
| 282 |
+
|
| 283 |
+
When Sentence Transformers encounters non-text pairs (e.g. image
|
| 284 |
+
documents), it converts them to structured messages with ``"query"``
|
| 285 |
+
and ``"document"`` roles and calls this method.
|
| 286 |
+
|
| 287 |
+
Args:
|
| 288 |
+
messages: Batch of conversations. Each conversation is a list of
|
| 289 |
+
message dicts with ``"role"`` (``"query"``/``"document"``) and
|
| 290 |
+
``"content"`` keys.
|
| 291 |
+
tokenize: Whether to tokenize (always True for ST).
|
| 292 |
+
return_dict: Whether to return a dict (always True for ST).
|
| 293 |
+
text_kwargs: Keyword arguments for text processing.
|
| 294 |
+
images_kwargs: Keyword arguments for image processing (unused).
|
| 295 |
+
audio_kwargs: Unused, for API compatibility.
|
| 296 |
+
videos_kwargs: Unused, for API compatibility.
|
| 297 |
+
common_kwargs: Common keyword arguments (e.g. return_tensors).
|
| 298 |
+
"""
|
| 299 |
+
text_kwargs = text_kwargs or {}
|
| 300 |
+
common_kwargs = common_kwargs or {}
|
| 301 |
+
tokenizer_kwargs = {**common_kwargs, **text_kwargs}
|
| 302 |
+
return_tensors = tokenizer_kwargs.pop("return_tensors", "pt")
|
| 303 |
+
padding = tokenizer_kwargs.pop("padding", self.padding)
|
| 304 |
+
truncation = tokenizer_kwargs.pop("truncation", True)
|
| 305 |
+
|
| 306 |
+
documents = []
|
| 307 |
+
for conversation in messages:
|
| 308 |
+
query_text = ""
|
| 309 |
+
doc_text = ""
|
| 310 |
+
doc_image = None
|
| 311 |
+
|
| 312 |
+
for msg in conversation:
|
| 313 |
+
role = msg.get("role", "")
|
| 314 |
+
content = msg.get("content", "")
|
| 315 |
+
|
| 316 |
+
if role == "query":
|
| 317 |
+
if isinstance(content, str):
|
| 318 |
+
query_text = content
|
| 319 |
+
elif isinstance(content, list):
|
| 320 |
+
for part in content:
|
| 321 |
+
if isinstance(part, dict) and part.get("type") == "text":
|
| 322 |
+
query_text = part.get("text", "")
|
| 323 |
+
elif role == "document":
|
| 324 |
+
if isinstance(content, str):
|
| 325 |
+
doc_text = content
|
| 326 |
+
elif isinstance(content, list):
|
| 327 |
+
for part in content:
|
| 328 |
+
if isinstance(part, dict):
|
| 329 |
+
if part.get("type") == "text":
|
| 330 |
+
doc_text = part.get("text", "")
|
| 331 |
+
elif part.get("type") == "image":
|
| 332 |
+
doc_image = part.get("image")
|
| 333 |
+
|
| 334 |
+
if self.prompt_template == "v1":
|
| 335 |
+
formatted = self.prompt_template_question_passage(query_text, doc_text)
|
| 336 |
+
else:
|
| 337 |
+
formatted = f"{query_text} \n {doc_text}"
|
| 338 |
+
|
| 339 |
+
documents.append({
|
| 340 |
+
"image": doc_image if doc_image is not None else "",
|
| 341 |
+
"text": formatted,
|
| 342 |
+
})
|
| 343 |
+
|
| 344 |
+
return self.process_query_documents(
|
| 345 |
+
documents,
|
| 346 |
+
return_tensors=return_tensors,
|
| 347 |
+
padding=padding,
|
| 348 |
+
truncation=truncation,
|
| 349 |
+
)
|
| 350 |
+
|
| 351 |
+
def process_query_documents(
|
| 352 |
+
self,
|
| 353 |
+
documents: Union[Dict, List[Dict]],
|
| 354 |
+
return_tensors: Literal["pt", "np"] = "pt",
|
| 355 |
+
padding: bool | str | None = None,
|
| 356 |
+
truncation: bool = True,
|
| 357 |
+
max_length: Optional[int] = None,
|
| 358 |
+
pixel_values_layout: Literal["per_image", "flat_tiles"] = "flat_tiles",
|
| 359 |
+
**kwargs,
|
| 360 |
+
) -> Dict[str, Any]:
|
| 361 |
+
"""Process query-document pairs into model inputs with tokenized text and pixel values.
|
| 362 |
+
|
| 363 |
+
Args:
|
| 364 |
+
documents: Either a dict with "images" and "texts" lists, or a list of
|
| 365 |
+
dicts each with "image" and "text" keys. Images can be PIL Images,
|
| 366 |
+
file paths, or None/empty string for text-only documents.
|
| 367 |
+
return_tensors: Output format — "pt" for PyTorch tensors, "np" for numpy arrays.
|
| 368 |
+
padding: Padding strategy passed to the tokenizer. Defaults to the value
|
| 369 |
+
set in the processor constructor.
|
| 370 |
+
truncation: Whether to truncate sequences to the tokenizer's model_max_length.
|
| 371 |
+
max_length: Optional override for the maximum sequence length. If None,
|
| 372 |
+
the tokenizer's model_max_length is used when truncation is enabled.
|
| 373 |
+
pixel_values_layout: How to structure the pixel values output:
|
| 374 |
+
- "flat_tiles": All image tiles concatenated into a single tensor of shape
|
| 375 |
+
(total_tiles, C, H, W). Different images may contribute different numbers
|
| 376 |
+
of tiles. None if no images are present. This is the format expected by
|
| 377 |
+
the model's forward() method.
|
| 378 |
+
- "per_image": A list aligned with the input documents, where each entry
|
| 379 |
+
is either a tensor of shape (num_tiles, C, H, W) or None.
|
| 380 |
+
|
| 381 |
+
Returns:
|
| 382 |
+
Dict with "input_ids", "attention_mask", and "pixel_values".
|
| 383 |
+
"""
|
| 384 |
+
if return_tensors not in ("pt", "np"):
|
| 385 |
+
raise ValueError(
|
| 386 |
+
f"Invalid return_tensors: {return_tensors!r}. Must be 'pt' or 'np'."
|
| 387 |
+
)
|
| 388 |
+
|
| 389 |
+
if isinstance(documents, dict):
|
| 390 |
+
images = documents["images"]
|
| 391 |
+
texts = documents["texts"]
|
| 392 |
+
assert len(texts) == len(images)
|
| 393 |
+
elif isinstance(documents, list):
|
| 394 |
+
images = [pair["image"] for pair in documents]
|
| 395 |
+
texts = [pair["text"] for pair in documents]
|
| 396 |
+
else:
|
| 397 |
+
raise ValueError("The documents need to be a dict or list of dicts")
|
| 398 |
+
|
| 399 |
+
contents = []
|
| 400 |
+
pil_images_by_idx = {}
|
| 401 |
+
max_input_tile_by_idx = {}
|
| 402 |
+
for idx, (image, text) in enumerate(zip(images, texts)):
|
| 403 |
+
prefix = ""
|
| 404 |
+
if image is not None and image != "":
|
| 405 |
+
pil_images_by_idx[idx] = load_image(image)
|
| 406 |
+
prefix = "<image>"
|
| 407 |
+
max_input_tile_by_idx[idx] = self.max_input_tiles
|
| 408 |
+
|
| 409 |
+
# ToDo: Order is hardcoded and different than before. No \n after <image>
|
| 410 |
+
content = text
|
| 411 |
+
if prefix != "":
|
| 412 |
+
content = prefix + " " + content
|
| 413 |
+
contents.append(content)
|
| 414 |
+
|
| 415 |
+
assert len(max_input_tile_by_idx) == len(pil_images_by_idx), (
|
| 416 |
+
"The number of max_input_tile_by_idx and pil_images_by_idx should be the same."
|
| 417 |
+
)
|
| 418 |
+
|
| 419 |
+
transform = build_transform(
|
| 420 |
+
input_size=self.image_size, norm_type=self.norm_type
|
| 421 |
+
)
|
| 422 |
+
|
| 423 |
+
template = get_conv_template(self.template)
|
| 424 |
+
template.system_message = self.system_message
|
| 425 |
+
|
| 426 |
+
IMG_START_TOKEN = "<img>"
|
| 427 |
+
IMG_END_TOKEN = "</img>"
|
| 428 |
+
IMG_CONTEXT_TOKEN = "<IMG_CONTEXT>"
|
| 429 |
+
|
| 430 |
+
content_prompts = []
|
| 431 |
+
pixel_values_list = []
|
| 432 |
+
for i, content in enumerate(contents):
|
| 433 |
+
pil_image = pil_images_by_idx.get(i)
|
| 434 |
+
max_input_tiles = max_input_tile_by_idx.get(i)
|
| 435 |
+
if pil_image is not None:
|
| 436 |
+
if self.dynamic_image_size:
|
| 437 |
+
image_tiles = dynamic_preprocess(
|
| 438 |
+
pil_image,
|
| 439 |
+
image_size=self.image_size,
|
| 440 |
+
max_num=max_input_tiles,
|
| 441 |
+
use_thumbnail=self.use_thumbnail,
|
| 442 |
+
)
|
| 443 |
+
else:
|
| 444 |
+
image_tiles = [pil_image]
|
| 445 |
+
|
| 446 |
+
pixel_values = [transform(item) for item in image_tiles]
|
| 447 |
+
pixel_values = torch.stack(pixel_values).to(dtype=torch.bfloat16)
|
| 448 |
+
else:
|
| 449 |
+
pixel_values = None
|
| 450 |
+
pixel_values_list.append(pixel_values)
|
| 451 |
+
|
| 452 |
+
if pixel_values is not None and "<image>" not in content:
|
| 453 |
+
content = "<image> " + content
|
| 454 |
+
|
| 455 |
+
# Reseting conversation messages
|
| 456 |
+
template.messages.clear()
|
| 457 |
+
|
| 458 |
+
# TODO: do we need this template?
|
| 459 |
+
template.append_message(template.roles[0], content) # user
|
| 460 |
+
template.append_message(template.roles[1], None) # assistant
|
| 461 |
+
content_prompt = template.get_prompt()
|
| 462 |
+
|
| 463 |
+
if pixel_values is not None:
|
| 464 |
+
num_patches = pixel_values.shape[0]
|
| 465 |
+
image_tokens = (
|
| 466 |
+
IMG_START_TOKEN
|
| 467 |
+
+ IMG_CONTEXT_TOKEN * self.num_image_token * num_patches
|
| 468 |
+
+ IMG_END_TOKEN
|
| 469 |
+
)
|
| 470 |
+
content_prompt = content_prompt.replace("<image>", image_tokens, 1)
|
| 471 |
+
else:
|
| 472 |
+
content_prompt = content_prompt.replace("<image>", "", 1)
|
| 473 |
+
|
| 474 |
+
content_prompts.append(content_prompt)
|
| 475 |
+
|
| 476 |
+
if max_length is None:
|
| 477 |
+
max_length = self.rerank_max_length
|
| 478 |
+
|
| 479 |
+
if padding is None:
|
| 480 |
+
padding = self.padding
|
| 481 |
+
|
| 482 |
+
model_inputs = self.tokenizer(
|
| 483 |
+
content_prompts,
|
| 484 |
+
truncation=truncation,
|
| 485 |
+
max_length=max_length,
|
| 486 |
+
padding=padding,
|
| 487 |
+
pad_to_multiple_of=self.pad_to_multiple_of,
|
| 488 |
+
return_tensors=return_tensors,
|
| 489 |
+
)
|
| 490 |
+
|
| 491 |
+
if pixel_values_layout == "flat_tiles":
|
| 492 |
+
pixel_values_list = [pv for pv in pixel_values_list if pv is not None]
|
| 493 |
+
if len(pixel_values_list) > 1:
|
| 494 |
+
pixel_values_squeezed = torch.concat(pixel_values_list, axis=0)
|
| 495 |
+
elif len(pixel_values_list) == 1:
|
| 496 |
+
pixel_values_squeezed = pixel_values_list[0]
|
| 497 |
+
else:
|
| 498 |
+
pixel_values_squeezed = None
|
| 499 |
+
|
| 500 |
+
if pixel_values_squeezed is not None and return_tensors == "np":
|
| 501 |
+
pixel_values_return_value = (
|
| 502 |
+
pixel_values_squeezed.to(dtype=torch.float16).cpu().numpy()
|
| 503 |
+
)
|
| 504 |
+
else:
|
| 505 |
+
pixel_values_return_value = pixel_values_squeezed
|
| 506 |
+
elif pixel_values_layout == "per_image":
|
| 507 |
+
if return_tensors == "np":
|
| 508 |
+
pixel_values_return_value = [
|
| 509 |
+
pv.to(dtype=torch.float16).cpu().numpy() if pv is not None else None
|
| 510 |
+
for pv in pixel_values_list
|
| 511 |
+
]
|
| 512 |
+
else:
|
| 513 |
+
pixel_values_return_value = pixel_values_list
|
| 514 |
+
else:
|
| 515 |
+
raise ValueError(
|
| 516 |
+
f"Invalid pixel_values_layout: {pixel_values_layout!r}. "
|
| 517 |
+
f"Must be 'flat_tiles' or 'per_image'."
|
| 518 |
+
)
|
| 519 |
+
|
| 520 |
+
batch_docs = {
|
| 521 |
+
"input_ids": model_inputs["input_ids"],
|
| 522 |
+
"attention_mask": model_inputs["attention_mask"],
|
| 523 |
+
"pixel_values": pixel_values_return_value,
|
| 524 |
+
}
|
| 525 |
+
|
| 526 |
+
return batch_docs
|
| 527 |
+
|
| 528 |
+
def prompt_template_question_passage(self, question, text):
|
| 529 |
+
return f"question:{question} \n \n passage:{text}"
|
| 530 |
+
|
| 531 |
+
def process_queries_documents_crossencoder(self, features: List[Dict], **kwargs) -> Dict[str, Any]:
|
| 532 |
+
images = [feature["doc_image"] for feature in features]
|
| 533 |
+
if self.prompt_template == "v1":
|
| 534 |
+
questions_texts = [
|
| 535 |
+
self.prompt_template_question_passage(
|
| 536 |
+
feature["question"], feature["doc_text"]
|
| 537 |
+
)
|
| 538 |
+
for feature in features
|
| 539 |
+
]
|
| 540 |
+
else:
|
| 541 |
+
questions_texts = [
|
| 542 |
+
f"{feature['question']} \n {feature['doc_text']}"
|
| 543 |
+
for feature in features
|
| 544 |
+
]
|
| 545 |
+
batch_dict = self.process_query_documents(
|
| 546 |
+
{"images": images, "texts": questions_texts}, **kwargs
|
| 547 |
+
)
|
| 548 |
+
|
| 549 |
+
if "num_labels" in features[0]:
|
| 550 |
+
batch_dict["labels"] = torch.zeros(
|
| 551 |
+
features[0]["num_labels"], dtype=torch.long
|
| 552 |
+
)
|
| 553 |
+
|
| 554 |
+
return batch_dict
|
processor_config.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"auto_map": {
|
| 3 |
+
"AutoProcessor": "processing_llama_nemotron_vl.LlamaNemotronVLRerankProcessor"
|
| 4 |
+
},
|
| 5 |
+
"dynamic_image_size": true,
|
| 6 |
+
"max_input_tiles": 6,
|
| 7 |
+
"num_image_token": 256,
|
| 8 |
+
"pad_to_multiple_of": null,
|
| 9 |
+
"padding": true,
|
| 10 |
+
"processor_class": "LlamaNemotronVLRerankProcessor",
|
| 11 |
+
"prompt_template": "v1",
|
| 12 |
+
"rerank_max_length": null,
|
| 13 |
+
"template": "bidirectional-llama-retriever",
|
| 14 |
+
"use_thumbnail": true
|
| 15 |
+
}
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token": {
|
| 3 |
+
"content": "<|begin_of_text|>",
|
| 4 |
+
"lstrip": false,
|
| 5 |
+
"normalized": false,
|
| 6 |
+
"rstrip": false,
|
| 7 |
+
"single_word": false
|
| 8 |
+
},
|
| 9 |
+
"eos_token": {
|
| 10 |
+
"content": "<|eot_id|>",
|
| 11 |
+
"lstrip": false,
|
| 12 |
+
"normalized": false,
|
| 13 |
+
"rstrip": false,
|
| 14 |
+
"single_word": false
|
| 15 |
+
},
|
| 16 |
+
"pad_token": {
|
| 17 |
+
"content": "<|finetune_right_pad_id|>",
|
| 18 |
+
"lstrip": false,
|
| 19 |
+
"normalized": false,
|
| 20 |
+
"rstrip": false,
|
| 21 |
+
"single_word": false
|
| 22 |
+
}
|
| 23 |
+
}
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:aec31b86a211fc74943c3dbbaaa37604e985ddabf1178102b523a155a8be1eb2
|
| 3 |
+
size 17212412
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,2165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_eos_token": false,
|
| 3 |
+
"added_tokens_decoder": {
|
| 4 |
+
"78191": {
|
| 5 |
+
"content": "assistant",
|
| 6 |
+
"lstrip": false,
|
| 7 |
+
"normalized": true,
|
| 8 |
+
"rstrip": false,
|
| 9 |
+
"single_word": false,
|
| 10 |
+
"special": false
|
| 11 |
+
},
|
| 12 |
+
"128000": {
|
| 13 |
+
"content": "<|begin_of_text|>",
|
| 14 |
+
"lstrip": false,
|
| 15 |
+
"normalized": false,
|
| 16 |
+
"rstrip": false,
|
| 17 |
+
"single_word": false,
|
| 18 |
+
"special": true
|
| 19 |
+
},
|
| 20 |
+
"128001": {
|
| 21 |
+
"content": "<|end_of_text|>",
|
| 22 |
+
"lstrip": false,
|
| 23 |
+
"normalized": false,
|
| 24 |
+
"rstrip": false,
|
| 25 |
+
"single_word": false,
|
| 26 |
+
"special": true
|
| 27 |
+
},
|
| 28 |
+
"128002": {
|
| 29 |
+
"content": "<|reserved_special_token_0|>",
|
| 30 |
+
"lstrip": false,
|
| 31 |
+
"normalized": false,
|
| 32 |
+
"rstrip": false,
|
| 33 |
+
"single_word": false,
|
| 34 |
+
"special": true
|
| 35 |
+
},
|
| 36 |
+
"128003": {
|
| 37 |
+
"content": "<|reserved_special_token_1|>",
|
| 38 |
+
"lstrip": false,
|
| 39 |
+
"normalized": false,
|
| 40 |
+
"rstrip": false,
|
| 41 |
+
"single_word": false,
|
| 42 |
+
"special": true
|
| 43 |
+
},
|
| 44 |
+
"128004": {
|
| 45 |
+
"content": "<|finetune_right_pad_id|>",
|
| 46 |
+
"lstrip": false,
|
| 47 |
+
"normalized": false,
|
| 48 |
+
"rstrip": false,
|
| 49 |
+
"single_word": false,
|
| 50 |
+
"special": true
|
| 51 |
+
},
|
| 52 |
+
"128005": {
|
| 53 |
+
"content": "<|reserved_special_token_2|>",
|
| 54 |
+
"lstrip": false,
|
| 55 |
+
"normalized": false,
|
| 56 |
+
"rstrip": false,
|
| 57 |
+
"single_word": false,
|
| 58 |
+
"special": true
|
| 59 |
+
},
|
| 60 |
+
"128006": {
|
| 61 |
+
"content": "<|start_header_id|>",
|
| 62 |
+
"lstrip": false,
|
| 63 |
+
"normalized": false,
|
| 64 |
+
"rstrip": false,
|
| 65 |
+
"single_word": false,
|
| 66 |
+
"special": true
|
| 67 |
+
},
|
| 68 |
+
"128007": {
|
| 69 |
+
"content": "<|end_header_id|>",
|
| 70 |
+
"lstrip": false,
|
| 71 |
+
"normalized": false,
|
| 72 |
+
"rstrip": false,
|
| 73 |
+
"single_word": false,
|
| 74 |
+
"special": true
|
| 75 |
+
},
|
| 76 |
+
"128008": {
|
| 77 |
+
"content": "<|eom_id|>",
|
| 78 |
+
"lstrip": false,
|
| 79 |
+
"normalized": false,
|
| 80 |
+
"rstrip": false,
|
| 81 |
+
"single_word": false,
|
| 82 |
+
"special": true
|
| 83 |
+
},
|
| 84 |
+
"128009": {
|
| 85 |
+
"content": "<|eot_id|>",
|
| 86 |
+
"lstrip": false,
|
| 87 |
+
"normalized": false,
|
| 88 |
+
"rstrip": false,
|
| 89 |
+
"single_word": false,
|
| 90 |
+
"special": true
|
| 91 |
+
},
|
| 92 |
+
"128010": {
|
| 93 |
+
"content": "<|python_tag|>",
|
| 94 |
+
"lstrip": false,
|
| 95 |
+
"normalized": false,
|
| 96 |
+
"rstrip": false,
|
| 97 |
+
"single_word": false,
|
| 98 |
+
"special": true
|
| 99 |
+
},
|
| 100 |
+
"128011": {
|
| 101 |
+
"content": "<|reserved_special_token_3|>",
|
| 102 |
+
"lstrip": false,
|
| 103 |
+
"normalized": false,
|
| 104 |
+
"rstrip": false,
|
| 105 |
+
"single_word": false,
|
| 106 |
+
"special": true
|
| 107 |
+
},
|
| 108 |
+
"128012": {
|
| 109 |
+
"content": "<|reserved_special_token_4|>",
|
| 110 |
+
"lstrip": false,
|
| 111 |
+
"normalized": false,
|
| 112 |
+
"rstrip": false,
|
| 113 |
+
"single_word": false,
|
| 114 |
+
"special": true
|
| 115 |
+
},
|
| 116 |
+
"128013": {
|
| 117 |
+
"content": "<|reserved_special_token_5|>",
|
| 118 |
+
"lstrip": false,
|
| 119 |
+
"normalized": false,
|
| 120 |
+
"rstrip": false,
|
| 121 |
+
"single_word": false,
|
| 122 |
+
"special": true
|
| 123 |
+
},
|
| 124 |
+
"128014": {
|
| 125 |
+
"content": "<|reserved_special_token_6|>",
|
| 126 |
+
"lstrip": false,
|
| 127 |
+
"normalized": false,
|
| 128 |
+
"rstrip": false,
|
| 129 |
+
"single_word": false,
|
| 130 |
+
"special": true
|
| 131 |
+
},
|
| 132 |
+
"128015": {
|
| 133 |
+
"content": "<|reserved_special_token_7|>",
|
| 134 |
+
"lstrip": false,
|
| 135 |
+
"normalized": false,
|
| 136 |
+
"rstrip": false,
|
| 137 |
+
"single_word": false,
|
| 138 |
+
"special": true
|
| 139 |
+
},
|
| 140 |
+
"128016": {
|
| 141 |
+
"content": "<|reserved_special_token_8|>",
|
| 142 |
+
"lstrip": false,
|
| 143 |
+
"normalized": false,
|
| 144 |
+
"rstrip": false,
|
| 145 |
+
"single_word": false,
|
| 146 |
+
"special": true
|
| 147 |
+
},
|
| 148 |
+
"128017": {
|
| 149 |
+
"content": "<|reserved_special_token_9|>",
|
| 150 |
+
"lstrip": false,
|
| 151 |
+
"normalized": false,
|
| 152 |
+
"rstrip": false,
|
| 153 |
+
"single_word": false,
|
| 154 |
+
"special": true
|
| 155 |
+
},
|
| 156 |
+
"128018": {
|
| 157 |
+
"content": "<|reserved_special_token_10|>",
|
| 158 |
+
"lstrip": false,
|
| 159 |
+
"normalized": false,
|
| 160 |
+
"rstrip": false,
|
| 161 |
+
"single_word": false,
|
| 162 |
+
"special": true
|
| 163 |
+
},
|
| 164 |
+
"128019": {
|
| 165 |
+
"content": "<|reserved_special_token_11|>",
|
| 166 |
+
"lstrip": false,
|
| 167 |
+
"normalized": false,
|
| 168 |
+
"rstrip": false,
|
| 169 |
+
"single_word": false,
|
| 170 |
+
"special": true
|
| 171 |
+
},
|
| 172 |
+
"128020": {
|
| 173 |
+
"content": "<|reserved_special_token_12|>",
|
| 174 |
+
"lstrip": false,
|
| 175 |
+
"normalized": false,
|
| 176 |
+
"rstrip": false,
|
| 177 |
+
"single_word": false,
|
| 178 |
+
"special": true
|
| 179 |
+
},
|
| 180 |
+
"128021": {
|
| 181 |
+
"content": "<|reserved_special_token_13|>",
|
| 182 |
+
"lstrip": false,
|
| 183 |
+
"normalized": false,
|
| 184 |
+
"rstrip": false,
|
| 185 |
+
"single_word": false,
|
| 186 |
+
"special": true
|
| 187 |
+
},
|
| 188 |
+
"128022": {
|
| 189 |
+
"content": "<|reserved_special_token_14|>",
|
| 190 |
+
"lstrip": false,
|
| 191 |
+
"normalized": false,
|
| 192 |
+
"rstrip": false,
|
| 193 |
+
"single_word": false,
|
| 194 |
+
"special": true
|
| 195 |
+
},
|
| 196 |
+
"128023": {
|
| 197 |
+
"content": "<|reserved_special_token_15|>",
|
| 198 |
+
"lstrip": false,
|
| 199 |
+
"normalized": false,
|
| 200 |
+
"rstrip": false,
|
| 201 |
+
"single_word": false,
|
| 202 |
+
"special": true
|
| 203 |
+
},
|
| 204 |
+
"128024": {
|
| 205 |
+
"content": "<|reserved_special_token_16|>",
|
| 206 |
+
"lstrip": false,
|
| 207 |
+
"normalized": false,
|
| 208 |
+
"rstrip": false,
|
| 209 |
+
"single_word": false,
|
| 210 |
+
"special": true
|
| 211 |
+
},
|
| 212 |
+
"128025": {
|
| 213 |
+
"content": "<|reserved_special_token_17|>",
|
| 214 |
+
"lstrip": false,
|
| 215 |
+
"normalized": false,
|
| 216 |
+
"rstrip": false,
|
| 217 |
+
"single_word": false,
|
| 218 |
+
"special": true
|
| 219 |
+
},
|
| 220 |
+
"128026": {
|
| 221 |
+
"content": "<|reserved_special_token_18|>",
|
| 222 |
+
"lstrip": false,
|
| 223 |
+
"normalized": false,
|
| 224 |
+
"rstrip": false,
|
| 225 |
+
"single_word": false,
|
| 226 |
+
"special": true
|
| 227 |
+
},
|
| 228 |
+
"128027": {
|
| 229 |
+
"content": "<|reserved_special_token_19|>",
|
| 230 |
+
"lstrip": false,
|
| 231 |
+
"normalized": false,
|
| 232 |
+
"rstrip": false,
|
| 233 |
+
"single_word": false,
|
| 234 |
+
"special": true
|
| 235 |
+
},
|
| 236 |
+
"128028": {
|
| 237 |
+
"content": "<|reserved_special_token_20|>",
|
| 238 |
+
"lstrip": false,
|
| 239 |
+
"normalized": false,
|
| 240 |
+
"rstrip": false,
|
| 241 |
+
"single_word": false,
|
| 242 |
+
"special": true
|
| 243 |
+
},
|
| 244 |
+
"128029": {
|
| 245 |
+
"content": "<|reserved_special_token_21|>",
|
| 246 |
+
"lstrip": false,
|
| 247 |
+
"normalized": false,
|
| 248 |
+
"rstrip": false,
|
| 249 |
+
"single_word": false,
|
| 250 |
+
"special": true
|
| 251 |
+
},
|
| 252 |
+
"128030": {
|
| 253 |
+
"content": "<|reserved_special_token_22|>",
|
| 254 |
+
"lstrip": false,
|
| 255 |
+
"normalized": false,
|
| 256 |
+
"rstrip": false,
|
| 257 |
+
"single_word": false,
|
| 258 |
+
"special": true
|
| 259 |
+
},
|
| 260 |
+
"128031": {
|
| 261 |
+
"content": "<|reserved_special_token_23|>",
|
| 262 |
+
"lstrip": false,
|
| 263 |
+
"normalized": false,
|
| 264 |
+
"rstrip": false,
|
| 265 |
+
"single_word": false,
|
| 266 |
+
"special": true
|
| 267 |
+
},
|
| 268 |
+
"128032": {
|
| 269 |
+
"content": "<|reserved_special_token_24|>",
|
| 270 |
+
"lstrip": false,
|
| 271 |
+
"normalized": false,
|
| 272 |
+
"rstrip": false,
|
| 273 |
+
"single_word": false,
|
| 274 |
+
"special": true
|
| 275 |
+
},
|
| 276 |
+
"128033": {
|
| 277 |
+
"content": "<|reserved_special_token_25|>",
|
| 278 |
+
"lstrip": false,
|
| 279 |
+
"normalized": false,
|
| 280 |
+
"rstrip": false,
|
| 281 |
+
"single_word": false,
|
| 282 |
+
"special": true
|
| 283 |
+
},
|
| 284 |
+
"128034": {
|
| 285 |
+
"content": "<|reserved_special_token_26|>",
|
| 286 |
+
"lstrip": false,
|
| 287 |
+
"normalized": false,
|
| 288 |
+
"rstrip": false,
|
| 289 |
+
"single_word": false,
|
| 290 |
+
"special": true
|
| 291 |
+
},
|
| 292 |
+
"128035": {
|
| 293 |
+
"content": "<|reserved_special_token_27|>",
|
| 294 |
+
"lstrip": false,
|
| 295 |
+
"normalized": false,
|
| 296 |
+
"rstrip": false,
|
| 297 |
+
"single_word": false,
|
| 298 |
+
"special": true
|
| 299 |
+
},
|
| 300 |
+
"128036": {
|
| 301 |
+
"content": "<|reserved_special_token_28|>",
|
| 302 |
+
"lstrip": false,
|
| 303 |
+
"normalized": false,
|
| 304 |
+
"rstrip": false,
|
| 305 |
+
"single_word": false,
|
| 306 |
+
"special": true
|
| 307 |
+
},
|
| 308 |
+
"128037": {
|
| 309 |
+
"content": "<|reserved_special_token_29|>",
|
| 310 |
+
"lstrip": false,
|
| 311 |
+
"normalized": false,
|
| 312 |
+
"rstrip": false,
|
| 313 |
+
"single_word": false,
|
| 314 |
+
"special": true
|
| 315 |
+
},
|
| 316 |
+
"128038": {
|
| 317 |
+
"content": "<|reserved_special_token_30|>",
|
| 318 |
+
"lstrip": false,
|
| 319 |
+
"normalized": false,
|
| 320 |
+
"rstrip": false,
|
| 321 |
+
"single_word": false,
|
| 322 |
+
"special": true
|
| 323 |
+
},
|
| 324 |
+
"128039": {
|
| 325 |
+
"content": "<|reserved_special_token_31|>",
|
| 326 |
+
"lstrip": false,
|
| 327 |
+
"normalized": false,
|
| 328 |
+
"rstrip": false,
|
| 329 |
+
"single_word": false,
|
| 330 |
+
"special": true
|
| 331 |
+
},
|
| 332 |
+
"128040": {
|
| 333 |
+
"content": "<|reserved_special_token_32|>",
|
| 334 |
+
"lstrip": false,
|
| 335 |
+
"normalized": false,
|
| 336 |
+
"rstrip": false,
|
| 337 |
+
"single_word": false,
|
| 338 |
+
"special": true
|
| 339 |
+
},
|
| 340 |
+
"128041": {
|
| 341 |
+
"content": "<|reserved_special_token_33|>",
|
| 342 |
+
"lstrip": false,
|
| 343 |
+
"normalized": false,
|
| 344 |
+
"rstrip": false,
|
| 345 |
+
"single_word": false,
|
| 346 |
+
"special": true
|
| 347 |
+
},
|
| 348 |
+
"128042": {
|
| 349 |
+
"content": "<|reserved_special_token_34|>",
|
| 350 |
+
"lstrip": false,
|
| 351 |
+
"normalized": false,
|
| 352 |
+
"rstrip": false,
|
| 353 |
+
"single_word": false,
|
| 354 |
+
"special": true
|
| 355 |
+
},
|
| 356 |
+
"128043": {
|
| 357 |
+
"content": "<|reserved_special_token_35|>",
|
| 358 |
+
"lstrip": false,
|
| 359 |
+
"normalized": false,
|
| 360 |
+
"rstrip": false,
|
| 361 |
+
"single_word": false,
|
| 362 |
+
"special": true
|
| 363 |
+
},
|
| 364 |
+
"128044": {
|
| 365 |
+
"content": "<|reserved_special_token_36|>",
|
| 366 |
+
"lstrip": false,
|
| 367 |
+
"normalized": false,
|
| 368 |
+
"rstrip": false,
|
| 369 |
+
"single_word": false,
|
| 370 |
+
"special": true
|
| 371 |
+
},
|
| 372 |
+
"128045": {
|
| 373 |
+
"content": "<|reserved_special_token_37|>",
|
| 374 |
+
"lstrip": false,
|
| 375 |
+
"normalized": false,
|
| 376 |
+
"rstrip": false,
|
| 377 |
+
"single_word": false,
|
| 378 |
+
"special": true
|
| 379 |
+
},
|
| 380 |
+
"128046": {
|
| 381 |
+
"content": "<|reserved_special_token_38|>",
|
| 382 |
+
"lstrip": false,
|
| 383 |
+
"normalized": false,
|
| 384 |
+
"rstrip": false,
|
| 385 |
+
"single_word": false,
|
| 386 |
+
"special": true
|
| 387 |
+
},
|
| 388 |
+
"128047": {
|
| 389 |
+
"content": "<|reserved_special_token_39|>",
|
| 390 |
+
"lstrip": false,
|
| 391 |
+
"normalized": false,
|
| 392 |
+
"rstrip": false,
|
| 393 |
+
"single_word": false,
|
| 394 |
+
"special": true
|
| 395 |
+
},
|
| 396 |
+
"128048": {
|
| 397 |
+
"content": "<|reserved_special_token_40|>",
|
| 398 |
+
"lstrip": false,
|
| 399 |
+
"normalized": false,
|
| 400 |
+
"rstrip": false,
|
| 401 |
+
"single_word": false,
|
| 402 |
+
"special": true
|
| 403 |
+
},
|
| 404 |
+
"128049": {
|
| 405 |
+
"content": "<|reserved_special_token_41|>",
|
| 406 |
+
"lstrip": false,
|
| 407 |
+
"normalized": false,
|
| 408 |
+
"rstrip": false,
|
| 409 |
+
"single_word": false,
|
| 410 |
+
"special": true
|
| 411 |
+
},
|
| 412 |
+
"128050": {
|
| 413 |
+
"content": "<|reserved_special_token_42|>",
|
| 414 |
+
"lstrip": false,
|
| 415 |
+
"normalized": false,
|
| 416 |
+
"rstrip": false,
|
| 417 |
+
"single_word": false,
|
| 418 |
+
"special": true
|
| 419 |
+
},
|
| 420 |
+
"128051": {
|
| 421 |
+
"content": "<|reserved_special_token_43|>",
|
| 422 |
+
"lstrip": false,
|
| 423 |
+
"normalized": false,
|
| 424 |
+
"rstrip": false,
|
| 425 |
+
"single_word": false,
|
| 426 |
+
"special": true
|
| 427 |
+
},
|
| 428 |
+
"128052": {
|
| 429 |
+
"content": "<|reserved_special_token_44|>",
|
| 430 |
+
"lstrip": false,
|
| 431 |
+
"normalized": false,
|
| 432 |
+
"rstrip": false,
|
| 433 |
+
"single_word": false,
|
| 434 |
+
"special": true
|
| 435 |
+
},
|
| 436 |
+
"128053": {
|
| 437 |
+
"content": "<|reserved_special_token_45|>",
|
| 438 |
+
"lstrip": false,
|
| 439 |
+
"normalized": false,
|
| 440 |
+
"rstrip": false,
|
| 441 |
+
"single_word": false,
|
| 442 |
+
"special": true
|
| 443 |
+
},
|
| 444 |
+
"128054": {
|
| 445 |
+
"content": "<|reserved_special_token_46|>",
|
| 446 |
+
"lstrip": false,
|
| 447 |
+
"normalized": false,
|
| 448 |
+
"rstrip": false,
|
| 449 |
+
"single_word": false,
|
| 450 |
+
"special": true
|
| 451 |
+
},
|
| 452 |
+
"128055": {
|
| 453 |
+
"content": "<|reserved_special_token_47|>",
|
| 454 |
+
"lstrip": false,
|
| 455 |
+
"normalized": false,
|
| 456 |
+
"rstrip": false,
|
| 457 |
+
"single_word": false,
|
| 458 |
+
"special": true
|
| 459 |
+
},
|
| 460 |
+
"128056": {
|
| 461 |
+
"content": "<|reserved_special_token_48|>",
|
| 462 |
+
"lstrip": false,
|
| 463 |
+
"normalized": false,
|
| 464 |
+
"rstrip": false,
|
| 465 |
+
"single_word": false,
|
| 466 |
+
"special": true
|
| 467 |
+
},
|
| 468 |
+
"128057": {
|
| 469 |
+
"content": "<|reserved_special_token_49|>",
|
| 470 |
+
"lstrip": false,
|
| 471 |
+
"normalized": false,
|
| 472 |
+
"rstrip": false,
|
| 473 |
+
"single_word": false,
|
| 474 |
+
"special": true
|
| 475 |
+
},
|
| 476 |
+
"128058": {
|
| 477 |
+
"content": "<|reserved_special_token_50|>",
|
| 478 |
+
"lstrip": false,
|
| 479 |
+
"normalized": false,
|
| 480 |
+
"rstrip": false,
|
| 481 |
+
"single_word": false,
|
| 482 |
+
"special": true
|
| 483 |
+
},
|
| 484 |
+
"128059": {
|
| 485 |
+
"content": "<|reserved_special_token_51|>",
|
| 486 |
+
"lstrip": false,
|
| 487 |
+
"normalized": false,
|
| 488 |
+
"rstrip": false,
|
| 489 |
+
"single_word": false,
|
| 490 |
+
"special": true
|
| 491 |
+
},
|
| 492 |
+
"128060": {
|
| 493 |
+
"content": "<|reserved_special_token_52|>",
|
| 494 |
+
"lstrip": false,
|
| 495 |
+
"normalized": false,
|
| 496 |
+
"rstrip": false,
|
| 497 |
+
"single_word": false,
|
| 498 |
+
"special": true
|
| 499 |
+
},
|
| 500 |
+
"128061": {
|
| 501 |
+
"content": "<|reserved_special_token_53|>",
|
| 502 |
+
"lstrip": false,
|
| 503 |
+
"normalized": false,
|
| 504 |
+
"rstrip": false,
|
| 505 |
+
"single_word": false,
|
| 506 |
+
"special": true
|
| 507 |
+
},
|
| 508 |
+
"128062": {
|
| 509 |
+
"content": "<|reserved_special_token_54|>",
|
| 510 |
+
"lstrip": false,
|
| 511 |
+
"normalized": false,
|
| 512 |
+
"rstrip": false,
|
| 513 |
+
"single_word": false,
|
| 514 |
+
"special": true
|
| 515 |
+
},
|
| 516 |
+
"128063": {
|
| 517 |
+
"content": "<|reserved_special_token_55|>",
|
| 518 |
+
"lstrip": false,
|
| 519 |
+
"normalized": false,
|
| 520 |
+
"rstrip": false,
|
| 521 |
+
"single_word": false,
|
| 522 |
+
"special": true
|
| 523 |
+
},
|
| 524 |
+
"128064": {
|
| 525 |
+
"content": "<|reserved_special_token_56|>",
|
| 526 |
+
"lstrip": false,
|
| 527 |
+
"normalized": false,
|
| 528 |
+
"rstrip": false,
|
| 529 |
+
"single_word": false,
|
| 530 |
+
"special": true
|
| 531 |
+
},
|
| 532 |
+
"128065": {
|
| 533 |
+
"content": "<|reserved_special_token_57|>",
|
| 534 |
+
"lstrip": false,
|
| 535 |
+
"normalized": false,
|
| 536 |
+
"rstrip": false,
|
| 537 |
+
"single_word": false,
|
| 538 |
+
"special": true
|
| 539 |
+
},
|
| 540 |
+
"128066": {
|
| 541 |
+
"content": "<|reserved_special_token_58|>",
|
| 542 |
+
"lstrip": false,
|
| 543 |
+
"normalized": false,
|
| 544 |
+
"rstrip": false,
|
| 545 |
+
"single_word": false,
|
| 546 |
+
"special": true
|
| 547 |
+
},
|
| 548 |
+
"128067": {
|
| 549 |
+
"content": "<|reserved_special_token_59|>",
|
| 550 |
+
"lstrip": false,
|
| 551 |
+
"normalized": false,
|
| 552 |
+
"rstrip": false,
|
| 553 |
+
"single_word": false,
|
| 554 |
+
"special": true
|
| 555 |
+
},
|
| 556 |
+
"128068": {
|
| 557 |
+
"content": "<|reserved_special_token_60|>",
|
| 558 |
+
"lstrip": false,
|
| 559 |
+
"normalized": false,
|
| 560 |
+
"rstrip": false,
|
| 561 |
+
"single_word": false,
|
| 562 |
+
"special": true
|
| 563 |
+
},
|
| 564 |
+
"128069": {
|
| 565 |
+
"content": "<|reserved_special_token_61|>",
|
| 566 |
+
"lstrip": false,
|
| 567 |
+
"normalized": false,
|
| 568 |
+
"rstrip": false,
|
| 569 |
+
"single_word": false,
|
| 570 |
+
"special": true
|
| 571 |
+
},
|
| 572 |
+
"128070": {
|
| 573 |
+
"content": "<|reserved_special_token_62|>",
|
| 574 |
+
"lstrip": false,
|
| 575 |
+
"normalized": false,
|
| 576 |
+
"rstrip": false,
|
| 577 |
+
"single_word": false,
|
| 578 |
+
"special": true
|
| 579 |
+
},
|
| 580 |
+
"128071": {
|
| 581 |
+
"content": "<|reserved_special_token_63|>",
|
| 582 |
+
"lstrip": false,
|
| 583 |
+
"normalized": false,
|
| 584 |
+
"rstrip": false,
|
| 585 |
+
"single_word": false,
|
| 586 |
+
"special": true
|
| 587 |
+
},
|
| 588 |
+
"128072": {
|
| 589 |
+
"content": "<|reserved_special_token_64|>",
|
| 590 |
+
"lstrip": false,
|
| 591 |
+
"normalized": false,
|
| 592 |
+
"rstrip": false,
|
| 593 |
+
"single_word": false,
|
| 594 |
+
"special": true
|
| 595 |
+
},
|
| 596 |
+
"128073": {
|
| 597 |
+
"content": "<|reserved_special_token_65|>",
|
| 598 |
+
"lstrip": false,
|
| 599 |
+
"normalized": false,
|
| 600 |
+
"rstrip": false,
|
| 601 |
+
"single_word": false,
|
| 602 |
+
"special": true
|
| 603 |
+
},
|
| 604 |
+
"128074": {
|
| 605 |
+
"content": "<|reserved_special_token_66|>",
|
| 606 |
+
"lstrip": false,
|
| 607 |
+
"normalized": false,
|
| 608 |
+
"rstrip": false,
|
| 609 |
+
"single_word": false,
|
| 610 |
+
"special": true
|
| 611 |
+
},
|
| 612 |
+
"128075": {
|
| 613 |
+
"content": "<|reserved_special_token_67|>",
|
| 614 |
+
"lstrip": false,
|
| 615 |
+
"normalized": false,
|
| 616 |
+
"rstrip": false,
|
| 617 |
+
"single_word": false,
|
| 618 |
+
"special": true
|
| 619 |
+
},
|
| 620 |
+
"128076": {
|
| 621 |
+
"content": "<|reserved_special_token_68|>",
|
| 622 |
+
"lstrip": false,
|
| 623 |
+
"normalized": false,
|
| 624 |
+
"rstrip": false,
|
| 625 |
+
"single_word": false,
|
| 626 |
+
"special": true
|
| 627 |
+
},
|
| 628 |
+
"128077": {
|
| 629 |
+
"content": "<|reserved_special_token_69|>",
|
| 630 |
+
"lstrip": false,
|
| 631 |
+
"normalized": false,
|
| 632 |
+
"rstrip": false,
|
| 633 |
+
"single_word": false,
|
| 634 |
+
"special": true
|
| 635 |
+
},
|
| 636 |
+
"128078": {
|
| 637 |
+
"content": "<|reserved_special_token_70|>",
|
| 638 |
+
"lstrip": false,
|
| 639 |
+
"normalized": false,
|
| 640 |
+
"rstrip": false,
|
| 641 |
+
"single_word": false,
|
| 642 |
+
"special": true
|
| 643 |
+
},
|
| 644 |
+
"128079": {
|
| 645 |
+
"content": "<|reserved_special_token_71|>",
|
| 646 |
+
"lstrip": false,
|
| 647 |
+
"normalized": false,
|
| 648 |
+
"rstrip": false,
|
| 649 |
+
"single_word": false,
|
| 650 |
+
"special": true
|
| 651 |
+
},
|
| 652 |
+
"128080": {
|
| 653 |
+
"content": "<|reserved_special_token_72|>",
|
| 654 |
+
"lstrip": false,
|
| 655 |
+
"normalized": false,
|
| 656 |
+
"rstrip": false,
|
| 657 |
+
"single_word": false,
|
| 658 |
+
"special": true
|
| 659 |
+
},
|
| 660 |
+
"128081": {
|
| 661 |
+
"content": "<|reserved_special_token_73|>",
|
| 662 |
+
"lstrip": false,
|
| 663 |
+
"normalized": false,
|
| 664 |
+
"rstrip": false,
|
| 665 |
+
"single_word": false,
|
| 666 |
+
"special": true
|
| 667 |
+
},
|
| 668 |
+
"128082": {
|
| 669 |
+
"content": "<|reserved_special_token_74|>",
|
| 670 |
+
"lstrip": false,
|
| 671 |
+
"normalized": false,
|
| 672 |
+
"rstrip": false,
|
| 673 |
+
"single_word": false,
|
| 674 |
+
"special": true
|
| 675 |
+
},
|
| 676 |
+
"128083": {
|
| 677 |
+
"content": "<|reserved_special_token_75|>",
|
| 678 |
+
"lstrip": false,
|
| 679 |
+
"normalized": false,
|
| 680 |
+
"rstrip": false,
|
| 681 |
+
"single_word": false,
|
| 682 |
+
"special": true
|
| 683 |
+
},
|
| 684 |
+
"128084": {
|
| 685 |
+
"content": "<|reserved_special_token_76|>",
|
| 686 |
+
"lstrip": false,
|
| 687 |
+
"normalized": false,
|
| 688 |
+
"rstrip": false,
|
| 689 |
+
"single_word": false,
|
| 690 |
+
"special": true
|
| 691 |
+
},
|
| 692 |
+
"128085": {
|
| 693 |
+
"content": "<|reserved_special_token_77|>",
|
| 694 |
+
"lstrip": false,
|
| 695 |
+
"normalized": false,
|
| 696 |
+
"rstrip": false,
|
| 697 |
+
"single_word": false,
|
| 698 |
+
"special": true
|
| 699 |
+
},
|
| 700 |
+
"128086": {
|
| 701 |
+
"content": "<|reserved_special_token_78|>",
|
| 702 |
+
"lstrip": false,
|
| 703 |
+
"normalized": false,
|
| 704 |
+
"rstrip": false,
|
| 705 |
+
"single_word": false,
|
| 706 |
+
"special": true
|
| 707 |
+
},
|
| 708 |
+
"128087": {
|
| 709 |
+
"content": "<|reserved_special_token_79|>",
|
| 710 |
+
"lstrip": false,
|
| 711 |
+
"normalized": false,
|
| 712 |
+
"rstrip": false,
|
| 713 |
+
"single_word": false,
|
| 714 |
+
"special": true
|
| 715 |
+
},
|
| 716 |
+
"128088": {
|
| 717 |
+
"content": "<|reserved_special_token_80|>",
|
| 718 |
+
"lstrip": false,
|
| 719 |
+
"normalized": false,
|
| 720 |
+
"rstrip": false,
|
| 721 |
+
"single_word": false,
|
| 722 |
+
"special": true
|
| 723 |
+
},
|
| 724 |
+
"128089": {
|
| 725 |
+
"content": "<|reserved_special_token_81|>",
|
| 726 |
+
"lstrip": false,
|
| 727 |
+
"normalized": false,
|
| 728 |
+
"rstrip": false,
|
| 729 |
+
"single_word": false,
|
| 730 |
+
"special": true
|
| 731 |
+
},
|
| 732 |
+
"128090": {
|
| 733 |
+
"content": "<|reserved_special_token_82|>",
|
| 734 |
+
"lstrip": false,
|
| 735 |
+
"normalized": false,
|
| 736 |
+
"rstrip": false,
|
| 737 |
+
"single_word": false,
|
| 738 |
+
"special": true
|
| 739 |
+
},
|
| 740 |
+
"128091": {
|
| 741 |
+
"content": "<|reserved_special_token_83|>",
|
| 742 |
+
"lstrip": false,
|
| 743 |
+
"normalized": false,
|
| 744 |
+
"rstrip": false,
|
| 745 |
+
"single_word": false,
|
| 746 |
+
"special": true
|
| 747 |
+
},
|
| 748 |
+
"128092": {
|
| 749 |
+
"content": "<|reserved_special_token_84|>",
|
| 750 |
+
"lstrip": false,
|
| 751 |
+
"normalized": false,
|
| 752 |
+
"rstrip": false,
|
| 753 |
+
"single_word": false,
|
| 754 |
+
"special": true
|
| 755 |
+
},
|
| 756 |
+
"128093": {
|
| 757 |
+
"content": "<|reserved_special_token_85|>",
|
| 758 |
+
"lstrip": false,
|
| 759 |
+
"normalized": false,
|
| 760 |
+
"rstrip": false,
|
| 761 |
+
"single_word": false,
|
| 762 |
+
"special": true
|
| 763 |
+
},
|
| 764 |
+
"128094": {
|
| 765 |
+
"content": "<|reserved_special_token_86|>",
|
| 766 |
+
"lstrip": false,
|
| 767 |
+
"normalized": false,
|
| 768 |
+
"rstrip": false,
|
| 769 |
+
"single_word": false,
|
| 770 |
+
"special": true
|
| 771 |
+
},
|
| 772 |
+
"128095": {
|
| 773 |
+
"content": "<|reserved_special_token_87|>",
|
| 774 |
+
"lstrip": false,
|
| 775 |
+
"normalized": false,
|
| 776 |
+
"rstrip": false,
|
| 777 |
+
"single_word": false,
|
| 778 |
+
"special": true
|
| 779 |
+
},
|
| 780 |
+
"128096": {
|
| 781 |
+
"content": "<|reserved_special_token_88|>",
|
| 782 |
+
"lstrip": false,
|
| 783 |
+
"normalized": false,
|
| 784 |
+
"rstrip": false,
|
| 785 |
+
"single_word": false,
|
| 786 |
+
"special": true
|
| 787 |
+
},
|
| 788 |
+
"128097": {
|
| 789 |
+
"content": "<|reserved_special_token_89|>",
|
| 790 |
+
"lstrip": false,
|
| 791 |
+
"normalized": false,
|
| 792 |
+
"rstrip": false,
|
| 793 |
+
"single_word": false,
|
| 794 |
+
"special": true
|
| 795 |
+
},
|
| 796 |
+
"128098": {
|
| 797 |
+
"content": "<|reserved_special_token_90|>",
|
| 798 |
+
"lstrip": false,
|
| 799 |
+
"normalized": false,
|
| 800 |
+
"rstrip": false,
|
| 801 |
+
"single_word": false,
|
| 802 |
+
"special": true
|
| 803 |
+
},
|
| 804 |
+
"128099": {
|
| 805 |
+
"content": "<|reserved_special_token_91|>",
|
| 806 |
+
"lstrip": false,
|
| 807 |
+
"normalized": false,
|
| 808 |
+
"rstrip": false,
|
| 809 |
+
"single_word": false,
|
| 810 |
+
"special": true
|
| 811 |
+
},
|
| 812 |
+
"128100": {
|
| 813 |
+
"content": "<|reserved_special_token_92|>",
|
| 814 |
+
"lstrip": false,
|
| 815 |
+
"normalized": false,
|
| 816 |
+
"rstrip": false,
|
| 817 |
+
"single_word": false,
|
| 818 |
+
"special": true
|
| 819 |
+
},
|
| 820 |
+
"128101": {
|
| 821 |
+
"content": "<|reserved_special_token_93|>",
|
| 822 |
+
"lstrip": false,
|
| 823 |
+
"normalized": false,
|
| 824 |
+
"rstrip": false,
|
| 825 |
+
"single_word": false,
|
| 826 |
+
"special": true
|
| 827 |
+
},
|
| 828 |
+
"128102": {
|
| 829 |
+
"content": "<|reserved_special_token_94|>",
|
| 830 |
+
"lstrip": false,
|
| 831 |
+
"normalized": false,
|
| 832 |
+
"rstrip": false,
|
| 833 |
+
"single_word": false,
|
| 834 |
+
"special": true
|
| 835 |
+
},
|
| 836 |
+
"128103": {
|
| 837 |
+
"content": "<|reserved_special_token_95|>",
|
| 838 |
+
"lstrip": false,
|
| 839 |
+
"normalized": false,
|
| 840 |
+
"rstrip": false,
|
| 841 |
+
"single_word": false,
|
| 842 |
+
"special": true
|
| 843 |
+
},
|
| 844 |
+
"128104": {
|
| 845 |
+
"content": "<|reserved_special_token_96|>",
|
| 846 |
+
"lstrip": false,
|
| 847 |
+
"normalized": false,
|
| 848 |
+
"rstrip": false,
|
| 849 |
+
"single_word": false,
|
| 850 |
+
"special": true
|
| 851 |
+
},
|
| 852 |
+
"128105": {
|
| 853 |
+
"content": "<|reserved_special_token_97|>",
|
| 854 |
+
"lstrip": false,
|
| 855 |
+
"normalized": false,
|
| 856 |
+
"rstrip": false,
|
| 857 |
+
"single_word": false,
|
| 858 |
+
"special": true
|
| 859 |
+
},
|
| 860 |
+
"128106": {
|
| 861 |
+
"content": "<|reserved_special_token_98|>",
|
| 862 |
+
"lstrip": false,
|
| 863 |
+
"normalized": false,
|
| 864 |
+
"rstrip": false,
|
| 865 |
+
"single_word": false,
|
| 866 |
+
"special": true
|
| 867 |
+
},
|
| 868 |
+
"128107": {
|
| 869 |
+
"content": "<|reserved_special_token_99|>",
|
| 870 |
+
"lstrip": false,
|
| 871 |
+
"normalized": false,
|
| 872 |
+
"rstrip": false,
|
| 873 |
+
"single_word": false,
|
| 874 |
+
"special": true
|
| 875 |
+
},
|
| 876 |
+
"128108": {
|
| 877 |
+
"content": "<|reserved_special_token_100|>",
|
| 878 |
+
"lstrip": false,
|
| 879 |
+
"normalized": false,
|
| 880 |
+
"rstrip": false,
|
| 881 |
+
"single_word": false,
|
| 882 |
+
"special": true
|
| 883 |
+
},
|
| 884 |
+
"128109": {
|
| 885 |
+
"content": "<|reserved_special_token_101|>",
|
| 886 |
+
"lstrip": false,
|
| 887 |
+
"normalized": false,
|
| 888 |
+
"rstrip": false,
|
| 889 |
+
"single_word": false,
|
| 890 |
+
"special": true
|
| 891 |
+
},
|
| 892 |
+
"128110": {
|
| 893 |
+
"content": "<|reserved_special_token_102|>",
|
| 894 |
+
"lstrip": false,
|
| 895 |
+
"normalized": false,
|
| 896 |
+
"rstrip": false,
|
| 897 |
+
"single_word": false,
|
| 898 |
+
"special": true
|
| 899 |
+
},
|
| 900 |
+
"128111": {
|
| 901 |
+
"content": "<|reserved_special_token_103|>",
|
| 902 |
+
"lstrip": false,
|
| 903 |
+
"normalized": false,
|
| 904 |
+
"rstrip": false,
|
| 905 |
+
"single_word": false,
|
| 906 |
+
"special": true
|
| 907 |
+
},
|
| 908 |
+
"128112": {
|
| 909 |
+
"content": "<|reserved_special_token_104|>",
|
| 910 |
+
"lstrip": false,
|
| 911 |
+
"normalized": false,
|
| 912 |
+
"rstrip": false,
|
| 913 |
+
"single_word": false,
|
| 914 |
+
"special": true
|
| 915 |
+
},
|
| 916 |
+
"128113": {
|
| 917 |
+
"content": "<|reserved_special_token_105|>",
|
| 918 |
+
"lstrip": false,
|
| 919 |
+
"normalized": false,
|
| 920 |
+
"rstrip": false,
|
| 921 |
+
"single_word": false,
|
| 922 |
+
"special": true
|
| 923 |
+
},
|
| 924 |
+
"128114": {
|
| 925 |
+
"content": "<|reserved_special_token_106|>",
|
| 926 |
+
"lstrip": false,
|
| 927 |
+
"normalized": false,
|
| 928 |
+
"rstrip": false,
|
| 929 |
+
"single_word": false,
|
| 930 |
+
"special": true
|
| 931 |
+
},
|
| 932 |
+
"128115": {
|
| 933 |
+
"content": "<|reserved_special_token_107|>",
|
| 934 |
+
"lstrip": false,
|
| 935 |
+
"normalized": false,
|
| 936 |
+
"rstrip": false,
|
| 937 |
+
"single_word": false,
|
| 938 |
+
"special": true
|
| 939 |
+
},
|
| 940 |
+
"128116": {
|
| 941 |
+
"content": "<|reserved_special_token_108|>",
|
| 942 |
+
"lstrip": false,
|
| 943 |
+
"normalized": false,
|
| 944 |
+
"rstrip": false,
|
| 945 |
+
"single_word": false,
|
| 946 |
+
"special": true
|
| 947 |
+
},
|
| 948 |
+
"128117": {
|
| 949 |
+
"content": "<|reserved_special_token_109|>",
|
| 950 |
+
"lstrip": false,
|
| 951 |
+
"normalized": false,
|
| 952 |
+
"rstrip": false,
|
| 953 |
+
"single_word": false,
|
| 954 |
+
"special": true
|
| 955 |
+
},
|
| 956 |
+
"128118": {
|
| 957 |
+
"content": "<|reserved_special_token_110|>",
|
| 958 |
+
"lstrip": false,
|
| 959 |
+
"normalized": false,
|
| 960 |
+
"rstrip": false,
|
| 961 |
+
"single_word": false,
|
| 962 |
+
"special": true
|
| 963 |
+
},
|
| 964 |
+
"128119": {
|
| 965 |
+
"content": "<|reserved_special_token_111|>",
|
| 966 |
+
"lstrip": false,
|
| 967 |
+
"normalized": false,
|
| 968 |
+
"rstrip": false,
|
| 969 |
+
"single_word": false,
|
| 970 |
+
"special": true
|
| 971 |
+
},
|
| 972 |
+
"128120": {
|
| 973 |
+
"content": "<|reserved_special_token_112|>",
|
| 974 |
+
"lstrip": false,
|
| 975 |
+
"normalized": false,
|
| 976 |
+
"rstrip": false,
|
| 977 |
+
"single_word": false,
|
| 978 |
+
"special": true
|
| 979 |
+
},
|
| 980 |
+
"128121": {
|
| 981 |
+
"content": "<|reserved_special_token_113|>",
|
| 982 |
+
"lstrip": false,
|
| 983 |
+
"normalized": false,
|
| 984 |
+
"rstrip": false,
|
| 985 |
+
"single_word": false,
|
| 986 |
+
"special": true
|
| 987 |
+
},
|
| 988 |
+
"128122": {
|
| 989 |
+
"content": "<|reserved_special_token_114|>",
|
| 990 |
+
"lstrip": false,
|
| 991 |
+
"normalized": false,
|
| 992 |
+
"rstrip": false,
|
| 993 |
+
"single_word": false,
|
| 994 |
+
"special": true
|
| 995 |
+
},
|
| 996 |
+
"128123": {
|
| 997 |
+
"content": "<|reserved_special_token_115|>",
|
| 998 |
+
"lstrip": false,
|
| 999 |
+
"normalized": false,
|
| 1000 |
+
"rstrip": false,
|
| 1001 |
+
"single_word": false,
|
| 1002 |
+
"special": true
|
| 1003 |
+
},
|
| 1004 |
+
"128124": {
|
| 1005 |
+
"content": "<|reserved_special_token_116|>",
|
| 1006 |
+
"lstrip": false,
|
| 1007 |
+
"normalized": false,
|
| 1008 |
+
"rstrip": false,
|
| 1009 |
+
"single_word": false,
|
| 1010 |
+
"special": true
|
| 1011 |
+
},
|
| 1012 |
+
"128125": {
|
| 1013 |
+
"content": "<|reserved_special_token_117|>",
|
| 1014 |
+
"lstrip": false,
|
| 1015 |
+
"normalized": false,
|
| 1016 |
+
"rstrip": false,
|
| 1017 |
+
"single_word": false,
|
| 1018 |
+
"special": true
|
| 1019 |
+
},
|
| 1020 |
+
"128126": {
|
| 1021 |
+
"content": "<|reserved_special_token_118|>",
|
| 1022 |
+
"lstrip": false,
|
| 1023 |
+
"normalized": false,
|
| 1024 |
+
"rstrip": false,
|
| 1025 |
+
"single_word": false,
|
| 1026 |
+
"special": true
|
| 1027 |
+
},
|
| 1028 |
+
"128127": {
|
| 1029 |
+
"content": "<|reserved_special_token_119|>",
|
| 1030 |
+
"lstrip": false,
|
| 1031 |
+
"normalized": false,
|
| 1032 |
+
"rstrip": false,
|
| 1033 |
+
"single_word": false,
|
| 1034 |
+
"special": true
|
| 1035 |
+
},
|
| 1036 |
+
"128128": {
|
| 1037 |
+
"content": "<|reserved_special_token_120|>",
|
| 1038 |
+
"lstrip": false,
|
| 1039 |
+
"normalized": false,
|
| 1040 |
+
"rstrip": false,
|
| 1041 |
+
"single_word": false,
|
| 1042 |
+
"special": true
|
| 1043 |
+
},
|
| 1044 |
+
"128129": {
|
| 1045 |
+
"content": "<|reserved_special_token_121|>",
|
| 1046 |
+
"lstrip": false,
|
| 1047 |
+
"normalized": false,
|
| 1048 |
+
"rstrip": false,
|
| 1049 |
+
"single_word": false,
|
| 1050 |
+
"special": true
|
| 1051 |
+
},
|
| 1052 |
+
"128130": {
|
| 1053 |
+
"content": "<|reserved_special_token_122|>",
|
| 1054 |
+
"lstrip": false,
|
| 1055 |
+
"normalized": false,
|
| 1056 |
+
"rstrip": false,
|
| 1057 |
+
"single_word": false,
|
| 1058 |
+
"special": true
|
| 1059 |
+
},
|
| 1060 |
+
"128131": {
|
| 1061 |
+
"content": "<|reserved_special_token_123|>",
|
| 1062 |
+
"lstrip": false,
|
| 1063 |
+
"normalized": false,
|
| 1064 |
+
"rstrip": false,
|
| 1065 |
+
"single_word": false,
|
| 1066 |
+
"special": true
|
| 1067 |
+
},
|
| 1068 |
+
"128132": {
|
| 1069 |
+
"content": "<|reserved_special_token_124|>",
|
| 1070 |
+
"lstrip": false,
|
| 1071 |
+
"normalized": false,
|
| 1072 |
+
"rstrip": false,
|
| 1073 |
+
"single_word": false,
|
| 1074 |
+
"special": true
|
| 1075 |
+
},
|
| 1076 |
+
"128133": {
|
| 1077 |
+
"content": "<|reserved_special_token_125|>",
|
| 1078 |
+
"lstrip": false,
|
| 1079 |
+
"normalized": false,
|
| 1080 |
+
"rstrip": false,
|
| 1081 |
+
"single_word": false,
|
| 1082 |
+
"special": true
|
| 1083 |
+
},
|
| 1084 |
+
"128134": {
|
| 1085 |
+
"content": "<|reserved_special_token_126|>",
|
| 1086 |
+
"lstrip": false,
|
| 1087 |
+
"normalized": false,
|
| 1088 |
+
"rstrip": false,
|
| 1089 |
+
"single_word": false,
|
| 1090 |
+
"special": true
|
| 1091 |
+
},
|
| 1092 |
+
"128135": {
|
| 1093 |
+
"content": "<|reserved_special_token_127|>",
|
| 1094 |
+
"lstrip": false,
|
| 1095 |
+
"normalized": false,
|
| 1096 |
+
"rstrip": false,
|
| 1097 |
+
"single_word": false,
|
| 1098 |
+
"special": true
|
| 1099 |
+
},
|
| 1100 |
+
"128136": {
|
| 1101 |
+
"content": "<|reserved_special_token_128|>",
|
| 1102 |
+
"lstrip": false,
|
| 1103 |
+
"normalized": false,
|
| 1104 |
+
"rstrip": false,
|
| 1105 |
+
"single_word": false,
|
| 1106 |
+
"special": true
|
| 1107 |
+
},
|
| 1108 |
+
"128137": {
|
| 1109 |
+
"content": "<|reserved_special_token_129|>",
|
| 1110 |
+
"lstrip": false,
|
| 1111 |
+
"normalized": false,
|
| 1112 |
+
"rstrip": false,
|
| 1113 |
+
"single_word": false,
|
| 1114 |
+
"special": true
|
| 1115 |
+
},
|
| 1116 |
+
"128138": {
|
| 1117 |
+
"content": "<|reserved_special_token_130|>",
|
| 1118 |
+
"lstrip": false,
|
| 1119 |
+
"normalized": false,
|
| 1120 |
+
"rstrip": false,
|
| 1121 |
+
"single_word": false,
|
| 1122 |
+
"special": true
|
| 1123 |
+
},
|
| 1124 |
+
"128139": {
|
| 1125 |
+
"content": "<|reserved_special_token_131|>",
|
| 1126 |
+
"lstrip": false,
|
| 1127 |
+
"normalized": false,
|
| 1128 |
+
"rstrip": false,
|
| 1129 |
+
"single_word": false,
|
| 1130 |
+
"special": true
|
| 1131 |
+
},
|
| 1132 |
+
"128140": {
|
| 1133 |
+
"content": "<|reserved_special_token_132|>",
|
| 1134 |
+
"lstrip": false,
|
| 1135 |
+
"normalized": false,
|
| 1136 |
+
"rstrip": false,
|
| 1137 |
+
"single_word": false,
|
| 1138 |
+
"special": true
|
| 1139 |
+
},
|
| 1140 |
+
"128141": {
|
| 1141 |
+
"content": "<|reserved_special_token_133|>",
|
| 1142 |
+
"lstrip": false,
|
| 1143 |
+
"normalized": false,
|
| 1144 |
+
"rstrip": false,
|
| 1145 |
+
"single_word": false,
|
| 1146 |
+
"special": true
|
| 1147 |
+
},
|
| 1148 |
+
"128142": {
|
| 1149 |
+
"content": "<|reserved_special_token_134|>",
|
| 1150 |
+
"lstrip": false,
|
| 1151 |
+
"normalized": false,
|
| 1152 |
+
"rstrip": false,
|
| 1153 |
+
"single_word": false,
|
| 1154 |
+
"special": true
|
| 1155 |
+
},
|
| 1156 |
+
"128143": {
|
| 1157 |
+
"content": "<|reserved_special_token_135|>",
|
| 1158 |
+
"lstrip": false,
|
| 1159 |
+
"normalized": false,
|
| 1160 |
+
"rstrip": false,
|
| 1161 |
+
"single_word": false,
|
| 1162 |
+
"special": true
|
| 1163 |
+
},
|
| 1164 |
+
"128144": {
|
| 1165 |
+
"content": "<|reserved_special_token_136|>",
|
| 1166 |
+
"lstrip": false,
|
| 1167 |
+
"normalized": false,
|
| 1168 |
+
"rstrip": false,
|
| 1169 |
+
"single_word": false,
|
| 1170 |
+
"special": true
|
| 1171 |
+
},
|
| 1172 |
+
"128145": {
|
| 1173 |
+
"content": "<|reserved_special_token_137|>",
|
| 1174 |
+
"lstrip": false,
|
| 1175 |
+
"normalized": false,
|
| 1176 |
+
"rstrip": false,
|
| 1177 |
+
"single_word": false,
|
| 1178 |
+
"special": true
|
| 1179 |
+
},
|
| 1180 |
+
"128146": {
|
| 1181 |
+
"content": "<|reserved_special_token_138|>",
|
| 1182 |
+
"lstrip": false,
|
| 1183 |
+
"normalized": false,
|
| 1184 |
+
"rstrip": false,
|
| 1185 |
+
"single_word": false,
|
| 1186 |
+
"special": true
|
| 1187 |
+
},
|
| 1188 |
+
"128147": {
|
| 1189 |
+
"content": "<|reserved_special_token_139|>",
|
| 1190 |
+
"lstrip": false,
|
| 1191 |
+
"normalized": false,
|
| 1192 |
+
"rstrip": false,
|
| 1193 |
+
"single_word": false,
|
| 1194 |
+
"special": true
|
| 1195 |
+
},
|
| 1196 |
+
"128148": {
|
| 1197 |
+
"content": "<|reserved_special_token_140|>",
|
| 1198 |
+
"lstrip": false,
|
| 1199 |
+
"normalized": false,
|
| 1200 |
+
"rstrip": false,
|
| 1201 |
+
"single_word": false,
|
| 1202 |
+
"special": true
|
| 1203 |
+
},
|
| 1204 |
+
"128149": {
|
| 1205 |
+
"content": "<|reserved_special_token_141|>",
|
| 1206 |
+
"lstrip": false,
|
| 1207 |
+
"normalized": false,
|
| 1208 |
+
"rstrip": false,
|
| 1209 |
+
"single_word": false,
|
| 1210 |
+
"special": true
|
| 1211 |
+
},
|
| 1212 |
+
"128150": {
|
| 1213 |
+
"content": "<|reserved_special_token_142|>",
|
| 1214 |
+
"lstrip": false,
|
| 1215 |
+
"normalized": false,
|
| 1216 |
+
"rstrip": false,
|
| 1217 |
+
"single_word": false,
|
| 1218 |
+
"special": true
|
| 1219 |
+
},
|
| 1220 |
+
"128151": {
|
| 1221 |
+
"content": "<|reserved_special_token_143|>",
|
| 1222 |
+
"lstrip": false,
|
| 1223 |
+
"normalized": false,
|
| 1224 |
+
"rstrip": false,
|
| 1225 |
+
"single_word": false,
|
| 1226 |
+
"special": true
|
| 1227 |
+
},
|
| 1228 |
+
"128152": {
|
| 1229 |
+
"content": "<|reserved_special_token_144|>",
|
| 1230 |
+
"lstrip": false,
|
| 1231 |
+
"normalized": false,
|
| 1232 |
+
"rstrip": false,
|
| 1233 |
+
"single_word": false,
|
| 1234 |
+
"special": true
|
| 1235 |
+
},
|
| 1236 |
+
"128153": {
|
| 1237 |
+
"content": "<|reserved_special_token_145|>",
|
| 1238 |
+
"lstrip": false,
|
| 1239 |
+
"normalized": false,
|
| 1240 |
+
"rstrip": false,
|
| 1241 |
+
"single_word": false,
|
| 1242 |
+
"special": true
|
| 1243 |
+
},
|
| 1244 |
+
"128154": {
|
| 1245 |
+
"content": "<|reserved_special_token_146|>",
|
| 1246 |
+
"lstrip": false,
|
| 1247 |
+
"normalized": false,
|
| 1248 |
+
"rstrip": false,
|
| 1249 |
+
"single_word": false,
|
| 1250 |
+
"special": true
|
| 1251 |
+
},
|
| 1252 |
+
"128155": {
|
| 1253 |
+
"content": "<|reserved_special_token_147|>",
|
| 1254 |
+
"lstrip": false,
|
| 1255 |
+
"normalized": false,
|
| 1256 |
+
"rstrip": false,
|
| 1257 |
+
"single_word": false,
|
| 1258 |
+
"special": true
|
| 1259 |
+
},
|
| 1260 |
+
"128156": {
|
| 1261 |
+
"content": "<|reserved_special_token_148|>",
|
| 1262 |
+
"lstrip": false,
|
| 1263 |
+
"normalized": false,
|
| 1264 |
+
"rstrip": false,
|
| 1265 |
+
"single_word": false,
|
| 1266 |
+
"special": true
|
| 1267 |
+
},
|
| 1268 |
+
"128157": {
|
| 1269 |
+
"content": "<|reserved_special_token_149|>",
|
| 1270 |
+
"lstrip": false,
|
| 1271 |
+
"normalized": false,
|
| 1272 |
+
"rstrip": false,
|
| 1273 |
+
"single_word": false,
|
| 1274 |
+
"special": true
|
| 1275 |
+
},
|
| 1276 |
+
"128158": {
|
| 1277 |
+
"content": "<|reserved_special_token_150|>",
|
| 1278 |
+
"lstrip": false,
|
| 1279 |
+
"normalized": false,
|
| 1280 |
+
"rstrip": false,
|
| 1281 |
+
"single_word": false,
|
| 1282 |
+
"special": true
|
| 1283 |
+
},
|
| 1284 |
+
"128159": {
|
| 1285 |
+
"content": "<|reserved_special_token_151|>",
|
| 1286 |
+
"lstrip": false,
|
| 1287 |
+
"normalized": false,
|
| 1288 |
+
"rstrip": false,
|
| 1289 |
+
"single_word": false,
|
| 1290 |
+
"special": true
|
| 1291 |
+
},
|
| 1292 |
+
"128160": {
|
| 1293 |
+
"content": "<|reserved_special_token_152|>",
|
| 1294 |
+
"lstrip": false,
|
| 1295 |
+
"normalized": false,
|
| 1296 |
+
"rstrip": false,
|
| 1297 |
+
"single_word": false,
|
| 1298 |
+
"special": true
|
| 1299 |
+
},
|
| 1300 |
+
"128161": {
|
| 1301 |
+
"content": "<|reserved_special_token_153|>",
|
| 1302 |
+
"lstrip": false,
|
| 1303 |
+
"normalized": false,
|
| 1304 |
+
"rstrip": false,
|
| 1305 |
+
"single_word": false,
|
| 1306 |
+
"special": true
|
| 1307 |
+
},
|
| 1308 |
+
"128162": {
|
| 1309 |
+
"content": "<|reserved_special_token_154|>",
|
| 1310 |
+
"lstrip": false,
|
| 1311 |
+
"normalized": false,
|
| 1312 |
+
"rstrip": false,
|
| 1313 |
+
"single_word": false,
|
| 1314 |
+
"special": true
|
| 1315 |
+
},
|
| 1316 |
+
"128163": {
|
| 1317 |
+
"content": "<|reserved_special_token_155|>",
|
| 1318 |
+
"lstrip": false,
|
| 1319 |
+
"normalized": false,
|
| 1320 |
+
"rstrip": false,
|
| 1321 |
+
"single_word": false,
|
| 1322 |
+
"special": true
|
| 1323 |
+
},
|
| 1324 |
+
"128164": {
|
| 1325 |
+
"content": "<|reserved_special_token_156|>",
|
| 1326 |
+
"lstrip": false,
|
| 1327 |
+
"normalized": false,
|
| 1328 |
+
"rstrip": false,
|
| 1329 |
+
"single_word": false,
|
| 1330 |
+
"special": true
|
| 1331 |
+
},
|
| 1332 |
+
"128165": {
|
| 1333 |
+
"content": "<|reserved_special_token_157|>",
|
| 1334 |
+
"lstrip": false,
|
| 1335 |
+
"normalized": false,
|
| 1336 |
+
"rstrip": false,
|
| 1337 |
+
"single_word": false,
|
| 1338 |
+
"special": true
|
| 1339 |
+
},
|
| 1340 |
+
"128166": {
|
| 1341 |
+
"content": "<|reserved_special_token_158|>",
|
| 1342 |
+
"lstrip": false,
|
| 1343 |
+
"normalized": false,
|
| 1344 |
+
"rstrip": false,
|
| 1345 |
+
"single_word": false,
|
| 1346 |
+
"special": true
|
| 1347 |
+
},
|
| 1348 |
+
"128167": {
|
| 1349 |
+
"content": "<|reserved_special_token_159|>",
|
| 1350 |
+
"lstrip": false,
|
| 1351 |
+
"normalized": false,
|
| 1352 |
+
"rstrip": false,
|
| 1353 |
+
"single_word": false,
|
| 1354 |
+
"special": true
|
| 1355 |
+
},
|
| 1356 |
+
"128168": {
|
| 1357 |
+
"content": "<|reserved_special_token_160|>",
|
| 1358 |
+
"lstrip": false,
|
| 1359 |
+
"normalized": false,
|
| 1360 |
+
"rstrip": false,
|
| 1361 |
+
"single_word": false,
|
| 1362 |
+
"special": true
|
| 1363 |
+
},
|
| 1364 |
+
"128169": {
|
| 1365 |
+
"content": "<|reserved_special_token_161|>",
|
| 1366 |
+
"lstrip": false,
|
| 1367 |
+
"normalized": false,
|
| 1368 |
+
"rstrip": false,
|
| 1369 |
+
"single_word": false,
|
| 1370 |
+
"special": true
|
| 1371 |
+
},
|
| 1372 |
+
"128170": {
|
| 1373 |
+
"content": "<|reserved_special_token_162|>",
|
| 1374 |
+
"lstrip": false,
|
| 1375 |
+
"normalized": false,
|
| 1376 |
+
"rstrip": false,
|
| 1377 |
+
"single_word": false,
|
| 1378 |
+
"special": true
|
| 1379 |
+
},
|
| 1380 |
+
"128171": {
|
| 1381 |
+
"content": "<|reserved_special_token_163|>",
|
| 1382 |
+
"lstrip": false,
|
| 1383 |
+
"normalized": false,
|
| 1384 |
+
"rstrip": false,
|
| 1385 |
+
"single_word": false,
|
| 1386 |
+
"special": true
|
| 1387 |
+
},
|
| 1388 |
+
"128172": {
|
| 1389 |
+
"content": "<|reserved_special_token_164|>",
|
| 1390 |
+
"lstrip": false,
|
| 1391 |
+
"normalized": false,
|
| 1392 |
+
"rstrip": false,
|
| 1393 |
+
"single_word": false,
|
| 1394 |
+
"special": true
|
| 1395 |
+
},
|
| 1396 |
+
"128173": {
|
| 1397 |
+
"content": "<|reserved_special_token_165|>",
|
| 1398 |
+
"lstrip": false,
|
| 1399 |
+
"normalized": false,
|
| 1400 |
+
"rstrip": false,
|
| 1401 |
+
"single_word": false,
|
| 1402 |
+
"special": true
|
| 1403 |
+
},
|
| 1404 |
+
"128174": {
|
| 1405 |
+
"content": "<|reserved_special_token_166|>",
|
| 1406 |
+
"lstrip": false,
|
| 1407 |
+
"normalized": false,
|
| 1408 |
+
"rstrip": false,
|
| 1409 |
+
"single_word": false,
|
| 1410 |
+
"special": true
|
| 1411 |
+
},
|
| 1412 |
+
"128175": {
|
| 1413 |
+
"content": "<|reserved_special_token_167|>",
|
| 1414 |
+
"lstrip": false,
|
| 1415 |
+
"normalized": false,
|
| 1416 |
+
"rstrip": false,
|
| 1417 |
+
"single_word": false,
|
| 1418 |
+
"special": true
|
| 1419 |
+
},
|
| 1420 |
+
"128176": {
|
| 1421 |
+
"content": "<|reserved_special_token_168|>",
|
| 1422 |
+
"lstrip": false,
|
| 1423 |
+
"normalized": false,
|
| 1424 |
+
"rstrip": false,
|
| 1425 |
+
"single_word": false,
|
| 1426 |
+
"special": true
|
| 1427 |
+
},
|
| 1428 |
+
"128177": {
|
| 1429 |
+
"content": "<|reserved_special_token_169|>",
|
| 1430 |
+
"lstrip": false,
|
| 1431 |
+
"normalized": false,
|
| 1432 |
+
"rstrip": false,
|
| 1433 |
+
"single_word": false,
|
| 1434 |
+
"special": true
|
| 1435 |
+
},
|
| 1436 |
+
"128178": {
|
| 1437 |
+
"content": "<|reserved_special_token_170|>",
|
| 1438 |
+
"lstrip": false,
|
| 1439 |
+
"normalized": false,
|
| 1440 |
+
"rstrip": false,
|
| 1441 |
+
"single_word": false,
|
| 1442 |
+
"special": true
|
| 1443 |
+
},
|
| 1444 |
+
"128179": {
|
| 1445 |
+
"content": "<|reserved_special_token_171|>",
|
| 1446 |
+
"lstrip": false,
|
| 1447 |
+
"normalized": false,
|
| 1448 |
+
"rstrip": false,
|
| 1449 |
+
"single_word": false,
|
| 1450 |
+
"special": true
|
| 1451 |
+
},
|
| 1452 |
+
"128180": {
|
| 1453 |
+
"content": "<|reserved_special_token_172|>",
|
| 1454 |
+
"lstrip": false,
|
| 1455 |
+
"normalized": false,
|
| 1456 |
+
"rstrip": false,
|
| 1457 |
+
"single_word": false,
|
| 1458 |
+
"special": true
|
| 1459 |
+
},
|
| 1460 |
+
"128181": {
|
| 1461 |
+
"content": "<|reserved_special_token_173|>",
|
| 1462 |
+
"lstrip": false,
|
| 1463 |
+
"normalized": false,
|
| 1464 |
+
"rstrip": false,
|
| 1465 |
+
"single_word": false,
|
| 1466 |
+
"special": true
|
| 1467 |
+
},
|
| 1468 |
+
"128182": {
|
| 1469 |
+
"content": "<|reserved_special_token_174|>",
|
| 1470 |
+
"lstrip": false,
|
| 1471 |
+
"normalized": false,
|
| 1472 |
+
"rstrip": false,
|
| 1473 |
+
"single_word": false,
|
| 1474 |
+
"special": true
|
| 1475 |
+
},
|
| 1476 |
+
"128183": {
|
| 1477 |
+
"content": "<|reserved_special_token_175|>",
|
| 1478 |
+
"lstrip": false,
|
| 1479 |
+
"normalized": false,
|
| 1480 |
+
"rstrip": false,
|
| 1481 |
+
"single_word": false,
|
| 1482 |
+
"special": true
|
| 1483 |
+
},
|
| 1484 |
+
"128184": {
|
| 1485 |
+
"content": "<|reserved_special_token_176|>",
|
| 1486 |
+
"lstrip": false,
|
| 1487 |
+
"normalized": false,
|
| 1488 |
+
"rstrip": false,
|
| 1489 |
+
"single_word": false,
|
| 1490 |
+
"special": true
|
| 1491 |
+
},
|
| 1492 |
+
"128185": {
|
| 1493 |
+
"content": "<|reserved_special_token_177|>",
|
| 1494 |
+
"lstrip": false,
|
| 1495 |
+
"normalized": false,
|
| 1496 |
+
"rstrip": false,
|
| 1497 |
+
"single_word": false,
|
| 1498 |
+
"special": true
|
| 1499 |
+
},
|
| 1500 |
+
"128186": {
|
| 1501 |
+
"content": "<|reserved_special_token_178|>",
|
| 1502 |
+
"lstrip": false,
|
| 1503 |
+
"normalized": false,
|
| 1504 |
+
"rstrip": false,
|
| 1505 |
+
"single_word": false,
|
| 1506 |
+
"special": true
|
| 1507 |
+
},
|
| 1508 |
+
"128187": {
|
| 1509 |
+
"content": "<|reserved_special_token_179|>",
|
| 1510 |
+
"lstrip": false,
|
| 1511 |
+
"normalized": false,
|
| 1512 |
+
"rstrip": false,
|
| 1513 |
+
"single_word": false,
|
| 1514 |
+
"special": true
|
| 1515 |
+
},
|
| 1516 |
+
"128188": {
|
| 1517 |
+
"content": "<|reserved_special_token_180|>",
|
| 1518 |
+
"lstrip": false,
|
| 1519 |
+
"normalized": false,
|
| 1520 |
+
"rstrip": false,
|
| 1521 |
+
"single_word": false,
|
| 1522 |
+
"special": true
|
| 1523 |
+
},
|
| 1524 |
+
"128189": {
|
| 1525 |
+
"content": "<|reserved_special_token_181|>",
|
| 1526 |
+
"lstrip": false,
|
| 1527 |
+
"normalized": false,
|
| 1528 |
+
"rstrip": false,
|
| 1529 |
+
"single_word": false,
|
| 1530 |
+
"special": true
|
| 1531 |
+
},
|
| 1532 |
+
"128190": {
|
| 1533 |
+
"content": "<|reserved_special_token_182|>",
|
| 1534 |
+
"lstrip": false,
|
| 1535 |
+
"normalized": false,
|
| 1536 |
+
"rstrip": false,
|
| 1537 |
+
"single_word": false,
|
| 1538 |
+
"special": true
|
| 1539 |
+
},
|
| 1540 |
+
"128191": {
|
| 1541 |
+
"content": "<|reserved_special_token_183|>",
|
| 1542 |
+
"lstrip": false,
|
| 1543 |
+
"normalized": false,
|
| 1544 |
+
"rstrip": false,
|
| 1545 |
+
"single_word": false,
|
| 1546 |
+
"special": true
|
| 1547 |
+
},
|
| 1548 |
+
"128192": {
|
| 1549 |
+
"content": "<|reserved_special_token_184|>",
|
| 1550 |
+
"lstrip": false,
|
| 1551 |
+
"normalized": false,
|
| 1552 |
+
"rstrip": false,
|
| 1553 |
+
"single_word": false,
|
| 1554 |
+
"special": true
|
| 1555 |
+
},
|
| 1556 |
+
"128193": {
|
| 1557 |
+
"content": "<|reserved_special_token_185|>",
|
| 1558 |
+
"lstrip": false,
|
| 1559 |
+
"normalized": false,
|
| 1560 |
+
"rstrip": false,
|
| 1561 |
+
"single_word": false,
|
| 1562 |
+
"special": true
|
| 1563 |
+
},
|
| 1564 |
+
"128194": {
|
| 1565 |
+
"content": "<|reserved_special_token_186|>",
|
| 1566 |
+
"lstrip": false,
|
| 1567 |
+
"normalized": false,
|
| 1568 |
+
"rstrip": false,
|
| 1569 |
+
"single_word": false,
|
| 1570 |
+
"special": true
|
| 1571 |
+
},
|
| 1572 |
+
"128195": {
|
| 1573 |
+
"content": "<|reserved_special_token_187|>",
|
| 1574 |
+
"lstrip": false,
|
| 1575 |
+
"normalized": false,
|
| 1576 |
+
"rstrip": false,
|
| 1577 |
+
"single_word": false,
|
| 1578 |
+
"special": true
|
| 1579 |
+
},
|
| 1580 |
+
"128196": {
|
| 1581 |
+
"content": "<|reserved_special_token_188|>",
|
| 1582 |
+
"lstrip": false,
|
| 1583 |
+
"normalized": false,
|
| 1584 |
+
"rstrip": false,
|
| 1585 |
+
"single_word": false,
|
| 1586 |
+
"special": true
|
| 1587 |
+
},
|
| 1588 |
+
"128197": {
|
| 1589 |
+
"content": "<|reserved_special_token_189|>",
|
| 1590 |
+
"lstrip": false,
|
| 1591 |
+
"normalized": false,
|
| 1592 |
+
"rstrip": false,
|
| 1593 |
+
"single_word": false,
|
| 1594 |
+
"special": true
|
| 1595 |
+
},
|
| 1596 |
+
"128198": {
|
| 1597 |
+
"content": "<|reserved_special_token_190|>",
|
| 1598 |
+
"lstrip": false,
|
| 1599 |
+
"normalized": false,
|
| 1600 |
+
"rstrip": false,
|
| 1601 |
+
"single_word": false,
|
| 1602 |
+
"special": true
|
| 1603 |
+
},
|
| 1604 |
+
"128199": {
|
| 1605 |
+
"content": "<|reserved_special_token_191|>",
|
| 1606 |
+
"lstrip": false,
|
| 1607 |
+
"normalized": false,
|
| 1608 |
+
"rstrip": false,
|
| 1609 |
+
"single_word": false,
|
| 1610 |
+
"special": true
|
| 1611 |
+
},
|
| 1612 |
+
"128200": {
|
| 1613 |
+
"content": "<|reserved_special_token_192|>",
|
| 1614 |
+
"lstrip": false,
|
| 1615 |
+
"normalized": false,
|
| 1616 |
+
"rstrip": false,
|
| 1617 |
+
"single_word": false,
|
| 1618 |
+
"special": true
|
| 1619 |
+
},
|
| 1620 |
+
"128201": {
|
| 1621 |
+
"content": "<|reserved_special_token_193|>",
|
| 1622 |
+
"lstrip": false,
|
| 1623 |
+
"normalized": false,
|
| 1624 |
+
"rstrip": false,
|
| 1625 |
+
"single_word": false,
|
| 1626 |
+
"special": true
|
| 1627 |
+
},
|
| 1628 |
+
"128202": {
|
| 1629 |
+
"content": "<|reserved_special_token_194|>",
|
| 1630 |
+
"lstrip": false,
|
| 1631 |
+
"normalized": false,
|
| 1632 |
+
"rstrip": false,
|
| 1633 |
+
"single_word": false,
|
| 1634 |
+
"special": true
|
| 1635 |
+
},
|
| 1636 |
+
"128203": {
|
| 1637 |
+
"content": "<|reserved_special_token_195|>",
|
| 1638 |
+
"lstrip": false,
|
| 1639 |
+
"normalized": false,
|
| 1640 |
+
"rstrip": false,
|
| 1641 |
+
"single_word": false,
|
| 1642 |
+
"special": true
|
| 1643 |
+
},
|
| 1644 |
+
"128204": {
|
| 1645 |
+
"content": "<|reserved_special_token_196|>",
|
| 1646 |
+
"lstrip": false,
|
| 1647 |
+
"normalized": false,
|
| 1648 |
+
"rstrip": false,
|
| 1649 |
+
"single_word": false,
|
| 1650 |
+
"special": true
|
| 1651 |
+
},
|
| 1652 |
+
"128205": {
|
| 1653 |
+
"content": "<|reserved_special_token_197|>",
|
| 1654 |
+
"lstrip": false,
|
| 1655 |
+
"normalized": false,
|
| 1656 |
+
"rstrip": false,
|
| 1657 |
+
"single_word": false,
|
| 1658 |
+
"special": true
|
| 1659 |
+
},
|
| 1660 |
+
"128206": {
|
| 1661 |
+
"content": "<|reserved_special_token_198|>",
|
| 1662 |
+
"lstrip": false,
|
| 1663 |
+
"normalized": false,
|
| 1664 |
+
"rstrip": false,
|
| 1665 |
+
"single_word": false,
|
| 1666 |
+
"special": true
|
| 1667 |
+
},
|
| 1668 |
+
"128207": {
|
| 1669 |
+
"content": "<|reserved_special_token_199|>",
|
| 1670 |
+
"lstrip": false,
|
| 1671 |
+
"normalized": false,
|
| 1672 |
+
"rstrip": false,
|
| 1673 |
+
"single_word": false,
|
| 1674 |
+
"special": true
|
| 1675 |
+
},
|
| 1676 |
+
"128208": {
|
| 1677 |
+
"content": "<|reserved_special_token_200|>",
|
| 1678 |
+
"lstrip": false,
|
| 1679 |
+
"normalized": false,
|
| 1680 |
+
"rstrip": false,
|
| 1681 |
+
"single_word": false,
|
| 1682 |
+
"special": true
|
| 1683 |
+
},
|
| 1684 |
+
"128209": {
|
| 1685 |
+
"content": "<|reserved_special_token_201|>",
|
| 1686 |
+
"lstrip": false,
|
| 1687 |
+
"normalized": false,
|
| 1688 |
+
"rstrip": false,
|
| 1689 |
+
"single_word": false,
|
| 1690 |
+
"special": true
|
| 1691 |
+
},
|
| 1692 |
+
"128210": {
|
| 1693 |
+
"content": "<|reserved_special_token_202|>",
|
| 1694 |
+
"lstrip": false,
|
| 1695 |
+
"normalized": false,
|
| 1696 |
+
"rstrip": false,
|
| 1697 |
+
"single_word": false,
|
| 1698 |
+
"special": true
|
| 1699 |
+
},
|
| 1700 |
+
"128211": {
|
| 1701 |
+
"content": "<|reserved_special_token_203|>",
|
| 1702 |
+
"lstrip": false,
|
| 1703 |
+
"normalized": false,
|
| 1704 |
+
"rstrip": false,
|
| 1705 |
+
"single_word": false,
|
| 1706 |
+
"special": true
|
| 1707 |
+
},
|
| 1708 |
+
"128212": {
|
| 1709 |
+
"content": "<|reserved_special_token_204|>",
|
| 1710 |
+
"lstrip": false,
|
| 1711 |
+
"normalized": false,
|
| 1712 |
+
"rstrip": false,
|
| 1713 |
+
"single_word": false,
|
| 1714 |
+
"special": true
|
| 1715 |
+
},
|
| 1716 |
+
"128213": {
|
| 1717 |
+
"content": "<|reserved_special_token_205|>",
|
| 1718 |
+
"lstrip": false,
|
| 1719 |
+
"normalized": false,
|
| 1720 |
+
"rstrip": false,
|
| 1721 |
+
"single_word": false,
|
| 1722 |
+
"special": true
|
| 1723 |
+
},
|
| 1724 |
+
"128214": {
|
| 1725 |
+
"content": "<|reserved_special_token_206|>",
|
| 1726 |
+
"lstrip": false,
|
| 1727 |
+
"normalized": false,
|
| 1728 |
+
"rstrip": false,
|
| 1729 |
+
"single_word": false,
|
| 1730 |
+
"special": true
|
| 1731 |
+
},
|
| 1732 |
+
"128215": {
|
| 1733 |
+
"content": "<|reserved_special_token_207|>",
|
| 1734 |
+
"lstrip": false,
|
| 1735 |
+
"normalized": false,
|
| 1736 |
+
"rstrip": false,
|
| 1737 |
+
"single_word": false,
|
| 1738 |
+
"special": true
|
| 1739 |
+
},
|
| 1740 |
+
"128216": {
|
| 1741 |
+
"content": "<|reserved_special_token_208|>",
|
| 1742 |
+
"lstrip": false,
|
| 1743 |
+
"normalized": false,
|
| 1744 |
+
"rstrip": false,
|
| 1745 |
+
"single_word": false,
|
| 1746 |
+
"special": true
|
| 1747 |
+
},
|
| 1748 |
+
"128217": {
|
| 1749 |
+
"content": "<|reserved_special_token_209|>",
|
| 1750 |
+
"lstrip": false,
|
| 1751 |
+
"normalized": false,
|
| 1752 |
+
"rstrip": false,
|
| 1753 |
+
"single_word": false,
|
| 1754 |
+
"special": true
|
| 1755 |
+
},
|
| 1756 |
+
"128218": {
|
| 1757 |
+
"content": "<|reserved_special_token_210|>",
|
| 1758 |
+
"lstrip": false,
|
| 1759 |
+
"normalized": false,
|
| 1760 |
+
"rstrip": false,
|
| 1761 |
+
"single_word": false,
|
| 1762 |
+
"special": true
|
| 1763 |
+
},
|
| 1764 |
+
"128219": {
|
| 1765 |
+
"content": "<|reserved_special_token_211|>",
|
| 1766 |
+
"lstrip": false,
|
| 1767 |
+
"normalized": false,
|
| 1768 |
+
"rstrip": false,
|
| 1769 |
+
"single_word": false,
|
| 1770 |
+
"special": true
|
| 1771 |
+
},
|
| 1772 |
+
"128220": {
|
| 1773 |
+
"content": "<|reserved_special_token_212|>",
|
| 1774 |
+
"lstrip": false,
|
| 1775 |
+
"normalized": false,
|
| 1776 |
+
"rstrip": false,
|
| 1777 |
+
"single_word": false,
|
| 1778 |
+
"special": true
|
| 1779 |
+
},
|
| 1780 |
+
"128221": {
|
| 1781 |
+
"content": "<|reserved_special_token_213|>",
|
| 1782 |
+
"lstrip": false,
|
| 1783 |
+
"normalized": false,
|
| 1784 |
+
"rstrip": false,
|
| 1785 |
+
"single_word": false,
|
| 1786 |
+
"special": true
|
| 1787 |
+
},
|
| 1788 |
+
"128222": {
|
| 1789 |
+
"content": "<|reserved_special_token_214|>",
|
| 1790 |
+
"lstrip": false,
|
| 1791 |
+
"normalized": false,
|
| 1792 |
+
"rstrip": false,
|
| 1793 |
+
"single_word": false,
|
| 1794 |
+
"special": true
|
| 1795 |
+
},
|
| 1796 |
+
"128223": {
|
| 1797 |
+
"content": "<|reserved_special_token_215|>",
|
| 1798 |
+
"lstrip": false,
|
| 1799 |
+
"normalized": false,
|
| 1800 |
+
"rstrip": false,
|
| 1801 |
+
"single_word": false,
|
| 1802 |
+
"special": true
|
| 1803 |
+
},
|
| 1804 |
+
"128224": {
|
| 1805 |
+
"content": "<|reserved_special_token_216|>",
|
| 1806 |
+
"lstrip": false,
|
| 1807 |
+
"normalized": false,
|
| 1808 |
+
"rstrip": false,
|
| 1809 |
+
"single_word": false,
|
| 1810 |
+
"special": true
|
| 1811 |
+
},
|
| 1812 |
+
"128225": {
|
| 1813 |
+
"content": "<|reserved_special_token_217|>",
|
| 1814 |
+
"lstrip": false,
|
| 1815 |
+
"normalized": false,
|
| 1816 |
+
"rstrip": false,
|
| 1817 |
+
"single_word": false,
|
| 1818 |
+
"special": true
|
| 1819 |
+
},
|
| 1820 |
+
"128226": {
|
| 1821 |
+
"content": "<|reserved_special_token_218|>",
|
| 1822 |
+
"lstrip": false,
|
| 1823 |
+
"normalized": false,
|
| 1824 |
+
"rstrip": false,
|
| 1825 |
+
"single_word": false,
|
| 1826 |
+
"special": true
|
| 1827 |
+
},
|
| 1828 |
+
"128227": {
|
| 1829 |
+
"content": "<|reserved_special_token_219|>",
|
| 1830 |
+
"lstrip": false,
|
| 1831 |
+
"normalized": false,
|
| 1832 |
+
"rstrip": false,
|
| 1833 |
+
"single_word": false,
|
| 1834 |
+
"special": true
|
| 1835 |
+
},
|
| 1836 |
+
"128228": {
|
| 1837 |
+
"content": "<|reserved_special_token_220|>",
|
| 1838 |
+
"lstrip": false,
|
| 1839 |
+
"normalized": false,
|
| 1840 |
+
"rstrip": false,
|
| 1841 |
+
"single_word": false,
|
| 1842 |
+
"special": true
|
| 1843 |
+
},
|
| 1844 |
+
"128229": {
|
| 1845 |
+
"content": "<|reserved_special_token_221|>",
|
| 1846 |
+
"lstrip": false,
|
| 1847 |
+
"normalized": false,
|
| 1848 |
+
"rstrip": false,
|
| 1849 |
+
"single_word": false,
|
| 1850 |
+
"special": true
|
| 1851 |
+
},
|
| 1852 |
+
"128230": {
|
| 1853 |
+
"content": "<|reserved_special_token_222|>",
|
| 1854 |
+
"lstrip": false,
|
| 1855 |
+
"normalized": false,
|
| 1856 |
+
"rstrip": false,
|
| 1857 |
+
"single_word": false,
|
| 1858 |
+
"special": true
|
| 1859 |
+
},
|
| 1860 |
+
"128231": {
|
| 1861 |
+
"content": "<|reserved_special_token_223|>",
|
| 1862 |
+
"lstrip": false,
|
| 1863 |
+
"normalized": false,
|
| 1864 |
+
"rstrip": false,
|
| 1865 |
+
"single_word": false,
|
| 1866 |
+
"special": true
|
| 1867 |
+
},
|
| 1868 |
+
"128232": {
|
| 1869 |
+
"content": "<|reserved_special_token_224|>",
|
| 1870 |
+
"lstrip": false,
|
| 1871 |
+
"normalized": false,
|
| 1872 |
+
"rstrip": false,
|
| 1873 |
+
"single_word": false,
|
| 1874 |
+
"special": true
|
| 1875 |
+
},
|
| 1876 |
+
"128233": {
|
| 1877 |
+
"content": "<|reserved_special_token_225|>",
|
| 1878 |
+
"lstrip": false,
|
| 1879 |
+
"normalized": false,
|
| 1880 |
+
"rstrip": false,
|
| 1881 |
+
"single_word": false,
|
| 1882 |
+
"special": true
|
| 1883 |
+
},
|
| 1884 |
+
"128234": {
|
| 1885 |
+
"content": "<|reserved_special_token_226|>",
|
| 1886 |
+
"lstrip": false,
|
| 1887 |
+
"normalized": false,
|
| 1888 |
+
"rstrip": false,
|
| 1889 |
+
"single_word": false,
|
| 1890 |
+
"special": true
|
| 1891 |
+
},
|
| 1892 |
+
"128235": {
|
| 1893 |
+
"content": "<|reserved_special_token_227|>",
|
| 1894 |
+
"lstrip": false,
|
| 1895 |
+
"normalized": false,
|
| 1896 |
+
"rstrip": false,
|
| 1897 |
+
"single_word": false,
|
| 1898 |
+
"special": true
|
| 1899 |
+
},
|
| 1900 |
+
"128236": {
|
| 1901 |
+
"content": "<|reserved_special_token_228|>",
|
| 1902 |
+
"lstrip": false,
|
| 1903 |
+
"normalized": false,
|
| 1904 |
+
"rstrip": false,
|
| 1905 |
+
"single_word": false,
|
| 1906 |
+
"special": true
|
| 1907 |
+
},
|
| 1908 |
+
"128237": {
|
| 1909 |
+
"content": "<|reserved_special_token_229|>",
|
| 1910 |
+
"lstrip": false,
|
| 1911 |
+
"normalized": false,
|
| 1912 |
+
"rstrip": false,
|
| 1913 |
+
"single_word": false,
|
| 1914 |
+
"special": true
|
| 1915 |
+
},
|
| 1916 |
+
"128238": {
|
| 1917 |
+
"content": "<|reserved_special_token_230|>",
|
| 1918 |
+
"lstrip": false,
|
| 1919 |
+
"normalized": false,
|
| 1920 |
+
"rstrip": false,
|
| 1921 |
+
"single_word": false,
|
| 1922 |
+
"special": true
|
| 1923 |
+
},
|
| 1924 |
+
"128239": {
|
| 1925 |
+
"content": "<|reserved_special_token_231|>",
|
| 1926 |
+
"lstrip": false,
|
| 1927 |
+
"normalized": false,
|
| 1928 |
+
"rstrip": false,
|
| 1929 |
+
"single_word": false,
|
| 1930 |
+
"special": true
|
| 1931 |
+
},
|
| 1932 |
+
"128240": {
|
| 1933 |
+
"content": "<|reserved_special_token_232|>",
|
| 1934 |
+
"lstrip": false,
|
| 1935 |
+
"normalized": false,
|
| 1936 |
+
"rstrip": false,
|
| 1937 |
+
"single_word": false,
|
| 1938 |
+
"special": true
|
| 1939 |
+
},
|
| 1940 |
+
"128241": {
|
| 1941 |
+
"content": "<|reserved_special_token_233|>",
|
| 1942 |
+
"lstrip": false,
|
| 1943 |
+
"normalized": false,
|
| 1944 |
+
"rstrip": false,
|
| 1945 |
+
"single_word": false,
|
| 1946 |
+
"special": true
|
| 1947 |
+
},
|
| 1948 |
+
"128242": {
|
| 1949 |
+
"content": "<|reserved_special_token_234|>",
|
| 1950 |
+
"lstrip": false,
|
| 1951 |
+
"normalized": false,
|
| 1952 |
+
"rstrip": false,
|
| 1953 |
+
"single_word": false,
|
| 1954 |
+
"special": true
|
| 1955 |
+
},
|
| 1956 |
+
"128243": {
|
| 1957 |
+
"content": "<|reserved_special_token_235|>",
|
| 1958 |
+
"lstrip": false,
|
| 1959 |
+
"normalized": false,
|
| 1960 |
+
"rstrip": false,
|
| 1961 |
+
"single_word": false,
|
| 1962 |
+
"special": true
|
| 1963 |
+
},
|
| 1964 |
+
"128244": {
|
| 1965 |
+
"content": "<|reserved_special_token_236|>",
|
| 1966 |
+
"lstrip": false,
|
| 1967 |
+
"normalized": false,
|
| 1968 |
+
"rstrip": false,
|
| 1969 |
+
"single_word": false,
|
| 1970 |
+
"special": true
|
| 1971 |
+
},
|
| 1972 |
+
"128245": {
|
| 1973 |
+
"content": "<|reserved_special_token_237|>",
|
| 1974 |
+
"lstrip": false,
|
| 1975 |
+
"normalized": false,
|
| 1976 |
+
"rstrip": false,
|
| 1977 |
+
"single_word": false,
|
| 1978 |
+
"special": true
|
| 1979 |
+
},
|
| 1980 |
+
"128246": {
|
| 1981 |
+
"content": "<|reserved_special_token_238|>",
|
| 1982 |
+
"lstrip": false,
|
| 1983 |
+
"normalized": false,
|
| 1984 |
+
"rstrip": false,
|
| 1985 |
+
"single_word": false,
|
| 1986 |
+
"special": true
|
| 1987 |
+
},
|
| 1988 |
+
"128247": {
|
| 1989 |
+
"content": "<|reserved_special_token_239|>",
|
| 1990 |
+
"lstrip": false,
|
| 1991 |
+
"normalized": false,
|
| 1992 |
+
"rstrip": false,
|
| 1993 |
+
"single_word": false,
|
| 1994 |
+
"special": true
|
| 1995 |
+
},
|
| 1996 |
+
"128248": {
|
| 1997 |
+
"content": "<|reserved_special_token_240|>",
|
| 1998 |
+
"lstrip": false,
|
| 1999 |
+
"normalized": false,
|
| 2000 |
+
"rstrip": false,
|
| 2001 |
+
"single_word": false,
|
| 2002 |
+
"special": true
|
| 2003 |
+
},
|
| 2004 |
+
"128249": {
|
| 2005 |
+
"content": "<|reserved_special_token_241|>",
|
| 2006 |
+
"lstrip": false,
|
| 2007 |
+
"normalized": false,
|
| 2008 |
+
"rstrip": false,
|
| 2009 |
+
"single_word": false,
|
| 2010 |
+
"special": true
|
| 2011 |
+
},
|
| 2012 |
+
"128250": {
|
| 2013 |
+
"content": "<|reserved_special_token_242|>",
|
| 2014 |
+
"lstrip": false,
|
| 2015 |
+
"normalized": false,
|
| 2016 |
+
"rstrip": false,
|
| 2017 |
+
"single_word": false,
|
| 2018 |
+
"special": true
|
| 2019 |
+
},
|
| 2020 |
+
"128251": {
|
| 2021 |
+
"content": "<|reserved_special_token_243|>",
|
| 2022 |
+
"lstrip": false,
|
| 2023 |
+
"normalized": false,
|
| 2024 |
+
"rstrip": false,
|
| 2025 |
+
"single_word": false,
|
| 2026 |
+
"special": true
|
| 2027 |
+
},
|
| 2028 |
+
"128252": {
|
| 2029 |
+
"content": "<|reserved_special_token_244|>",
|
| 2030 |
+
"lstrip": false,
|
| 2031 |
+
"normalized": false,
|
| 2032 |
+
"rstrip": false,
|
| 2033 |
+
"single_word": false,
|
| 2034 |
+
"special": true
|
| 2035 |
+
},
|
| 2036 |
+
"128253": {
|
| 2037 |
+
"content": "<|reserved_special_token_245|>",
|
| 2038 |
+
"lstrip": false,
|
| 2039 |
+
"normalized": false,
|
| 2040 |
+
"rstrip": false,
|
| 2041 |
+
"single_word": false,
|
| 2042 |
+
"special": true
|
| 2043 |
+
},
|
| 2044 |
+
"128254": {
|
| 2045 |
+
"content": "<|reserved_special_token_246|>",
|
| 2046 |
+
"lstrip": false,
|
| 2047 |
+
"normalized": false,
|
| 2048 |
+
"rstrip": false,
|
| 2049 |
+
"single_word": false,
|
| 2050 |
+
"special": true
|
| 2051 |
+
},
|
| 2052 |
+
"128255": {
|
| 2053 |
+
"content": "<|reserved_special_token_247|>",
|
| 2054 |
+
"lstrip": false,
|
| 2055 |
+
"normalized": false,
|
| 2056 |
+
"rstrip": false,
|
| 2057 |
+
"single_word": false,
|
| 2058 |
+
"special": true
|
| 2059 |
+
},
|
| 2060 |
+
"128256": {
|
| 2061 |
+
"content": "<img>",
|
| 2062 |
+
"lstrip": false,
|
| 2063 |
+
"normalized": false,
|
| 2064 |
+
"rstrip": false,
|
| 2065 |
+
"single_word": false,
|
| 2066 |
+
"special": true
|
| 2067 |
+
},
|
| 2068 |
+
"128257": {
|
| 2069 |
+
"content": "</img>",
|
| 2070 |
+
"lstrip": false,
|
| 2071 |
+
"normalized": false,
|
| 2072 |
+
"rstrip": false,
|
| 2073 |
+
"single_word": false,
|
| 2074 |
+
"special": true
|
| 2075 |
+
},
|
| 2076 |
+
"128258": {
|
| 2077 |
+
"content": "<IMG_CONTEXT>",
|
| 2078 |
+
"lstrip": false,
|
| 2079 |
+
"normalized": false,
|
| 2080 |
+
"rstrip": false,
|
| 2081 |
+
"single_word": false,
|
| 2082 |
+
"special": true
|
| 2083 |
+
},
|
| 2084 |
+
"128259": {
|
| 2085 |
+
"content": "<quad>",
|
| 2086 |
+
"lstrip": false,
|
| 2087 |
+
"normalized": false,
|
| 2088 |
+
"rstrip": false,
|
| 2089 |
+
"single_word": false,
|
| 2090 |
+
"special": true
|
| 2091 |
+
},
|
| 2092 |
+
"128260": {
|
| 2093 |
+
"content": "</quad>",
|
| 2094 |
+
"lstrip": false,
|
| 2095 |
+
"normalized": false,
|
| 2096 |
+
"rstrip": false,
|
| 2097 |
+
"single_word": false,
|
| 2098 |
+
"special": true
|
| 2099 |
+
},
|
| 2100 |
+
"128261": {
|
| 2101 |
+
"content": "<ref>",
|
| 2102 |
+
"lstrip": false,
|
| 2103 |
+
"normalized": false,
|
| 2104 |
+
"rstrip": false,
|
| 2105 |
+
"single_word": false,
|
| 2106 |
+
"special": true
|
| 2107 |
+
},
|
| 2108 |
+
"128262": {
|
| 2109 |
+
"content": "</ref>",
|
| 2110 |
+
"lstrip": false,
|
| 2111 |
+
"normalized": false,
|
| 2112 |
+
"rstrip": false,
|
| 2113 |
+
"single_word": false,
|
| 2114 |
+
"special": true
|
| 2115 |
+
},
|
| 2116 |
+
"128263": {
|
| 2117 |
+
"content": "<box>",
|
| 2118 |
+
"lstrip": false,
|
| 2119 |
+
"normalized": false,
|
| 2120 |
+
"rstrip": false,
|
| 2121 |
+
"single_word": false,
|
| 2122 |
+
"special": true
|
| 2123 |
+
},
|
| 2124 |
+
"128264": {
|
| 2125 |
+
"content": "</box>",
|
| 2126 |
+
"lstrip": false,
|
| 2127 |
+
"normalized": false,
|
| 2128 |
+
"rstrip": false,
|
| 2129 |
+
"single_word": false,
|
| 2130 |
+
"special": true
|
| 2131 |
+
},
|
| 2132 |
+
"128265": {
|
| 2133 |
+
"content": "<interval>",
|
| 2134 |
+
"lstrip": false,
|
| 2135 |
+
"normalized": false,
|
| 2136 |
+
"rstrip": false,
|
| 2137 |
+
"single_word": false,
|
| 2138 |
+
"special": true
|
| 2139 |
+
},
|
| 2140 |
+
"128266": {
|
| 2141 |
+
"content": "</interval>",
|
| 2142 |
+
"lstrip": false,
|
| 2143 |
+
"normalized": false,
|
| 2144 |
+
"rstrip": false,
|
| 2145 |
+
"single_word": false,
|
| 2146 |
+
"special": true
|
| 2147 |
+
}
|
| 2148 |
+
},
|
| 2149 |
+
"auto_map": {
|
| 2150 |
+
"AutoProcessor": "processing_llama_nemotron_vl.LlamaNemotronVLRerankProcessor"
|
| 2151 |
+
},
|
| 2152 |
+
"bos_token": "<|begin_of_text|>",
|
| 2153 |
+
"clean_up_tokenization_spaces": true,
|
| 2154 |
+
"eos_token": "<|eot_id|>",
|
| 2155 |
+
"extra_special_tokens": {},
|
| 2156 |
+
"model_input_names": [
|
| 2157 |
+
"input_ids",
|
| 2158 |
+
"attention_mask",
|
| 2159 |
+
"pixel_values"
|
| 2160 |
+
],
|
| 2161 |
+
"model_max_length": 10240,
|
| 2162 |
+
"pad_token": "<|finetune_right_pad_id|>",
|
| 2163 |
+
"processor_class": "LlamaNemotronVLRerankProcessor",
|
| 2164 |
+
"tokenizer_class": "PreTrainedTokenizerFast"
|
| 2165 |
+
}
|