Phi-3

Microsoft · 2024-04-22 · analysed 2026-08-08 · skill v0.3.1

dense full-attention text-only undisclosed medium on-device

Design overview

Phi-3-mini is a compact dense decoder-only transformer built, per the report, on a block structure similar to Llama-2: 32 layers, hidden size 3072, 32 attention heads, and a 32,064-token vocabulary shared with the Llama-2 tokenizer (BoS tokens removed, chat tokens added). The report never names its positional encoding, normalization, or activation — only dimensions and head counts — though the stated Llama-2 lineage and the LongRope extension point to RoPE. Its defining contribution is not the block but the data: a 'data-optimal regime' in which heavily filtered web data (selected for 'educational level') and LLM-generated synthetic data are calibrated to a small model's capacity, trained in two sequential phases (web-heavy, then filtered-web plus synthetic) for 3.3T tokens in bfloat16. Default context is 4K, extended to 128K by LongRope for the phi-3-mini-128K variant. Post-training is a two-stage SFT + DPO pipeline with red-teaming and RAI safety evaluation. The family scales the recipe: phi-3-small (7B) swaps in the tiktoken tokenizer, GEGLU, muP-tuned hyperparameters, GQA (4 queries per key), and a novel blocksparse attention that alternates dense and sparse layers with custom Triton/vLLM kernels; phi-3-medium (14B) reuses mini's architecture at 40 layers and hidden size 5120. Later phi-3.5 variants add a top-2-of-16 MoE (6.6B active of 42B), long-context mid-training, and a CLIP-based vision variant. The result is a 3.8B model that rivals far larger models on the report's own benchmarks and runs fully offline on a phone.

What the report claims is novel

Atlas assessment: The genuinely novel pieces are the 'data-optimal regime' training recipe — heavily filtered web plus synthetic data at small scale, explicitly deviating from compute-optimal scaling laws — and phi-3-small's blocksparse attention with custom kernels; nearly everything else (Llama-2-style decoder block, MHA, GQA, GEGLU, muP, LongRope extension, SFT + DPO) is adopted from prior architectures the report itself names and cites. The headline claim that a 3.8B model rivals Mixtral 8x7B and GPT-3.5 rests on the report's own evaluation pipeline, which the report discloses as unoptimised for phi-3 — a credible but self-run comparison. The phi-3.5-MoE variant is a conventional top-2-of-16 routed MoE whose SparseMixer router training is cited from prior work, adding little architectural novelty. Relative to other atlas entries, phi-3 is architecturally conservative (like Llama 3.1) but methodologically distinctive in making data quality, not compute, the primary lever — and it is the atlas taxonomy's anchor for on-device design intent.

Relation to the atlas

Lineage in

Influence out

Notable omissions

Closest relatives in the atlas

Spec sheet

Identity

FamilyPhi-3[1]
OrganisationMicrosoft[2]
Release date2024-04-22
Report URLhttps://arxiv.org/abs/2404.14219[3]
Licensenot disclosed
Open weightsnot disclosed

Variants

Scale

Total parameters3.8B[4]
Active parameters / token3.8B
Layers32[5]
Hidden dimension3072[5]
FFN inner dimensionnot disclosed
FFN rationot disclosed
Query heads32[5]
KV heads32
Head dimension96
Vocabulary size32064[6]
Embedding tyingnot disclosed

Per-variant configs

VariantTotalLayersHiddenFFNQ headsKV headsContext
phi-3-small7B324096not disclosed3288,192
phi-3-medium14B405120not disclosed4040not disclosed

Core block

Block typedense
Attention variantMHA
Attention layer patternuniform
Depth mixingsequential-residual
Activationnot disclosed
Expert countn/a[7]
Experts per tokenn/a[7]
Shared expertsn/a[7]
Routingn/a[7]
Load balancingn/a[7]
Expert granularityn/a[7]
Methodnot disclosed
RoPE base frequencynot disclosed
Partial RoPEnot disclosed
Typenot disclosed
Placementnot disclosed
QK-normnot disclosed
Attention sinksnot disclosed
Softcappingnot disclosed
Othernot disclosed

Context

Trained context length4,096[5]
Deployed context length131,072
Extension methodLongRope (LongRoPE, [DZZ+24a]); the phi-3.5 series additionally uses 'a mixed context window approach' during mid-training[8]

Tokenizer

AlgorithmSentencePiece BPE (same tokenizer as Llama-2)
NotesSame tokenizer as Llama-2: BoS tokens removed and additional tokens added for the chat template (footnote 1, §2); vocab size 32064 lives in scale.vocab_size. phi-3-small instead 'leverages the tiktoken tokenizer (for better multilingual tokenization) with a vocabulary size of 100352' with unused tokens removed (§2).[5]

Training

Training tokens3.3T[4]
Data compositionHeavily filtered publicly available web data (filtered to an 'educational level' from various open internet sources) plus synthetic LLM-generated data; mixture proportions not disclosed. phi-3-small adds 'an additional 10% multilingual data' (§2). phi-3-medium and phi-3-small trained on 4.8T tokens (Abstract).[9]
Curriculum / stagingTwo disjoint sequential pre-training phases: phase-1 mostly web sources for general knowledge and language understanding; phase-2 a more heavily filtered subset of the web data plus synthetic data for logical reasoning and niche skills. Framed as the 'data optimal regime' — calibrating data quality for a given scale — rather than the compute-optimal regime.[10]
Optimizernot disclosed
LR schedulenot disclosed
Batch schedulenot disclosed
Precisionbfloat16[5]
Parallelismnot disclosed
Hardwarenot disclosed
Disclosed computenot disclosed

Post-training

SFTyes[11]
Preference optimisationDPO[12]
Reasoning trainingnot disclosed
Distillationnot disclosed

Modality

Typetext-only
Attachmentn/a[7]

Inference efficiency

KV-cache designMHA with 32 heads: full per-head KV cache with no sharing, so KV-cache size scales with all 32 heads
Quantisation shipped4-bit quantization: phi-3-mini occupies approximately 1.8 GB and runs natively on an iPhone 14 (A16 Bionic), fully offline, at over 12 tokens per second[13]
Speculative decodingnone disclosed
Serving optimisationsnone disclosed

Evaluation

Benchmarks (report's own numbers only)

BenchmarkValueRef
MMLU (5-Shot)68.8§3 benchmark table (phi-3-mini column)
MT Bench (2 round ave.)8.38§3 benchmark table (phi-3-mini column)
HellaSwag (5-Shot)76.7§3 benchmark table (phi-3-mini column)
GSM-8K (8-Shot; CoT)82.5§3 benchmark table (phi-3-mini column)
MATH (0-Shot; CoT)41.3§3 benchmark table (phi-3-mini column)
MedQA (2-Shot)53.8§3 benchmark table (phi-3-mini column)
TriviaQA (5-Shot)64.0§3 benchmark table (phi-3-mini column)
Arc-C (10-Shot)84.9§3 benchmark table (phi-3-mini column)
BigBench-Hard (3-Shot; CoT)71.7§3 benchmark table (phi-3-mini column)
WinoGrande (5-Shot)70.8§3 benchmark table (phi-3-mini column)
TruthfulQA (10-Shot; MC2)65.0§3 benchmark table (phi-3-mini column)
BoolQ (2-Shot)77.2§3 benchmark table (phi-3-mini column)
HumanEval (0-Shot)58.5§3 benchmark table (phi-3-mini column)
MBPP (3-Shot)70.0§3 benchmark table (phi-3-mini column)
GPQA (2-Shot; CoT)32.8§3 benchmark table (phi-3-mini column)

Provenance references

  1. stated · Title / Abstract
  2. stated · Title block
  3. stated · pipeline
  4. stated · Abstract / §1 / §2
  5. stated · §2
  6. stated · §2 (footnote 1)
  7. n/a · §2
  8. stated · §2 / §4
  9. stated · Abstract / §1 / Training Methodology
  10. stated · Training Methodology
  11. stated · Post-training / §2
  12. stated · Post-training
  13. stated · §2 / Figure 2