模型概述
模型特點
模型能力
使用案例
🚀 XGen-MM系列大模型
XGen-MM是Salesforce AI Research研發的一系列最新大型多模態基礎模型。該系列在BLIP系列的成功設計基礎上進行了改進,為多模態技術提供了更強大的基礎。這些模型在高質量圖像描述數據集和交錯的圖像文本數據上進行了大規模訓練,具有出色的性能和特性。
🚀 快速開始
你可以按照以下步驟使用XGen-MM
模型:
from transformers import AutoModelForVision2Seq, AutoTokenizer, AutoImageProcessor
import requests
from PIL import Image
import IPython.display as display
import torch
model_name_or_path = "Salesforce/xgen-mm-phi3-mini-base-r-v1"
model = AutoModelForVision2Seq.from_pretrained(model_name_or_path, trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, trust_remote_code=True, use_fast=True, legacy=False)
image_processor = AutoImageProcessor.from_pretrained(model_name_or_path, trust_remote_code=True)
tokenizer = model.update_special_tokens(tokenizer)
model = model.to('cuda')
tokenizer.padding_side = "left"
def apply_prompt_template(prompt, num_images=1, num_tokens_per_vis = 128, in_context=False, output=None):
"""
num_tokens_per_vis: model.vlm.num_tokens_per_vis
"""
placeholder_image_tokens = "<image placeholder>" * (num_tokens_per_vis - 1)
if in_context:
formatted_prompt = f"<image>{placeholder_image_tokens}" + f"{prompt}" + f"{output}" + "<|endofchunk|>"
else:
formatted_prompt = f"<image>{placeholder_image_tokens}"*num_images + f"{prompt}"
return formatted_prompt
############ Zero shot inference ##########
img_url = 'https://storage.googleapis.com/sfr-vision-language-research/BLIP/demo.jpg'
raw_image = Image.open(requests.get(img_url, stream=True).raw).convert('RGB')
instruction = "Describe what is the dog doing in this image in one sentence:"
print("==> Instruction: ", instruction)
print("==> Image: ")
display.display(raw_image.resize((int(raw_image.width*0.3), int(raw_image.height*0.3))))
inputs = image_processor([raw_image], return_tensors="pt")
prompt = apply_prompt_template(instruction)
language_inputs = tokenizer([prompt], return_tensors="pt")
inputs.update(language_inputs)
inputs = {name: tensor.cuda() for name, tensor in inputs.items()}
with torch.cuda.amp.autocast(dtype=torch.bfloat16):
generated_text = model.generate(**inputs,
pad_token_id=tokenizer.pad_token_id,
do_sample=False, max_new_tokens=64, top_p=None, num_beams=1,
length_penalty=1.0, repetition_penalty=3.0)
prediction = tokenizer.decode(generated_text[0], skip_special_tokens=True)
print("==> prediciton: ", prediction)
print("-"*120)
# ==> prediciton: The dog is sitting on the beach and waving at his owner.
更多全面的示例可在notebook中找到,其中分別提供了零樣本和少樣本示例。
✨ 主要特性
- 預訓練基礎模型:
xgen-mm-phi3-mini-base-r-v1
在50億參數下達到了最先進的性能,並展示了強大的上下文學習能力。 - 指令微調模型:
xgen-mm-phi3-mini-instruct-r-v1
在50億參數的開源和閉源視覺語言模型中達到了最先進的性能。 - 靈活的高分辨率圖像編碼:
xgen-mm-phi3-mini-instruct-r-v1
支持靈活的高分辨率圖像編碼,並採用高效的視覺令牌採樣。
📚 詳細文檔
模型描述
我們很高興地宣佈,將我們的BLIP系列更名為XGen-MM,以更好地與Salesforce統一的大型基礎模型XGen計劃保持一致!這次品牌重塑標誌著我們在前沿多模態技術持續發展中的重要一步。
XGen-MM
是Salesforce AI Research開發的一系列最新大型多模態基礎模型(LMMs)。該系列在BLIP
系列的成功設計基礎上進行了改進,融入了基礎增強功能,確保了更強大、更卓越的基礎。這些模型在高質量圖像描述數據集和交錯的圖像文本數據上進行了大規模訓練。XGen-MM具有以下幾個特點:
結果
預訓練(無指令微調的基礎模型)
模型 | 樣本數 | COCO (驗證集) | NoCaps (驗證集) | TextCaps (驗證集) | OKVQA (驗證集) | TextVQA (驗證集) | VizWiz (測試開發集) | VQAv2 (測試開發集) |
---|---|---|---|---|---|---|---|---|
Flamingo-3B | 4 | 85.0 | - | - | 43.3 | 32.7 | 34 | 53.2 |
8 | 90.6 | - | - | 44.6 | 32.4 | 38.4 | 55.4 | |
MM1-3B | 0 | 73.5 | 55.6 | 63.3 | 26.1 | 29.4 | 15.6 | 46.2 |
4 | 112.3 | 99.7 | 84.1 | 48.6 | 45.3 | 38.0 | 57.9 | |
8 | 114.6 | 104.7 | 88.8 | 48.4 | 44.6 | 46.4 | 63.6 | |
xgen-mm-phi3-mini-base-r-v1 (我們的模型) | 0 | 81.7 | 80.2 | 60.7 | 26.5 | 36.0 | 21.2 | 48.1 |
4 | 110.5 | 101.7 | 84.6 | 49.2 | 46.1 | 38.4 | 63.9 | |
8 | 112.1 | 104.4 | 87.7 | 49.1 | 46.4 | 44.3 | 63.8 |
指令微調後
模型 | SEED-IMG | MMBench(開發集) | MME總分 | MME-P | MME-C | MMStar | MMMU (驗證集) | MMVet | MathVista (迷你版) | ScienceQA (測試集) | POPE | AI2D |
---|---|---|---|---|---|---|---|---|---|---|---|---|
MM1-3B-Chat | 68.8 | 67.8 | 1761 | 1482 | 279 | - | 33.9 | 43.7 | - | - | 87.4 | - |
openbmb/MiniCPM-V-2 | 67.1 | 69.6 | 1808 | - | - | - | 38.2 | - | 38.7 | - | - | - |
VILA1.5-3B | 67.9 | 63.4 | - | 1442 | - | - | 33.3 | 35.4 | - | 69.0 | 85.9 | - |
xtuner/llava-phi-3-mini-hf | 70.0 | 69.2 | 1790 | 1477 | 313 | 43.7 | 41.4 | - | - | 73.7 | 87.3 | 69.3 |
xgen-mm-phi3-mini-instruct-r-v1 (我們的模型) | 72.1 | 74.1 | 1827 | 1467 | 360 | 44.6 | 39.8 | 45.1 | 39.3 | 74.2 | 87.2 | 75.8 |
可重複性
我們的SFT評估基於VLMEvalKit,在其中我們修復了與官方基準測試(如LLM評判API)的一些不一致之處。在開發過程中,我們注意到在某些情況下,輸入圖像的原始分辨率會顯著影響模型輸出。
偏差、風險、侷限性和倫理考量
主要數據來源來自互聯網,包括網頁、圖像素材網站和研究社區發佈的精選數據集。由於已知的CSAM問題,我們排除了某些數據,如LAION。模型可能會受到原始數據源的偏差以及大語言模型和商業API的偏差影響。我們強烈建議用戶在應用於下游任務之前評估安全性和公平性。
倫理考量
此版本僅用於支持學術論文的研究目的。我們的模型、數據集和代碼並非專門為所有下游用途設計或評估。我們強烈建議用戶在部署此模型之前評估並解決與準確性、安全性和公平性相關的潛在問題。我們鼓勵用戶考慮人工智能的常見侷限性,遵守適用法律,並在選擇用例時採用最佳實踐,特別是在錯誤或濫用可能對人們的生活、權利或安全產生重大影響的高風險場景中。有關用例的進一步指導,請參考我們的AUP和AI AUP。
🔧 技術細節
該模型用於研究目的,更多技術細節將隨技術報告很快公佈。
📄 許可證
我們的代碼和權重遵循Apache-2.0許可證發佈。訓練數據的版權歸原始數據所有者所有。
代碼致謝
引用
@misc{xue2024xgenmmblip3familyopen,
title={xGen-MM (BLIP-3): A Family of Open Large Multimodal Models},
author={Le Xue and Manli Shu and Anas Awadalla and Jun Wang and An Yan and Senthil Purushwalkam and Honglu Zhou and Viraj Prabhu and Yutong Dai and Michael S Ryoo and Shrikant Kendre and Jieyu Zhang and Can Qin and Shu Zhang and Chia-Chih Chen and Ning Yu and Juntao Tan and Tulika Manoj Awalgaonkar and Shelby Heinecke and Huan Wang and Yejin Choi and Ludwig Schmidt and Zeyuan Chen and Silvio Savarese and Juan Carlos Niebles and Caiming Xiong and Ran Xu},
year={2024},
eprint={2408.08872},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2408.08872},
}
故障排除
- 如果你缺少任何軟件包,請考慮以下安裝命令:
pip install torch==2.2.1 torchvision==0.17.1 torchaudio==2.2.1 --index-url https://download.pytorch.org/whl/cu121
pip install open_clip_torch==2.24.0
pip install einops
pip install einops-exts
pip install transformers==4.41.1
更新日誌
- 2024年5月24日:更新代碼庫以兼容
transformers==4.41.1
。








