🚀 さらしな2視覺14B模型
さらしな2視覺14B模型(Sarashina2-Vision-14B) 是由 SB直覺公司 訓練的日本大型視覺語言模型。該模型基於 さらしな2-13B模型(Sarashina2-13B) 以及 通義千問2視覺7B模型(Qwen2-VL-7B) 的圖像編碼器構建。截至2025年3月7日,在四項基準測試中,該模型相較於其他日本視覺語言模型取得了最高分。
🚀 快速開始
✨ 主要特性
- 基於先進的基礎模型和圖像編碼器構建,具備強大的視覺語言處理能力。
- 在多項基準測試中表現優異,展現出較高的性能水平。
📦 安裝指南
1. 安裝依賴項
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-14b"
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-14b/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) 通過以下三個階段的學習過程創建:
- 利用字幕數據集調整投影器中的參數。
- 利用字幕數據集調整視覺編碼器和投影器中的參數。
- 利用視覺指令數據集調整投影器和大語言模型中的參數。
📚 詳細文檔
評估結果
- 僅對單圖像樣本(1286個樣本)進行評估。若答案提取失敗,則將其視為錯誤(得分為0),而非隨機選擇,以消除隨機性。
- 使用GPT - 4o(gpt - 4o - 2024 - 08 - 06)作為大語言模型評判器。
⚠️ 重要提示
さらしな2視覺模型可能會生成一些無意義的序列、不準確的實例或有偏差/令人反感的輸出。在使用該模型之前,建議開發者根據人類偏好和安全考慮對模型進行調整。
📄 許可證
本項目採用 MIT許可證。