Instructions to use charakaweb/phi4-clinical with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use charakaweb/phi4-clinical with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="charakaweb/phi4-clinical", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("charakaweb/phi4-clinical", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("charakaweb/phi4-clinical", trust_remote_code=True, device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use charakaweb/phi4-clinical with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "charakaweb/phi4-clinical" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "charakaweb/phi4-clinical", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/charakaweb/phi4-clinical
- SGLang
How to use charakaweb/phi4-clinical with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "charakaweb/phi4-clinical" \ --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": "charakaweb/phi4-clinical", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
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 "charakaweb/phi4-clinical" \ --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": "charakaweb/phi4-clinical", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use charakaweb/phi4-clinical with Docker Model Runner:
docker model run hf.co/charakaweb/phi4-clinical
Phi-4-mini Clinical (PyTorch / Transformers)
A specialized 3.8B biomedical & clinical reasoning foundation model built on Microsoft's Phi-4-mini-instruct, formatted for standard Hugging Face transformers and PyTorch.
ποΈ 3-Stage Transfer Learning Curriculum
- Stage 1 (STEM Foundation): 116,000 instruction pairs across NCERT Classes 6β12 (Physics, Chemistry, Biology) eliminating foundational science hallucinations.
- Stage 2 (PubMed 2026 Evidence): 12 recent 2026 clinical update archives from NCBI FTP covering survival outcomes (OS, PFS, HR), targeted therapeutics, and clinical trial endpoints.
- Stage 3 (Comprehensive Internal Medicine): Balanced multi-specialty clinical curriculum (cardiology, nephrology, endocrinology, pulmonology) with an active oncology replay buffer.
All LoRA adapter weights have been permanently fused into the base weights.
π Benchmark Results (PubMedQA)
Evaluated on 50 biomedical research decision tasks from PubMedQA:
| Model | Accuracy | Score | Avg Latency | Relative Improvement |
|---|---|---|---|---|
| Base Phi-4-mini (4-bit) | 26.0% | 13 / 50 | 1.02s / question | Baseline |
| Phi-4-mini Clinical (Merged) | 40.0% | 20 / 50 | 0.93s / question | +53.8% relative gain |
β‘ Quickstart with Transformers
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "charakaweb/phi4-clinical"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
device_map="auto"
)
prompt = "<|user|>\nWhat are the first-line therapeutic recommendations for heart failure with preserved ejection fraction (HFpEF)?<|end|>\n<|assistant|>\n"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=256)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
βοΈ Clinical Disclaimer
This model is intended solely for biomedical research, educational exploration, and experimental evaluation. It is not an FDA-cleared medical device and must not be used as a substitute for professional clinical judgment, diagnosis, or treatment.
π Verified Medical Benchmark Results
| Benchmark | Scope | Tested Samples | Accuracy | Evaluation Hardware |
|---|---|---|---|---|
| PubMedQA | Clinical Trial Evidence Decisions | 100 | 49.0% | Apple Silicon Metal GPU |
| MedQA (USMLE) | Medical Board Diagnostic Cases | 100 | 53.0% | Apple Silicon Metal GPU |
- Downloads last month
- 462
Model tree for charakaweb/phi4-clinical
Base model
microsoft/Phi-4-mini-instruct