Instructions to use eyepyon/rcgemma2_9b_it-finetuned with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use eyepyon/rcgemma2_9b_it-finetuned with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="eyepyon/rcgemma2_9b_it-finetuned") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("eyepyon/rcgemma2_9b_it-finetuned", dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use eyepyon/rcgemma2_9b_it-finetuned with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "eyepyon/rcgemma2_9b_it-finetuned" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "eyepyon/rcgemma2_9b_it-finetuned", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/eyepyon/rcgemma2_9b_it-finetuned
- SGLang
How to use eyepyon/rcgemma2_9b_it-finetuned 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 "eyepyon/rcgemma2_9b_it-finetuned" \ --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": "eyepyon/rcgemma2_9b_it-finetuned", "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 "eyepyon/rcgemma2_9b_it-finetuned" \ --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": "eyepyon/rcgemma2_9b_it-finetuned", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use eyepyon/rcgemma2_9b_it-finetuned with Docker Model Runner:
docker model run hf.co/eyepyon/rcgemma2_9b_it-finetuned
eyepyon/rcgemma2_9b_it-finetuned
このモデルは、google/gemma-2-9b-it をベースにLoRAでファインチューニングされたモデルです。
🔧 モデル情報
- ベースモデル: google/gemma-2-9b-it
- ファインチューニング手法: LoRA (Low-Rank Adaptation)
- アテンション実装: eager (Gemma推奨)
- 量子化: 4ビット (QLoRA)
- 対応言語: 日本語
- タスク: 質問応答
🚀 使用方法
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
# ベースモデルとトークナイザーを読み込み
base_model = AutoModelForCausalLM.from_pretrained(
"google/gemma-2-9b-it",
torch_dtype="auto",
device_map="auto",
attn_implementation="eager", # Gemma推奨
trust_remote_code=True
)
tokenizer = AutoTokenizer.from_pretrained("google/gemma-2-9b-it")
# LoRAアダプターを適用
model = PeftModel.from_pretrained(base_model, "eyepyon/rcgemma2_9b_it-finetuned")
# 推論
def generate_response(context, question):
input_text = f"### コンテキスト:\n{context}\n\n### 質問:\n{question}\n\n### 回答:\n"
inputs = tokenizer(input_text, return_tensors="pt")
# GPUに移動
if torch.cuda.is_available():
inputs = {k: v.to(model.device) for k, v in inputs.items()}
with torch.no_grad():
outputs = model.generate(
**inputs,
max_length=512,
do_sample=True,
temperature=0.7,
top_p=0.9,
pad_token_id=tokenizer.eos_token_id
)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
if "### 回答:" in response:
response = response.split("### 回答:")[-1].strip()
return response
# 使用例
context = "人工知能は機械学習技術を使用してデータから学習します。"
question = "機械学習の特徴は何ですか?"
answer = generate_response(context, question)
print(answer)
📊 入力フォーマット
### コンテキスト:
[背景情報やコンテキスト]
### 質問:
[ユーザーの質問]
### 回答:
[期待される回答]
⚙️ トレーニング設定
- LoRAランク: 8
- LoRA Alpha: 16
- ターゲットモジュール: q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj
- 学習率: 2e-4
- バッチサイズ: 1 × 4 (gradient accumulation)
- グラディエントチェックポイント: use_reentrant=False
⚠️ 重要な注意事項
Gemma特有の設定
- eager attention必須:
attn_implementation="eager"を使用してください - use_cache=False: グラディエントチェックポイントとの互換性のため
- use_reentrant=False: 新しい推奨設定
制限事項
- 主に日本語での質問応答に最適化
- 生成される回答の事実確認が必要
- 特定のドメイン知識でのファインチューニング
📄 ライセンス
Apache 2.0 License
🔗 関連リンク
最終更新: 2025年05月25日