Text Generation
PEFT
Safetensors
Transformers
Japanese
lora
sft
trl
japanese
kansai-dialect
conversational
Instructions to use hpscript/kansai_gemma_lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use hpscript/kansai_gemma_lora with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("google/gemma-2-2b-it") model = PeftModel.from_pretrained(base_model, "hpscript/kansai_gemma_lora") - Transformers
How to use hpscript/kansai_gemma_lora with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="hpscript/kansai_gemma_lora") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("hpscript/kansai_gemma_lora", dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use hpscript/kansai_gemma_lora with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "hpscript/kansai_gemma_lora" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "hpscript/kansai_gemma_lora", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/hpscript/kansai_gemma_lora
- SGLang
How to use hpscript/kansai_gemma_lora with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "hpscript/kansai_gemma_lora" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "hpscript/kansai_gemma_lora", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "hpscript/kansai_gemma_lora" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "hpscript/kansai_gemma_lora", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use hpscript/kansai_gemma_lora with Docker Model Runner:
docker model run hf.co/hpscript/kansai_gemma_lora
| base_model: google/gemma-2-2b-it | |
| library_name: peft | |
| pipeline_tag: text-generation | |
| tags: | |
| - base_model:adapter:google/gemma-2-2b-it | |
| - lora | |
| - sft | |
| - transformers | |
| - trl | |
| - japanese | |
| - kansai-dialect | |
| language: | |
| - ja | |
| license: gemma | |
| # Kansai Gemma LoRA 🗣️ | |
| 関西弁で応答するGemma 2 2B ITモデルのLoRAアダプターです。 | |
| ## モデル概要 | |
| このモデルは、Googleの`gemma-2-2b-it`をベースに、関西弁での対話を可能にするためにLoRA(Low-Rank Adaptation)を使用してファインチューニングされています。標準語での質問に対して、自然な関西弁で応答することができます。 | |
| ### 主な特徴 | |
| - **ベースモデル**: google/gemma-2-2b-it | |
| - **言語**: 日本語(関西弁) | |
| - **モデルサイズ**: 2B parameters | |
| - **ファインチューニング手法**: LoRA (Low-Rank Adaptation) | |
| - **タスク**: テキスト生成、対話 | |
| ## モデル詳細 | |
| ### Model Description | |
| - **開発者**: hpscript | |
| - **モデルタイプ**: 言語モデル (LoRAアダプター) | |
| - **言語**: 日本語(関西弁) | |
| - **ライセンス**: Gemma License | |
| - **ベースモデル**: google/gemma-2-2b-it | |
| ### LoRA設定 | |
| - **r (rank)**: 16 | |
| - **lora_alpha**: 32 | |
| - **lora_dropout**: 0.05 | |
| - **target_modules**: q_proj, k_proj, v_proj, o_proj | |
| - **task_type**: CAUSAL_LM | |
| ## 使用方法 | |
| ### インストール | |
| ```bash | |
| pip install transformers peft torch | |
| ``` | |
| ### 基本的な使用例 | |
| ```python | |
| from transformers import AutoTokenizer, AutoModelForCausalLM | |
| from peft import PeftModel | |
| # ベースモデルとトークナイザーのロード | |
| base_model_id = "google/gemma-2-2b-it" | |
| model = AutoModelForCausalLM.from_pretrained( | |
| base_model_id, | |
| device_map="auto", | |
| torch_dtype="auto" | |
| ) | |
| tokenizer = AutoTokenizer.from_pretrained(base_model_id) | |
| # LoRAアダプターのロード | |
| model = PeftModel.from_pretrained(model, "hpscript/kansai_gemma_lora") | |
| # テキスト生成 | |
| prompt = "今日はいい天気ですね。" | |
| inputs = tokenizer(prompt, return_tensors="pt").to(model.device) | |
| outputs = model.generate( | |
| **inputs, | |
| max_new_tokens=100, | |
| temperature=0.7, | |
| top_p=0.9, | |
| do_sample=True | |
| ) | |
| response = tokenizer.decode(outputs[0], skip_special_tokens=True) | |
| print(response) | |
| ``` | |
| ### チャット形式での使用 | |
| ```python | |
| # チャットテンプレートを使用 | |
| messages = [ | |
| {"role": "user", "content": "おはようございます!今日の予定は?"} | |
| ] | |
| input_ids = tokenizer.apply_chat_template( | |
| messages, | |
| add_generation_prompt=True, | |
| return_tensors="pt" | |
| ).to(model.device) | |
| outputs = model.generate( | |
| input_ids, | |
| max_new_tokens=256, | |
| temperature=0.7, | |
| top_p=0.9, | |
| do_sample=True | |
| ) | |
| response = tokenizer.decode(outputs[0], skip_special_tokens=True) | |
| print(response) | |
| ``` | |
| ## トレーニング詳細 | |
| ### トレーニングデータ | |
| 関西弁の対話データセットを使用してファインチューニングを実施しました。 | |
| ### トレーニング設定 | |
| - **Framework**: PEFT 0.18.0 | |
| - **手法**: LoRA (Low-Rank Adaptation) | |
| - **ベースモデル**: google/gemma-2-2b-it | |
| - **最適化手法**: Supervised Fine-Tuning (SFT) | |
| ## 制限事項 | |
| ### 技術的制限 | |
| - 関西弁の表現は学習データに依存するため、一部不自然な表現が含まれる可能性があります | |
| - 特定の方言表現や語彙については、ベースモデルの能力に制約されます | |
| - 複雑な文脈や専門用語については、標準語が混在する可能性があります | |
| ### 推奨される使用方法 | |
| - カジュアルな対話システム | |
| - 言語学習・方言研究 | |
| - エンターテインメント用途 | |
| ### 推奨されない使用方法 | |
| - 公式文書の作成 | |
| - 医療・法律などの専門的なアドバイス | |
| - 重要な意思決定のサポート | |
| ## バイアスとリスク | |
| - 関西弁の表現にはステレオタイプや偏りが含まれる可能性があります | |
| - ベースモデルの持つバイアスが継承されている可能性があります | |
| - 文化的に不適切な表現が生成される可能性があります | |
| 使用者は、これらの制限を理解した上で適切に使用してください。 | |
| ## ライセンス | |
| このモデルは、ベースモデルであるGemma 2のライセンス条項に従います。詳細は[Gemma Terms of Use](https://ai.google.dev/gemma/terms)をご確認ください。 | |
| ## 引用 | |
| このモデルを使用する場合は、以下のように引用してください: | |
| ```bibtex | |
| @misc{kansai_gemma_lora, | |
| author = {[Your Name]}, | |
| title = {Kansai Gemma LoRA: A Gemma 2 2B model fine-tuned for Kansai dialect}, | |
| year = {2025}, | |
| publisher = {HuggingFace}, | |
| howpublished = {\url{https://huggingface.co/YOUR_USERNAME/kansai_gemma_lora}} | |
| } | |
| ``` | |
| ## お問い合わせ | |
| 質問や問題がある場合は、[Issues](https://huggingface.co/YOUR_USERNAME/kansai_gemma_lora/discussions)でお知らせください。 | |
| --- | |
| ### Framework versions | |
| - PEFT 0.18.0 | |
| - Transformers 4.x | |
| - PyTorch 2.x | |