Text Generation
Transformers
Safetensors
phi3
nlp
code
conversational
custom_code
text-generation-inference
Instructions to use ErazerControl/Phi-4-mini-instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ErazerControl/Phi-4-mini-instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ErazerControl/Phi-4-mini-instruct", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("ErazerControl/Phi-4-mini-instruct", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("ErazerControl/Phi-4-mini-instruct", trust_remote_code=True) 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]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use ErazerControl/Phi-4-mini-instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ErazerControl/Phi-4-mini-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": "ErazerControl/Phi-4-mini-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ErazerControl/Phi-4-mini-instruct
- SGLang
How to use ErazerControl/Phi-4-mini-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 "ErazerControl/Phi-4-mini-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": "ErazerControl/Phi-4-mini-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 "ErazerControl/Phi-4-mini-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": "ErazerControl/Phi-4-mini-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use ErazerControl/Phi-4-mini-instruct with Docker Model Runner:
docker model run hf.co/ErazerControl/Phi-4-mini-instruct
Update modeling_phi3.py
Browse files- modeling_phi3.py +1 -2
modeling_phi3.py
CHANGED
|
@@ -35,7 +35,6 @@ from transformers.modeling_rope_utils import ROPE_INIT_FUNCTIONS
|
|
| 35 |
from transformers.modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
|
| 36 |
from transformers.processing_utils import Unpack
|
| 37 |
from transformers.utils import (
|
| 38 |
-
LossKwargs,
|
| 39 |
add_code_sample_docstrings,
|
| 40 |
add_start_docstrings,
|
| 41 |
add_start_docstrings_to_model_forward,
|
|
@@ -817,7 +816,7 @@ class Phi3Model(Phi3PreTrainedModel):
|
|
| 817 |
return causal_mask
|
| 818 |
|
| 819 |
|
| 820 |
-
class KwargsForCausalLM(FlashAttentionKwargs
|
| 821 |
|
| 822 |
|
| 823 |
class Phi3ForCausalLM(Phi3PreTrainedModel, GenerationMixin):
|
|
|
|
| 35 |
from transformers.modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
|
| 36 |
from transformers.processing_utils import Unpack
|
| 37 |
from transformers.utils import (
|
|
|
|
| 38 |
add_code_sample_docstrings,
|
| 39 |
add_start_docstrings,
|
| 40 |
add_start_docstrings_to_model_forward,
|
|
|
|
| 816 |
return causal_mask
|
| 817 |
|
| 818 |
|
| 819 |
+
class KwargsForCausalLM(FlashAttentionKwargs): ...
|
| 820 |
|
| 821 |
|
| 822 |
class Phi3ForCausalLM(Phi3PreTrainedModel, GenerationMixin):
|