🚀 佐良娜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視覺模型可能會生成一些無意義的序列、不準確的實例或有偏差/令人反感的輸出。在使用該模型之前,我們希望開發者根據人類偏好和安全考慮對模型進行調整。