This is a
W4A16 quantized version of
TomoroAI/tomoro-colqwen3-embed-8b, a state-of-the-art
ColPali-style multimodal embedding model. The quantization was performed using
AutoRound with AutoAWQ backend.
1pip install torch==2.8.0 torchvision==0.23.0 --index-url https://download.pytorch.org/whl/cu128
2pip install auto-round==0.9.2
3pip install autoawq==0.2.9
4pip install transformers pillow requests
5pip install flash-attn --no-build-isolation # Optional but recommended
1import torch
2from transformers import AutoModel, AutoProcessor
3from PIL import Image
4import requests
5from io import BytesIO
6
7# Configuration
8MODEL_ID = "TomoroAI/tomoro-ai-colqwen3-embed-8b-awq"
9DTYPE = torch.bfloat16
10DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
11
12# Load Model & Processor
13processor = AutoProcessor.from_pretrained(
14 MODEL_ID,
15 trust_remote_code=True,
16 max_num_visual_tokens=1280,
17)
18model = AutoModel.from_pretrained(
19 MODEL_ID,
20 dtype=DTYPE,
21 attn_implementation="sdpa", # Use "flash_attention_2" if available
22 trust_remote_code=True,
23 device_map=DEVICE,
24).eval()
25
26# Sample queries and documents
27queries = [
28 "Retrieve the city of Singapore",
29 "Retrieve the city of Beijing",
30]
31doc_urls = [
32 "https://upload.wikimedia.org/wikipedia/commons/2/27/Singapore_skyline_2022.jpg",
33 "https://upload.wikimedia.org/wikipedia/commons/6/61/Beijing_skyline_at_night.JPG",
34]
35
36def load_image(url: str) -> Image.Image:
37 headers = {"User-Agent": "Mozilla/5.0"}
38 resp = requests.get(url, headers=headers, timeout=10)
39 resp.raise_for_status()
40 return Image.open(BytesIO(resp.content)).convert("RGB")
41
42def encode_queries(texts):
43 batch = processor.process_texts(texts=texts)
44 batch = {k: v.to(DEVICE) for k, v in batch.items()}
45 with torch.inference_mode():
46 out = model(**batch)
47 return out.embeddings.to(torch.bfloat16).cpu()
48
49def encode_docs(urls):
50 images = [load_image(url) for url in urls]
51 features = processor.process_images(images=images)
52 features = {k: v.to(DEVICE) if isinstance(v, torch.Tensor) else v for k, v in features.items()}
53 with torch.inference_mode():
54 out = model(**features)
55 return out.embeddings.to(torch.bfloat16).cpu()
56
57# Encode and score
58query_embeddings = encode_queries(queries)
59doc_embeddings = encode_docs(doc_urls)
60scores = processor.score_multi_vector(query_embeddings, doc_embeddings)
61print(scores)
This model is released under the
Apache 2.0 License, consistent with the original model.
If you use this model, please cite both the original model and this quantized version:
1@misc{huang2025beyond,
2 author = {Huang, Xin and Tan, Kye Min},
3 title = {Beyond Text: Unlocking True Multimodal, End-to-end RAG with Tomoro ColQwen3},
4 year = {2025},
5 url = {https://tomoro.ai/insights/beyond-text-unlocking-true-multimodal-end-to-end-rag-with-tomoro-colqwen3},
6 publisher = {Tomoro.ai}
7}
8
9@misc{autoround,
10 author = {Intel Corporation},
11 title = {AutoRound: Advanced Weight-Only Quantization Algorithm},
12 year = {2024},
13 url = {https://github.com/intel/auto-round}
14}