iqd2rad 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- iqd2rad-0.1.0/.gitignore +49 -0
- iqd2rad-0.1.0/CITATION.cff +12 -0
- iqd2rad-0.1.0/LICENSE +201 -0
- iqd2rad-0.1.0/NOTICE +10 -0
- iqd2rad-0.1.0/PKG-INFO +242 -0
- iqd2rad-0.1.0/README.md +210 -0
- iqd2rad-0.1.0/configs/data/activitynet_test.json +9 -0
- iqd2rad-0.1.0/configs/data/activitynet_train.json +9 -0
- iqd2rad-0.1.0/configs/data/didemo_test.json +9 -0
- iqd2rad-0.1.0/configs/data/flickr30k_test.json +12 -0
- iqd2rad-0.1.0/configs/data/flickr30k_train.json +9 -0
- iqd2rad-0.1.0/configs/data/mscoco_1k.json +8 -0
- iqd2rad-0.1.0/configs/data/mscoco_5k.json +10 -0
- iqd2rad-0.1.0/configs/data/mscoco_train.json +13 -0
- iqd2rad-0.1.0/configs/data/msrvtt_test.json +11 -0
- iqd2rad-0.1.0/configs/data/msrvtt_train.json +11 -0
- iqd2rad-0.1.0/configs/data/msvd_test.json +9 -0
- iqd2rad-0.1.0/configs/data/splits/msrvtt_provenance.json +19 -0
- iqd2rad-0.1.0/configs/data/splits/msrvtt_test_ids.txt +1000 -0
- iqd2rad-0.1.0/configs/data/splits/msrvtt_train_ids.txt +7010 -0
- iqd2rad-0.1.0/configs/data/visualnews_test.json +8 -0
- iqd2rad-0.1.0/configs/eval/activitynet_test.json +21 -0
- iqd2rad-0.1.0/configs/eval/didemo_test.json +21 -0
- iqd2rad-0.1.0/configs/eval/flickr30k_test.json +21 -0
- iqd2rad-0.1.0/configs/eval/mscoco_1k.json +21 -0
- iqd2rad-0.1.0/configs/eval/mscoco_5k.json +21 -0
- iqd2rad-0.1.0/configs/eval/msrvtt_test.json +21 -0
- iqd2rad-0.1.0/configs/eval/msvd_test.json +21 -0
- iqd2rad-0.1.0/configs/eval/visualnews_test.json +21 -0
- iqd2rad-0.1.0/configs/iqd/clip_mscoco.json +16 -0
- iqd2rad-0.1.0/configs/iqd/clip_msrvtt.json +18 -0
- iqd2rad-0.1.0/configs/iqd/qwen_mscoco.json +16 -0
- iqd2rad-0.1.0/configs/iqd/qwen_msrvtt.json +16 -0
- iqd2rad-0.1.0/configs/qwen/image_a.json +54 -0
- iqd2rad-0.1.0/configs/qwen/image_b.json +54 -0
- iqd2rad-0.1.0/configs/qwen/image_c.json +54 -0
- iqd2rad-0.1.0/configs/qwen/image_d.json +54 -0
- iqd2rad-0.1.0/configs/qwen/image_d_8bit.json +52 -0
- iqd2rad-0.1.0/configs/qwen/image_e.json +54 -0
- iqd2rad-0.1.0/configs/qwen/image_e_8bit.json +52 -0
- iqd2rad-0.1.0/configs/qwen/image_f.json +54 -0
- iqd2rad-0.1.0/configs/qwen/video_a.json +54 -0
- iqd2rad-0.1.0/configs/qwen/video_b.json +54 -0
- iqd2rad-0.1.0/configs/qwen/video_c.json +54 -0
- iqd2rad-0.1.0/configs/qwen/video_d.json +54 -0
- iqd2rad-0.1.0/configs/qwen/video_e.json +54 -0
- iqd2rad-0.1.0/configs/qwen/video_f.json +54 -0
- iqd2rad-0.1.0/docs/assets/iqd-analysis.png +0 -0
- iqd2rad-0.1.0/docs/assets/teaser.png +0 -0
- iqd2rad-0.1.0/docs/data.md +183 -0
- iqd2rad-0.1.0/docs/environment.md +54 -0
- iqd2rad-0.1.0/docs/evaluation.md +106 -0
- iqd2rad-0.1.0/docs/iqd.md +145 -0
- iqd2rad-0.1.0/docs/training.md +223 -0
- iqd2rad-0.1.0/examples/make_toy_embeddings.py +24 -0
- iqd2rad-0.1.0/pyproject.toml +54 -0
- iqd2rad-0.1.0/src/iqd2rad/__init__.py +3 -0
- iqd2rad-0.1.0/src/iqd2rad/analysis/__init__.py +5 -0
- iqd2rad-0.1.0/src/iqd2rad/analysis/cli.py +109 -0
- iqd2rad-0.1.0/src/iqd2rad/analysis/core.py +314 -0
- iqd2rad-0.1.0/src/iqd2rad/analysis/plotting.py +42 -0
- iqd2rad-0.1.0/src/iqd2rad/data/__init__.py +6 -0
- iqd2rad-0.1.0/src/iqd2rad/data/cli.py +75 -0
- iqd2rad-0.1.0/src/iqd2rad/data/frames.py +51 -0
- iqd2rad-0.1.0/src/iqd2rad/data/manifests.py +115 -0
- iqd2rad-0.1.0/src/iqd2rad/data/prepare.py +432 -0
- iqd2rad-0.1.0/src/iqd2rad/evaluation/__init__.py +5 -0
- iqd2rad-0.1.0/src/iqd2rad/evaluation/cli.py +44 -0
- iqd2rad-0.1.0/src/iqd2rad/evaluation/core.py +193 -0
- iqd2rad-0.1.0/src/iqd2rad/models/__init__.py +1 -0
- iqd2rad-0.1.0/src/iqd2rad/models/encode.py +124 -0
- iqd2rad-0.1.0/src/iqd2rad/models/qwen.py +269 -0
- iqd2rad-0.1.0/src/iqd2rad/training/__init__.py +1 -0
- iqd2rad-0.1.0/src/iqd2rad/training/cli.py +43 -0
- iqd2rad-0.1.0/src/iqd2rad/training/config.py +110 -0
- iqd2rad-0.1.0/src/iqd2rad/training/data.py +89 -0
- iqd2rad-0.1.0/src/iqd2rad/training/loss.py +127 -0
- iqd2rad-0.1.0/src/iqd2rad/training/trainer.py +313 -0
- iqd2rad-0.1.0/tests/test_data_prepare.py +284 -0
- iqd2rad-0.1.0/tests/test_encoding.py +131 -0
- iqd2rad-0.1.0/tests/test_evaluation_protocol.py +98 -0
- iqd2rad-0.1.0/tests/test_iqd.py +168 -0
- iqd2rad-0.1.0/tests/test_qwen_backbone.py +73 -0
- iqd2rad-0.1.0/tests/test_training_config_data.py +93 -0
- iqd2rad-0.1.0/tests/test_training_forward.py +269 -0
- iqd2rad-0.1.0/tests/test_training_loss.py +129 -0
- iqd2rad-0.1.0/uv.lock +1507 -0
iqd2rad-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Local environments and credentials
|
|
2
|
+
.venv/
|
|
3
|
+
.venv-*/
|
|
4
|
+
venv/
|
|
5
|
+
.env
|
|
6
|
+
.env.*
|
|
7
|
+
!.env.example
|
|
8
|
+
*cookies*.txt
|
|
9
|
+
*.pem
|
|
10
|
+
*.key
|
|
11
|
+
.DS_Store
|
|
12
|
+
|
|
13
|
+
# Python build and cache files
|
|
14
|
+
__pycache__/
|
|
15
|
+
*.py[cod]
|
|
16
|
+
*.egg-info/
|
|
17
|
+
build/
|
|
18
|
+
dist/
|
|
19
|
+
.pytest_cache/
|
|
20
|
+
.ruff_cache/
|
|
21
|
+
|
|
22
|
+
# Local data, weights, and generated experiment outputs
|
|
23
|
+
data/raw/
|
|
24
|
+
data/processed/
|
|
25
|
+
data/prepared/
|
|
26
|
+
metadata/
|
|
27
|
+
checkpoints/
|
|
28
|
+
outputs/
|
|
29
|
+
artifacts/
|
|
30
|
+
logs/
|
|
31
|
+
wandb/
|
|
32
|
+
.cache/
|
|
33
|
+
*.safetensors
|
|
34
|
+
*.pt
|
|
35
|
+
*.pth
|
|
36
|
+
*.ckpt
|
|
37
|
+
*.npy
|
|
38
|
+
*.npz
|
|
39
|
+
pytorch_model*.bin
|
|
40
|
+
adapter_model.bin
|
|
41
|
+
|
|
42
|
+
# Local editor and agent state
|
|
43
|
+
.idea/
|
|
44
|
+
.vscode/
|
|
45
|
+
.claude/
|
|
46
|
+
.cursor/
|
|
47
|
+
|
|
48
|
+
# Project page is maintained separately from the code release
|
|
49
|
+
/webpage/
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
message: "Please cite the accompanying paper, accepted at TMLR, when using this software. BibTeX will be added once the final camera-ready citation metadata is available."
|
|
3
|
+
title: "IQD2RAD: Intrinsic Quantization Difficulty and Ranking-Aware Distillation"
|
|
4
|
+
type: software
|
|
5
|
+
version: 0.1.0
|
|
6
|
+
license: Apache-2.0
|
|
7
|
+
repository-code: "https://github.com/froyohunter/iqd2rad"
|
|
8
|
+
authors:
|
|
9
|
+
- family-names: Chen
|
|
10
|
+
given-names: Leiyue
|
|
11
|
+
- family-names: Chen
|
|
12
|
+
given-names: Hao
|
iqd2rad-0.1.0/LICENSE
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 [2026] [Tongyi Lab, Alibaba Group]
|
|
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.
|
iqd2rad-0.1.0/NOTICE
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
IQD2RAD includes adapted Qwen3-VL-Embedding model and preprocessing code from
|
|
2
|
+
https://github.com/QwenLM/Qwen3-VL-Embedding
|
|
3
|
+
Copyright Tongyi Lab, Alibaba Group, licensed under the Apache License 2.0.
|
|
4
|
+
The upstream license and copyright notice are preserved in LICENSE.
|
|
5
|
+
|
|
6
|
+
The Qwen integration has been adapted for explicit base/adapter loading,
|
|
7
|
+
public manifest inputs, differentiable encoding, and fail-fast preprocessing.
|
|
8
|
+
The IQD analysis and RAD training components accompany the paper
|
|
9
|
+
"From Intrinsic Quantization Difficulty to Ranking-Aware Distillation for
|
|
10
|
+
Low-Bit Multimodal Retrieval" by Leiyue Chen and Hao Chen.
|
iqd2rad-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: iqd2rad
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Intrinsic Quantization Difficulty analysis and Ranking-Aware Distillation for multimodal retrieval
|
|
5
|
+
Project-URL: Repository, https://github.com/froyohunter/iqd2rad
|
|
6
|
+
Project-URL: Paper, https://openreview.net/pdf?id=4h8YJsubM1
|
|
7
|
+
License-Expression: Apache-2.0
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
License-File: NOTICE
|
|
10
|
+
Requires-Python: <3.13,>=3.11
|
|
11
|
+
Requires-Dist: numpy<2,>=1.26
|
|
12
|
+
Requires-Dist: scipy<2,>=1.11
|
|
13
|
+
Provides-Extra: analysis
|
|
14
|
+
Requires-Dist: matplotlib<4,>=3.8; extra == 'analysis'
|
|
15
|
+
Provides-Extra: dev
|
|
16
|
+
Requires-Dist: pytest<9,>=8.3; extra == 'dev'
|
|
17
|
+
Requires-Dist: ruff<1,>=0.11; extra == 'dev'
|
|
18
|
+
Provides-Extra: train
|
|
19
|
+
Requires-Dist: accelerate<2,>=1.0; extra == 'train'
|
|
20
|
+
Requires-Dist: av<17,>=14; extra == 'train'
|
|
21
|
+
Requires-Dist: huggingface-hub==0.36.2; extra == 'train'
|
|
22
|
+
Requires-Dist: peft==0.19.1; extra == 'train'
|
|
23
|
+
Requires-Dist: pillow<12,>=10; extra == 'train'
|
|
24
|
+
Requires-Dist: qwen-vl-utils==0.0.14; extra == 'train'
|
|
25
|
+
Requires-Dist: safetensors<1,>=0.5; extra == 'train'
|
|
26
|
+
Requires-Dist: torch==2.7.1; extra == 'train'
|
|
27
|
+
Requires-Dist: torchvision==0.22.1; extra == 'train'
|
|
28
|
+
Requires-Dist: transformers==4.57.1; extra == 'train'
|
|
29
|
+
Provides-Extra: wandb
|
|
30
|
+
Requires-Dist: wandb<1,>=0.19; extra == 'wandb'
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
# IQD2RAD
|
|
34
|
+
|
|
35
|
+
**From Intrinsic Quantization Difficulty to
|
|
36
|
+
Ranking-Aware Distillation for Low-Bit Multimodal Retrieval**
|
|
37
|
+
|
|
38
|
+
**Accepted at TMLR.**
|
|
39
|
+
|
|
40
|
+
[Leiyue Chen](mailto:leiyue.ml@gmail.com) ·
|
|
41
|
+
[Hao Chen](mailto:haochen.umd@gmail.com)<sup>†</sup>
|
|
42
|
+
|
|
43
|
+
<sup>†</sup> Corresponding author.
|
|
44
|
+
|
|
45
|
+
[Paper](https://openreview.net/pdf?id=4h8YJsubM1) ·
|
|
46
|
+
[Project Page](https://froyohunter.github.io/iqd2rad/)
|
|
47
|
+
|
|
48
|
+

|
|
49
|
+
|
|
50
|
+
**Storage–quality–speed trade-off.** ODARD (RAD with online difficulty weighting)
|
|
51
|
+
preserves retrieval quality with compact embeddings on MSR-VTT and MSVD.
|
|
52
|
+
Search speedups shown here use the paper's pinned FAISS 1.13.2 CPU setup;
|
|
53
|
+
see the paper for the full measurement protocol.
|
|
54
|
+
|
|
55
|
+
IQD measures how quantization changes retrieval rankings for individual samples.
|
|
56
|
+
RAD preserves ranking structure by distilling similarity distributions from the
|
|
57
|
+
float branch into low-bit branches. Online difficulty weighting provides an
|
|
58
|
+
optional, dataset-dependent extension.
|
|
59
|
+
|
|
60
|
+
This repository provides the Qwen3-VL-Embedding-2B reference training recipes,
|
|
61
|
+
an independent IQD analyzer, and data preparation and evaluation tools for the
|
|
62
|
+
paper's image and video settings.
|
|
63
|
+
|
|
64
|
+
The implementation quantizes **output embeddings**, not the backbone's model
|
|
65
|
+
weights. A trained adapter can be evaluated at several dimensions and bit widths.
|
|
66
|
+
The analyzer also accepts embeddings exported from other models.
|
|
67
|
+
|
|
68
|
+
## IQD analysis
|
|
69
|
+
|
|
70
|
+

|
|
71
|
+
|
|
72
|
+
**IQD is real but emergent.** Samples stratified by the online loss gap show
|
|
73
|
+
recall drops from 2.7% (easy) to 57.4% (hard), a 21.3× disparity
|
|
74
|
+
(Qwen3-VL, MSR-VTT, 128 dimensions, 2-bit).
|
|
75
|
+
Use the [independent IQD analyzer](https://github.com/froyohunter/iqd2rad/blob/main/docs/iqd.md) with your own embeddings,
|
|
76
|
+
or start with the [synthetic example below](#try-the-analyzer-without-a-model-or-dataset).
|
|
77
|
+
|
|
78
|
+
## Install
|
|
79
|
+
|
|
80
|
+
Use Python 3.11 or 3.12 in a separate environment. Install the package with pip:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
python -m pip install iqd2rad
|
|
84
|
+
# Optional plotting dependencies:
|
|
85
|
+
python -m pip install 'iqd2rad[analysis]'
|
|
86
|
+
# Qwen encoding and training dependencies:
|
|
87
|
+
python -m pip install 'iqd2rad[train]'
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
The configuration recipes and example scripts below live in the repository.
|
|
91
|
+
To use them, clone the repository and work from its root:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
git clone https://github.com/froyohunter/iqd2rad.git
|
|
95
|
+
cd iqd2rad
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
For the locked reference environment, install
|
|
99
|
+
[uv](https://docs.astral.sh/uv/getting-started/installation/) (tested with 0.10.4),
|
|
100
|
+
then synchronize from the committed dependency lock:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
uv sync --locked --python 3.11 --extra analysis --extra dev
|
|
104
|
+
source .venv/bin/activate
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
The core analyzer/evaluator need only NumPy and SciPy; plots use the `analysis`
|
|
108
|
+
extra. For Qwen encoding and training, additionally install:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
uv sync --locked --extra analysis --extra dev --extra train
|
|
112
|
+
# Optional public Weights & Biases logging:
|
|
113
|
+
uv sync --locked --extra analysis --extra dev --extra train --extra wandb
|
|
114
|
+
wandb login
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
The lock records the release's direct and transitive package versions.
|
|
118
|
+
See [environment provenance](https://github.com/froyohunter/iqd2rad/blob/main/docs/environment.md) for the relationship to the
|
|
119
|
+
reference checkpoints, and [training setup](https://github.com/froyohunter/iqd2rad/blob/main/docs/training.md) for CUDA,
|
|
120
|
+
Flash Attention and SDPA options.
|
|
121
|
+
W&B logging is enabled by setting `wandb_project` in the training configuration.
|
|
122
|
+
|
|
123
|
+
## Try the analyzer without a model or dataset
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
python examples/make_toy_embeddings.py --output outputs/toy.npz
|
|
127
|
+
iqd2rad-iqd --embeddings outputs/toy.npz --output-dir outputs/toy-iqd \
|
|
128
|
+
--dims 8,16 --bits 1,2,4,8 --k 5 --plots
|
|
129
|
+
iqd2rad-evaluate --embeddings outputs/toy.npz --output outputs/toy-eval.json \
|
|
130
|
+
--dims 8 16 --backends float sign sq2 sq4 sq8
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
This is a synthetic smoke example, not a paper result.
|
|
134
|
+
|
|
135
|
+
## Encode and evaluate your prepared data
|
|
136
|
+
|
|
137
|
+
[Data preparation](https://github.com/froyohunter/iqd2rad/blob/main/docs/data.md) documents supported annotation formats and
|
|
138
|
+
explicit split/query selection. Supply your own raw images/videos or extracted
|
|
139
|
+
frames from the dataset providers, then prepare manifests with the supplied recipes:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
iqd2rad-data prepare --config configs/data/msrvtt_train.json \
|
|
143
|
+
--annotations /path/to/MSRVTT_train.7k.csv --raw-root /path/to/media
|
|
144
|
+
iqd2rad-data prepare --config configs/data/mscoco_1k.json \
|
|
145
|
+
--annotations /path/to/mscoco_mmeb_test.jsonl --raw-root /path/to/images
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
A retrieval dataset consists of `queries.jsonl` and `candidates.jsonl`;
|
|
149
|
+
queries name their `positive_ids`. Gallery alignment is never inferred from row
|
|
150
|
+
position. Visual evaluation candidates must not contain caption text.
|
|
151
|
+
The encoding archive stores raw embeddings; each analysis/evaluation protocol
|
|
152
|
+
performs normalization at its own specified stage.
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
iqd2rad-encode \
|
|
156
|
+
--queries /path/to/manifests/queries.jsonl \
|
|
157
|
+
--candidates /path/to/manifests/candidates.jsonl \
|
|
158
|
+
--data-root /path/to/raw-data \
|
|
159
|
+
--base-model Qwen/Qwen3-VL-Embedding-2B \
|
|
160
|
+
--revision BASE_MODEL_COMMIT \
|
|
161
|
+
--output outputs/embeddings.npz
|
|
162
|
+
|
|
163
|
+
iqd2rad-evaluate --embeddings outputs/embeddings.npz \
|
|
164
|
+
--dims 128 256 512 1024 2048 --backends float sign sq2 sq4 sq8 \
|
|
165
|
+
--output outputs/retrieval.json
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Use `--adapter /path/to/adapter` for a trained model. Set `--local-files-only`
|
|
169
|
+
explicitly for an offline installation. Keep the base-model revision alongside
|
|
170
|
+
every adapter and result.
|
|
171
|
+
|
|
172
|
+
## Three explicit quantization protocols
|
|
173
|
+
|
|
174
|
+
- **IQD measurement:** L2-normalize each vector, quantize on a fixed symmetric
|
|
175
|
+
`[-1, 1]` grid (sign for 1 bit), then normalize for similarity computation.
|
|
176
|
+
- **Training:** the fixed symmetric grid with the straight-through estimator,
|
|
177
|
+
using the main 2/4/8-bit branches.
|
|
178
|
+
- **Retrieval SQ:** fit per-channel affine ranges on the candidate index for each
|
|
179
|
+
dimensionality, freeze them, and transform queries and candidates with the
|
|
180
|
+
same ranges. Query vectors and relevance labels do not enter calibration.
|
|
181
|
+
|
|
182
|
+
These protocols are separate because they answer different experimental
|
|
183
|
+
questions. See [IQD analysis](https://github.com/froyohunter/iqd2rad/blob/main/docs/iqd.md) and [evaluation](https://github.com/froyohunter/iqd2rad/blob/main/docs/evaluation.md).
|
|
184
|
+
|
|
185
|
+
## Train the Qwen experiments
|
|
186
|
+
|
|
187
|
+
[Training](https://github.com/froyohunter/iqd2rad/blob/main/docs/training.md) documents the a–f configurations, manifest paths,
|
|
188
|
+
ordinary `torchrun` execution, attention backend and optional public W&B logging.
|
|
189
|
+
The two main recipes train on MSR-VTT and MSCOCO; the same manifest interface
|
|
190
|
+
supports the paper's Flickr30k and ActivityNet training data.
|
|
191
|
+
Separate image MSE/RAD configurations provide the optional 8-bit-only control;
|
|
192
|
+
the main recipes retain all three 2/4/8-bit training branches.
|
|
193
|
+
|
|
194
|
+
For example, launch the image RAD recipe on eight GPUs with SDPA:
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
torchrun --standalone --nproc_per_node=8 -m iqd2rad.training.cli \
|
|
198
|
+
--config configs/qwen/image_e.json \
|
|
199
|
+
--manifest data/prepared/mscoco_train/train.jsonl \
|
|
200
|
+
--data-root /path/to/images --output-dir outputs/image-rad \
|
|
201
|
+
--attn-implementation sdpa
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
The training guide records the reference settings, input convention, local
|
|
205
|
+
negative pool and multi-node launch instructions. Preparation recipes cover
|
|
206
|
+
MSR-VTT, MSCOCO (including Karpathy 5K), MSVD, DiDeMo, Flickr30k, ActivityNet
|
|
207
|
+
Captions and VisualNews. Keep split IDs, caption selection and frame policies
|
|
208
|
+
with your manifests when comparing settings.
|
|
209
|
+
|
|
210
|
+
## Development
|
|
211
|
+
|
|
212
|
+
Run the CPU algorithm and interface tests with:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
python -m pytest -q
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
We welcome extensions to new backbones, datasets and quantization settings.
|
|
219
|
+
The manifest and embedding interfaces are intended to make those explorations
|
|
220
|
+
straightforward; please describe the setting alongside any results you share.
|
|
221
|
+
|
|
222
|
+
## Attribution
|
|
223
|
+
|
|
224
|
+
The Qwen model wrapper and preprocessing derive from
|
|
225
|
+
[Qwen3-VL-Embedding](https://github.com/QwenLM/Qwen3-VL-Embedding).
|
|
226
|
+
See [LICENSE](https://github.com/froyohunter/iqd2rad/blob/main/LICENSE) and [NOTICE](https://github.com/froyohunter/iqd2rad/blob/main/NOTICE) for the retained upstream attribution.
|
|
227
|
+
|
|
228
|
+
## Citation
|
|
229
|
+
|
|
230
|
+
If you use this implementation, please cite the accompanying paper.
|
|
231
|
+
|
|
232
|
+
```bibtex
|
|
233
|
+
@article{chen2026from,
|
|
234
|
+
title={From Intrinsic Quantization Difficulty to Ranking-Aware Distillation for Low-Bit Multimodal Retrieval},
|
|
235
|
+
author={Leiyue Chen and Hao Chen},
|
|
236
|
+
journal={Transactions on Machine Learning Research},
|
|
237
|
+
issn={2835-8856},
|
|
238
|
+
year={2026},
|
|
239
|
+
url={https://openreview.net/forum?id=4h8YJsubM1},
|
|
240
|
+
note={}
|
|
241
|
+
}
|
|
242
|
+
```
|