Instructions to use if001/sample_phi-2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use if001/sample_phi-2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="if001/sample_phi-2")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("if001/sample_phi-2") model = AutoModelForCausalLM.from_pretrained("if001/sample_phi-2", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use if001/sample_phi-2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "if001/sample_phi-2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "if001/sample_phi-2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/if001/sample_phi-2
- SGLang
How to use if001/sample_phi-2 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 "if001/sample_phi-2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "if001/sample_phi-2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "if001/sample_phi-2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "if001/sample_phi-2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use if001/sample_phi-2 with Docker Model Runner:
docker model run hf.co/if001/sample_phi-2
fix
Browse files
README.md
CHANGED
|
@@ -26,14 +26,14 @@ PhiConfig {
|
|
| 26 |
"tie_word_embeddings": false,
|
| 27 |
"transformers_version": "4.38.2",
|
| 28 |
"use_cache": true,
|
| 29 |
-
"vocab_size":
|
| 30 |
}
|
| 31 |
```
|
| 32 |
|
| 33 |
```
|
| 34 |
PhiForCausalLM(
|
| 35 |
(model): PhiModel(
|
| 36 |
-
(embed_tokens): Embedding(
|
| 37 |
(embed_dropout): Dropout(p=0.0, inplace=False)
|
| 38 |
(layers): ModuleList(
|
| 39 |
(0-5): 6 x PhiDecoderLayer(
|
|
@@ -55,9 +55,8 @@ PhiForCausalLM(
|
|
| 55 |
)
|
| 56 |
(final_layernorm): LayerNorm((8,), eps=1e-05, elementwise_affine=True)
|
| 57 |
)
|
| 58 |
-
(lm_head): Linear(in_features=8, out_features=
|
| 59 |
)
|
| 60 |
-
|
| 61 |
```
|
| 62 |
|
| 63 |
```
|
|
@@ -66,7 +65,7 @@ Layer (type:depth-idx) Param #
|
|
| 66 |
===========================================================================
|
| 67 |
PhiForCausalLM --
|
| 68 |
├─PhiModel: 1-1 --
|
| 69 |
-
│ └─Embedding: 2-1
|
| 70 |
│ └─Dropout: 2-2 --
|
| 71 |
│ └─ModuleList: 2-3 --
|
| 72 |
│ │ └─PhiDecoderLayer: 3-1 410
|
|
@@ -76,10 +75,10 @@ PhiForCausalLM --
|
|
| 76 |
│ │ └─PhiDecoderLayer: 3-5 410
|
| 77 |
│ │ └─PhiDecoderLayer: 3-6 410
|
| 78 |
│ └─LayerNorm: 2-4 16
|
| 79 |
-
├─Linear: 1-2
|
| 80 |
===========================================================================
|
| 81 |
-
Total params:
|
| 82 |
-
Trainable params:
|
| 83 |
Non-trainable params: 0
|
| 84 |
===========================================================================
|
| 85 |
-
```
|
|
|
|
| 26 |
"tie_word_embeddings": false,
|
| 27 |
"transformers_version": "4.38.2",
|
| 28 |
"use_cache": true,
|
| 29 |
+
"vocab_size": 51200
|
| 30 |
}
|
| 31 |
```
|
| 32 |
|
| 33 |
```
|
| 34 |
PhiForCausalLM(
|
| 35 |
(model): PhiModel(
|
| 36 |
+
(embed_tokens): Embedding(51200, 8)
|
| 37 |
(embed_dropout): Dropout(p=0.0, inplace=False)
|
| 38 |
(layers): ModuleList(
|
| 39 |
(0-5): 6 x PhiDecoderLayer(
|
|
|
|
| 55 |
)
|
| 56 |
(final_layernorm): LayerNorm((8,), eps=1e-05, elementwise_affine=True)
|
| 57 |
)
|
| 58 |
+
(lm_head): Linear(in_features=8, out_features=51200, bias=True)
|
| 59 |
)
|
|
|
|
| 60 |
```
|
| 61 |
|
| 62 |
```
|
|
|
|
| 65 |
===========================================================================
|
| 66 |
PhiForCausalLM --
|
| 67 |
├─PhiModel: 1-1 --
|
| 68 |
+
│ └─Embedding: 2-1 409,600
|
| 69 |
│ └─Dropout: 2-2 --
|
| 70 |
│ └─ModuleList: 2-3 --
|
| 71 |
│ │ └─PhiDecoderLayer: 3-1 410
|
|
|
|
| 75 |
│ │ └─PhiDecoderLayer: 3-5 410
|
| 76 |
│ │ └─PhiDecoderLayer: 3-6 410
|
| 77 |
│ └─LayerNorm: 2-4 16
|
| 78 |
+
├─Linear: 1-2 460,800
|
| 79 |
===========================================================================
|
| 80 |
+
Total params: 872,876
|
| 81 |
+
Trainable params: 872,876
|
| 82 |
Non-trainable params: 0
|
| 83 |
===========================================================================
|
| 84 |
+
```
|