Text Generation
Transformers
Safetensors
English
phi3
Merge
mergekit
medical
clinical
conversational
text-generation-inference
Instructions to use microsoft/MediPhi with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use microsoft/MediPhi with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="microsoft/MediPhi") 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("microsoft/MediPhi") model = AutoModelForCausalLM.from_pretrained("microsoft/MediPhi", 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 microsoft/MediPhi with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "microsoft/MediPhi" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "microsoft/MediPhi", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/microsoft/MediPhi
- SGLang
How to use microsoft/MediPhi 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 "microsoft/MediPhi" \ --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": "microsoft/MediPhi", "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 "microsoft/MediPhi" \ --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": "microsoft/MediPhi", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use microsoft/MediPhi with Docker Model Runner:
docker model run hf.co/microsoft/MediPhi
Download mergekit_config.yml from microsoft/MediPhi: direct link, hf CLI and curl.
- Browser
- Download file 1.06 kB
-
https://huggingface.co/microsoft/MediPhi/resolve/main/mergekit_config.yml
- Command line
-
hf download hf://microsoft/MediPhi/mergekit_config.yml
-
curl -L -o mergekit_config.yml https://huggingface.co/microsoft/MediPhi/resolve/main/mergekit_config.yml
1.06 kB
| base_model: ./Phi-3.5-mini-instruct/ | |
| dtype: bfloat16 | |
| merge_method: breadcrumbs_ties | |
| parameters: | |
| int8_mask: 1.0 | |
| normalize: 0.0 | |
| slices: | |
| - sources: | |
| - layer_range: [0, 32] | |
| model: ./MediPhi-PubMed/ | |
| parameters: | |
| density: 0.493602636300503 | |
| gamma: 1.6720241134317 | |
| weight: 0.06352674368303199 | |
| - layer_range: [0, 32] | |
| model: ./MediPhi-Clinical/ | |
| parameters: | |
| density: 0.13945100550914405 | |
| gamma: 0.6330106659403112 | |
| weight: 0.5538401962393489 | |
| - layer_range: [0, 32] | |
| model: ./MediPhi-MedCode/ | |
| parameters: | |
| density: 0.9265424817500185 | |
| gamma: 1.9263067682230453 | |
| weight: 0.2591472607914765 | |
| - layer_range: [0, 32] | |
| model: ./MediPhi-MedWiki/ | |
| parameters: | |
| density: 0.22471877839197088 | |
| gamma: 0.8906459105787018 | |
| weight: 0.017904019341096117 | |
| - layer_range: [0, 32] | |
| model: ./MediPhi-Guidelines/ | |
| parameters: | |
| density: 0.766362712622725 | |
| gamma: 0.2721241668046967 | |
| weight: 1.604598536238056 | |
| - layer_range: [0, 32] | |
| model: ./Phi-3.5-mini-instruct/ |