🚀 PaliGemma-3B-Chat-v0.2
本模型是基于 google/paligemma-3b-mix-448 微调而来,用于多轮聊天完成任务。
您可以在以下链接体验我们的实时演示:https://huggingface.co/spaces/llamafactory/PaliGemma-3B-Chat-v0.2

🚀 快速开始
✨ 主要特性
- 基于预训练模型
google/paligemma-3b-mix-448
进行微调,适用于多轮聊天完成任务。
- 支持图像文本到文本的转换。
- 提供实时演示,方便用户体验。
📦 安装指南
此部分原文档未提供具体安装命令,跳过。
💻 使用示例
基础用法
import requests
import torch
from PIL import Image
from transformers import AutoModelForVision2Seq, AutoProcessor, AutoTokenizer, TextStreamer
model_id = "BUAADreamer/PaliGemma-3B-Chat-v0.2"
tokenizer = AutoTokenizer.from_pretrained(model_id)
processor = AutoProcessor.from_pretrained(model_id)
model = AutoModelForVision2Seq.from_pretrained(model_id, torch_dtype="auto", device_map="auto")
streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/car.jpg?download=true"
image = Image.open(requests.get(url, stream=True).raw)
pixel_values = processor(images=[image], return_tensors="pt").to(model.device)["pixel_values"]
messages = [
{"role": "user", "content": "What is in this image?"}
]
input_ids = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt")
image_token_id = tokenizer.convert_tokens_to_ids("<image>")
image_prefix = torch.empty((1, getattr(processor, "image_seq_length")), dtype=input_ids.dtype).fill_(image_token_id)
input_ids = torch.cat((image_prefix, input_ids), dim=-1).to(model.device)
generate_ids = model.generate(input_ids, pixel_values=pixel_values, streamer=streamer, max_new_tokens=50)
📚 详细文档
训练过程
我们使用 LLaMA Factory 对该模型进行微调。在微调过程中,我们冻结了视觉塔,并调整了语言模型和投影层的参数。
训练超参数
以下是训练过程中使用的超参数:
- 学习率:0.000003
- 训练轮数:2.0
- 训练批次大小:4
- 梯度累积步数:16
- 总训练批次大小:64
- 随机种子:42
- 学习率调度器类型:余弦
- 混合精度训练:bf16
显示 Llama Factory 配置 [点击展开]
model_name_or_path: google/paligemma-3b-mix-448
visual_inputs: true
stage: sft
do_train: true
finetuning_type: full
ddp_timeout: 180000000
deepspeed: examples/deepspeed/ds_z3_config.json
dataset: identity,llava_150k_en,llava_150k_zh
template: gemma
cutoff_len: 1536
overwrite_cache: true
preprocessing_num_workers: 16
tokenized_path: cache/paligemma-identity-llava-zh-en-300k
output_dir: models/paligemma-3b-chat-v0.2
logging_steps: 10
save_steps: 1000
plot_loss: true
per_device_train_batch_size: 1
gradient_accumulation_steps: 16
learning_rate: 0.000003
num_train_epochs: 2.0
lr_scheduler_type: cosine
warmup_steps: 50
bf16: true
do_eval: false
框架版本
- Pytorch 2.3.0
- Transformers 4.41.0
评估结果
模型 |
MMMU_Val |
CMMMU_Val |
Yi-VL-6B |
36.8 |
32.2 |
Paligemma-3B-Chat-v0.2 |
33.0 |
29.0 |
🔧 技术细节
此部分原文档技术说明较少,跳过。
📄 许可证
许可证:gemma
信息表格
属性 |
详情 |
模型类型 |
基于 google/paligemma-3b-mix-448 微调的多轮聊天完成模型 |
训练数据 |
BUAADreamer/llava-en-zh-300k |
支持语言 |
英文、中文 |
库名称 |
transformers |
任务类型 |
图像文本到文本 |
基础模型 |
google/paligemma-3b-mix-448 |
推理功能 |
否 |
标签 |
paligemma、llama-factory、mllm、vlm |