Text Generation
TensorBoard
Safetensors
GGUF
Chinese
qwen3_5_text
medical
qwen
lora
chinese-medical
doctor-song
quantized
conversational
Instructions to use Songlei327/Doctor.Song-0.8B-Medical with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use Songlei327/Doctor.Song-0.8B-Medical with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf Songlei327/Doctor.Song-0.8B-Medical:Q4_K_M # Run inference directly in the terminal: llama cli -hf Songlei327/Doctor.Song-0.8B-Medical:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf Songlei327/Doctor.Song-0.8B-Medical:Q4_K_M # Run inference directly in the terminal: llama cli -hf Songlei327/Doctor.Song-0.8B-Medical:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf Songlei327/Doctor.Song-0.8B-Medical:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf Songlei327/Doctor.Song-0.8B-Medical:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf Songlei327/Doctor.Song-0.8B-Medical:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf Songlei327/Doctor.Song-0.8B-Medical:Q4_K_M
Use Docker
docker model run hf.co/Songlei327/Doctor.Song-0.8B-Medical:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use Songlei327/Doctor.Song-0.8B-Medical with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Songlei327/Doctor.Song-0.8B-Medical" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Songlei327/Doctor.Song-0.8B-Medical", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Songlei327/Doctor.Song-0.8B-Medical:Q4_K_M
- Ollama
How to use Songlei327/Doctor.Song-0.8B-Medical with Ollama:
ollama run hf.co/Songlei327/Doctor.Song-0.8B-Medical:Q4_K_M
- Unsloth Desktop
- Pi
How to use Songlei327/Doctor.Song-0.8B-Medical with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf Songlei327/Doctor.Song-0.8B-Medical:Q4_K_M
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "Songlei327/Doctor.Song-0.8B-Medical:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use Songlei327/Doctor.Song-0.8B-Medical with Docker Model Runner:
docker model run hf.co/Songlei327/Doctor.Song-0.8B-Medical:Q4_K_M
- Lemonade
How to use Songlei327/Doctor.Song-0.8B-Medical with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull Songlei327/Doctor.Song-0.8B-Medical:Q4_K_M
Run and chat with the model
lemonade run user.Doctor.Song-0.8B-Medical-Q4_K_M
List all available models
lemonade list
- Hermes Agent
How to use Songlei327/Doctor.Song-0.8B-Medical with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf Songlei327/Doctor.Song-0.8B-Medical:Q4_K_M
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default Songlei327/Doctor.Song-0.8B-Medical:Q4_K_M
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use Songlei327/Doctor.Song-0.8B-Medical with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf Songlei327/Doctor.Song-0.8B-Medical:Q4_K_M
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "Songlei327/Doctor.Song-0.8B-Medical:Q4_K_M" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
Doctor.Song-0.8B-Medical
中文医学对话大模型。基于 Qwen3.5-0.8B-Base,在单卡 RTX 3090 (24GB) 上完成 PT → SFT → DPO → SFT-CoT 四阶段全流程训练。
模型规格
| 项目 | 值 |
|---|---|
| 基座模型 | Qwen3.5-0.8B-Base |
| 参数 | 0.8B (24层, hidden=1024, 8头注意力) |
| 词表大小 | 248,320 |
| 训练硬件 | 单卡 RTX 3090 (24GB) |
| 全流程微调耗时 | ~5 小时 |
可用版本
| 版本 | 路径 | 体积 | 用途 |
|---|---|---|---|
| FP32 | 根目录 | 2.82 GB | 完整精度,适合 GPU 生产部署 |
| 4-bit NF4 | /4bit |
1.21 GB | 双重量化,适合低显存/移动端 |
| GGUF Q4_K_M | /gguf |
505 MB | llama.cpp 推理,Mac Metal 可达 63 tok/s |
| LoRA 适配器 | /lora/* |
40~60 MB/个 | 复现训练过程或继续微调 |
训练数据
| 阶段 | 样本量 | 方法 | 产物 |
|---|---|---|---|
| PT 增量预训练 | 11,475 条 | 全参数 | 医学教科书/论文/临床指南语料 |
| SFT 指令微调 | 7,981 对 | LoRA (r=8, α=16) | /lora/sft-lora |
| DPO 偏好对齐 | 7,316 对 | LoRA (r=8, β=0.1) | /lora/dpo-lora |
| CoT 推理链 | 3,000 条 | LoRA (r=16) | /lora/sft-cot-lora |
使用方式
Transformers(FP32 完整版)
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained(
"Songlei327/Doctor.Song-0.8B-Medical",
torch_dtype="auto",
device_map="auto",
)
tokenizer = AutoTokenizer.from_pretrained("Songlei327/Doctor.Song-0.8B-Medical")
messages = [{"role": "user", "content": "感冒发烧了应该怎么办?"}]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
output = model.generate(**inputs, max_new_tokens=512, temperature=0.7)
print(tokenizer.decode(output[0], skip_special_tokens=True))
4-bit 量化版
pip install bitsandbytes
model = AutoModelForCausalLM.from_pretrained(
"Songlei327/Doctor.Song-0.8B-Medical",
subfolder="4bit",
device_map="auto",
)
tokenizer = AutoTokenizer.from_pretrained("Songlei327/Doctor.Song-0.8B-Medical")
# 使用方式同上
llama.cpp / GGUF
# 下载 GGUF
huggingface-cli download Songlei327/Doctor.Song-0.8B-Medical --local-dir . gguf/
# 直接推理
llama-cli -m gguf/doctor-song-Q4_K_M.gguf \
-p "<|im_start|>user\n感冒发烧了应该怎么办?<|im_end|>\n<|im_start|>assistant\n" \
-n 512 -t 4
# 或启动 OpenAI 兼容 API 服务
llama-server -m gguf/doctor-song-Q4_K_M.gguf \
--port 8000 -ngl 99 --ctx-size 4096
# curl http://localhost:8000/v1/chat/completions
LoRA 适配器(复现/继续训练)
# 合并 SFT LoRA 到基座模型
python tools/merge_peft_adapter.py \
--base_model Qwen/Qwen3.5-0.8B-Base \
--lora_model ./lora/sft-lora \
--output_dir ./outputs/sft-merge
# 合并 DPO LoRA
python tools/merge_peft_adapter.py \
--base_model ./outputs/sft-merge \
--lora_model ./lora/dpo-lora \
--output_dir ./outputs/dpo-merge
推理速度参考
| 环境 | 格式 | 速度 |
|---|---|---|
| RTX 3090 bf16 | FP32 | 预估 20-40 tok/s |
| Mac MPS (Apple Silicon) | FP32 | 实测 2.3 tok/s |
| Mac Metal + llama.cpp | GGUF Q4_K_M | 实测 ~63 tok/s |
免责声明
本模型仅限研究目的使用,不能替代专业医生诊断。模型输出不代表医学建议,具体医疗问题请咨询执业医师。
- Downloads last month
- 39