Inference code is provided in the
GitHub repository. Set
pooling="last.normal" for dense embeddings or
pooling="splade.last" for sparse embeddings.
1import torch
2from src.models.qwen35_embedding import Qwen35Embedder
3
4model = Qwen35Embedder(
5 model_name_or_path="./models/UEmbed-2B",
6 torch_dtype=torch.bfloat16,
7 # flash_attention_2 for better acceleration and memory saving
8 attn_implementation="flash_attention_2",
9)
10
11inputs = [{
12 "text": "A woman playing with her dog on a beach at sunset.",
13 "instruction": "Retrieve images or text relevant to the user's query.",
14}, {
15 "text": "A woman shares a joyful moment with her golden retriever on a sun-drenched beach at sunset, as the dog offers its paw in a heartwarming display of companionship and trust."
16}, {
17 "image": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg"
18}, {
19 "text": "A woman shares a joyful moment with her golden retriever on a sun-drenched beach at sunset, as the dog offers its paw in a heartwarming display of companionship and trust.",
20 "image": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg"
21}]
22
23embeddings = model.process(inputs)
24print(embeddings @ embeddings.T)
For multimodal data, hard negatives are mined with Qwen3-VL-Embedding-8B as the teacher retriever.
1@misc{uembed2026,
2 title={UEmbed: Unified Sparse and Dense Multimodal Embeddings},
3 author={Tingyu Song and Mingxin Li and Yanzhao Zhang and Dingkun Long and Pengjun Xie and Zhijie Nie and Yilun Zhao and Shu Wu},
4 year={2026},
5 eprint={2608.02583},
6 archivePrefix={arXiv},
7 primaryClass={cs.CV},
8 url={https://arxiv.org/abs/2608.02583},
9}
Thanks to the
Qwen3-VL-Embedding repo for the evaluation framework.