🚀 Medical-Llama3-8B-16bit: 医療用質問応答に微調整されたLlama3
このリポジトリは、強力なLlama3 8Bモデルを微調整したものを提供しています。このモデルは、医療関連の質問に有益な回答をするように特別に設計されています。AI医療チャットボットデータセット(ruslanmv/ai-medical-chatbot)に含まれる豊富な知識を活用しています。
🚀 クイックスタート
このモデルは、医療関連の質問に有益な回答を提供するために、Llama3 8Bモデルを微調整したものです。AI医療チャットボットデータセットの知識を活用しています。
✨ 主な機能
- 医療特化:健康関連の質問に最適化されています。
- 知識ベース:包括的な医療チャットボットデータセットで学習されています。
- テキスト生成:有益な回答を生成します。
📦 インストール
このモデルはHugging Face Transformersライブラリを通じて利用できます。pipを使ってインストールします。
pip install transformers bitsandbytes accelerate
💻 使用例
基本的な使用法
以下は、Medical-Llama3-8B-16bit
モデルと対話し、医療関連の質問に回答を生成するPythonコードの例です。
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
import torch
model_name = "ruslanmv/Medical-Llama3-8B"
device_map = 'auto'
bnb_config = BitsAndBytesConfig(load_in_4bit=True, bnb_4bit_quant_type="nf4",bnb_4bit_compute_dtype=torch.float16,)
model = AutoModelForCausalLM.from_pretrained( model_name,quantization_config=bnb_config, trust_remote_code=True,use_cache=False,device_map=device_map)
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
tokenizer.pad_token = tokenizer.eos_token
def askme(question):
sys_message = '''
You are an AI Medical Assistant trained on a vast dataset of health information. Please be thorough and
provide an informative answer. If you don't know the answer to a specific medical inquiry, advise seeking professional help.
'''
messages = [{"role": "system", "content": sys_message}, {"role": "user", "content": question}]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
outputs = model.generate(**inputs, max_new_tokens=100, use_cache=True)
response_text = tokenizer.batch_decode(outputs)[0].strip()
answer = response_text.split('<|im_start|>assistant')[-1].strip()
return answer
question = '''I'm a 35-year-old male and for the past few months, I've been experiencing fatigue,
increased sensitivity to cold, and dry, itchy skin.
Could these symptoms be related to hypothyroidism?
If so, what steps should I take to get a proper diagnosis and discuss treatment options?'''
print(askme(question))
回答のタイプは以下のようになります。
Based on your description, it sounds like you may be experiencing symptoms of hypothyroidism.
Hypothyroidism is a condition where the thyroid gland doesn't produce enough hormones, leading to a variety of symptoms.
Some common symptoms include fatigue, weight gain, constipation, and dry skin.
If you're experiencing any of these symptoms, it's important to see a doctor for a proper diagnosis and treatment plan.
Your doctor may order blood tests to check your thyroid hormone levels
📚 ドキュメント
モデルと開発
- 開発者: ruslanmv
- ライセンス: Apache-2.0
- 微調整元のモデル: meta-llama/Meta-Llama-3-8B
重要な注意事項
このモデルは情報提供を目的としており、専門的な医療アドバイスの代替として使用すべきではありません。いかなる医療上の懸念についても、常に適格な医療提供者に相談してください。
ライセンス
このモデルはApache License 2.0の下で配布されています(詳細はLICENSEファイルを参照)。
貢献
このリポジトリへの貢献を歓迎します!改善点や提案があれば、自由にプルリクエストを作成してください。
免責事項
有益な回答を提供するよう努めていますが、モデルの出力の正確性を保証することはできません。確定的な医療アドバイスについては、医師または他の医療専門家に相談することが重要です。