Instructions to use microsoft/Phi-3-small-8k-instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use microsoft/Phi-3-small-8k-instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="microsoft/Phi-3-small-8k-instruct", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("microsoft/Phi-3-small-8k-instruct", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use microsoft/Phi-3-small-8k-instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "microsoft/Phi-3-small-8k-instruct" # 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/Phi-3-small-8k-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/microsoft/Phi-3-small-8k-instruct
- SGLang
How to use microsoft/Phi-3-small-8k-instruct 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/Phi-3-small-8k-instruct" \ --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/Phi-3-small-8k-instruct", "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/Phi-3-small-8k-instruct" \ --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/Phi-3-small-8k-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use microsoft/Phi-3-small-8k-instruct with Docker Model Runner:
docker model run hf.co/microsoft/Phi-3-small-8k-instruct
| { | |
| "_name_or_path": "Phi-3-small-8k-instruct", | |
| "architectures": [ | |
| "Phi3SmallForCausalLM" | |
| ], | |
| "attention_dropout_prob": 0.0, | |
| "auto_map": { | |
| "AutoConfig": "configuration_phi3_small.Phi3SmallConfig", | |
| "AutoModelForCausalLM": "modeling_phi3_small.Phi3SmallForCausalLM", | |
| "AutoModelForSequenceClassification": "modeling_phi3_small.Phi3SmallForSequenceClassification", | |
| "AutoTokenizer": "tokenization_phi3_small.Phi3SmallTokenizer" | |
| }, | |
| "blocksparse_block_size": 64, | |
| "blocksparse_homo_head_pattern": false, | |
| "blocksparse_num_local_blocks": 16, | |
| "blocksparse_triton_kernel_block_size": 64, | |
| "blocksparse_vert_stride": 8, | |
| "bos_token_id": 100257, | |
| "dense_attention_every_n_layers": 2, | |
| "embedding_dropout_prob": 0.1, | |
| "eos_token_id": 100257, | |
| "ff_dim_multiplier": null, | |
| "ff_intermediate_size": 14336, | |
| "ffn_dropout_prob": 0.1, | |
| "gegelu_limit": 20.0, | |
| "gegelu_pad_to_256": true, | |
| "hidden_act": "gegelu", | |
| "hidden_size": 4096, | |
| "initializer_range": 0.02, | |
| "layer_norm_epsilon": 1e-05, | |
| "max_position_embeddings": 8192, | |
| "model_type": "phi3small", | |
| "mup_attn_multiplier": 1.0, | |
| "mup_embedding_multiplier": 10.0, | |
| "mup_use_scaling": true, | |
| "mup_width_multiplier": 8.0, | |
| "num_attention_heads": 32, | |
| "num_hidden_layers": 32, | |
| "num_key_value_heads": 8, | |
| "pad_sequence_to_multiple_of_64": true, | |
| "reorder_and_upcast_attn": false, | |
| "rope_embedding_base": 1000000, | |
| "rope_position_scale": 1.0, | |
| "torch_dtype": "bfloat16", | |
| "transformers_version": "4.38.1", | |
| "use_cache": true, | |
| "attention_bias": false, | |
| "vocab_size": 100352 | |
| } |