WeMM-Embedding-9B 是基于 Qwen3.5 构建的通用多模态嵌入模型。它支持文本、图像、视频、视觉文档和交错式多模态输入,并返回 4,096 维的 L2 归一化嵌入。不支持音频输入。
pip install torch transformers==5.2.0 "qwen-vl-utils[decord]==0.0.14" \
"sentence-transformers>=5.7.0" "accelerate>=1.1.0"import torch
from qwen_vl_utils import process_vision_info
from transformers import AutoModel, AutoProcessor
model_id = "tencent/WeMM-Embedding-9B"
processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
model = AutoModel.from_pretrained(
model_id, trust_remote_code=True, dtype=torch.bfloat16
).cuda().eval()
messages = [{"role": "user", "content": [
{"type": "image", "image": "/path/to/image.jpg"},
{"type": "video", "video": "/path/to/video.mp4"},
{"type": "text", "text": "This can be any text input."},
]}]
text = processor.apply_chat_template(
messages, tokenize=False, add_generation_prompt=False
)
images, videos, video_kwargs = process_vision_info(
messages,
image_patch_size=16,
return_video_kwargs=True,
return_video_metadata=True,
)
if videos is not None:
videos, video_metadata = zip(*videos)
videos, video_metadata = list(videos), list(video_metadata)
else:
video_metadata = None
inputs = processor(
text=text,
images=images,
videos=videos,
video_metadata=video_metadata,
return_tensors="pt",
**video_kwargs,
).to("cuda")
with torch.inference_mode():
embedding = model.embedding(**inputs)使用内容项中的任意子集,独立编码文本、图像或视频。
from sentence_transformers import SentenceTransformer
model_id = "tencent/WeMM-Embedding-9B"
model = SentenceTransformer(model_id, trust_remote_code=True)
queries = [
"Which Llama 4 model variants are available?",
"How is mapo tofu prepared?",
]
documents = [
"Mapo tofu is a Sichuan dish of soft tofu simmered in a spicy, numbing sauce of chili bean paste and Sichuan peppercorn.",
{
"image": "https://huggingface.co/datasets/sentence-transformers/example-documents/resolve/main/llama4_hgf.png",
"text": "Represent this image.",
},
{
"video": "https://huggingface.co/datasets/sentence-transformers/example-documents/resolve/main/mapo_tofu.mp4",
"text": "Represent this video.",
},
]
query_embeddings = model.encode_query(queries)
document_embeddings = model.encode_document(documents)
print(query_embeddings.shape, document_embeddings.shape)
# (2, 4096) (3, 4096)
similarities = model.similarity(query_embeddings, document_embeddings)
print(similarities)
# tensor([[0.2153, 0.5843, 0.1221],
# [0.7665, 0.2604, 0.5366]])每条输入均为字符串、URL 或路径、PIL.Image,或一个同时包含 image、
video 和 text 键的字典。请将 image 或 video 放在 text 之前,使提示词
与上述顺序保持一致。聊天消息,例如
{"role": "user", "content": [{"type": "image", "image": ...}, {"type": "text", "text": ...}]}
也受支持,这是在同一条输入中交错放置多张图片或多个视频的方式。
d = 256
embedding_d = torch.nn.functional.normalize(embedding[..., :d], dim=-1)当使用 Sentence Transformers 时,传入 truncate_dim,由其完成重新归一化:
embeddings_d = model.encode_document(documents, truncate_dim=d, normalize_embeddings=True)使用 model.config.matryoshka_dimensions 中列出的维度。
vLLM 0.27.0:
MODEL_PATH=/path/to/WeMM-Embedding-9B
vllm serve "$MODEL_PATH" \
--runner pooling \
--chat-template "$MODEL_PATH/embedding_chat_template.jinja"SGLang 0.5.9:
MODEL_PATH=/path/to/WeMM-Embedding-9B
python patch_sglang_video.py
python -m sglang.launch_server \
--model-path "$MODEL_PATH" \
--is-embedding \
--enable-precise-embedding-interpolation技术报告表 1 中 78 个数据集的结果。图像和视频任务采用 Hit@1,视觉文档任务采用 NDCG@5。越高越好。
| 模型 | 规模 | 平均 | 图像 | 视频 | 视觉文档 |
|---|---|---|---|---|---|
| VLM2Vec | 2B | 47.8 | 59.7 | 29.0 | 44.0 |
| GME | 2B | 55.4 | 51.9 | 33.9 | 76.8 |
| VLM2Vec-V2 | 2B | 59.3 | 64.9 | 34.9 | 69.2 |
| Qwen3-VL-Embedding | 2B | 73.2 | 75.0 | 61.9 | 79.2 |
| DME-Small† | 2B | 74.8 | 75.9 | 65.6 | 79.9 |
| WeMM-Embedding | 2B | 77.9 | 79.6 | 70.8 | 80.7 |
| WeMM-Embedding | 4B | 79.2 | 80.8 | 72.1 | 82.0 |
| VLM2Vec | 8B | 53.2 | 65.5 | 34.0 | 49.1 |
| GME | 8B | 59.2 | 56.0 | 38.6 | 79.3 |
| Qwen3-VL-Embedding | 8B | 77.8 | 80.1 | 67.1 | 82.4 |
| DME-Medium† | 9B | 78.4 | 79.8 | 70.8 | 82.0 |
| WeMM-Embedding | 9B | 80.6 | 81.9 | 74.3 | 83.3 |
† 闭源排行榜提交,未公开模型权重,也未提供公开推理端点。
技术报告表 2 中全部 190 个任务的结果。V3-All 包含 78 个 MMEB-v2 任务、53 个文本任务、47 个智能体任务、11 个音频任务以及 MCMR。不支持的任务记 0 分。
| 模型 | 规模 | V3-All | 文本 | 智能体 | MCMR | 音频 |
|---|---|---|---|---|---|---|
| VLM2Vec-V2 | 2B | 38.3 | 24.5 | 28.7 | 4.1 | 0.0 |
| Omni-Embed-Nemotron | 3B | 43.5 | 39.2 | 36.5 | 26.1 | 36.5 |
| E5-Omni | 3B | 44.6 | 26.7 | 36.9 | 31.9 | 30.8 |
| Qwen3-VL-Embedding | 2B | 50.9 | 39.2 | 39.3 | 42.0 | 0.0 |
| WeMM-Embedding | 2B | 56.0 | 45.3 | 45.1 | 42.5 | 0.0 |
| WeMM-Embedding | 4B | 58.2 | 47.9 | 49.0 | 41.9 | 0.0 |
| WAVE | 7B | 26.3 | 13.7 | 11.3 | 8.9 | 31.8 |
| VLM2Vec | 8B | 32.9 | 22.2 | 19.7 | 0.9 | 0.0 |
| LCO-Embedding-Omni | 7B | 40.6 | 32.4 | 27.8 | 20.0 | 43.2 |
| GME | 8B | 43.6 | 37.1 | 35.6 | 27.3 | 0.0 |
| E5-Omni | 7B | 47.1 | 26.9 | 36.7 | 41.1 | 43.0 |
| Tianmu-Emb-Uni | 8B | 53.3 | 43.6 | 39.4 | 38.8 | 38.9 |
| Qwen3-VL-Embedding | 8B | 53.5 | 42.5 | 38.4 | 38.0 | 0.0 |
| WeMM-Embedding | 9B | 59.5 | 48.8 | 51.0 | 49.3 | 0.0 |
文本结果采用 NDCG@5;智能体、MCMR 和音频结果采用 Hit@1。
如果您觉得本仓库对您有帮助,请考虑给予 star ⭐ 并引用本项目。
@article{wemm-embedding,
title={WeMM-Embedding: WeChat Multi-Modal Embedding Technical Report},
author={Junjie Zhou and Ke Mei and Lei Li and Tianyi Wang and Fengyun Rao and Jing Lyu},
year={2026},
eprint={2608.24053},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2608.24053},
}由腾讯公开发布的 WeMM-Embedding-9B,包括代码、模型参数和权重,均依据 Apache License 2.0 许可证授权。
第三方组件仍受其各自原始许可证约束。