Model guide
Phi-3 Mini 3.8B Instruct
Phi-3 Mini 4K Instruct is a compact text model for short instructions, extraction and bounded reasoning tasks. The 4K suffix matters: this is not the separate long-context Phi-3 download. Keep both your input and the generated answer inside that window when deciding whether it suits an older Phi-based application.
At a glance
- Parameters
- 3.8B
- Accepts
- Text
- Returns
- Text
- Published context limit
- 4,096 tokens
- Model format
- safetensors · GGUF · ONNX
- Software and download hosts
- Ollama · Transformers. Follow the exact setup below; this list does not establish support for every format, input type or software version.
- Suggested compression
- Q4
- Model-weight download
- Q4 weights · 2.39 GBmicrosoft (model publisher)Phi-3-mini-4k-instruct-q4.gguf
- Languages
- English
- License
- MIT
Will it fit?
Phi-3 Mini 3.8B Instruct · Q4 download. Fit depends on your computer, the app you run it in and the conversation length you need.
Check on your computerBest for
- Run a short packing arithmetic problem within a 4,096-token window. Leave room for the reply as well as the prompt.
Choose something else when
- Choose another Phi-3 variant or divide the material if the prompt alone approaches 4,096 tokens.
First setup
Check a representative task
Check a bounded arithmetic instruction within the short context.
A box holds 6 folders. You have 23 folders. What is the minimum number of boxes, and how many empty folder spaces remain? Give the two numbers and one sentence explaining them.
Check the result: You need 4 boxes, leaving 1 empty space. Three boxes hold only 18 folders.
This creates a 4,096-token copy of phi3:mini named phi-3-mini-4k-instruct-short-context. Save the following as a file named Modelfile in your working folder:
FROM phi3:mini
PARAMETER num_ctx 4096
Then run these commands from that folder:
ollama pull phi3:mini
ollama create phi-3-mini-4k-instruct-short-context -f ./Modelfile
ollama run phi-3-mini-4k-instruct-short-context
Run the task check. While the model is loaded, run ollama ps in another terminal and check CONTEXT and PROCESSOR.
The recorded Ollama package is Q4_0: 2.18 GB of model weights. Use Ollama 0.40.18 or a supporting newer release. A Hugging Face GGUF or MLX checkpoint is a separate representation; choose the matching source and runner in the memory calculator.
See Ollama context settings and the Modelfile instructions.
Open LM Studio’s Discover tab, search for microsoft/Phi-3-mini-4k-instruct-gguf, and download Phi-3-mini-4k-instruct-q4.gguf (Q4, 2.39 GB). See the download files. Select the file in Chat, set context to 4,096, then load it. Run the task check. If it will not load, open LM Studio Model Will Not Load.
Open a terminal in the extracted llama.cpp release folder. On Windows, replace ./llama-server below with .\llama-server.exe:
./llama-server -hf microsoft/Phi-3-mini-4k-instruct-gguf -hff Phi-3-mini-4k-instruct-q4.gguf -c 4096 --host 127.0.0.1 --port 8080
The server downloads the selected model. Wait for the model to load, then open http://127.0.0.1:8080 in your browser. Run the task check and inspect the result against its acceptance criteria. Keep the server terminal open; press Ctrl+C there to stop the server. The file list identifies the exact download. If the command fails: Unknown architecture? Update the runner. Allocation failed? Retry with less context or a smaller weight file.
Load the model, start a fresh chat and time your usual prompt. Record time until the first useful word and time until the full answer. Note the processor, context and output length when comparing another run.
