Instructions to use shoibl/phi2_onnx with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use shoibl/phi2_onnx with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="shoibl/phi2_onnx", trust_remote_code=True)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("shoibl/phi2_onnx", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("shoibl/phi2_onnx", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use shoibl/phi2_onnx with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "shoibl/phi2_onnx" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "shoibl/phi2_onnx", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/shoibl/phi2_onnx
- SGLang
How to use shoibl/phi2_onnx 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 "shoibl/phi2_onnx" \ --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": "shoibl/phi2_onnx", "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 "shoibl/phi2_onnx" \ --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": "shoibl/phi2_onnx", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use shoibl/phi2_onnx with Docker Model Runner:
docker model run hf.co/shoibl/phi2_onnx
Upload folder using huggingface_hub
Browse files- .gitattributes +1 -0
- _model_layers.0_self_attn_rotary_emb_Constant_4_attr__value +0 -0
- _model_layers.0_self_attn_rotary_emb_Constant_attr__value +0 -0
- config.json +1 -1
- generation_config.json +6 -0
- onnx/model.onnx +3 -0
- onnx/model.onnx_data +3 -0
- onnx/model_quantized.onnx +3 -0
- quantize_config.json +38 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
onnx/model.onnx_data filter=lfs diff=lfs merge=lfs -text
|
_model_layers.0_self_attn_rotary_emb_Constant_4_attr__value
ADDED
|
Binary file (262 kB). View file
|
|
|
_model_layers.0_self_attn_rotary_emb_Constant_attr__value
ADDED
|
Binary file (262 kB). View file
|
|
|
config.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
{
|
| 2 |
-
"_name_or_path": "
|
| 3 |
"architectures": [
|
| 4 |
"PhiForCausalLM"
|
| 5 |
],
|
|
|
|
| 1 |
{
|
| 2 |
+
"_name_or_path": "microsoft/phi-2",
|
| 3 |
"architectures": [
|
| 4 |
"PhiForCausalLM"
|
| 5 |
],
|
generation_config.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"bos_token_id": 50256,
|
| 4 |
+
"eos_token_id": 50256,
|
| 5 |
+
"transformers_version": "4.37.2"
|
| 6 |
+
}
|
onnx/model.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9ed32f3280929a5a355b44d4fb2e42a38fbcd3d58ea769b044af4d360774fd1f
|
| 3 |
+
size 1628979
|
onnx/model.onnx_data
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b530fa988b74eee7a9a874998f95ea2e5bf2dfe4bccf6eb62b2255997fd33418
|
| 3 |
+
size 22237470720
|
onnx/model_quantized.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bb904a32b7edfe037e89206228d729ccc0a46395476a96de38f3d7bf7909e8a5
|
| 3 |
+
size 2784697161
|
quantize_config.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"per_channel": false,
|
| 3 |
+
"reduce_range": false,
|
| 4 |
+
"per_model_config": {
|
| 5 |
+
"model": {
|
| 6 |
+
"op_types": [
|
| 7 |
+
"Sub",
|
| 8 |
+
"Cast",
|
| 9 |
+
"Less",
|
| 10 |
+
"Add",
|
| 11 |
+
"ConstantOfShape",
|
| 12 |
+
"Concat",
|
| 13 |
+
"Reshape",
|
| 14 |
+
"Mul",
|
| 15 |
+
"MatMul",
|
| 16 |
+
"Shape",
|
| 17 |
+
"ReduceMean",
|
| 18 |
+
"Slice",
|
| 19 |
+
"Softmax",
|
| 20 |
+
"Neg",
|
| 21 |
+
"Transpose",
|
| 22 |
+
"Div",
|
| 23 |
+
"Where",
|
| 24 |
+
"Range",
|
| 25 |
+
"Unsqueeze",
|
| 26 |
+
"Squeeze",
|
| 27 |
+
"Equal",
|
| 28 |
+
"Gather",
|
| 29 |
+
"Pow",
|
| 30 |
+
"Tanh",
|
| 31 |
+
"Sqrt",
|
| 32 |
+
"Expand",
|
| 33 |
+
"Constant"
|
| 34 |
+
],
|
| 35 |
+
"weight_type": "QInt8"
|
| 36 |
+
}
|
| 37 |
+
}
|
| 38 |
+
}
|