Downloads · 30 days
6
8% of all-time downloads
xjh666/medical-o1-qwen2.5-0.5b
medical-o1-qwen2.5-0.5b is a text generation model from xjh666. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as mit.
基于 Qwen2.5-0.5B-Instruct 使用 Unsloth + QLoRA 微调的医疗推理问答模型。
Downloads · 30 days
6
8% of all-time downloads
All-time downloads
79
Public
Repo size
1 GB
Likes
1
Public
Click a slice to open those files.
.safetensors1 GB · 98%
From the Hugging Face model README
基于 Qwen2.5-0.5B-Instruct 使用 Unsloth + QLoRA 微调的医疗推理问答模型。
在 RTX 3050 (4GB VRAM) 上训练完成。模型学会了先进行 <think> 推理链思考,再给出最终答案。
| 指标 | 1 epoch | 2 epoch |
|---|---|---|
| 训练 Loss | 1.70 | — |
| 验证 Loss | 1.692 | — |
| 答案关键词重叠 (50条) | 41% | 48% |
| 训练耗时 | ~6h | ~12h |
from unsloth import FastLanguageModel
import torch
model, tokenizer = FastLanguageModel.from_pretrained(
model_name="xjh666/medical-o1-qwen2.5-0.5b", # 本 LoRA 适配器
max_seq_length=1024,
dtype=None,
load_in_4bit=True,
)
FastLanguageModel.for_inference(model)
messages = [
{"role": "user", "content": "A 45-year-old man presents with chest pain and shortness of breath. What is the most likely diagnosis?"},
]
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=True,
return_tensors="pt",
).to("cuda")
outputs = model.generate(input_ids=inputs, max_new_tokens=512, temperature=0.1, top_p=0.9)
print(tokenizer.decode(outputs[0][inputs.shape[1]:], skip_special_tokens=True))
~45MB),需要配合基座模型 unsloth/Qwen2.5-0.5B-Instruct-bnb-4bit 使用merged_16bit/:完整 16-bit 合并权重 (~954MB),可直接推理(不含 LoRA 依赖)FreedomIntelligence/medical-o1-reasoning-SFT (英文子集)
包含医学问答 + 复杂推理链(Complex CoT),格式为 <think>推理</think>答案
| 参数 | 值 |
|---|---|
| 基座模型 | Qwen2.5-0.5B-Instruct-bnb-4bit (4-bit) |
| LoRA rank / alpha | 16 / 16 |
| 目标模块 | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| Batch size | 1 × 8 (gradient accumulation) |
| Max seq length | 1024 |
| Learning rate | 2e-4 (cosine) |
| 优化器 | adamw_8bit |
| 训练步数 | ~2340(1 epoch),~4680(2 epoch) |
MIT
@misc{chen2024huatuogpto1medicalcomplexreasoning,
title={HuatuoGPT-o1, Towards Medical Complex Reasoning with LLMs},
author={Junying Chen and Zhenyang Cai and Ke Ji and Xidong Wang and Wanlong Liu and Rongsheng Wang and Jianye Hou and Benyou Wang},
year={2024},
eprint={2412.18925},
archivePrefix={arXiv},
}