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)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("microsoft/MediPhi") model = AutoModelForCausalLM.from_pretrained("microsoft/MediPhi") 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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- 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
Update mergekit_config.yml
Browse files- mergekit_config.yml +39 -39
mergekit_config.yml
CHANGED
|
@@ -1,40 +1,40 @@
|
|
| 1 |
-
base_model: ./Phi-3.5-mini-instruct/
|
| 2 |
-
dtype: bfloat16
|
| 3 |
-
merge_method: breadcrumbs_ties
|
| 4 |
-
parameters:
|
| 5 |
-
int8_mask: 1.0
|
| 6 |
-
normalize: 0.0
|
| 7 |
-
slices:
|
| 8 |
-
- sources:
|
| 9 |
-
- layer_range: [0, 32]
|
| 10 |
-
model: ./
|
| 11 |
-
parameters:
|
| 12 |
-
density: 0.493602636300503
|
| 13 |
-
gamma: 1.6720241134317
|
| 14 |
-
weight: 0.06352674368303199
|
| 15 |
-
- layer_range: [0, 32]
|
| 16 |
-
model: ./
|
| 17 |
-
parameters:
|
| 18 |
-
density: 0.13945100550914405
|
| 19 |
-
gamma: 0.6330106659403112
|
| 20 |
-
weight: 0.5538401962393489
|
| 21 |
-
- layer_range: [0, 32]
|
| 22 |
-
model: ./
|
| 23 |
-
parameters:
|
| 24 |
-
density: 0.9265424817500185
|
| 25 |
-
gamma: 1.9263067682230453
|
| 26 |
-
weight: 0.2591472607914765
|
| 27 |
-
- layer_range: [0, 32]
|
| 28 |
-
model: ./
|
| 29 |
-
parameters:
|
| 30 |
-
density: 0.22471877839197088
|
| 31 |
-
gamma: 0.8906459105787018
|
| 32 |
-
weight: 0.017904019341096117
|
| 33 |
-
- layer_range: [0, 32]
|
| 34 |
-
model: ./
|
| 35 |
-
parameters:
|
| 36 |
-
density: 0.766362712622725
|
| 37 |
-
gamma: 0.2721241668046967
|
| 38 |
-
weight: 1.604598536238056
|
| 39 |
-
- layer_range: [0, 32]
|
| 40 |
model: ./Phi-3.5-mini-instruct/
|
|
|
|
| 1 |
+
base_model: ./Phi-3.5-mini-instruct/
|
| 2 |
+
dtype: bfloat16
|
| 3 |
+
merge_method: breadcrumbs_ties
|
| 4 |
+
parameters:
|
| 5 |
+
int8_mask: 1.0
|
| 6 |
+
normalize: 0.0
|
| 7 |
+
slices:
|
| 8 |
+
- sources:
|
| 9 |
+
- layer_range: [0, 32]
|
| 10 |
+
model: ./MediPhi-PubMed/
|
| 11 |
+
parameters:
|
| 12 |
+
density: 0.493602636300503
|
| 13 |
+
gamma: 1.6720241134317
|
| 14 |
+
weight: 0.06352674368303199
|
| 15 |
+
- layer_range: [0, 32]
|
| 16 |
+
model: ./MediPhi-Clinical/
|
| 17 |
+
parameters:
|
| 18 |
+
density: 0.13945100550914405
|
| 19 |
+
gamma: 0.6330106659403112
|
| 20 |
+
weight: 0.5538401962393489
|
| 21 |
+
- layer_range: [0, 32]
|
| 22 |
+
model: ./MediPhi-MedCode/
|
| 23 |
+
parameters:
|
| 24 |
+
density: 0.9265424817500185
|
| 25 |
+
gamma: 1.9263067682230453
|
| 26 |
+
weight: 0.2591472607914765
|
| 27 |
+
- layer_range: [0, 32]
|
| 28 |
+
model: ./MediPhi-MedWiki/
|
| 29 |
+
parameters:
|
| 30 |
+
density: 0.22471877839197088
|
| 31 |
+
gamma: 0.8906459105787018
|
| 32 |
+
weight: 0.017904019341096117
|
| 33 |
+
- layer_range: [0, 32]
|
| 34 |
+
model: ./MediPhi-Guidelines/
|
| 35 |
+
parameters:
|
| 36 |
+
density: 0.766362712622725
|
| 37 |
+
gamma: 0.2721241668046967
|
| 38 |
+
weight: 1.604598536238056
|
| 39 |
+
- layer_range: [0, 32]
|
| 40 |
model: ./Phi-3.5-mini-instruct/
|