FreedomIntelligence/medical-o1-reasoning-SFT
Viewer • Updated • 90.1k • 17.1k • 1.18k
How to use ChiKoi7/Qwen2.5-3B-instruct-medical-finetuned-Heretic with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("image-text-to-text", model="ChiKoi7/Qwen2.5-3B-instruct-medical-finetuned-Heretic")
messages = [
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"},
{"type": "text", "text": "What animal is on the candy?"}
]
},
]
pipe(text=messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("ChiKoi7/Qwen2.5-3B-instruct-medical-finetuned-Heretic")
model = AutoModelForCausalLM.from_pretrained("ChiKoi7/Qwen2.5-3B-instruct-medical-finetuned-Heretic", device_map="auto")
messages = [
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"},
{"type": "text", "text": "What animal is on the candy?"}
]
},
]
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
).to(model.device)
outputs = model.generate(**inputs, max_new_tokens=40)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))How to use ChiKoi7/Qwen2.5-3B-instruct-medical-finetuned-Heretic with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "ChiKoi7/Qwen2.5-3B-instruct-medical-finetuned-Heretic"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "ChiKoi7/Qwen2.5-3B-instruct-medical-finetuned-Heretic",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this image in one sentence."
},
{
"type": "image_url",
"image_url": {
"url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"
}
}
]
}
]
}'docker model run hf.co/ChiKoi7/Qwen2.5-3B-instruct-medical-finetuned-Heretic
How to use ChiKoi7/Qwen2.5-3B-instruct-medical-finetuned-Heretic with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "ChiKoi7/Qwen2.5-3B-instruct-medical-finetuned-Heretic" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "ChiKoi7/Qwen2.5-3B-instruct-medical-finetuned-Heretic",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this image in one sentence."
},
{
"type": "image_url",
"image_url": {
"url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"
}
}
]
}
]
}'docker run --gpus all \
--shm-size 32g \
-p 30000:30000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
--env "HF_TOKEN=<secret>" \
--ipc=host \
lmsysorg/sglang:latest \
python3 -m sglang.launch_server \
--model-path "ChiKoi7/Qwen2.5-3B-instruct-medical-finetuned-Heretic" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "ChiKoi7/Qwen2.5-3B-instruct-medical-finetuned-Heretic",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this image in one sentence."
},
{
"type": "image_url",
"image_url": {
"url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"
}
}
]
}
]
}'How to use ChiKoi7/Qwen2.5-3B-instruct-medical-finetuned-Heretic with Docker Model Runner:
docker model run hf.co/ChiKoi7/Qwen2.5-3B-instruct-medical-finetuned-Heretic
| Qwen2.5-3B-instruct-medical-finetuned-Heretic | Original model (Joker-sxj/Qwen2.5-3B-instruct-medical-finetuned) |
|
|---|---|---|
| Refusals | 4/100 | 79/100 |
| KL divergence | 0.0126 | 0 (by definition) |
| Parameter | Value |
|---|---|
| direction_index | 24.64 |
| attn.o_proj.max_weight | 1.32 |
| attn.o_proj.max_weight_position | 24.56 |
| attn.o_proj.min_weight | 0.58 |
| attn.o_proj.min_weight_distance | 19.88 |
| mlp.down_proj.max_weight | 0.96 |
| mlp.down_proj.max_weight_position | 23.74 |
| mlp.down_proj.min_weight | 0.22 |
| mlp.down_proj.min_weight_distance | 17.35 |
dtypes: "bfloat16"
max_response_length: 384
kl_divergence_scale: 1.0
kl_divergence_target: 0.015
orthogonalize_direction: true
row_normalization: "full"
full_normalization_lora_rank: 3
winsorization_quantile: 0.975
n_trials: 200
n_startup_trials: 40
refusal_markers:
# defaults plus the following:
"unsafe",
"unethical",
"ethical boundaries",
"cannot assist",
"can't assist",
"not able to",
"not appropriate",
"against policies",
system_prompt: "You are a helpful assistant."
模型经过医疗数据集微调后,已初步具备推理能力,可以进行基础的问诊,且文本的质量BLEU比原模型更优。
After fine-tuning on a medical dataset, the model has initially acquired reasoning capabilities and can conduct basic consultations, with the textual quality achieving a better BLEU score than the original model.