Instructions to use Kerassy/Qwen3.5-4B-Medical-Reasoning with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- llama-cpp-python
How to use Kerassy/Qwen3.5-4B-Medical-Reasoning with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="Kerassy/Qwen3.5-4B-Medical-Reasoning", filename="Qwen3.5-4B.BF16-mmproj.gguf", )
llm.create_chat_completion( messages = [ { "role": "user", "content": "What is the capital of France?" } ] ) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use Kerassy/Qwen3.5-4B-Medical-Reasoning 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 Kerassy/Qwen3.5-4B-Medical-Reasoning:Q4_K_M # Run inference directly in the terminal: llama cli -hf Kerassy/Qwen3.5-4B-Medical-Reasoning:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf Kerassy/Qwen3.5-4B-Medical-Reasoning:Q4_K_M # Run inference directly in the terminal: llama cli -hf Kerassy/Qwen3.5-4B-Medical-Reasoning: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 Kerassy/Qwen3.5-4B-Medical-Reasoning:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf Kerassy/Qwen3.5-4B-Medical-Reasoning: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 Kerassy/Qwen3.5-4B-Medical-Reasoning:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf Kerassy/Qwen3.5-4B-Medical-Reasoning:Q4_K_M
Use Docker
docker model run hf.co/Kerassy/Qwen3.5-4B-Medical-Reasoning:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use Kerassy/Qwen3.5-4B-Medical-Reasoning with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Kerassy/Qwen3.5-4B-Medical-Reasoning" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Kerassy/Qwen3.5-4B-Medical-Reasoning", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Kerassy/Qwen3.5-4B-Medical-Reasoning:Q4_K_M
- Ollama
How to use Kerassy/Qwen3.5-4B-Medical-Reasoning with Ollama:
ollama run hf.co/Kerassy/Qwen3.5-4B-Medical-Reasoning:Q4_K_M
- Unsloth Studio
How to use Kerassy/Qwen3.5-4B-Medical-Reasoning with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for Kerassy/Qwen3.5-4B-Medical-Reasoning to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for Kerassy/Qwen3.5-4B-Medical-Reasoning to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for Kerassy/Qwen3.5-4B-Medical-Reasoning to start chatting
- Pi
How to use Kerassy/Qwen3.5-4B-Medical-Reasoning with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf Kerassy/Qwen3.5-4B-Medical-Reasoning:Q4_K_M
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "Kerassy/Qwen3.5-4B-Medical-Reasoning:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use Kerassy/Qwen3.5-4B-Medical-Reasoning with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf Kerassy/Qwen3.5-4B-Medical-Reasoning: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 Kerassy/Qwen3.5-4B-Medical-Reasoning:Q4_K_M
Run Hermes
hermes
- Atomic Chat new
- OpenClaw new
How to use Kerassy/Qwen3.5-4B-Medical-Reasoning with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf Kerassy/Qwen3.5-4B-Medical-Reasoning: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 "Kerassy/Qwen3.5-4B-Medical-Reasoning: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"
- Docker Model Runner
How to use Kerassy/Qwen3.5-4B-Medical-Reasoning with Docker Model Runner:
docker model run hf.co/Kerassy/Qwen3.5-4B-Medical-Reasoning:Q4_K_M
- Lemonade
How to use Kerassy/Qwen3.5-4B-Medical-Reasoning with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull Kerassy/Qwen3.5-4B-Medical-Reasoning:Q4_K_M
Run and chat with the model
lemonade run user.Qwen3.5-4B-Medical-Reasoning-Q4_K_M
List all available models
lemonade list
Qwen3.5-4B-Medical-Reasoning
Qwen3.5-4B-Medical-Reasoning is a fine-tuned 4-billion parameter model optimized for complex clinical reasoning and medical question-answering. By leveraging chain-of-thought (CoT) fine-tuning on medical reasoning traces, the model generates explicit step-by-step diagnostic reasoning inside <think> tags prior to delivering a final medical conclusion.
Key Highlights
- Reasoning Capabilities: Fine-tuned using step-by-step medical reasoning datasets to prevent superficial guessing and encourage clinical chain-of-thought.
- Dual Output Modes:
- Thinking Mode (Default): Produces explicit CoT traces inside
<think>...</think>tags for explainable medical reasoning. - Direct Mode: Can be forced to bypass reasoning and yield succinct direct answers by pre-filling closed tags (
<think>\n</think>).
- Thinking Mode (Default): Produces explicit CoT traces inside
- Strong Medical Benchmark Accuracy: Outperforms standard base models and many 7B-13B non-reasoning models on board-style medical exams.
Evaluation Results
MedQA (USMLE 4-Options Benchmark)
Evaluated on the full 1,273-question test set of GBaker/MedQA-USMLE-4-options using single-pass greedy decoding on an NVIDIA A100 GPU:
| Metric | Score / Result |
|---|---|
| Overall Accuracy | 68.34% (870 / 1,273) |
| Successfully Parsed Answers | 97.72% (1,244 / 1,273) |
| Average Inference Time | 5.95 seconds / question |
| Total Evaluation Time | 2.10 hours |
Extraction & Response Formatting Breakdown
- Option Text / Pattern Extraction: 96.2%
- Tail Fallback Matching: 1.4%
- Empty / Generation Timeout (
max_tokens=1024): 2.0% - Unparseable / Failed Extractions: 0.3%
Training Details
- Base Model:
Qwen/Qwen3.5-4B - Fine-Tuning Dataset:
FreedomIntelligence/medical-o1-reasoning-SFT(Subset:-EM, Split:Train) - Fine-Tuning Framework: Unsloth (LoRA fine-tuning)
- Hardware: 1x NVIDIA A100 (40GB VRAM)
- Prompt Format: Qwen ChatML (
<|im_start|>,<|im_end|>)
How to Use
1. Thinking Mode (Chain-of-Thought Enabled)
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
MODEL_ID = "Kerassy/Qwen3.5-4B-Medical-Reasoning"
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
model = AutoModelForCausalLM.from_pretrained(
MODEL_ID,
torch_dtype=torch.bfloat16 if torch.cuda.is_bf16_supported() else torch.float16,
device_map="auto"
)
system_prompt = "You are a clinical expert. Think step-by-step inside <think> tags before providing your final medical answer."
user_prompt = "A 45-year-old male presents with sudden chest pain, diaphoresis, and radiation to the left jaw. What is the most likely diagnosis?"
prompt = (
f"<|im_start|>system\n{system_prompt}<|im_end|>\n"
f"<|im_start|>user\n{user_prompt}<|im_end|>\n"
f"<|im_start|>assistant\n"
)
inputs = tokenizer([prompt], return_tensors="pt").to("cuda")
outputs = model.generate(
**inputs,
max_tokens=1024,
use_cache=True,
temperature=0.7,
top_p=0.9,
eos_token_id=tokenizer.eos_token_id
)
decoded = tokenizer.batch_decode(outputs, skip_special_tokens=False)[0]
response = decoded.split("<|im_start|>assistant\n")[-1].replace("<|im_end|>", "").strip()
print(response)
2. Direct Mode (Bypassing Reasoning)
To bypass the reasoning phase and generate a direct response, pre-fill the assistant turn with closed empty \n tags:
prompt_direct = (
f"<|im_start|>system\nYou are a succinct medical assistant.<|im_end|>\n"
f"<|im_start|>user\n{user_prompt}<|im_end|>\n"
f"<|im_start|>assistant\n<think>\n</think>\n"
)
inputs_direct = tokenizer([prompt_direct], return_tensors="pt").to("cuda")
outputs_direct = model.generate(
**inputs_direct,
max_tokens=1024,
eos_token_id=tokenizer.eos_token_id
)
decoded_direct = tokenizer.batch_decode(outputs_direct, skip_special_tokens=False)[0]
response_direct = decoded_direct.split("<think>\n</think>\n")[-1].replace("<|im_end|>", "").strip()
print(response_direct)
Intended Use & Limitations
Intended Use
- Medical research and evaluation of chain-of-thought capabilities in compact LLMs.
- AI-assisted clinical reasoning benchmark comparison and analysis.
Medical Disclaimer
IMPORTANT: This model is built for research and evaluation purposes only. It is not a certified medical device and should never be used for direct patient diagnosis, treatment advice, or real-world clinical decision-making. Always consult a qualified medical professional for health-related decisions.
- Downloads last month
- 343