Views
No views yet

| Method | Tokens | R@10 | nDCG@10 |
|---|---|---|---|
| SeqResize | 64 | 41.1 | 38.5 |
| MemTok (this model) | 64 | 48.7 | 44.8 |
| H-Pool | 64 | 49.2 | 46.5 |
| AGC | 64 | 49.6 | 46.3 |
| Initial weights | Qwen2.5-Omni-3B-Instruct (thinker) |
| Architecture | Qwen2.5-Omni (thinker) with bidirectional attention |
| Hidden dimension | 2048 |
| Compression method | MemTok (memory tokens) |
| Memory tokens | 64 learned tokens (<|mem0|> – <|mem63|>) appended to document |
| Default budget | 64 vectors per document |
| Scoring | ColBERT-style MaxSim (late interaction) |
| Normalization | L2-normalized embeddings |
| Query prefix | "Query: " |
| Passage prefix | "Passage: " |
| Precision | bfloat16 |
| Training video frames | 24 |
| Audio sampling rate | 4KHz |
1import torch
2from transformers import AutoProcessor
3from qwen_omni_utils import process_mm_info
4
5from src.arguments import ModelArguments
6from src.encoder.multivec_encoder import MultiVecEncoder
7from src.models.qwen2_5_omni_embed.qwen2_5_omni_embed import Qwen2_5OmniForEmbedding
8from src.utils import get_appending_token_strings
9
10MODEL_ID = "PLACEHOLDER"
11VIDEO_PATH = "PLACEHOLDER"
12AUDIO_PATH = "PLACEHOLDER"
13NUM_MEMORY_TOKENS = 64
14APPENDING_SUFFIX = "".join(get_appending_token_strings(NUM_MEMORY_TOKENS))
15
16# --- Setup ---
17model_args = ModelArguments(
18 model_name_or_path=MODEL_ID,
19 pooling="memory",
20 normalize=True,
21 num_appending_token=NUM_MEMORY_TOKENS,
22 use_parametric_appending_tokens=True,
23 attn_implementation="flash_attention_2",
24)
25
26processor = AutoProcessor.from_pretrained(MODEL_ID)
27model = MultiVecEncoder.load(
28 Qwen2_5OmniForEmbedding,
29 model_args,
30 attn_implementation=model_args.attn_implementation,
31 dtype=torch.bfloat16,
32)
33model = model.to("cuda").eval()
34
35# --- Encode a video+audio document ---
36passage_messages = [
37 {
38 "role": "user",
39 "content": [
40 {"type": "text", "text": "Passage: "},
41 {"type": "video", "video": VIDEO_PATH, "nframes": 24, "max_pixels": 75264, "min_pixels": 65856},
42 {"type": "audio", "audio": AUDIO_PATH},
43 ],
44 }
45]
46text = processor.apply_chat_template(passage_messages, tokenize=False, add_generation_prompt=False)
47text += APPENDING_SUFFIX
48audio_inputs, image_inputs, video_inputs = process_mm_info([passage_messages], use_audio_in_video=False)
49passage_inputs = processor(
50 text=[text], images=image_inputs, videos=video_inputs, audio=audio_inputs, padding=True, return_tensors="pt",
51).to("cuda")
52
53with torch.amp.autocast(device_type="cuda", dtype=torch.bfloat16):
54 with torch.inference_mode():
55 doc_embeddings, doc_mask = model.encode(passage_inputs, is_query=False)
56 print(doc_embeddings.shape)
57 # doc_embeddings: (1, 64, 2048) — 64 MemTok vectors
58
59# --- Encode a text query ---
60query_messages = [{"role": "user", "content": [{"type": "text", "text": "Query: a person is cooking"}]}]
61query_text = processor.apply_chat_template(query_messages, tokenize=False, add_generation_prompt=False)
62query_inputs = processor(text=[query_text], padding=True, return_tensors="pt").to("cuda")
63
64with torch.amp.autocast(device_type="cuda", dtype=torch.bfloat16):
65 with torch.inference_mode():
66 query_embeddings, query_mask = model.encode(query_inputs, is_query=True)
67 print(query_embeddings.shape)
68
69# --- ColBERT MaxSim scoring ---
70score = model.compute_similarity(query_embeddings, doc_embeddings, query_mask, doc_mask)
71print(f"Similarity score: {score.item():.4f}")1@misc{qin2026multivectorindexcompressionmodality,
2 title={Multi-Vector Index Compression in Any Modality},
3 author={Hanxiang Qin and Alexander Martin and Rohan Jha and Chunsheng Zuo and Reno Kriz and Benjamin Van Durme},
4 year={2026},
5 eprint={2602.21202},
6 archivePrefix={arXiv},
7 primaryClass={cs.IR},
8 url={https://arxiv.org/abs/2602.21202},
9}