模型概述
模型特點
模型能力
使用案例
🚀 PaliGemma 2模型卡片
PaliGemma 2是一款多功能的視覺語言模型(VLM),它結合了圖像和文本處理能力,可用於圖像描述、視覺問答等多種任務。該模型基於Gemma 2架構,經過在多個數據集上的預訓練和微調,具有出色的性能和廣泛的適用性。
模型信息鏈接
🚀 快速開始
要訪問Hugging Face上的PaliGemma,你需要查看並同意Google的使用許可。請確保你已登錄Hugging Face,然後點擊下方按鈕。請求將立即處理。 [確認許可](Acknowledge license)
Transformers PaliGemma 2 10B權重是在DOCCI數據集上使用448*448輸入圖像進行微調的。該模型僅以bfloat16
格式提供,用於研究目的。微調配置可在big_vision中找到。
✨ 主要特性
- 多模態處理:能夠同時處理圖像和文本輸入,生成文本輸出。
- 多語言支持:支持多種語言,適用於不同地區的用戶。
- 高性能微調:在多種視覺語言任務上具有出色的微調性能。
📦 安裝指南
本部分未提及具體安裝步驟,暫不提供相關內容。
💻 使用示例
基礎用法
from transformers import (
PaliGemmaProcessor,
PaliGemmaForConditionalGeneration,
)
from transformers.image_utils import load_image
import torch
model_id = "google/paligemma2-3b-ft-docci-448"
url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/car.jpg"
image = load_image(url)
model = PaliGemmaForConditionalGeneration.from_pretrained(model_id, torch_dtype=torch.bfloat16, device_map="auto").eval()
processor = PaliGemmaProcessor.from_pretrained(model_id)
# Instruct the model to create a caption in English
prompt = "caption en"
model_inputs = processor(text=prompt, images=image, return_tensors="pt").to(torch.bfloat16).to(model.device)
input_len = model_inputs["input_ids"].shape[-1]
with torch.inference_mode():
generation = model.generate(**model_inputs, max_new_tokens=100, do_sample=False)
generation = generation[0][input_len:]
decoded = processor.decode(generation, skip_special_tokens=True)
print(decoded)
📚 詳細文檔
模型信息
模型概述
PaliGemma 2是PaliGemma視覺語言模型(VLM)的更新版本,它融合了Gemma 2模型的能力。PaliGemma系列模型受到PaLI - 3的啟發,基於開放組件構建,如SigLIP視覺模型和Gemma 2語言模型。它以圖像和文本作為輸入,生成文本作為輸出,支持多種語言。該模型專為在各種視覺語言任務(如圖像和短視頻描述、視覺問答、文本閱讀、目標檢測和目標分割)上實現領先的微調性能而設計。
模型架構
PaliGemma 2由Transformer解碼器和Vision Transformer圖像編碼器組成。文本解碼器從Gemma 2的2B、9B和27B參數大小版本初始化。圖像編碼器從SigLIP - So400m/14初始化。與原始的PaliGemma模型類似,PaliGemma 2按照PaLI - 3的方法進行訓練。
輸入和輸出
- 輸入:圖像和文本字符串,如圖像描述提示或問題。
- 輸出:針對輸入生成的文本,如圖像描述、問題答案、目標邊界框座標列表或分割碼字。
引用
@article{
title={PaliGemma 2: A Family of Versatile VLMs for Transfer},
author={Andreas Steiner and André Susano Pinto and Michael Tschannen and Daniel Keysers and Xiao Wang and Yonatan Bitton and Alexey Gritsenko and Matthias Minderer and Anthony Sherbondy and Shangbang Long and Siyang Qin and Reeve Ingle and Emanuele Bugliarello and Sahar Kazemzadeh and Thomas Mesnard and Ibrahim Alabdulmohsin and Lucas Beyer and Xiaohua Zhai},
year={2024},
journal={arXiv preprint arXiv:2412.03555}
}
模型數據
預訓練數據集
PaliGemma 2在以下數據集的混合上進行預訓練:
- WebLI:WebLI (Web Language Image)是一個基於公共網絡構建的網絡規模多語言圖像 - 文本數據集。使用了多種WebLI分割來獲得通用的模型能力,如視覺語義理解、目標定位、視覺情境文本理解和多語言能力。
- CC3M - 35L:從網頁中精心挑選的英語圖像 - 替代文本對(Sharma et al., 2018)。使用Google Cloud Translation API將其翻譯成另外34種語言。
- VQ²A - CC3M - 35L/VQG - CC3M - 35L:VQ2A - CC3M的一個子集(Changpinyo et al., 2022a),使用Google Cloud Translation API翻譯成與CC3M - 35L相同的另外34種語言。
- OpenImages:基於OpenImages數據集通過手工規則生成的檢測和目標感知問題及答案(Piergiovanni et al. 2022)。
- WIT:從維基百科收集的圖像和文本(Srinivasan et al., 2021)。
PaliGemma 2基於Gemma 2,你可以在Gemma 2模型卡片中找到Gemma 2的預訓練數據集信息。
數據責任過濾
為了在安全和負責任的數據上訓練PaliGemma 2,對WebLI應用了以下過濾:
- 色情圖像過濾:此過濾器去除被認為具有色情性質的圖像。
- 文本安全過濾:識別並過濾掉與不安全文本配對的圖像。不安全文本是指任何被認為包含或涉及兒童性虐待圖像(CSAI)、色情內容、粗俗內容或其他冒犯性內容的文本。
- 文本毒性過濾:進一步使用Perspective API識別並過濾掉與被認為具有侮辱性、淫穢性、仇恨性或其他毒性的文本配對的圖像。
- 文本個人信息過濾:使用Cloud Data Loss Prevention (DLP) API過濾某些個人信息和其他敏感數據,以保護個人隱私。去除了如社會安全號碼和其他敏感信息類型等標識符。
- 其他方法:根據我們的政策和實踐,基於內容質量和安全性進行過濾。
🔧 技術細節
硬件
PaliGemma 2使用最新一代的張量處理單元(TPU)硬件(TPUv5e)進行訓練。
軟件
訓練使用JAX、Flax、TFDS和big_vision
完成。
JAX允許研究人員利用最新一代的硬件(包括TPU)來更快、更高效地訓練大型模型。
TFDS用於訪問數據集,Flax用於模型架構。PaliGemma 2的微調代碼和推理代碼在big_vision
GitHub倉庫中發佈。
📊 評估信息
基準測試結果
為了驗證PaliGemma 2在各種學術任務上的可遷移性,我們在每個任務上對預訓練模型進行微調。我們報告了不同分辨率下的結果,以瞭解哪些任務受益於更高的分辨率。重要的是,這些任務或數據集都不是預訓練數據混合的一部分,並且它們的圖像已從網絡規模的預訓練數據中明確移除。
按模型分辨率和大小劃分的PaliGemma 2結果
基準測試 | 224 - 3B | 224 - 10B | 224 - 28B | 448 - 3B | 448 - 10B | 448 - 28B |
---|---|---|---|---|---|---|
[AI2D][ai2d] | 74.7 | 83.1 | 83.2 | 76.0 | 84.4 | 84.6 |
[AOKVQA - DA][aokvqa - da] (val) | 64.2 | 68.9 | 70.2 | 67.9 | 70.8 | 71.2 |
[AOKVQA - MC][aokvqa - mc] (val) | 79.7 | 83.7 | 84.7 | 82.5 | 85.9 | 87.0 |
[ActivityNet - CAP][anet - cap] | 34.2 | 35.9 | - | - | - | - |
[ActivityNet - QA][anet - qa] | 51.3 | 53.2 | - | - | - | - |
[COCO - 35L][coco - 35l] (avg34) | 113.9 | 115.8 | 116.5 | 115.8 | 117.2 | 117.2 |
[COCO - 35L][coco - 35l] (en) | 138.4 | 140.8 | 142.4 | 140.4 | 142.4 | 142.3 |
[COCOcap][coco - cap] | 141.3 | 143.7 | 144.0 | 143.4 | 145.0 | 145.2 |
[ChartQA][chartqa] (aug) | 74.4 | 74.2 | 68.9 | 89.2 | 90.1 | 85.1 |
[ChartQA][chartqa] (human) | 42.0 | 48.4 | 46.8 | 54.0 | 66.4 | 61.3 |
[CountBenchQA][countbenchqa] | 81.0 | 84.0 | 86.4 | 82.0 | 85.3 | 87.4 |
[DocVQA][docvqa] (val) | 39.9 | 43.9 | 44.9 | 73.6 | 76.6 | 76.1 |
[GQA][gqa] | 66.2 | 67.2 | 67.3 | 68.1 | 68.3 | 68.3 |
[InfoVQA][info - vqa] (val) | 25.2 | 33.6 | 36.4 | 37.5 | 47.8 | 46.7 |
[MARVL][marvl] (avg5) | 83.5 | 89.5 | 90.6 | 82.7 | 89.1 | 89.7 |
[MSRVTT - CAP][msrvtt] | 68.5 | 72.1 | - | - | - | - |
[MSRVTT - QA][msrvtt] | 50.5 | 51.9 | - | - | - | - |
[MSVD - QA][msvd - qa] | 61.1 | 62.5 | - | - | - | - |
[NLVR2][nlvr2] | 91.4 | 93.9 | 94.2 | 91.6 | 93.7 | 94.1 |
[NoCaps][nocaps] | 123.1 | 126.3 | 127.1 | 123.5 | 126.9 | 127.0 |
[OCR - VQA][ocr - vqa] | 73.4 | 74.7 | 75.3 | 75.7 | 76.3 | 76.6 |
[OKVQA][okvqa] | 64.2 | 68.0 | 71.2 | 64.1 | 68.6 | 70.6 |
[RSVQA - hr][rsvqa - hr] (test) | 92.7 | 92.6 | 92.7 | 92.8 | 92.8 | 92.8 |
[RSVQA - hr][rsvqa - hr] (test2) | 90.9 | 90.8 | 90.9 | 90.7 | 90.7 | 90.8 |
[RSVQA - lr][rsvqa - lr] | 93.0 | 92.8 | 93.5 | 92.7 | 93.1 | 93.7 |
[RefCOCO][refcoco] (testA) | 75.7 | 77.2 | 76.8 | 78.6 | 79.7 | 79.3 |
[RefCOCO][refcoco] (testB) | 71.0 | 74.2 | 73.9 | 73.5 | 76.2 | 74.8 |
[RefCOCO][refcoco] (val) | 73.4 | 75.9 | 75.0 | 76.3 | 78.2 | 77.3 |
[RefCOCO+][refcoco +] (testA) | 72.7 | 74.7 | 73.6 | 76.1 | 77.7 | 76.6 |
[RefCOCO+][refcoco +] (testB) | 64.2 | 68.4 | 67.1 | 67.0 | 71.1 | 68.6 |
[RefCOCO+][refcoco +] (val) | 68.6 | 72.0 | 70.3 | 72.1 | 74.4 | 72.8 |
[RefCOCOg][refcocog] (test) | 69.0 | 71.9 | 70.7 | 72.7 | 74.8 | 73.7 |
[RefCOCOg][refcocog] (val) | 68.3 | 71.4 | 70.5 | 72.3 | 74.4 | 73.0 |
[ST - VQA][st - vqa] (val) | 61.9 | 64.3 | 65.1 | 80.5 | 82.0 | 81.8 |
[SciCap][scicap] | 165.1 | 159.5 | 156.9 | 183.3 | 177.2 | 172.7 |
[ScienceQA][scienceqa] | 96.1 | 98.2 | 98.2 | 96.2 | 98.5 | 98.6 |
[Screen2Words][screen2words] | 113.3 | 117.8 | 122.8 | 114.0 | 119.1 | 123.4 |
[TallyQA][tallyqa] (complex) | 70.3 | 73.4 | 74.2 | 73.6 | 76.7 | 76.8 |
[TallyQA][tallyqa] (simple) | 81.8 | 83.2 | 83.4 | 85.3 | 86.2 | 85.7 |
[TextCaps][textcaps] | 127.5 | 137.9 | 139.9 | 152.1 | 157.7 | 153.6 |
[TextVQA][textvqa] (val) | 59.6 | 64.0 | 64.7 | 75.2 | 76.6 | 76.2 |
[VATEX][vatex] | 80.8 | 82.7 | - | - | - | - |
[VQAv2][vqav2] (minival) | 83.0 | 84.3 | 84.5 | 84.8 | 85.8 | 85.8 |
[VizWizVQA][vizwiz - vqa] (val) | 76.4 | 78.1 | 78.7 | 77.5 | 78.6 | 78.9 |
[WidgetCap][widgetcap] | 138.1 | 139.8 | 138.8 | 151.4 | 151.9 | 148.9 |
[XM3600][xm3600] (avg35) | 42.8 | 44.5 | 45.2 | 43.2 | 44.6 | 45.2 |
[XM3600][xm3600] (en) | 79.8 | 80.7 | 81.0 | 80.3 | 81.5 | 81.0 |
[xGQA][xgqa] (avg7) | 58.6 | 61.4 | 61.1 | 60.4 | 62.6 | 62.1 |
其他基準測試
[ICDAR 2015 Incidental][icdar2015 - inc]
模型 | 精度 | 召回率 | F1 |
---|---|---|---|
PaliGemma 2 3B | 81.88 | 70.73 | 75.9 |
[Total - Text][total - text]
模型 | 精度 | 召回率 | F1 |
---|---|---|---|
PaliGemma 2 3B | 73.8 | 74.54 | 74.17 |
[FinTabNet][fintabnet]
模型 | S - TEDS | TEDS | GriTS - Top | GriTS - Con |
---|---|---|---|---|
PaliGemma 2 3B | 99.18 | 98.94 | 99.43 | 99.21 |
[PubTabNet][pubtabnet]
模型 | S - TEDS | TEDS | GriTS - Top | GriTS - Con |
---|---|---|---|---|
PaliGemma 2 3B | 97.6 | 97.31 | 97.99 | 97.84 |
[GrandStaff][grandstaff]
模型 | CER | LER | SER |
---|---|---|---|
PaliGemma 2 3B | 1.6 | 6.7 | 2.3 |
[PubChem][pubchem]
- PaliGemma 2 3B,完全匹配:94.8
[DOCCI][docci]
模型 | 平均字符數 | 平均句子數 | NES % |
---|---|---|---|
PaliGemma 2 3B | 529 | 7.74 | 28.42 |
PaliGemma 2 10B | 521 | 7.45 | 20.27 |
- avg#char:平均字符數
- avg#sent:平均句子數
- NES:非蘊含句子
[MIMIC - CXR][mimic - cxr]
模型 | CIDEr | BLEU4 | Rouge - L | RadGraph F1 |
---|---|---|---|---|
PaliGemma 2 3B | 19.9% | 14.6% | 31.92% | 28.8% |
PaliGemma 2 10B | 17.4% | 15% | 32.41% | 29.5% |
[Visual Spatial Reasoning][vsr]
模型 | VSR零樣本分割 (測試) | VSR隨機分割 (測試) |
---|---|---|
PaliGemma 2 3B | 0.75 | 0.82 |
PaliGemma 2 10B | 0.80 | 0.87 |
📄 許可證
本模型基於gemma許可證。








