[whatmodel.sh](../../README.md) / Phi-2 (2.7B) # Phi-2 (2.7B) Microsoft · released 2023-12 · 2.78B params · mit **score 40.3** ±0.6 · #559 of 732 · from 19 benchmark results across 8 sources Score within the [LMArena (text)](https://whatmodel.sh/?set=lmarena-text&score=set) comparison set only. ## What it's good at ● marks Phi-2 (2.7B) among every model on that task or test, worst to best.
task vs the others rank counts tests coding ▁▁▁▃●▇█▇▅▄▃▁ #383 of 469 70% 6 chat & writing ▁●▁▃▆▄▆█▆▇▇▃ #398 of 402* 8.0% 2 math ▁▁▃▅█●▄█▄▂▁▁ #219 of 431* 2.8% 1
test result vs the others in its run difficulty counts why HumanEval 49.4% ▁·▁▁▃▄●▅█▃▁▁ beats 35/99 easy · avg 76% 43% sharp · at its level · several runs HumanEval+ 45.1% ▁·▁▁▁▃▄●▄█▃▁ beats 37/99 easy · avg 70% 19% sharp · at its level MBPP+ 54.2% ▁···▁▁▂▅●█▆▂ beats 25/75 easy · avg 66% 3.8% at its level MBPP 55.0% ▁▁▁▄▅█●▅▄▁▂▁ beats 46/86 easy · avg 68% 1.7% at its level CRUXEval-I 31.6% ▁··▁●▂█▇▁··▁ beats 5/22 medium · avg 52% 1.1% at its level CRUXEval-O 33.5% ▁·▂●▁█▁▂···▁ beats 4/22 medium · avg 51% 1.1% blunt · at its level
test result vs the others in its run difficulty counts why AlpacaEval 2 length-controlled 4.4% ▁●▂▃▆▆█▆▄▄▁▁ beats 7/122 medium · avg 35% 7.4% sharp AlpacaEval 1.0 win rate (vs text-… 30.7% ▂●·▆·▇▃▆█▆▄▂ beats 3/45 very easy · avg 94% 0.6% sharp · noisy
test result vs the others in its run difficulty counts why GSM8K 57.2% ▂▂▂▂▃▄▅●██▆▄ beats 96/206 easy · avg 73% 2.8% sharp · at its level
test result vs the others in its run difficulty counts why EvoEval (overall) 31.8% ▂▂▃▄▄●▁▄▅▃▁▃ beats 16/42 medium · avg 52% 7.9% at its level BIG-Bench Hard 43.4% ▁▁▁▁▂▄●▆█▃▃▁ beats 44/155 medium · avg 65% 4.7% sharp ARC Challenge 71.3% ▄▁▁▂▁▄█▇▃●▃▂ beats 120/140 easy · avg 85% 2.3% sharp · at its level MMLU 52.7% ▁▁▁▁▁▂▂●██▆▄ beats 60/214 easy · avg 79% 2.2% at its level Open PT-LLM Leaderboard average (… 36.5% ▃▁▁▁●▁▁▁▂█▅▁ beats 45/276 medium · avg 72% 0.7% at its level · noisy C-Eval 23.4% ●···▁▁▂▁▂▂▃█ beats 0/33 medium · avg 59% 0.7% at its level · noisy Vectara hallucination leaderboard… 93.3% ▁▁▂▃▄●█▆▃▂▂▁ beats 45/140 very easy · avg 94% 0.3% blunt · noisy COPA 90.2% ▅·▃·▃··█●··▃ beats 7/8 easy · avg 92% 0.1% at its level · noisy
source results share of the score EvalPlus / EvalPerf published evaluatio… 3 48% ▇▇▇▇▇▇ Top Leaderboard Ranking = Top Coding Pr… 2 23% ▇▇▇ MiniCPM: Unveiling the Potential of Sma… 7 18% ▇▇ AlpacaEval 1.0 and 2.0 leaderboards 2 8% ▇ CRUXEval published evaluation results 2 2% ▇ Open Portuguese LLM Leaderboard 1 1% ▇ Vectara hallucination leaderboard 1 0% ▇ From Test-Taking to Test-Making: Examin… 1 0% ▇ prior: pull toward the middle 0% ▇ weighted average = 40.3Licences: EvalPlus / EvalPerf published evaluation runs ([Apache-2.0](../../licenses/evalplus-published-runs-Apache-2.0.txt)) · Top Leaderboard Ranking = Top Coding Proficiency ([CC BY 4.0](../../licenses/paper-2403.19114v1-CC-BY-4.0.txt)) · MiniCPM: Unveiling the Potential of Small Language Models with Scalable Training Strategies ([CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)) · AlpacaEval 1.0 and 2.0 leaderboards ([Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0)) · CRUXEval published evaluation results ([MIT](../../licenses/cruxeval-published-results-MIT.txt)) · Open Portuguese LLM Leaderboard ([Apache-2.0](../../licenses/hf-leaderboard-spaces-Apache-2.0.txt)) · Vectara hallucination leaderboard ([Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0)) · From Test-Taking to Test-Making: Examining LLM Authoring of Commonsense Assessment Items ([CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/)) ## How to run it ### llama.cpp (recommended) 1. Install llama.cpp. Homebrew and winget installs name the commands llama-cli and llama-server instead. [Other ways to install](https://github.com/ggml-org/llama.cpp/blob/master/docs/install.md) ```sh # macOS / Linux curl -LsSf https://llama.app/install.sh | sh # Windows irm https://llama.app/install.ps1 | iex ``` 2. Run Phi-2 (2.7B) (Q4_K_M, needs ~1.8 GB, from [huggingface.co/TheBloke](https://huggingface.co/TheBloke/phi-2-GGUF/tree/5a454d977c6438bb9fb2df233c8ca70f21c87420)) ```sh llama cli -hf TheBloke/phi-2-GGUF:Q4_K_M ``` 3. Or start a local server and open the address it prints (http://localhost:9931) ```sh llama serve -hf TheBloke/phi-2-GGUF:Q4_K_M ``` Other versions: Q8_0 (~3 GB) `llama cli -hf TheBloke/phi-2-GGUF:Q8_0` ### LM Studio 1. Install LM Studio. Open the app once before using the lms command. [Download it (macOS / Windows / Linux)](https://lmstudio.ai/download) 2. Run Phi-2 (2.7B) (Q4_K_M, needs ~1.8 GB, from [huggingface.co/TheBloke](https://huggingface.co/TheBloke/phi-2-GGUF/tree/5a454d977c6438bb9fb2df233c8ca70f21c87420)) ```sh lms get https://huggingface.co/TheBloke/phi-2-GGUF@Q4_K_M -y ``` 3. Then run lms ls to see its name, and lms chat followed by that name Other versions: Q8_0 (~3 GB) `lms get https://huggingface.co/TheBloke/phi-2-GGUF@Q8_0 -y` · 4bit (~1.6 GB, Mac only) `lms get https://huggingface.co/jesusoctavioas/phi-2-mlx-4Bit -y` ### Ollama 1. Install Ollama. [Download it (macOS / Windows)](https://ollama.com/download) ```sh # Linux curl -fsSL https://ollama.com/install.sh | sh ``` 2. Run Phi-2 (2.7B) (Q4_0, needs ~1.6 GB, from [ollama.com](https://ollama.com/library/phi/tags)) ```sh ollama run phi:2.7b ``` ### MLX (Mac) 1. Install MLX (Mac). Apple silicon Macs only, text only. ```sh # with uv uv tool install mlx-lm # or pip install mlx-lm ``` 2. Run Phi-2 (2.7B) (4bit, needs ~1.6 GB, Mac only, from [huggingface.co/jesusoctavioas](https://huggingface.co/jesusoctavioas/phi-2-mlx-4Bit/tree/6fef5f4133b69b3370df229b9f11dd7c42d24333)) ```sh mlx_lm.chat --model jesusoctavioas/phi-2-mlx-4Bit ``` 3. Or start an OpenAI-compatible server at http://localhost:8080/v1 ```sh mlx_lm.server --model jesusoctavioas/phi-2-mlx-4Bit ``` ### Other ways to run it 1. Run it as published (fp16, needs ~5.56 GB, from [huggingface.co/microsoft](https://huggingface.co/microsoft/phi-2/tree/810d367871c1d460086d9f82db8696f2e0a0fcd0)) ```sh uv run --with torch --with 'transformers<5' python -c "from transformers import pipeline; print(pipeline('text-generation', model='microsoft/phi-2')('Once upon a time', max_new_tokens=40)[0]['generated_text'])" ``` Model repository and documentation: [huggingface.co/microsoft](https://huggingface.co/microsoft/phi-2) [interactive version](https://whatmodel.sh/model/phi-2) · [JSON](https://whatmodel.sh/api?format=json&all=1)