🚀 Qwen2.5-3B-Medical-LoRA
Qwen2.5-3B-Medical-LoRA
は、医療分野に特化したデータセットChatDoctor-HealthCareMagic-100k
を使用して、Qwen2.5-3B-Instructをファインチューニングしたモデルです。ユーザーの指示に対して医学的に関連する応答を生成し、明確かつ簡潔な健康上のガイダンスを提供することができます。

作者: AbdullahAlnemr1
ベースモデル: Qwen/Qwen2.5-3B-Instruct
データセット: lavita/ChatDoctor-HealthCareMagic-100k
トレーニングタイプ: パラメータ効率的ファインチューニング (LoRA)
フレームワーク: Transformers, PEFT, bitsandbytes, Accelerate
✨ 主な機能
Qwen2.5-3B-Medical-LoRA
は、医療分野に特化したデータセットでファインチューニングされたモデルです。以下のような機能を提供します。
- 医療に関連する質問に対して、明確かつ簡潔な回答を生成することができます。
- LoRA (Low-Rank Adaptation) を使用した効率的なトレーニングが可能で、bitsandbytesを用いた4-bit量子化により、一般的なハードウェアでのデプロイが可能です。
📦 インストール
このモデルを使用するには、以下のライブラリが必要です。
- Transformers
- PEFT
- bitsandbytes
- Accelerate
以下のコマンドでインストールできます。
pip install transformers peft bitsandbytes accelerate
💻 使用例
基本的な使用法
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
from peft import PeftModel
import torch
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-3B-Instruct", trust_remote_code=True)
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_compute_dtype=torch.float16,
bnb_4bit_use_double_quant=True,
bnb_4bit_quant_type="nf4"
)
base_model = AutoModelForCausalLM.from_pretrained(
"Qwen/Qwen2.5-3B-Instruct",
quantization_config=bnb_config,
device_map="auto",
trust_remote_code=True
)
model = PeftModel.from_pretrained(base_model, "AbdullahAlnemr1/qwen2.5-medical-lora")
model = model.merge_and_unload()
model.eval()
prompt = '''<|im_start|>system
You are a highly knowledgeable and accurate medical assistant...
<|im_end|>
<|im_start|>user
Instruction: What are the symptoms of anemia?<|im_end|>
<|im_start|>assistant
'''
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=512)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response)
高度な使用法
instruction = "I'm a 60-year-old man with a history of hypertension and type 2 diabetes..."
prompt = f'''<|im_start|>system
You are a highly knowledgeable and accurate medical assistant...
<|im_end|>
<|im_start|>user
Instruction: {instruction}<|im_end|>
<|im_start|>assistant
'''
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=512)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response)
📚 ドキュメント
ファイルとアーティファクト
adapter_model
: 医療データセットでトレーニングされたLoRAの重みです。
README.md
: プロジェクトのドキュメントです。
training_args.bin
: トレーニングの設定ファイルです。
tokenizer_config.json
, tokenizer.model
, special_tokens_map.json
: トークナイザーのファイルです。
想定される使用方法
- 医療質問応答システム
- 健康相談システム
- 医療関係者向けの教育ツール
- AI支援医療アシスタント
⚠️ 重要提示
このモデルは、専門的な医療アドバイス、診断、または治療の代替品ではありません。常に許可を得た医療提供者に相談してください。
プロンプトフォーマット
このモデルは、指示調整されたフォーマットに従っています。
<|im_start|>system
You are a highly knowledgeable and accurate medical assistant trained to provide evidence-based medical advice. Answer clearly and concisely using medical best practices. If the question is unclear or potentially harmful to answer, respond with a disclaimer.<|im_end|>
<|im_start|>user
Instruction: [YOUR INSTRUCTION HERE]
[OPTIONAL INPUT]<|im_end|>
<|im_start|>assistant
📄 ライセンス
このモデルは、Apache-2.0ライセンスの下で提供されています。