Llave 7B
L
Llave 7B
Developed by zhibinlan
LLaVE-7B是基於LLaVA-OneVision-7B模型的70億參數多模態嵌入模型,具備文本、圖像、多圖像和視頻的嵌入表示能力。
Downloads 1,389
Release Time : 2/9/2025
Model Overview
LLaVE-7B是一個多模態嵌入模型,能夠處理文本、圖像、多圖像和視頻的嵌入表示,在MMEB排行榜上表現優異,並展現出強大的遷移學習能力。
Model Features
多模態嵌入能力
能夠同時對文本、圖像、多圖像和視頻進行嵌入表示
卓越性能
僅使用66.2萬訓練樣本就在MMEB上實現了最先進的性能
強大的遷移能力
雖然在圖文數據上訓練,但能零樣本泛化到文本-視頻檢索任務
高效訓練
僅使用少量數據就取得優異表現
Model Capabilities
文本嵌入表示
圖像嵌入表示
多圖像嵌入表示
視頻嵌入表示
跨模態檢索
零樣本遷移學習
Use Cases
信息檢索
跨模態檢索
根據文本查詢檢索相關圖像或視頻
在MMEB排行榜上取得首位
內容理解
圖像內容理解
理解圖像內容並生成相關文本表示
能準確區分圖像中的不同對象
🚀 LLaVE-7B
LLaVE-7B 是一個基於 LLaVA-OneVision-7B 模型的 70 億參數多模態嵌入模型,上下文窗口為 4K 個標記。它能夠對文本、圖像、多圖像和視頻進行嵌入處理,在 MMEB 排行榜上取得了優異成績,還能零樣本遷移到文本 - 視頻檢索任務中。
🚀 快速開始
首先克隆我們的 GitHub 倉庫:
git clone https://github.com/DeepLearnXMU/LLaVE
cd LLaVE
pip install -e ".[train]"
我們提供了使用模型的簡單嵌入過程。更多詳細信息,請參考 Github。
基礎用法
# pip install git+https://github.com/DeepLearnXMU/LLaVE
import torch
import copy
from PIL import Image
from llava.constants import IMAGE_TOKEN_INDEX, DEFAULT_IMAGE_TOKEN
from llava.conversation import conv_templates
from llava.model.builder import load_pretrained_model
from llava.mm_utils import tokenizer_image_token, process_images
pretrained = "zhibinlan/LLaVE-7B"
model_name = "llava_qwen"
device = "cuda"
device_map = "auto"
tokenizer, model, image_processor, max_length = load_pretrained_model(pretrained, None, model_name, device_map=device_map) # Add any other thing you want to pass in llava_model_args
model.eval()
# Image + Text -> Text
image = Image.open("figures/example.jpg")
image_tensor = process_images([image], image_processor, model.config)
image_tensor = [_image.to(dtype=torch.float16, device=device) for _image in image_tensor]
conv_template = "qwen_1_5" # Make sure you use correct chat template for different models
question = DEFAULT_IMAGE_TOKEN + " Represent the given image with the following question: What is in the image"
conv = copy.deepcopy(conv_templates[conv_template])
conv.append_message(conv.roles[0], question)
conv.append_message(conv.roles[1], "\n")
prompt_question = conv.get_prompt()
input_ids = tokenizer_image_token(prompt_question, tokenizer, IMAGE_TOKEN_INDEX, return_tensors="pt").unsqueeze(0).to(device)
attention_mask=input_ids.ne(tokenizer.pad_token_id)
image_sizes = [image.size]
query_embed = model.encode_multimodal_embeddings(input_ids, attention_mask=attention_mask,images=image_tensor, image_sizes=image_sizes)
target_string = "A cat and a dog"
conv = copy.deepcopy(conv_templates[conv_template])
conv.append_message(conv.roles[0], target_string)
conv.append_message(conv.roles[1], "\n")
target_string = conv.get_prompt()
target_input_ids = tokenizer(target_string, return_tensors="pt").input_ids.to(device)
attention_mask=target_input_ids.ne(tokenizer.pad_token_id)
target_embed = model.encode_multimodal_embeddings(target_input_ids, attention_mask=attention_mask)
print("A cat and a dog similarity score: ", query_embed @ target_embed.T)
# 7B: A cat and a dog similarity score: tensor([[0.6240]]
neg_string = "A cat and a tiger"
conv = copy.deepcopy(conv_templates[conv_template])
conv.append_message(conv.roles[0], neg_string)
conv.append_message(conv.roles[1], "\n")
neg_string = conv.get_prompt()
neg_input_ids = tokenizer(neg_string, return_tensors="pt").input_ids.to(device)
attention_mask=neg_input_ids.ne(tokenizer.pad_token_id)
neg_embed = model.encode_multimodal_embeddings(neg_input_ids, attention_mask=attention_mask)
print("A cat and a tiger similarity score: ", query_embed @ neg_embed.T)
# 7B: A cat and a tiger similarity score: tensor([[0.4543]]
# Text -> Image
pos_string = "Find me an everyday image that matches the given caption: A cat and a dog."
conv = copy.deepcopy(conv_templates[conv_template])
conv.append_message(conv.roles[0], pos_string)
conv.append_message(conv.roles[1], "\n")
pos_string = conv.get_prompt()
pos_input_ids = tokenizer(pos_string, return_tensors="pt").input_ids.to(device)
attention_mask=pos_input_ids.ne(tokenizer.pad_token_id)
pos_query_embed = model.encode_multimodal_embeddings(pos_input_ids, attention_mask=attention_mask)
target = DEFAULT_IMAGE_TOKEN + " Represent the given image."
conv = copy.deepcopy(conv_templates[conv_template])
conv.append_message(conv.roles[0], target)
conv.append_message(conv.roles[1], "\n")
prompt_target = conv.get_prompt()
target_input_ids = tokenizer_image_token(prompt_target, tokenizer, IMAGE_TOKEN_INDEX, return_tensors="pt").unsqueeze(0).to(device)
attention_mask=target_input_ids.ne(tokenizer.pad_token_id)
target_image_sizes = [image.size]
target_embed = model.encode_multimodal_embeddings(target_input_ids, attention_mask=attention_mask,images=image_tensor, image_sizes=target_image_sizes)
print("A cat and a dog image similarity score: ", pos_query_embed @ target_embed.T)
# 7B: A cat and a dog similarity score: tensor([[0.5347]]
neg_string = "Find me an everyday image that matches the given caption: A cat and a tiger."
conv = copy.deepcopy(conv_templates[conv_template])
conv.append_message(conv.roles[0], neg_string)
conv.append_message(conv.roles[1], "\n")
neg_string = conv.get_prompt()
neg_input_ids = tokenizer(neg_string, return_tensors="pt").input_ids.to(device)
attention_mask=neg_input_ids.ne(tokenizer.pad_token_id)
neg_query_embed = model.encode_multimodal_embeddings(neg_input_ids, attention_mask=attention_mask)
print("A cat and a tiger image similarity score: ", neg_query_embed @ target_embed.T)
# 7B: A cat and a dog similarity score: tensor([[0.4001]]
✨ 主要特性
- 多模態嵌入能力:該模型能夠對文本、圖像、多圖像和視頻進行嵌入處理。
- 優異的排行榜成績:僅使用少量數據就在 MMEB 排行榜上取得了頂級排名。
- 零樣本遷移能力:雖然模型是在圖像 - 文本數據上訓練的,但可以零樣本遷移到文本 - 視頻檢索任務中,並取得了不錯的性能。
📦 安裝指南
git clone https://github.com/DeepLearnXMU/LLaVE
cd LLaVE
pip install -e ".[train]"
📚 詳細文檔
模型概述
LLaVE 模型是基於 LLaVA-OneVision-7B 模型的 70 億參數多模態嵌入模型,上下文窗口為 4K 個標記。
訓練/評估數據
- 訓練數據:https://huggingface.co/datasets/TIGER-Lab/MMEB-train
- 評估數據:https://huggingface.co/datasets/TIGER-Lab/MMEB-eval
MMEB 排行榜
我們僅使用少量數據就在 MMEB 排行榜上取得了頂級排名。
模型性能
LLaVE-7B 僅使用 66.2 萬個訓練對就在 MMEB 上取得了最優性能。
儘管 LLaVE 是在圖像 - 文本數據上訓練的,但它可以零樣本遷移到文本 - 視頻檢索任務中,並取得了不錯的性能,展示了其在其他嵌入任務中的巨大潛力。
🔧 技術細節
硬件與軟件
- GPU:16 * Ascend 910B GPUs (64GB)(用於全模型訓練)
- 編排工具:Huggingface Trainer
- 神經網絡框架:PyTorch
📄 許可證
本項目採用 Apache-2.0 許可證。
📖 引用
@article{lan2025llave,
title={LLaVE: Large Language and Vision Embedding Models with Hardness-Weighted Contrastive Learning},
author={Lan, Zhibin and Niu, Liqiang and Meng, Fandong and Zhou, Jie and Su, Jinsong},
journal={arXiv preprint arXiv:2503.04812},
year={2025}
}
Codebert Base
CodeBERT是一個面向編程語言與自然語言的預訓練模型,基於RoBERTa架構,支持代碼搜索和代碼生成文檔等功能。
多模態融合
C
microsoft
1.6M
248
Llama 4 Scout 17B 16E Instruct
Other
Llama 4 Scout是Meta開發的多模態AI模型,採用混合專家架構,支持12種語言的文本和圖像交互,具有17B激活參數和109B總參數。
多模態融合
Transformers Supports Multiple Languages

L
meta-llama
817.62k
844
Unixcoder Base
Apache-2.0
UniXcoder是一個統一的多模態預訓練模型,利用代碼註釋和抽象語法樹等多模態數據預訓練代碼表示。
多模態融合
Transformers English

U
microsoft
347.45k
51
TITAN
TITAN是一個多模態全切片基礎模型,通過視覺自監督學習和視覺-語言對齊進行預訓練,用於病理學圖像分析。
多模態融合
Safetensors English
T
MahmoodLab
213.39k
37
Qwen2.5 Omni 7B
Other
Qwen2.5-Omni 是一個端到端的多模態模型,能夠感知文本、圖像、音頻和視頻等多種模態,並以流式方式生成文本和自然語音響應。
多模態融合
Transformers English

Q
Qwen
206.20k
1,522
Minicpm O 2 6
MiniCPM-o 2.6是一款手機端運行的GPT-4o級多模態大模型,支持視覺、語音與直播流處理
多模態融合
Transformers Other

M
openbmb
178.38k
1,117
Llama 4 Scout 17B 16E Instruct
Other
Llama 4 Scout是Meta推出的17B參數/16專家混合的多模態AI模型,支持12種語言和圖像理解,具有行業領先性能。
多模態融合
Transformers Supports Multiple Languages

L
chutesai
173.52k
2
Qwen2.5 Omni 3B
Other
Qwen2.5-Omni是一款端到端多模態模型,能夠感知文本、圖像、音頻和視頻等多種模態信息,並以流式方式同步生成文本和自然語音響應。
多模態融合
Transformers English

Q
Qwen
48.07k
219
One Align
MIT
Q-Align是一個多任務視覺評估模型,專注於圖像質量評估(IQA)、美學評估(IAA)和視頻質量評估(VQA),在ICML2024上發表。
多模態融合
Transformers

O
q-future
39.48k
25
Biomedvlp BioViL T
MIT
BioViL-T是一個專注於分析胸部X光片和放射學報告的視覺語言模型,通過時序多模態預訓練提升性能。
多模態融合
Transformers English

B
microsoft
26.39k
35
Featured Recommended AI Models
Llama 3 Typhoon V1.5x 8b Instruct
專為泰語設計的80億參數指令模型,性能媲美GPT-3.5-turbo,優化了應用場景、檢索增強生成、受限生成和推理任務
大型語言模型
Transformers Supports Multiple Languages

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-Tiny是一個基於SODA數據集訓練的超小型對話模型,專為邊緣設備推理設計,體積僅為Cosmo-3B模型的2%左右。
對話系統
Transformers English

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
基於RoBERTa架構的中文抽取式問答模型,適用於從給定文本中提取答案的任務。
問答系統 Chinese
R
uer
2,694
98