🚀 Sarashina2-Vision-14B
Sarashina2-Vision-14B は、SB Intuitions によって学習された日本語の大規模ビジョン言語モデルです。このモデルは、Sarashina2-13B と 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-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])
"""この写真に写っているもので、最も有名と考えられる建築物は東京タワーです。東京タワーは、東京の街並みの右側に写っています。"""
実際の例
プロンプト |
出力 |
この写真に写っているもので、最も有名と考えられる建築物は何でどこに写っていますか? |
この写真に写っているもので、最も有名と考えられる建築物は東京タワーです。東京タワーは、東京の街並みの右側に写っています。 |
真ん中に映っている赤と白の物は何ですか? |
赤と白の物はクレーンです。 |
📚 ドキュメント
🔧 技術詳細
Sarashina2-Vision は、以下の3段階の学習プロセスを通じて作成されています。
- キャプションデータセットを使用して、プロジェクターのパラメータを調整します。
- キャプションデータセットを使用して、ビジョンエンコーダーとプロジェクターのパラメータを調整します。
- ビジュアル命令データセットを使用して、プロジェクターと大規模言語モデル(LLM)のパラメータを調整します。
評価結果
注釈:
- 単一画像サンプル(1,286サンプル)のみを評価しました。回答の抽出に失敗した場合は、確率的要素を排除するために、ランダムな選択ではなく、不正解(スコア0)として扱いました。
- LLM-as-a-Judgeには、GPT-4o (gpt-4o-2024-08-06) を使用しました。
⚠️ 倫理的な考慮事項と制限
Sarashina2-Visionは、意味のないシーケンス、不正確なインスタンス、または偏見や不快な出力を生成する可能性があります。Sarashina2-Visionを使用する前に、開発者には人間の好みと安全性を考慮してモデルを調整することをお勧めします。
📄 ライセンス
このモデルは、MITライセンス の下で提供されています。