--- license: gemma language: - ja - en base_model: - google/gemma-3-4b-it pipeline_tag: text-generation --- # DataPilot/ArrowMint-Gemma3-4B-ChocoMint-instruct-v0.1 このモデルは、Google の [google/gemma-3-4b-it](https://huggingface.co/google/gemma-3-4b-it) をベースモデルとしています。 ## Overview このモデルは、[Unsloth](https://github.com/unslothai/unsloth) フレームワークと合成データセットを用いてファインチューニングされました。主な目的は、**プロンプト追従能力の向上**です。ベースモデルである `google/gemma-3-4b-it` の持つマルチモーダル機能(テキストと画像の入力、テキストの出力)と多言語対応能力を継承しています。 このモデルは、特定の指示や文脈に対する応答精度を高めるようにトレーニングされており、対話システム、コンテンツ生成、タスク実行支援など、より的確な応答が求められる場面での利用に適しています。 ## How to use **注意:** 以下のコードを実行する前に、必要なライブラリをインストールしてください。特に `transformers` ライブラリは Gemma 3 をサポートするバージョン (4.50.0 以降) が必要です。 ```sh pip install -U transformers accelerate torch ``` ### 画像付き推論 ```python from transformers import AutoProcessor, Gemma3ForConditionalGeneration from PIL import Image import requests import torch model_id = "DataPilot/ArrowMint-Gemma3-4B-ChocoMint-instruct-v0.1" 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-instruct-v0.1" 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": "GPT3やGPT3.5などと比べてGPT4はどこがすごいのでしょうか?"} ] } ] 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](https://ai.google.dev/gemma/terms) このモデルを利用する際は、ライセンス条件を遵守してください。