Phi-4-mini-instruct is a lightweight open model built upon synthetic data and filtered publicly available websites - with a focus on high-quality, reasoning dense data. The model belongs to the Phi-4 model family and supports 128K token context length. The model underwent an enhancement process, incorporating both supervised fine-tuning and direct preference optimization to support precise instruction adherence and robust safety measures.
Phi-4-mini-instruct supports a vocabulary size of up to
200064
tokens. The
tokenizer files
already provide placeholder tokens that can be used for downstream fine-tuning, but they can also be extended up to the model's vocabulary size.
Input Formats
Given the nature of the training data, the Phi-4-mini-instruct
model is best suited for prompts using specific formats.
Below are the two primary formats:
Chat format
This format is used for general conversation and instructions:
This format is used when the user wants the model to provide function calls based on the given tools. The user should provide the available tools in the system prompt, wrapped by <|tool|> and <|/tool|> tokens. The tools should be specified in JSON format, using a JSON dump structure. Example:
<|system|>You are a helpful assistant with some tools.<|tool|>[{"name": "get_weather_updates", "description": "Fetches weather updates for a given city using the RapidAPI Weather API.", "parameters": {"city": {"description": "The name of the city for which to retrieve weather information.", "type": "str", "default": "London"}}}]<|/tool|><|end|><|user|>What is the weather like in Paris today?<|end|><|assistant|>
Inference with vLLM
Requirements
List of required packages:
flash_attn==2.7.4.post1
torch==2.6.0
vllm>=0.7.2
Example
To perform inference using vLLM, you can use the following code snippet:
from vllm import LLM, SamplingParams
llm = LLM(model="microsoft/Phi-4-mini-instruct", trust_remote_code=True)
messages = [
{"role": "system", "content": "You are a helpful AI assistant."},
{"role": "user", "content": "Can you provide ways to eat combinations of bananas and dragonfruits?"},
{"role": "assistant", "content": "Sure! Here are some ways to eat bananas and dragonfruits together: 1. Banana and dragonfruit smoothie: Blend bananas and dragonfruits together with some milk and honey. 2. Banana and dragonfruit salad: Mix sliced bananas and dragonfruits together with some lemon juice and honey."},
{"role": "user", "content": "What about solving an 2x + 3 = 7 equation?"},
]
sampling_params = SamplingParams(
max_tokens=500,
temperature=0.0,
)
output = llm.chat(messages=messages, sampling_params=sampling_params)
print(output[0].outputs[0].text)
Inference with Transformers
Requirements
Phi-4 family has been integrated in the
4.49.0
version of
transformers
. The current
transformers
version can be verified with:
pip list | grep transformers
.
After obtaining the Phi-4-mini-instruct model checkpoints, users can use this sample code for inference.
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
torch.random.manual_seed(0)
model_path = "microsoft/Phi-4-mini-instruct"
model = AutoModelForCausalLM.from_pretrained(
model_path,
device_map="auto",
torch_dtype="auto",
trust_remote_code=True,
)
tokenizer = AutoTokenizer.from_pretrained(model_path)
messages = [
{"role": "system", "content": "You are a helpful AI assistant."},
{"role": "user", "content": "Can you provide ways to eat combinations of bananas and dragonfruits?"},
{"role": "assistant", "content": "Sure! Here are some ways to eat bananas and dragonfruits together: 1. Banana and dragonfruit smoothie: Blend bananas and dragonfruits together with some milk and honey. 2. Banana and dragonfruit salad: Mix sliced bananas and dragonfruits together with some lemon juice and honey."},
{"role": "user", "content": "What about solving an 2x + 3 = 7 equation?"},
]
pipe = pipeline(
"text-generation",
model=model,
tokenizer=tokenizer,
)
generation_args = {
"max_new_tokens": 500,
"return_full_text": False,
"temperature": 0.0,
"do_sample": False,
}
output = pipe(messages, **generation_args)
print(output[0]['generated_text'])
Runs of duyntnet Phi-4-mini-instruct-imatrix-GGUF on huggingface.co
385
Total runs
-5
24-hour runs
2
3-day runs
-570
7-day runs
-510
30-day runs
More Information About Phi-4-mini-instruct-imatrix-GGUF huggingface.co Model
More Phi-4-mini-instruct-imatrix-GGUF license Visit here:
Phi-4-mini-instruct-imatrix-GGUF huggingface.co is an AI model on huggingface.co that provides Phi-4-mini-instruct-imatrix-GGUF's model effect (), which can be used instantly with this duyntnet Phi-4-mini-instruct-imatrix-GGUF model. huggingface.co supports a free trial of the Phi-4-mini-instruct-imatrix-GGUF model, and also provides paid use of the Phi-4-mini-instruct-imatrix-GGUF. Support call Phi-4-mini-instruct-imatrix-GGUF model through api, including Node.js, Python, http.
Phi-4-mini-instruct-imatrix-GGUF huggingface.co is an online trial and call api platform, which integrates Phi-4-mini-instruct-imatrix-GGUF's modeling effects, including api services, and provides a free online trial of Phi-4-mini-instruct-imatrix-GGUF, you can try Phi-4-mini-instruct-imatrix-GGUF online for free by clicking the link below.
duyntnet Phi-4-mini-instruct-imatrix-GGUF online free url in huggingface.co:
Phi-4-mini-instruct-imatrix-GGUF is an open source model from GitHub that offers a free installation service, and any user can find Phi-4-mini-instruct-imatrix-GGUF on GitHub to install. At the same time, huggingface.co provides the effect of Phi-4-mini-instruct-imatrix-GGUF install, users can directly use Phi-4-mini-instruct-imatrix-GGUF installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
Phi-4-mini-instruct-imatrix-GGUF install url in huggingface.co: