模型页面: PaliGemma
Transformers PaliGemma 2 3B 权重版本,采用 448*448 输入图像和 512 个令牌的输入/输出文本序列进行预训练。
该模型提供 bfloat16 格式用于微调。
资源与技术文档:
使用条款: 条款
作者: Google
PaliGemma 2 是 PaliGemma 视觉语言模型(VLM)的升级版本,融合了 Gemma 2 模型的能力。PaliGemma 系列模型受 PaLI-3 启发,基于开源组件构建,包括 SigLIP 视觉模型和 Gemma 2 语言模型。该模型支持图像和文本双模态输入,并生成文本输出,具备多语言处理能力。其设计目标是在图像及短视频描述、视觉问答、文本阅读、目标检测与目标分割等广泛视觉语言任务上实现顶尖的微调性能。
PaliGemma 2 由 Transformer 解码器 和 视觉 Transformer 图像编码器 组合构成。 文本解码器初始化自参数规模为 2B、9B 和 27B 的 Gemma 2 模型。 图像编码器初始化自 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 基于以下混合数据集进行预训练:
PaliGemma 2 基于 Gemma 2 构建,您可在 Gemma 2 模型卡片中查看 Gemma 2 的预训练数据集信息。
为确保 PaliGemma 2 基于安全可靠的数据进行训练,我们对 WebLI 数据应用了以下过滤措施:
以下代码片段以参考为目的使用 google/paligemma2-3b-pt-448 模型。
这是一个基础模型,建议在下游任务上完成微调后使用。
此处提供展示 PaliGemma 2 微调过程的 notebook 供参考。
from transformers import (
PaliGemmaProcessor,
PaliGemmaForConditionalGeneration,
)
from transformers.image_utils import load_image
import torch
model_id = "google/paligemma2-3b-pt-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)
# Leaving the prompt blank for pre-trained models
prompt = ""
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 采用最新一代张量处理单元(TPUv5e)进行训练。
训练使用 JAX、Flax、TFDS 及 big_vision 完成。
JAX 使研究人员能够充分利用包括 TPU 在内的最新硬件优势,实现大模型更快速高效的训练。TFDS 用于访问数据集,Flax 用于构建模型架构。PaliGemma 2 的微调代码与推理代码已发布于 big_vision GitHub 代码库。
为验证 PaliGemma 2 在各类学术任务中的迁移能力,我们在每个任务上对预训练模型进行微调。通过报告不同分辨率下的结果,展示哪些任务能从更高分辨率中受益。需特别说明的是,这些任务及数据集均未包含在预训练数据混合集中,且其图像已明确从网络级预训练数据中移除。
| 基准测试项目 | 224-3B | 224-10B | 224-28B | 448-3B | 448-10B | 448-28B |
|---|---|---|---|---|---|---|
| AI2D | 74.7 | 83.1 | 83.2 | 76.0 | 84.4 | 84.6 |
| AOKVQA-DA (验证集) | 64.2 | 68.9 | 70.2 | 67.9 | 70.8 | 71.2 |
| AOKVQA-MC (验证集) | 79.7 | 83.7 | 84.7 | 82.5 | 85.9 | 87.0 |
| ActivityNet-CAP | 34.2 | 35.9 | - | - | - | - |
| ActivityNet-QA | 51.3 | 53.2 | - | - | - | - |
| COCO-35L (平均34) | 113.9 | 115.8 | 116.5 | 115.8 | 117.2 | 117.2 |
| COCO-35L (英文) | 138.4 | 140.8 | 142.4 | 140.4 | 142.4 | 142.3 |
| COCOcap | 141.3 | 143.7 | 144.0 | 143.4 | 145.0 | 145.2 |
| ChartQA (增强集) | 74.4 | 74.2 | 68.9 | 89.2 | 90.1 | 85.1 |
| ChartQA (人工集) | 42.0 | 48.4 | 46.8 | 54.0 | 66.4 | 61.3 |
| CountBenchQA | 81.0 | 84.0 | 86.4 | 82.0 | 85.3 | 87.4 |
| DocVQA (验证集) | 39.9 | 43.9 | 44.9 | 73.6 | 76.6 | 76.1 |
| GQA | 66.2 | 67.2 | 67.3 | 68.1 | 68.3 | 68.3 |
| InfoVQA (验证集) | 25.2 | 33.6 | 36.4 | 37.5 | 47.8 | 46.7 |
| MARVL (平均5) | 83.5 | 89.5 | 90.6 | 82.7 | 89.1 | 89.7 |
| MSRVTT-CAP | 68.5 | 72.1 | - | - | - | - |
| MSRVTT-QA | 50.5 | 51.9 | - | - | - | - |
| MSVD-QA | 61.1 | 62.5 | - | - | - | - |
| NLVR2 | 91.4 | 93.9 | 94.2 | 91.6 | 93.7 | 94.1 |
| NoCaps | 123.1 | 126.3 | 127.1 | 123.5 | 126.9 | 127.0 |
| OCR-VQA | 73.4 | 74.7 | 75.3 | 75.7 | 76.3 | 76.6 |
| OKVQA | 64.2 | 68.0 | 71.2 | 64.1 | 68.6 | 70.6 |
| RSVQA-hr (测试集) | 92.7 | 92.6 | 92.7 | 92.8 | 92.8 | 92.8 |
| RSVQA-hr (测试集2) | 90.9 | 90.8 | 90.9 | 90.7 | 90.7 | 90.8 |
| RSVQA-lr | 93.0 | 92.8 | 93.5 | 92.7 | 93.1 | 93.7 |
| RefCOCO (测试集A) | 75.7 | 77.2 | 76.8 | 78.6 | 79.7 | 79.3 |
| RefCOCO (测试集B) | 71.0 | 74.2 | 73.9 | 73.5 | 76.2 | 74.8 |
| RefCOCO (验证集) | 73.4 | 75.9 | 75.0 | 76.3 | 78.2 | 77.3 |
| RefCOCO+ (测试集A) | 72.7 | 74.7 | 73.6 | 76.1 | 77.7 | 76.6 |
| RefCOCO+ (测试集B) | 64.2 | 68.4 | 67.1 | 67.0 | 71.1 | 68.6 |
| RefCOCO+ (验证集) | 68.6 | 72.0 | 70.3 | 72.1 | 74.4 | 72.8 |
| RefCOCOg (测试集) | 69.0 | 71.9 | 70.7 | 72.7 | 74.8 | 73.7 |
| RefCOCOg (验证集) | 68.3 | 71.4 | 70.5 | 72.3 | 74.4 | 73.0 |
| ST-VQA (验证集) | 61.9 | 64.3 | 65.1 | 80.5 | 82.0 | 81.8 |
| SciCap | 165.1 | 159.5 | 156.9 | 183.3 | 177.2 | 172.7 |
| ScienceQA | 96.1 | 98.2 | 98.2 | 96.2 | 98.5 | 98.6 |
| Screen2Words | 113.3 | 117.8 | 122.8 | 114.0 | 119.1 | 123.4 |
| TallyQA (复杂集) | 70.3 | 73.4 | 74.2 | 73.6 | 76.7 | 76.8 |
| TallyQA (简单集) | 81.8 | 83.2 | 83.4 | 85.3 | 86.2 | 85.7 |
| TextCaps | 127.5 | 137.9 | 139.9 | 152.1 | 157.7 | 153.6 |
| TextVQA (验证集) | 59.6 | 64.0 | 64.7 | 75.2 | 76.6 | 76.2 |
| VATEX | 80.8 | 82.7 | - | - | - | - |
| VQAv2 (最小验证集) | 83.0 | 84.3 | 84.5 | 84.8 | 85.8 | 85.8 |
| VizWizVQA (验证集) | 76.4 | 78.1 | 78.7 | 77.5 | 78.6 | 78.9 |
| WidgetCap | 138.1 | 139.8 | 138.8 | 151.4 | 151.9 | 148.9 |
| XM3600 (平均35) | 42.8 | 44.5 | 45.2 | 43.2 | 44.6 | 45.2 |
| XM3600 (英文) | 79.8 | 80.7 | 81.0 | 80.3 | 81.5 | 81.0 |
| xGQA (平均7) | 58.6 | 61.4 | 61.1 | 60.4 | 62.6 | 62.1 |
| 模型 | 精确率 | 召回率 | F1值 |
|---|---|---|---|
| PaliGemma 2 3B | 81.88 | 70.73 | 75.9 |
| 模型 | 精确率 | 召回率 | F1值 |
|---|---|---|---|
| PaliGemma 2 3B | 73.8 | 74.54 | 74.17 |
| 模型 | S-TEDS | TEDS | GriTS-Top | GriTS-Con |
|---|---|---|---|---|
| PaliGemma 2 3B | 99.18 | 98.94 | 99.43 | 99.21 |
| 模型 | S-TEDS | TEDS | GriTS-Top | GriTS-Con |
|---|---|---|---|---|
| PaliGemma 2 3B | 97.6 | 97.31 | 97.99 | 97.84 |
| 模型 | 字符错误率 | 行错误率 | 序列错误率 |
|---|---|---|---|
| PaliGemma 2 3B | 1.6 | 6.7 | 2.3 |
| 模型 | 平均字符数 | 平均句子数 | 非蕴含句占比 |
|---|---|---|---|
| PaliGemma 2 3B | 529 | 7.74 | 28.42% |
| PaliGemma 2 10B | 521 | 7.45 | 20.27% |
| 模型 | 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% |
| 模型 | VSR 零样本分割(测试集) | VSR 随机分割(测试集) |
|---|---|---|
| PaliGemma 2 3B | 0.75 | 0.82 |
| PaliGemma 2 10B | 0.80 | 0.87 |
我们的评估方法包括针对相关内容政策的结构化伦理与安全评估,具体涵盖:
| 指标 | 感知性别 | 种族 | 年龄组 | ||||||
|---|---|---|---|---|---|---|---|---|---|
| 模型规模 | 3B | 10B | 28B | 3B | 10B | 28B | 3B | 10B | 28B |
| 最大值 | |||||||||
| 毒性 | 0.14% | 0.15% | 0.19% | 0.29% | 0.39% | 0.39% | 0.26% | 0.18% | 0.32% |
| 身份攻击 | 0.04% | 0.02% | 0.02% | 0.13% | 0.06% | 0.06% | 0.06% | 0.03% | 0.06% |
| 侮辱 | 0.17% | 0.25% | 0.17% | 0.37% | 0.52% | 0.52% | 0.27% | 0.39% | 0.24% |
| 威胁 | 0.55% | 0.43% | 0.57% | 0.83% | 0.48% | 0.48% | 0.64% | 0.43% | 0.64% |
| 污言秽语 | 0.00% | 0.00% | 0.00% | 0.00% | 0.00% | 0.00% | 0.00% | 0.00% | 0.00% |
| 中位数 | |||||||||
| 毒性 | 0.13% | 0.10% | 0.18% | 0.07% | 0.07% | 0.14% | 0.12% | 0.08% | 0.12% |
| 身份攻击 | 0.02% | 0.01% | 0.02% | 0.00% | 0.00% | 0.00% | 0.00% | 0.00% | 0.00% |
| 侮辱 | 0.15% | 0.23% | 0.14% | 0.14% | 0.17% | 0.13% | 0.09% | 0.18% | 0.16% |
| 威胁 | 0.35% | 0.27% | 0.41% | 0.28% | 0.19% | 0.42% | 0.27% | 0.31% | 0.40% |
| 污言秽语 | 0.00% | 0.00% | 0.00% | 0.00% | 0.00% | 0.00% | 0.00% | 0.00% | 0.00% |
开放视觉语言模型(VLM)在各行业和领域具有广泛的应用前景。以下潜在用途列表并非详尽无遗,其目的在于提供模型创建者在训练和开发过程中考虑的可能用例背景信息。Gemma模型的禁止用途详见Gemma禁止使用政策。
特定视觉语言任务的微调:
视觉语言研究:
视觉语言模型(VLM)的发展引发多项伦理问题。在开发开放模型过程中,我们已审慎考虑以下方面:
已识别的风险与缓解措施: