Views
No views yet
2025-4-13 🎉🎉 We have uploaded our MegaPairs dataset to 🤗Hugging Face, which contains over 26 million multimodal retrieval instruction-tuning triplets. To reduce upload time and enhance data accessibility, we resized all images to a resolution of 512 × 512 instead of using their original size. This adjustment has minimal impact on performance, considering that most vision-language models (e.g., CLIP) use even smaller input image sizes. Dataset Card2025-4-2 🌟🌟 BGE-VL models are also available on WiseModel.2025-3-6 📰📰 Thank you to SyncedTech (机器之心), QbitAI (量子位), and AI Era (新智元) for reporting on our work!2025-3-4 🚀🚀 We have released the BGE-VL-MLLM models on Huggingface: BGE-VL-MLLM-S1 and BGE-VL-MLLM-S2. BGE-VL-MLLM-S1 is trained exclusively on our MegaPairs dataset, achieving outstanding performance in composed image retrieval, with an 8.1% improvement on the CIRCO benchmark (mAP@5) over the previous state-of-the-art. BGE-VL-MLLM-S2 builds on BGE-VL-MLLM-S1 with an additional epoch of fine-tuning on the MMEB benchmark training set, delivering enhanced performance across a broader range of multimodal embedding tasks.2024-12-19 🎉🎉 Release our paper: MegaPairs: Massive Data Synthesis For Universal Multimodal Retrieval.pip install sentence_transformers[image]prompt with a task instruction to format inputs as queries, or omit it to format as candidates.1import torch
2from sentence_transformers import SentenceTransformer
3from PIL import Image
4
5model = SentenceTransformer("BAAI/BGE-VL-v1.5-zs", model_kwargs={"torch_dtype": torch.float16})
6
7# Composed image retrieval: text + image query
8query_img = Image.open("./assets/cir_query.png").resize((512, 512))
9query_emb = model.encode(
10 {"text": "Make the background dark, as if the camera has taken the photo at night", "image": query_img},
11 prompt="Retrieve the target image that best meets the combined criteria by using both the provided image and the image retrieval instructions: ",
12)
13
14# Image-only candidates (no prompt = candidate format)
15candidate_imgs = [
16 Image.open("./assets/cir_candi_1.png").resize((512, 512)),
17 Image.open("./assets/cir_candi_2.png").resize((512, 512)),
18]
19candidate_embs = model.encode(candidate_imgs, batch_size=1)
20print(candidate_embs.shape)
21# (2, 4096)
22
23similarities = model.similarity(query_emb, candidate_embs)
24print(similarities)
25# tensor([[0.3320, 0.1440]], dtype=torch.float16)transformersOur code works well on transformers==4.45.2, and we recommend using this version.
1import torch
2from transformers import AutoModel
3
4MODEL_NAME = "BAAI/BGE-VL-base" # or "BAAI/BGE-VL-large"
5
6model = AutoModel.from_pretrained(MODEL_NAME, trust_remote_code=True) # You must set trust_remote_code=True
7model.set_processor(MODEL_NAME)
8model.eval()
9
10with torch.no_grad():
11 query = model.encode(
12 images = "./assets/cir_query.png",
13 text = "Make the background dark, as if the camera has taken the photo at night"
14 )
15
16 candidates = model.encode(
17 images = ["./assets/cir_candi_1.png", "./assets/cir_candi_2.png"]
18 )
19
20 scores = query @ candidates.T
21print(scores)Our code works well on transformers==4.45.2, and we recommend using this version.
1import torch
2from transformers import AutoModel
3from PIL import Image
4
5MODEL_NAME= "BAAI/BGE-VL-MLLM-S1"
6
7model = AutoModel.from_pretrained(MODEL_NAME, trust_remote_code=True)
8model.eval()
9model.cuda()
10
11with torch.no_grad():
12 model.set_processor(MODEL_NAME)
13
14 query_inputs = model.data_process(
15 text="Make the background dark, as if the camera has taken the photo at night",
16 images="./assets/cir_query.png",
17 q_or_c="q",
18 task_instruction="Retrieve the target image that best meets the combined criteria by using both the provided image and the image retrieval instructions: "
19 )
20
21 candidate_inputs = model.data_process(
22 images=["./assets/cir_candi_1.png", "./assets/cir_candi_2.png"],
23 q_or_c="c",
24 )
25
26 query_embs = model(**query_inputs, output_hidden_states=True)[:, -1, :]
27 candi_embs = model(**candidate_inputs, output_hidden_states=True)[:, -1, :]
28
29 query_embs = torch.nn.functional.normalize(query_embs, dim=-1)
30 candi_embs = torch.nn.functional.normalize(candi_embs, dim=-1)
31
32 scores = torch.matmul(query_embs, candi_embs.T)
33print(scores)strliststrq_img and q_text.listhns[0] (the query image itself) being a mandatory choice. In our experiments, we used four hard negative samples per query.



@article{zhou2024megapairs,
title={MegaPairs: Massive Data Synthesis For Universal Multimodal Retrieval},
author={Zhou, Junjie and Liu, Zheng and Liu, Ze and Xiao, Shitao and Wang, Yueze and Zhao, Bo and Zhang, Chen Jason and Lian, Defu and Xiong, Yongping},
journal={arXiv preprint arXiv:2412.14475},
year={2024}
}