🚀 佐良娜2视觉8B模型
佐良娜2视觉8B(Sarashina2-Vision-8B) 是由 SB直觉公司 训练的日本大型视觉语言模型。该模型基于 佐良娜2-7B(Sarashina2-7B) 和 通义千问2-VL-7B(Qwen2-VL-7B) 的图像编码器构建。截至2025年3月7日,在4个基准测试中,它相较于其他日本视觉语言模型取得了最高分数。
🚀 快速开始
📦 安装指南
安装所需依赖:
pip install -U transformers==4.47.0 torch torchvision pillow protobuf sentencepiece accelerate
💻 使用示例
基础用法
以下脚本可加载模型并进行推理:
import requests
from PIL import Image
from transformers import AutoModelForCausalLM, AutoProcessor
model_path = "sbintuitions/sarashina2-vision-8b"
processor = AutoProcessor.from_pretrained(model_path, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
model_path,
device_map="cuda",
torch_dtype="auto",
trust_remote_code=True,
)
message = [{"role": "user", "content": "この写真に写っているもので、最も有名と考えられる建築物は何でどこに写っていますか?"}]
text_prompt = processor.apply_chat_template(message, add_generation_prompt=True)
"""text_prompt: <s><|prefix|><|file|><|suffix|>A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.
### Human: この写真に写っているもので、最も有名と考えられる建築物は何でどこに写っていますか?
### Assistant:"""
sample_image_url = "https://huggingface.co/sbintuitions/sarashina2-vision-8b/resolve/main/sample.jpg"
image = Image.open(requests.get(sample_image_url, stream=True).raw).convert("RGB")
inputs = processor(
text=[text_prompt],
images=[image],
padding=True,
return_tensors="pt",
)
inputs = inputs.to("cuda")
stopping_criteria = processor.get_stopping_criteria(["\n###"])
output_ids = model.generate(
**inputs,
max_new_tokens=128,
temperature=0.0,
do_sample=False,
stopping_criteria=stopping_criteria,
)
generated_ids = [
output_ids[len(input_ids) :] for input_ids, output_ids in zip(inputs.input_ids, output_ids)
]
output_text = processor.batch_decode(
generated_ids, skip_special_tokens=True, clean_up_tokenization_spaces=True
)
print(output_text[0])
"""この写真に写っているもので、最も有名と考えられる建築物は東京タワーです。東京タワーは、東京のランドマークであり、この写真では、高層ビル群の向こう側に写っています。"""
示例展示

提示 |
输出 |
この写真に写っているもので、最も有名と考えられる建築物は何でどこに写っていますか? |
この写真に写っているもので、最も有名と考えられる建築物は東京タワーです。東京タワーは、東京のランドマークであり、この写真では、高層ビル群の向こう側に写っています。 |
真ん中に映っている赤と白の物は何ですか? |
真ん中に映っている赤と白のものはクレーンです。 |
🔧 技术细节
训练过程
佐良娜2视觉(Sarashina2-Vision) 是通过以下三个阶段的学习过程创建的:
- 通过字幕数据集调整投影器中的参数。
- 通过字幕数据集调整视觉编码器和投影器中的参数。
- 通过视觉指令数据集调整投影器和大语言模型(LLM)中的参数。
评估结果
注:
- 仅对单图像样本(1286个样本)进行评估。若答案提取失败,则视为错误(得分为0),而非随机选择,以消除随机性。
- 使用GPT - 4o(gpt - 4o - 2024 - 08 - 06)作为大语言模型评判器。
📄 许可证
本项目采用 MIT许可证。
⚠️ 重要提示
佐良娜2视觉模型可能会生成一些无意义的序列、不准确的实例或有偏差/令人反感的输出。在使用该模型之前,我们希望开发者根据人类偏好和安全考虑对模型进行调整。