🚀 医疗聊天模型 Meditron-7b-Guanaco
这是一个基于医疗领域的聊天模型,基于 epfl-llm/meditron-7b
基础模型,使用 open assist dataset 数据集,通过 SFT QLora 方法进行微调。它能为医疗相关问题提供专业、安全且有用的回答。
🚀 快速开始
本模型是 llama3 8b 家族的聊天模型,从基础模型 epfl-llm/meditron-7b
微调而来,使用了 open assist dataset 数据集和 SFT QLora 方法。所有线性参数的秩设为 16 并可训练。
✨ 主要特性
- 基于医疗领域的基础模型微调,能提供专业医疗建议。
- 使用特定的提示模板,确保回答的安全性和有用性。
📦 安装指南
此部分原文档未提及具体安装命令,跳过。
💻 使用示例
基础用法
model_name='jiviadmin/meditron-7b-guanaco-chat'
base_model = AutoModelForCausalLM.from_pretrained(
model_name,
low_cpu_mem_usage=True,
return_dict=True,
torch_dtype=torch.float16,
device_map={"": 0},
)
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True,add_eos_token=True)
tokenizer.add_special_tokens({'pad_token': '[PAD]'})
tokenizer.pad_token_id = 18610
tokenizer.padding_side = "right"
default_system_prompt="You are a helpful, respectful and honest medical assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature.
If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.Please consider the context below if applicable:
Context:NA"
def format_prompt(question):
return f'''<s> [INST] <<SYS>> {default_system_prompt} <</SYS>> [INST] {question} [/INST]'''
question=' My father has a big white colour patch inside of his right cheek. please suggest a reason.'
pipe = pipeline(task="text-generation", model=base_model, tokenizer=tokenizer, max_length=512,repetition_penalty=1.1,return_full_text=False)
result = pipe(format_prompt(question))
answer=result[0]['generated_text']
print(answer)
📚 详细文档
提示模板:Llama
'<s> [INST] <<SYS>>
You are a helpful, respectful and medical honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature.
If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.
<</SYS>> {question} [/INST] {Model answer } </s>'
📄 许可证
本项目采用 Apache-2.0 许可证。
📋 模型信息
属性 |
详情 |
库名称 |
transformers |
许可证 |
Apache-2.0 |
数据集 |
skumar9/orpo-mmlu |
标签 |
医疗 |