Instructions to use charakaweb/phi4-clinical-mlx with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use charakaweb/phi4-clinical-mlx with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("charakaweb/phi4-clinical-mlx") prompt = "Write a story about Einstein" messages = [{"role": "user", "content": prompt}] prompt = tokenizer.apply_chat_template( messages, add_generation_prompt=True ) text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Pi
How to use charakaweb/phi4-clinical-mlx with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "charakaweb/phi4-clinical-mlx"
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "charakaweb/phi4-clinical-mlx" } ] } } }Run Pi
# Start Pi in your project directory: pi
- MLX LM
How to use charakaweb/phi4-clinical-mlx with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "charakaweb/phi4-clinical-mlx"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "charakaweb/phi4-clinical-mlx" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "charakaweb/phi4-clinical-mlx", "messages": [ {"role": "user", "content": "Hello"} ] }' - Hermes Agent
How to use charakaweb/phi4-clinical-mlx with Hermes Agent:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "charakaweb/phi4-clinical-mlx"
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 charakaweb/phi4-clinical-mlx
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use charakaweb/phi4-clinical-mlx with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "charakaweb/phi4-clinical-mlx"
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 "charakaweb/phi4-clinical-mlx" \ --custom-provider-id mlx-lm \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
Phi-4-mini Clinical MLX (4-Bit Merged)
A specialized 3.8B biomedical & clinical reasoning model built on Microsoft's Phi-4-mini-instruct, optimized natively for Apple Silicon Metal acceleration via Apple MLX.
The model underwent a 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.
The LoRA adapter weights have been permanently fused into the base 4-bit weights (mlx_lm fuse) to deliver zero-latency execution.
๐ 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 MLX (Merged) | 40.0% | 20 / 50 | 0.93s / question | +53.8% relative gain |
โก Quickstart with Apple MLX
Install mlx-lm:
pip install mlx-lm
CLI Generation
python -m mlx_lm.generate \
--model <repo_id> \
--prompt "<|user|>\nWhat are the first-line therapeutic recommendations for heart failure with preserved ejection fraction (HFpEF)?<|end|>\n<|assistant|>\n" \
--max-tokens 512
Python API
from mlx_lm import load, generate
model, tokenizer = load("<repo_id>")
prompt = "<|user|>\nSummarize the mechanism of action of SGLT2 inhibitors in diabetic kidney disease.<|end|>\n<|assistant|>\n"
response = generate(model, tokenizer, prompt=prompt, max_tokens=300)
print(response)
Local OpenAI-Compatible Server
python -m mlx_lm.server --model <repo_id> --port 8080
โ๏ธ 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
- 239
4-bit
Model tree for charakaweb/phi4-clinical-mlx
Base model
microsoft/Phi-4-mini-instruct