Visual Document Retrieval
sentence-transformers
Safetensors
ColPali
ultravbert
vision-language
multimodal
document-retrieval
late-interaction
multi-vector
colbert
vidore
custom_code
Instructions to use vllm/ColUltraVBERT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use vllm/ColUltraVBERT with sentence-transformers:
from sentence_transformers import MultiVectorEncoder model = MultiVectorEncoder("vllm/ColUltraVBERT", trust_remote_code=True) queries = ["Which planet is known as the Red Planet?"] documents = [ "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.", ] query_embeddings = model.encode_query(queries) document_embeddings = model.encode_document(documents) similarities = model.similarity(query_embeddings, document_embeddings) print(similarities) - ColPali
How to use vllm/ColUltraVBERT with ColPali:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Commit ·
e730d84
0
Parent(s):
Duplicate from athrael-soju/ColUltraVBERT
Browse filesCo-authored-by: Athrael Soju <athrael-soju@users.noreply.huggingface.co>
- .gitattributes +37 -0
- 1_Dense/config.json +8 -0
- 1_Dense/model.safetensors +3 -0
- 2_MultiVectorMask/config.json +7 -0
- 3_Normalize/config.json +4 -0
- LICENSE +21 -0
- LICENSE-APACHE +201 -0
- README.md +173 -0
- additional_chat_templates/sentence_transformers.jinja +1 -0
- chat_template.jinja +2 -0
- colultravbert-hero.png +3 -0
- config.json +102 -0
- config_sentence_transformers.json +21 -0
- configuration_ultravbert.py +29 -0
- image_processing_ultravbert.py +73 -0
- model.safetensors +3 -0
- modeling_ultravbert.py +47 -0
- modules.json +26 -0
- processor_config.json +35 -0
- sentence_bert_config.json +24 -0
- tokenizer.json +0 -0
- tokenizer_config.json +23 -0
.gitattributes
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.xz 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 |
+
ultravbert-hero.png filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
colultravbert-hero.png filter=lfs diff=lfs merge=lfs -text
|
1_Dense/config.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"in_features": 768,
|
| 3 |
+
"out_features": 768,
|
| 4 |
+
"bias": true,
|
| 5 |
+
"activation_function": "torch.nn.modules.linear.Identity",
|
| 6 |
+
"module_input_name": "token_embeddings",
|
| 7 |
+
"module_output_name": "token_embeddings"
|
| 8 |
+
}
|
1_Dense/model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:facf4afeec7f58311e1ac48af6fe722e6212ba0af8ba884342108db747317900
|
| 3 |
+
size 1181344
|
2_MultiVectorMask/config.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"skiplist_words": [],
|
| 3 |
+
"skiplist_tasks": [
|
| 4 |
+
"document"
|
| 5 |
+
],
|
| 6 |
+
"keep_only_token_ids": null
|
| 7 |
+
}
|
3_Normalize/config.json
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"module_input_name": "token_embeddings",
|
| 3 |
+
"module_output_name": "token_embeddings"
|
| 4 |
+
}
|
LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2026 Athrael Soju
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
LICENSE-APACHE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Apache License
|
| 2 |
+
Version 2.0, January 2004
|
| 3 |
+
http://www.apache.org/licenses/
|
| 4 |
+
|
| 5 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
| 6 |
+
|
| 7 |
+
1. Definitions.
|
| 8 |
+
|
| 9 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
| 10 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
| 11 |
+
|
| 12 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
| 13 |
+
the copyright owner that is granting the License.
|
| 14 |
+
|
| 15 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
| 16 |
+
other entities that control, are controlled by, or are under common
|
| 17 |
+
control with that entity. For the purposes of this definition,
|
| 18 |
+
"control" means (i) the power, direct or indirect, to cause the
|
| 19 |
+
direction or management of such entity, whether by contract or
|
| 20 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
| 21 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
| 22 |
+
|
| 23 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
| 24 |
+
exercising permissions granted by this License.
|
| 25 |
+
|
| 26 |
+
"Source" form shall mean the preferred form for making modifications,
|
| 27 |
+
including but not limited to software source code, documentation
|
| 28 |
+
source, and configuration files.
|
| 29 |
+
|
| 30 |
+
"Object" form shall mean any form resulting from mechanical
|
| 31 |
+
transformation or translation of a Source form, including but
|
| 32 |
+
not limited to compiled object code, generated documentation,
|
| 33 |
+
and conversions to other media types.
|
| 34 |
+
|
| 35 |
+
"Work" shall mean the work of authorship, whether in Source or
|
| 36 |
+
Object form, made available under the License, as indicated by a
|
| 37 |
+
copyright notice that is included in or attached to the work
|
| 38 |
+
(an example is provided in the Appendix below).
|
| 39 |
+
|
| 40 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
| 41 |
+
form, that is based on (or derived from) the Work and for which the
|
| 42 |
+
editorial revisions, annotations, elaborations, or other modifications
|
| 43 |
+
represent, as a whole, an original work of authorship. For the purposes
|
| 44 |
+
of this License, Derivative Works shall not include works that remain
|
| 45 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
| 46 |
+
the Work and Derivative Works thereof.
|
| 47 |
+
|
| 48 |
+
"Contribution" shall mean any work of authorship, including
|
| 49 |
+
the original version of the Work and any modifications or additions
|
| 50 |
+
to that Work or Derivative Works thereof, that is intentionally
|
| 51 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
| 52 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
| 53 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
| 54 |
+
means any form of electronic, verbal, or written communication sent
|
| 55 |
+
to the Licensor or its representatives, including but not limited to
|
| 56 |
+
communication on electronic mailing lists, source code control systems,
|
| 57 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
| 58 |
+
Licensor for the purpose of discussing and improving the Work, but
|
| 59 |
+
excluding communication that is conspicuously marked or otherwise
|
| 60 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
| 61 |
+
|
| 62 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
| 63 |
+
on behalf of whom a Contribution has been received by Licensor and
|
| 64 |
+
subsequently incorporated within the Work.
|
| 65 |
+
|
| 66 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
| 67 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 68 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 69 |
+
copyright license to reproduce, prepare Derivative Works of,
|
| 70 |
+
publicly display, publicly perform, sublicense, and distribute the
|
| 71 |
+
Work and such Derivative Works in Source or Object form.
|
| 72 |
+
|
| 73 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
| 74 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 75 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 76 |
+
(except as stated in this section) patent license to make, have made,
|
| 77 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
| 78 |
+
where such license applies only to those patent claims licensable
|
| 79 |
+
by such Contributor that are necessarily infringed by their
|
| 80 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
| 81 |
+
with the Work to which such Contribution(s) was submitted. If You
|
| 82 |
+
institute patent litigation against any entity (including a
|
| 83 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
| 84 |
+
or a Contribution incorporated within the Work constitutes direct
|
| 85 |
+
or contributory patent infringement, then any patent licenses
|
| 86 |
+
granted to You under this License for that Work shall terminate
|
| 87 |
+
as of the date such litigation is filed.
|
| 88 |
+
|
| 89 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
| 90 |
+
Work or Derivative Works thereof in any medium, with or without
|
| 91 |
+
modifications, and in Source or Object form, provided that You
|
| 92 |
+
meet the following conditions:
|
| 93 |
+
|
| 94 |
+
(a) You must give any other recipients of the Work or
|
| 95 |
+
Derivative Works a copy of this License; and
|
| 96 |
+
|
| 97 |
+
(b) You must cause any modified files to carry prominent notices
|
| 98 |
+
stating that You changed the files; and
|
| 99 |
+
|
| 100 |
+
(c) You must retain, in the Source form of any Derivative Works
|
| 101 |
+
that You distribute, all copyright, patent, trademark, and
|
| 102 |
+
attribution notices from the Source form of the Work,
|
| 103 |
+
excluding those notices that do not pertain to any part of
|
| 104 |
+
the Derivative Works; and
|
| 105 |
+
|
| 106 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
| 107 |
+
distribution, then any Derivative Works that You distribute must
|
| 108 |
+
include a readable copy of the attribution notices contained
|
| 109 |
+
within such NOTICE file, excluding those notices that do not
|
| 110 |
+
pertain to any part of the Derivative Works, in at least one
|
| 111 |
+
of the following places: within a NOTICE text file distributed
|
| 112 |
+
as part of the Derivative Works; within the Source form or
|
| 113 |
+
documentation, if provided along with the Derivative Works; or,
|
| 114 |
+
within a display generated by the Derivative Works, if and
|
| 115 |
+
wherever such third-party notices normally appear. The contents
|
| 116 |
+
of the NOTICE file are for informational purposes only and
|
| 117 |
+
do not modify the License. You may add Your own attribution
|
| 118 |
+
notices within Derivative Works that You distribute, alongside
|
| 119 |
+
or as an addendum to the NOTICE text from the Work, provided
|
| 120 |
+
that such additional attribution notices cannot be construed
|
| 121 |
+
as modifying the License.
|
| 122 |
+
|
| 123 |
+
You may add Your own copyright statement to Your modifications and
|
| 124 |
+
may provide additional or different license terms and conditions
|
| 125 |
+
for use, reproduction, or distribution of Your modifications, or
|
| 126 |
+
for any such Derivative Works as a whole, provided Your use,
|
| 127 |
+
reproduction, and distribution of the Work otherwise complies with
|
| 128 |
+
the conditions stated in this License.
|
| 129 |
+
|
| 130 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
| 131 |
+
any Contribution intentionally submitted for inclusion in the Work
|
| 132 |
+
by You to the Licensor shall be under the terms and conditions of
|
| 133 |
+
this License, without any additional terms or conditions.
|
| 134 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
| 135 |
+
the terms of any separate license agreement you may have executed
|
| 136 |
+
with Licensor regarding such Contributions.
|
| 137 |
+
|
| 138 |
+
6. Trademarks. This License does not grant permission to use the trade
|
| 139 |
+
names, trademarks, service marks, or product names of the Licensor,
|
| 140 |
+
except as required for reasonable and customary use in describing the
|
| 141 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
| 142 |
+
|
| 143 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
| 144 |
+
agreed to in writing, Licensor provides the Work (and each
|
| 145 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
| 146 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 147 |
+
implied, including, without limitation, any warranties or conditions
|
| 148 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
| 149 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
| 150 |
+
appropriateness of using or redistributing the Work and assume any
|
| 151 |
+
risks associated with Your exercise of permissions under this License.
|
| 152 |
+
|
| 153 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
| 154 |
+
whether in tort (including negligence), contract, or otherwise,
|
| 155 |
+
unless required by applicable law (such as deliberate and grossly
|
| 156 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
| 157 |
+
liable to You for damages, including any direct, indirect, special,
|
| 158 |
+
incidental, or consequential damages of any character arising as a
|
| 159 |
+
result of this License or out of the use or inability to use the
|
| 160 |
+
Work (including but not limited to damages for loss of goodwill,
|
| 161 |
+
work stoppage, computer failure or malfunction, or any and all
|
| 162 |
+
other commercial damages or losses), even if such Contributor
|
| 163 |
+
has been advised of the possibility of such damages.
|
| 164 |
+
|
| 165 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
| 166 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
| 167 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
| 168 |
+
or other liability obligations and/or rights consistent with this
|
| 169 |
+
License. However, in accepting such obligations, You may act only
|
| 170 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
| 171 |
+
of any other Contributor, and only if You agree to indemnify,
|
| 172 |
+
defend, and hold each Contributor harmless for any liability
|
| 173 |
+
incurred by, or claims asserted against, such Contributor by reason
|
| 174 |
+
of your accepting any such warranty or additional liability.
|
| 175 |
+
|
| 176 |
+
END OF TERMS AND CONDITIONS
|
| 177 |
+
|
| 178 |
+
APPENDIX: How to apply the Apache License to your work.
|
| 179 |
+
|
| 180 |
+
To apply the Apache License to your work, attach the following
|
| 181 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
| 182 |
+
replaced with your own identifying information. (Don't include
|
| 183 |
+
the brackets!) The text should be enclosed in the appropriate
|
| 184 |
+
comment syntax for the file format. We also recommend that a
|
| 185 |
+
file or class name and description of purpose be included on the
|
| 186 |
+
same "printed page" as the copyright notice for easier
|
| 187 |
+
identification within third-party archives.
|
| 188 |
+
|
| 189 |
+
Copyright [yyyy] [name of copyright owner]
|
| 190 |
+
|
| 191 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 192 |
+
you may not use this file except in compliance with the License.
|
| 193 |
+
You may obtain a copy of the License at
|
| 194 |
+
|
| 195 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 196 |
+
|
| 197 |
+
Unless required by applicable law or agreed to in writing, software
|
| 198 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 199 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 200 |
+
See the License for the specific language governing permissions and
|
| 201 |
+
limitations under the License.
|
README.md
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
- es
|
| 6 |
+
- de
|
| 7 |
+
- fr
|
| 8 |
+
- it
|
| 9 |
+
- pt
|
| 10 |
+
base_model:
|
| 11 |
+
- athrael-soju/UltraVBERT
|
| 12 |
+
base_model_relation: finetune
|
| 13 |
+
datasets:
|
| 14 |
+
- athrael-soju/vdr-train-500k
|
| 15 |
+
tags:
|
| 16 |
+
- ultravbert
|
| 17 |
+
- sentence-transformers
|
| 18 |
+
- vision-language
|
| 19 |
+
- multimodal
|
| 20 |
+
- document-retrieval
|
| 21 |
+
- late-interaction
|
| 22 |
+
- multi-vector
|
| 23 |
+
- colbert
|
| 24 |
+
- colpali
|
| 25 |
+
- vidore
|
| 26 |
+
pipeline_tag: visual-document-retrieval
|
| 27 |
+
library_name: sentence-transformers
|
| 28 |
+
---
|
| 29 |
+
|
| 30 |
+
<img src="colultravbert-hero.png" width="100%" alt="ColUltraVBERT">
|
| 31 |
+
|
| 32 |
+
# ColUltraVBERT
|
| 33 |
+
|
| 34 |
+
ColUltraVBERT is a 255M-parameter late-interaction retriever for visual documents, fine-tuned from
|
| 35 |
+
[UltraVBERT](https://huggingface.co/athrael-soju/UltraVBERT). It encodes each query token and each page token as a
|
| 36 |
+
768-d vector and ranks pages by MaxSim. Truncating the vectors to 128, 256, 320 or 512 dimensions gives a smaller
|
| 37 |
+
index.
|
| 38 |
+
|
| 39 |
+
## Models
|
| 40 |
+
|
| 41 |
+
<table style="display: table; width: 100%;">
|
| 42 |
+
<thead>
|
| 43 |
+
<tr><th align="left">Model</th><th align="left">Role</th><th align="left">Status</th></tr>
|
| 44 |
+
</thead>
|
| 45 |
+
<tbody>
|
| 46 |
+
<tr><td><a href="https://huggingface.co/athrael-soju/UltraVBERT">UltraVBERT</a></td><td>Base encoder aligned to page images</td><td>Available</td></tr>
|
| 47 |
+
<tr><td><a href="https://huggingface.co/athrael-soju/BiUltraVBERT">BiUltraVBERT</a></td><td>Single-vector retriever for visual documents</td><td>Available</td></tr>
|
| 48 |
+
<tr><td><a href="https://huggingface.co/athrael-soju/ColUltraVBERT">ColUltraVBERT</a></td><td>Late-interaction retriever for visual documents</td><td>Available · <a href="https://huggingface.co/spaces/athrael-soju/ColUltraVBERT">Demo</a></td></tr>
|
| 49 |
+
</tbody>
|
| 50 |
+
</table>
|
| 51 |
+
|
| 52 |
+
## Data
|
| 53 |
+
|
| 54 |
+
<table style="display: table; width: 100%;">
|
| 55 |
+
<thead>
|
| 56 |
+
<tr><th align="left">Dataset</th><th align="left">Content</th></tr>
|
| 57 |
+
</thead>
|
| 58 |
+
<tbody>
|
| 59 |
+
<tr><td><a href="https://huggingface.co/datasets/athrael-soju/vdr-train-500k">VDR Train 500k</a></td><td>499,704 query-page pairs; queries in English (73%), Spanish, German, French, Italian and Portuguese</td></tr>
|
| 60 |
+
</tbody>
|
| 61 |
+
</table>
|
| 62 |
+
|
| 63 |
+
## Usage
|
| 64 |
+
|
| 65 |
+
Requires `sentence-transformers>=6.1` and `transformers>=5.21`, which supports UltraVBERT natively
|
| 66 |
+
([docs](https://huggingface.co/docs/transformers/model_doc/ultravbert)). On 5.20.x, pass `trust_remote_code=True` to load the code in this repository.
|
| 67 |
+
|
| 68 |
+
```python
|
| 69 |
+
from PIL import Image
|
| 70 |
+
from sentence_transformers import MultiVectorEncoder
|
| 71 |
+
|
| 72 |
+
model = MultiVectorEncoder("athrael-soju/ColUltraVBERT")
|
| 73 |
+
|
| 74 |
+
pages = [Image.open("page1.png"), Image.open("page2.png")]
|
| 75 |
+
queries = ["What was the 2023 revenue?", "Which table lists regional margins?"]
|
| 76 |
+
|
| 77 |
+
page_embeddings = model.encode_document(pages)
|
| 78 |
+
query_embeddings = model.encode_query(queries)
|
| 79 |
+
|
| 80 |
+
# One row per query, one column per page.
|
| 81 |
+
scores = model.similarity(query_embeddings, page_embeddings)
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
For a smaller index, keep the first 128, 256, 320 or 512 dimensions of each vector and L2-normalize it again.
|
| 85 |
+
|
| 86 |
+
## Model
|
| 87 |
+
|
| 88 |
+
A linear layer projects each of UltraVBERT's 768-d token states to a 768-d retrieval vector. Vectors are L2-normalized
|
| 89 |
+
and padding tokens are dropped. Pages are resized to at most 3,072 px on the longest edge and split into up to 25 tiles
|
| 90 |
+
of 512 px, plus a downscaled view of the whole page: at most 1,664 image vectors per page, plus the prompt and
|
| 91 |
+
tile-tag vectors.
|
| 92 |
+
|
| 93 |
+
## Training
|
| 94 |
+
|
| 95 |
+
The released weights are a per-block merge of four fine-tunes of UltraVBERT on VDR Train 500k that differ in
|
| 96 |
+
hard negatives, distillation and seed. Each fine-tune trains rank-32 LoRA adapters on the text encoder and the output
|
| 97 |
+
projection for one epoch at batch size 256, with Matryoshka losses at 128, 256, 320, 512 and 768 dimensions; the vision
|
| 98 |
+
encoder and connector stay frozen.
|
| 99 |
+
|
| 100 |
+
## ViDoRe
|
| 101 |
+
|
| 102 |
+
ColUltraVBERT's scores are its official MTEB results
|
| 103 |
+
([results#783](https://github.com/embeddings-benchmark/results/pull/783)): MTEB 2.26.3, 768-d vectors, bf16 and SDPA
|
| 104 |
+
attention. The MTEB maintainers scored the private ViDoRe V3 tasks, Nuclear and Telecom
|
| 105 |
+
([results#792](https://github.com/embeddings-benchmark/results/pull/792)). ColModernVBERT's V1 and V2 scores are our
|
| 106 |
+
MTEB 2.26.3 runs of [`ModernVBERT/colmodernvbert`](https://huggingface.co/ModernVBERT/colmodernvbert) at revision
|
| 107 |
+
`9052fc0e`; its V3 scores are its MTEB results.
|
| 108 |
+
|
| 109 |
+
| ViDoRe V1 (nDCG@5) | ColModernVBERT | ColUltraVBERT |
|
| 110 |
+
| --- | ---: | ---: |
|
| 111 |
+
| ArxivQA | 75.0 | 80.1 |
|
| 112 |
+
| DocVQA | 56.2 | 57.7 |
|
| 113 |
+
| InfoVQA | 86.5 | 89.5 |
|
| 114 |
+
| TabFQuAD | 76.1 | 92.5 |
|
| 115 |
+
| TAT-DQA | 73.9 | 75.1 |
|
| 116 |
+
| ShiftProject | 64.8 | 81.2 |
|
| 117 |
+
| SyntheticDocQA AI | 97.5 | 99.6 |
|
| 118 |
+
| SyntheticDocQA Energy | 94.2 | 95.7 |
|
| 119 |
+
| SyntheticDocQA Government Reports | 93.3 | 95.1 |
|
| 120 |
+
| SyntheticDocQA Healthcare Industry | 96.9 | 97.9 |
|
| 121 |
+
| **Mean** | **81.4** | **86.4** |
|
| 122 |
+
|
| 123 |
+
| ViDoRe V2 (nDCG@5) | ColModernVBERT | ColUltraVBERT |
|
| 124 |
+
| --- | ---: | ---: |
|
| 125 |
+
| ESG Reports | 40.5 | 49.8 |
|
| 126 |
+
| Economics Reports | 32.6 | 51.2 |
|
| 127 |
+
| BioMedical Lectures | 34.8 | 54.3 |
|
| 128 |
+
| ESG Reports HL | 54.8 | 64.0 |
|
| 129 |
+
| **Mean** | **40.7** | **54.8** |
|
| 130 |
+
|
| 131 |
+
| ViDoRe V3 (nDCG@10) | ColModernVBERT | ColUltraVBERT |
|
| 132 |
+
| --- | ---: | ---: |
|
| 133 |
+
| Computer Science | 37.6 | 66.5 |
|
| 134 |
+
| Energy | 32.5 | 51.9 |
|
| 135 |
+
| Finance EN | 28.8 | 53.3 |
|
| 136 |
+
| Finance FR | 19.8 | 33.3 |
|
| 137 |
+
| HR | 19.8 | 51.1 |
|
| 138 |
+
| Industrial | 15.7 | 37.6 |
|
| 139 |
+
| Pharmaceuticals | 32.2 | 57.6 |
|
| 140 |
+
| Physics | 22.6 | 37.7 |
|
| 141 |
+
| Nuclear (private) | 21.5 | 42.0 |
|
| 142 |
+
| Telecom (private) | 30.3 | 62.0 |
|
| 143 |
+
| **Mean, public** | **26.1** | **48.6** |
|
| 144 |
+
| **Mean, private** | **25.9** | **52.0** |
|
| 145 |
+
| **Mean, all** | **26.1** | **49.3** |
|
| 146 |
+
|
| 147 |
+
### Smaller indexes
|
| 148 |
+
|
| 149 |
+
Scores come from cached page features; at 768 dimensions and 3,072 px they are within 0.1 of the official means. For
|
| 150 |
+
2,048 px pages with 16 tiles, set `size.longest_edge` to 2048 and `max_image_tiles` to 16 in `processor_config.json`; a
|
| 151 |
+
page then produces at most 1,088 image vectors.
|
| 152 |
+
|
| 153 |
+
| Vector size | Page resolution | V1 | V2 | V3 public |
|
| 154 |
+
| ---: | --- | ---: | ---: | ---: |
|
| 155 |
+
| 768 | 3,072 px, 25 tiles | 86.4 | 54.8 | 48.7 |
|
| 156 |
+
| 512 | 3,072 px, 25 tiles | 86.3 | 54.3 | 48.4 |
|
| 157 |
+
| 320 | 3,072 px, 25 tiles | 86.0 | 54.2 | 48.2 |
|
| 158 |
+
| 256 | 3,072 px, 25 tiles | 86.0 | 54.3 | 48.0 |
|
| 159 |
+
| 128 | 3,072 px, 25 tiles | 85.7 | 54.3 | 46.8 |
|
| 160 |
+
| 768 | 2,048 px, 16 tiles | 86.3 | 53.3 | 47.6 |
|
| 161 |
+
| 512 | 2,048 px, 16 tiles | 86.3 | 52.9 | 47.5 |
|
| 162 |
+
| 320 | 2,048 px, 16 tiles | 86.4 | 52.4 | 47.2 |
|
| 163 |
+
| 256 | 2,048 px, 16 tiles | 86.4 | 52.1 | 46.9 |
|
| 164 |
+
| 128 | 2,048 px, 16 tiles | 85.6 | 52.6 | 45.9 |
|
| 165 |
+
|
| 166 |
+
## Limits
|
| 167 |
+
|
| 168 |
+
- A page produces up to 1,664 image vectors, 2.4 MiB at 768 dimensions in bf16, plus its prompt and tile-tag vectors.
|
| 169 |
+
|
| 170 |
+
## License
|
| 171 |
+
|
| 172 |
+
`MIT`. The UltraBERT-150M and SigLIP2-B/16-512 components are Apache-2.0, with their license text in
|
| 173 |
+
`LICENSE-APACHE`.
|
additional_chat_templates/sentence_transformers.jinja
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{%- for message in messages -%}{%- set content = message['content'] -%}{%- if content is string -%}{%- set content = [{'type': 'text', 'text': content}] -%}{%- endif -%}{%- for part in content if part['type'] == 'image' -%}{{ 'User:<image>Describe the image.<end_of_utterance>\nAssistant:' }}{%- endfor -%}{%- for part in content if part['type'] == 'text' -%}{{ part['text'] }}{%- endfor -%}{%- if task == 'query' and content | selectattr('type', 'equalto', 'text') | list -%}{{ '<end_of_utterance><end_of_utterance><end_of_utterance><end_of_utterance><end_of_utterance><end_of_utterance><end_of_utterance><end_of_utterance><end_of_utterance><end_of_utterance>' }}{%- endif -%}{%- endfor -%}
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{% for message in messages %}{{message['role'] | capitalize}}{% if message['content'][0]['type'] == 'image' %}{{':'}}{% else %}{{': '}}{% endif %}{% for line in message['content'] %}{% if line['type'] == 'text' %}{{line['text']}}{% elif line['type'] == 'image' %}{{ '<image>' }}{% endif %}{% endfor %}<end_of_utterance>
|
| 2 |
+
{% endfor %}{% if add_generation_prompt %}{{ 'Assistant:' }}{% endif %}
|
colultravbert-hero.png
ADDED
|
Git LFS Details
|
config.json
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"UltraVBertModel"
|
| 4 |
+
],
|
| 5 |
+
"auto_map": {
|
| 6 |
+
"AutoConfig": "configuration_ultravbert.UltraVBertConfig",
|
| 7 |
+
"AutoModel": "modeling_ultravbert.UltraVBertModel"
|
| 8 |
+
},
|
| 9 |
+
"classifier_dropout": 0.0,
|
| 10 |
+
"classifier_pooling": "cls",
|
| 11 |
+
"connector_norm": true,
|
| 12 |
+
"dtype": "bfloat16",
|
| 13 |
+
"image_token_id": 49191,
|
| 14 |
+
"initializer_cutoff_factor": 2.0,
|
| 15 |
+
"initializer_range": 0.02,
|
| 16 |
+
"model_type": "ultravbert",
|
| 17 |
+
"pixel_shuffle_factor": 4,
|
| 18 |
+
"text_config": {
|
| 19 |
+
"architectures": [
|
| 20 |
+
"UltrabertForMaskedLM"
|
| 21 |
+
],
|
| 22 |
+
"attention_bias": false,
|
| 23 |
+
"attention_dropout": 0.0,
|
| 24 |
+
"bos_token_id": 0,
|
| 25 |
+
"classifier_dropout": 0.0,
|
| 26 |
+
"classifier_pooling": "cls",
|
| 27 |
+
"dtype": "bfloat16",
|
| 28 |
+
"eos_token_id": 0,
|
| 29 |
+
"head_dim": 128,
|
| 30 |
+
"hidden_act": "silu",
|
| 31 |
+
"hidden_size": 768,
|
| 32 |
+
"initializer_range": 0.02,
|
| 33 |
+
"intermediate_size": 1024,
|
| 34 |
+
"layer_types": [
|
| 35 |
+
"sliding_attention",
|
| 36 |
+
"sliding_attention",
|
| 37 |
+
"full_attention",
|
| 38 |
+
"sliding_attention",
|
| 39 |
+
"sliding_attention",
|
| 40 |
+
"full_attention",
|
| 41 |
+
"sliding_attention",
|
| 42 |
+
"sliding_attention",
|
| 43 |
+
"full_attention",
|
| 44 |
+
"sliding_attention",
|
| 45 |
+
"sliding_attention",
|
| 46 |
+
"full_attention",
|
| 47 |
+
"sliding_attention",
|
| 48 |
+
"sliding_attention",
|
| 49 |
+
"full_attention",
|
| 50 |
+
"sliding_attention",
|
| 51 |
+
"sliding_attention",
|
| 52 |
+
"full_attention",
|
| 53 |
+
"sliding_attention",
|
| 54 |
+
"sliding_attention",
|
| 55 |
+
"full_attention",
|
| 56 |
+
"sliding_attention",
|
| 57 |
+
"sliding_attention",
|
| 58 |
+
"full_attention"
|
| 59 |
+
],
|
| 60 |
+
"max_position_embeddings": 32768,
|
| 61 |
+
"mlp_bias": false,
|
| 62 |
+
"model_type": "ultrabert",
|
| 63 |
+
"num_attention_heads": 6,
|
| 64 |
+
"num_hidden_layers": 24,
|
| 65 |
+
"num_key_value_heads": 6,
|
| 66 |
+
"pad_token_id": 0,
|
| 67 |
+
"prediction_head_size": 768,
|
| 68 |
+
"rms_norm_eps": 1e-06,
|
| 69 |
+
"rope_parameters": {
|
| 70 |
+
"full_attention": {
|
| 71 |
+
"rope_theta": 2560000.0,
|
| 72 |
+
"rope_type": "default"
|
| 73 |
+
},
|
| 74 |
+
"sliding_attention": {
|
| 75 |
+
"rope_theta": 10000.0,
|
| 76 |
+
"rope_type": "default"
|
| 77 |
+
}
|
| 78 |
+
},
|
| 79 |
+
"sliding_window": 128,
|
| 80 |
+
"tie_word_embeddings": false,
|
| 81 |
+
"use_cache": false,
|
| 82 |
+
"vocab_size": 49280
|
| 83 |
+
},
|
| 84 |
+
"tie_word_embeddings": false,
|
| 85 |
+
"transformers_version": "5.21.0.dev0",
|
| 86 |
+
"vision_config": {
|
| 87 |
+
"attention_dropout": 0.0,
|
| 88 |
+
"dtype": "bfloat16",
|
| 89 |
+
"hidden_act": "gelu_pytorch_tanh",
|
| 90 |
+
"hidden_size": 768,
|
| 91 |
+
"image_size": 512,
|
| 92 |
+
"intermediate_size": 3072,
|
| 93 |
+
"layer_norm_eps": 1e-06,
|
| 94 |
+
"model_type": "siglip_vision_model",
|
| 95 |
+
"num_attention_heads": 12,
|
| 96 |
+
"num_channels": 3,
|
| 97 |
+
"num_hidden_layers": 12,
|
| 98 |
+
"patch_size": 16,
|
| 99 |
+
"vision_use_head": false
|
| 100 |
+
},
|
| 101 |
+
"vocab_size": 49280
|
| 102 |
+
}
|
config_sentence_transformers.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"__version__": {
|
| 3 |
+
"pytorch": "2.14.0+cu130",
|
| 4 |
+
"sentence_transformers": "6.1.0",
|
| 5 |
+
"transformers": "5.21.0.dev0"
|
| 6 |
+
},
|
| 7 |
+
"default_prompt_name": null,
|
| 8 |
+
"model_type": "MultiVectorEncoder",
|
| 9 |
+
"prompts": {
|
| 10 |
+
"document": "",
|
| 11 |
+
"query": ""
|
| 12 |
+
},
|
| 13 |
+
"similarity_fn_name": "maxsim",
|
| 14 |
+
"requirements": {
|
| 15 |
+
"transformers": {
|
| 16 |
+
"specifier": ">=5.20",
|
| 17 |
+
"reason": "Native `ultravbert` support ships from 5.21; on 5.20.x, load with `trust_remote_code=True` to use the remote code in this repository."
|
| 18 |
+
},
|
| 19 |
+
"sentence-transformers": ">=6.1"
|
| 20 |
+
}
|
| 21 |
+
}
|
configuration_ultravbert.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Literal
|
| 2 |
+
|
| 3 |
+
from huggingface_hub.dataclasses import strict
|
| 4 |
+
from transformers import AutoConfig
|
| 5 |
+
from transformers.configuration_utils import PreTrainedConfig, SubConfigSpec
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
@strict
|
| 9 |
+
class UltraVBertConfig(PreTrainedConfig):
|
| 10 |
+
model_type = "ultravbert"
|
| 11 |
+
sub_configs_defaults = {
|
| 12 |
+
"text_config": SubConfigSpec(config_class=AutoConfig, model_type="ultrabert"),
|
| 13 |
+
"vision_config": SubConfigSpec(config_class=AutoConfig, model_type="siglip_vision_model"),
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
text_config: PreTrainedConfig | dict | None = None
|
| 17 |
+
vision_config: PreTrainedConfig | dict | None = None
|
| 18 |
+
|
| 19 |
+
image_token_id: int = 49191
|
| 20 |
+
pixel_shuffle_factor: int = 4
|
| 21 |
+
initializer_range: float = 0.02
|
| 22 |
+
initializer_cutoff_factor: float = 2.0
|
| 23 |
+
classifier_pooling: Literal["cls", "mean"] = "cls"
|
| 24 |
+
classifier_dropout: float | int = 0.0
|
| 25 |
+
tie_word_embeddings: bool = False
|
| 26 |
+
connector_norm: bool = True
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
__all__ = ["UltraVBertConfig"]
|
image_processing_ultravbert.py
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import math
|
| 2 |
+
|
| 3 |
+
from transformers.image_utils import SizeDict
|
| 4 |
+
from transformers.models.idefics3.image_processing_idefics3 import (
|
| 5 |
+
MAX_IMAGE_SIZE,
|
| 6 |
+
Idefics3ImageProcessor,
|
| 7 |
+
Idefics3ImageProcessorKwargs,
|
| 8 |
+
_resize_output_size_rescale_to_max_len,
|
| 9 |
+
_resize_output_size_scale_below_upper_bound,
|
| 10 |
+
)
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def get_capped_longest_edge(height: int, width: int, longest_edge: int, tile_size: int, max_image_tiles: int) -> int:
|
| 14 |
+
for edge in range(longest_edge, tile_size - 1, -tile_size):
|
| 15 |
+
resized_height, resized_width = _resize_output_size_rescale_to_max_len(height, width, max_len=edge)
|
| 16 |
+
resized_height, resized_width = _resize_output_size_scale_below_upper_bound(
|
| 17 |
+
resized_height, resized_width, max_len=MAX_IMAGE_SIZE
|
| 18 |
+
)
|
| 19 |
+
aspect_ratio = resized_width / resized_height
|
| 20 |
+
if resized_width >= resized_height:
|
| 21 |
+
cols = math.ceil(resized_width / tile_size)
|
| 22 |
+
rows = math.ceil(int(cols * tile_size / aspect_ratio) / tile_size)
|
| 23 |
+
else:
|
| 24 |
+
rows = math.ceil(resized_height / tile_size)
|
| 25 |
+
cols = math.ceil(int(rows * tile_size * aspect_ratio) / tile_size)
|
| 26 |
+
if rows * cols <= max_image_tiles:
|
| 27 |
+
return edge
|
| 28 |
+
return tile_size
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
class UltraVBertImageProcessorKwargs(Idefics3ImageProcessorKwargs, total=False):
|
| 32 |
+
max_image_tiles: int | None
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
class UltraVBertImageProcessor(Idefics3ImageProcessor):
|
| 36 |
+
max_image_tiles = None
|
| 37 |
+
valid_kwargs = UltraVBertImageProcessorKwargs
|
| 38 |
+
|
| 39 |
+
def _preprocess(self, images, *, do_resize, size, resample, do_image_splitting, max_image_size,
|
| 40 |
+
max_image_tiles=None, **kwargs):
|
| 41 |
+
if do_resize and do_image_splitting and max_image_tiles is not None:
|
| 42 |
+
tile_size = max_image_size["longest_edge"]
|
| 43 |
+
images = [
|
| 44 |
+
[
|
| 45 |
+
self.resize(
|
| 46 |
+
image,
|
| 47 |
+
SizeDict(
|
| 48 |
+
longest_edge=get_capped_longest_edge(
|
| 49 |
+
*image.shape[-2:], size.longest_edge, tile_size, max_image_tiles
|
| 50 |
+
)
|
| 51 |
+
),
|
| 52 |
+
resample=resample,
|
| 53 |
+
)
|
| 54 |
+
for image in batch_images
|
| 55 |
+
]
|
| 56 |
+
for batch_images in images
|
| 57 |
+
]
|
| 58 |
+
do_resize = False
|
| 59 |
+
return super()._preprocess(images, do_resize=do_resize, size=size, resample=resample,
|
| 60 |
+
do_image_splitting=do_image_splitting, max_image_size=max_image_size, **kwargs)
|
| 61 |
+
|
| 62 |
+
def get_number_of_image_patches(self, height: int, width: int, images_kwargs: dict | None = None):
|
| 63 |
+
images_kwargs = dict(images_kwargs or {})
|
| 64 |
+
max_image_tiles = images_kwargs.get("max_image_tiles", self.max_image_tiles)
|
| 65 |
+
if max_image_tiles is not None:
|
| 66 |
+
size = images_kwargs.get("size", self.size)
|
| 67 |
+
tile_size = images_kwargs.get("max_image_size", self.max_image_size)["longest_edge"]
|
| 68 |
+
longest_edge = get_capped_longest_edge(height, width, size["longest_edge"], tile_size, max_image_tiles)
|
| 69 |
+
images_kwargs["size"] = {"longest_edge": longest_edge}
|
| 70 |
+
return super().get_number_of_image_patches(height, width, images_kwargs)
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
__all__ = ["UltraVBertImageProcessor"]
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1b3c7b0013dd63e4666bbdae4490b12a71814486dd49a3c9f06335108fb95744
|
| 3 |
+
size 508228848
|
modeling_ultravbert.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from torch import nn
|
| 2 |
+
from transformers import AutoModel
|
| 3 |
+
from transformers.models.modernvbert.modeling_modernvbert import (
|
| 4 |
+
ModernVBertConnector,
|
| 5 |
+
ModernVBertModel,
|
| 6 |
+
ModernVBertPreTrainedModel,
|
| 7 |
+
)
|
| 8 |
+
from transformers.models.ultrabert.modeling_ultrabert import UltrabertRMSNorm
|
| 9 |
+
|
| 10 |
+
from .configuration_ultravbert import UltraVBertConfig
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
class UltraVBertConnector(ModernVBertConnector):
|
| 14 |
+
def __init__(self, config: UltraVBertConfig):
|
| 15 |
+
super().__init__(config)
|
| 16 |
+
# UltraBERT's first layer takes embeddings unnormalized; raw projections would swamp its token embeddings.
|
| 17 |
+
self.norm = (
|
| 18 |
+
UltrabertRMSNorm(config.text_config.hidden_size, eps=config.text_config.rms_norm_eps)
|
| 19 |
+
if config.connector_norm
|
| 20 |
+
else nn.Identity()
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
def forward(self, image_hidden_states):
|
| 24 |
+
return self.norm(super().forward(image_hidden_states))
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
class UltraVBertModel(ModernVBertModel):
|
| 28 |
+
config_class = UltraVBertConfig
|
| 29 |
+
_keys_to_ignore_on_load_unexpected = [r"vision_model\.head\."]
|
| 30 |
+
|
| 31 |
+
def __init__(self, config: UltraVBertConfig):
|
| 32 |
+
# ModernVBertModel.__init__ builds ModernVBertConnector; the rest of its body follows unchanged.
|
| 33 |
+
ModernVBertPreTrainedModel.__init__(self, config)
|
| 34 |
+
self.padding_idx = config.text_config.pad_token_id
|
| 35 |
+
self.vocab_size = config.text_config.vocab_size
|
| 36 |
+
self.vision_model = AutoModel.from_config(config.vision_config)
|
| 37 |
+
self.connector = UltraVBertConnector(config)
|
| 38 |
+
self.text_model = AutoModel.from_config(config.text_config)
|
| 39 |
+
self.image_seq_len = int(
|
| 40 |
+
((config.vision_config.image_size // config.vision_config.patch_size) ** 2)
|
| 41 |
+
/ (config.pixel_shuffle_factor**2)
|
| 42 |
+
)
|
| 43 |
+
self.image_token_id = config.image_token_id
|
| 44 |
+
self.post_init()
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
__all__ = ["UltraVBertModel"]
|
modules.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
{
|
| 3 |
+
"idx": 0,
|
| 4 |
+
"name": "0",
|
| 5 |
+
"path": "",
|
| 6 |
+
"type": "sentence_transformers.base.modules.transformer.Transformer"
|
| 7 |
+
},
|
| 8 |
+
{
|
| 9 |
+
"idx": 1,
|
| 10 |
+
"name": "1",
|
| 11 |
+
"path": "1_Dense",
|
| 12 |
+
"type": "sentence_transformers.base.modules.dense.Dense"
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"idx": 2,
|
| 16 |
+
"name": "2",
|
| 17 |
+
"path": "2_MultiVectorMask",
|
| 18 |
+
"type": "sentence_transformers.multi_vector_encoder.modules.multi_vector_mask.MultiVectorMask"
|
| 19 |
+
},
|
| 20 |
+
{
|
| 21 |
+
"idx": 3,
|
| 22 |
+
"name": "3",
|
| 23 |
+
"path": "3_Normalize",
|
| 24 |
+
"type": "sentence_transformers.base.modules.normalize.Normalize"
|
| 25 |
+
}
|
| 26 |
+
]
|
processor_config.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"image_processor": {
|
| 3 |
+
"auto_map": {
|
| 4 |
+
"AutoImageProcessor": "image_processing_ultravbert.UltraVBertImageProcessor"
|
| 5 |
+
},
|
| 6 |
+
"do_convert_rgb": true,
|
| 7 |
+
"do_image_splitting": true,
|
| 8 |
+
"do_normalize": true,
|
| 9 |
+
"do_pad": true,
|
| 10 |
+
"do_rescale": true,
|
| 11 |
+
"do_resize": true,
|
| 12 |
+
"image_mean": [
|
| 13 |
+
0.5,
|
| 14 |
+
0.5,
|
| 15 |
+
0.5
|
| 16 |
+
],
|
| 17 |
+
"image_processor_type": "UltraVBertImageProcessor",
|
| 18 |
+
"image_std": [
|
| 19 |
+
0.5,
|
| 20 |
+
0.5,
|
| 21 |
+
0.5
|
| 22 |
+
],
|
| 23 |
+
"max_image_size": {
|
| 24 |
+
"longest_edge": 512
|
| 25 |
+
},
|
| 26 |
+
"max_image_tiles": 27,
|
| 27 |
+
"resample": 1,
|
| 28 |
+
"rescale_factor": 0.00392156862745098,
|
| 29 |
+
"size": {
|
| 30 |
+
"longest_edge": 3072
|
| 31 |
+
}
|
| 32 |
+
},
|
| 33 |
+
"image_seq_len": 64,
|
| 34 |
+
"processor_class": "Idefics3Processor"
|
| 35 |
+
}
|
sentence_bert_config.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"transformer_task": "feature-extraction",
|
| 3 |
+
"modality_config": {
|
| 4 |
+
"text": {
|
| 5 |
+
"method": "forward",
|
| 6 |
+
"method_output_name": "last_hidden_state"
|
| 7 |
+
},
|
| 8 |
+
"image": {
|
| 9 |
+
"method": "forward",
|
| 10 |
+
"method_output_name": "last_hidden_state"
|
| 11 |
+
},
|
| 12 |
+
"message": {
|
| 13 |
+
"method": "forward",
|
| 14 |
+
"method_output_name": "last_hidden_state",
|
| 15 |
+
"format": "structured"
|
| 16 |
+
}
|
| 17 |
+
},
|
| 18 |
+
"module_output_name": "token_embeddings",
|
| 19 |
+
"processing_kwargs": {
|
| 20 |
+
"chat_template": {
|
| 21 |
+
"chat_template": "sentence_transformers"
|
| 22 |
+
}
|
| 23 |
+
}
|
| 24 |
+
}
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": false,
|
| 3 |
+
"backend": "tokenizers",
|
| 4 |
+
"bos_token": "<|endoftext|>",
|
| 5 |
+
"clean_up_tokenization_spaces": false,
|
| 6 |
+
"eos_token": "<|endoftext|>",
|
| 7 |
+
"errors": "replace",
|
| 8 |
+
"extra_special_tokens": [
|
| 9 |
+
"<fake_token_around_image>",
|
| 10 |
+
"<image>",
|
| 11 |
+
"<end_of_utterance>"
|
| 12 |
+
],
|
| 13 |
+
"is_local": true,
|
| 14 |
+
"local_files_only": true,
|
| 15 |
+
"mask_token": "<|mask|>",
|
| 16 |
+
"model_max_length": 32768,
|
| 17 |
+
"pad_token": "<|endoftext|>",
|
| 18 |
+
"processor_class": "Idefics3Processor",
|
| 19 |
+
"sep_token": "<|sep|>",
|
| 20 |
+
"tokenizer_class": "GPT2Tokenizer",
|
| 21 |
+
"unk_token": "<|endoftext|>",
|
| 22 |
+
"vocab_size": 49152
|
| 23 |
+
}
|