--- license: gemma language: - ja - en base_model: - google/gemma-3-4b-it pipeline_tag: text-generation --- # DataPilot/ArrowMint-Gemma3-4B-ChocoMint-jp ## Overview DataPilot/ArrowMint-Gemma3-4B-ChocoMint-jp は、Googleによって開発された軽量な最先端オープンモデルファミリーである [Gemma 3](https://ai.google.dev/gemma/docs/core) の `google/gemma-3-4b-it` をベースモデルとしています。 このモデルは、[Unsloth](https://github.com/unslothai/unsloth) と合成データセットを用いてファインチューニングされており、特に**日本語における性能向上**を目的としてトレーニングされました。 Gemma 3 ファミリーと同様に、テキストと画像のマルチモーダル入力を処理し、テキストを出力します。128Kトークンという広大なコンテキストウィンドウを持ち、日本語を含む140以上の言語に対応しています。 このモデルは、質問応答、要約、推論、創造的な文章生成など、様々な日本語テキスト生成タスクに適しています。 **ベースモデル:** [google/gemma-3-4b-it](https://huggingface.co/google/gemma-3-4b-it) **ファインチューニング:** Unsloth, 合成データセット **主な特徴:** 日本語性能の向上 ## How to use ### 必要なライブラリのインストール まず、必要なライブラリをインストールします。Gemma 3は `transformers` 4.50.0 以降が必要です。 ```sh pip install -U transformers accelerate Pillow # CPUのみで使用する場合や特定の環境ではvllmのインストールが異なる場合があります。 # vLLMの公式ドキュメントを参照してください: https://docs.vllm.ai/en/latest/getting_started/installation.html ``` ### 画像付き推論 ```python from transformers import AutoProcessor, Gemma3ForConditionalGeneration from PIL import Image import requests import torch model_id = "DataPilot/ArrowMint-Gemma3-4B-ChocoMint-jp" model = Gemma3ForConditionalGeneration.from_pretrained( model_id, device_map="auto" ).eval() processor = AutoProcessor.from_pretrained(model_id) messages = [ { "role": "system", "content": [{"type": "text", "text": "あなたは素晴らしい日本語アシスタントです。"}] }, { "role": "user", "content": [ {"type": "image", "image": "https://cs.stanford.edu/people/rak248/VG_100K_2/2399540.jpg"}, {"type": "text", "text": "この画像を説明してください。"} ] } ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt" ).to(model.device, dtype=torch.bfloat16) input_len = inputs["input_ids"].shape[-1] with torch.inference_mode(): generation = model.generate(**inputs, max_new_tokens=100, do_sample=False) generation = generation[0][input_len:] decoded = processor.decode(generation, skip_special_tokens=True) print(decoded) ``` ### 画像無し推論 ```python from transformers import AutoProcessor, Gemma3ForConditionalGeneration import torch model_id = "DataPilot/ArrowMint-Gemma3-4B-ChocoMint-jp" model = Gemma3ForConditionalGeneration.from_pretrained( model_id, device_map="auto" ).eval() processor = AutoProcessor.from_pretrained(model_id) messages = [ { "role": "system", "content": [{"type": "text", "text": "あなたは素晴らしい日本語アシスタントです。"}] }, { "role": "user", "content": [ {"type": "text", "text": "福岡に一人で遊びに行くのですがお勧めスポットはありますか?"} ] } ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt" ).to(model.device, dtype=torch.bfloat16) input_len = inputs["input_ids"].shape[-1] with torch.inference_mode(): generation = model.generate(**inputs, max_new_tokens=100, do_sample=False) generation = generation[0][input_len:] decoded = processor.decode(generation, skip_special_tokens=True) print(decoded) ``` ## License このモデルは、ベースモデルである `google/gemma-3-4b-it` のライセンスに基づいています。 モデルの使用にあたっては、[Gemma Terms of Use](https://ai.google.dev/gemma/terms) に従ってください。 また、Gemmaモデルの使用には、[Gemma Prohibited Use Policy](https://ai.google.dev/gemma/prohibited_use_policy) が適用されます。責任あるAI開発のためのガイドラインについては、[Responsible Generative AI Toolkit](https://ai.google.dev/responsible) を参照してください。