ModelRefs / Phi-4 - AI model implementation reference

Phi-4 - AI model implementation reference

Phi-4 is Microsoft's December 12, 2024 open-weight 14B dense decoder-only language model for reasoning-heavy text tasks. Microsoft trained it on 9.8 trillion tokens with a data-quality and synthetic-data-centered curriculum, then applied supervised fine-tuning and direct preference optimization. Its 16,384-token context, MIT license, downloadable weights, and Microsoft Foundry availability make it a candidate for controlled self-hosted or managed deployments where quality per parameter matters.

Overview

Phi-4 is attributed to Microsoft in ModelRefs' canonical registry. Tracked modalities: Text input and output. Primary use cases considered on ModelRefs: Compact reasoning, mathematics, coding, and analysis workloads on controlled infrastructure; Private or cost-constrained text generation where open weights and an MIT license matter.

This ModelRefs profile is decision-support material, not a final or universal ranking. Confirm current behavior, access, pricing, limits, licensing, and lifecycle in Microsoft's own documentation, and evaluate Phi-4 on representative workloads before implementation.

Benchmark & Evaluation

ModelRefs holds sourced benchmark evidence for Phi-4, but a benchmark score describes only its stated protocol and date — treat it as one input, not a guarantee of real-world performance, and evaluate Phi-4 on representative workloads before selecting it.

  • Seven canonical records cover MMLU, HumanEval, DROP, GPQA, MGSM, SimpleQA, and the benchmark-maintainer Open LLM Leaderboard v2 row for the exact microsoft/phi-4 artifact.
  • The six Microsoft-reported SimpleEval rows are provider-run and have no disclosed execution date. The Open LLM Leaderboard v2 row is pinned to model SHA 381727a5ee103da6c1b14ecd3d39cd09832cbcf8 with an evaluation date of January 8, 2025.

Implementation considerations

  • Use the artifact chat template and pin microsoft/phi-4 plus a reviewed revision; Phi-family variants, quantizations, and fine-tunes cannot inherit this page's benchmark evidence.
  • Evaluate factuality and multilingual behavior on representative workloads: Microsoft reports strong reasoning results but only 3.0 on SimpleQA and identifies English as the primary intended language.
  • The exact open-weight artifact is distributed as microsoft/phi-4 under MIT and can be loaded with Transformers; hardware, precision, quantization, and serving-engine choices remain deployment responsibilities.
  • Microsoft Foundry lists Phi-4 for text chat completion with 16,384-token input and output limits and no tool calling. Managed-compute cost is deployment-specific, so this page does not present invented per-token pricing.

Architecture disclosure

  • Microsoft identifies Phi-4 as a 14B-parameter dense decoder-only Transformer with a 16K context window and text-only input/output. It is distinct from Phi-4-mini, Phi-4-multimodal, and Phi-4 reasoning variants.
  • The model card documents 1,920 H100-80G GPUs and 21 days of training. It does not publish every optimizer, parallelism, energy, carbon, or monetary-cost detail needed to reproduce the full training run.

Prompts and code examples

Load the exact Phi-4 artifact with its chat template

from transformers import AutoModelForCausalLM, AutoTokenizer

model_id = "microsoft/phi-4"
revision = "b8beb3aca94150e794f4f130ec2eb59940da9cc8"
tokenizer = AutoTokenizer.from_pretrained(model_id, revision=revision)
model = AutoModelForCausalLM.from_pretrained(
    model_id,
    revision=revision,
    device_map="auto",
    torch_dtype="auto",
)

messages = [{"role": "user", "content": "Check this proof and identify the first unsupported step."}]
inputs = tokenizer.apply_chat_template(
    messages,
    add_generation_prompt=True,
    return_tensors="pt",
    return_dict=True,
).to(model.device)
outputs = model.generate(**inputs, max_new_tokens=512, do_sample=False)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))

Provider implementation source

Training disclosure

  • Microsoft reports 9.8T training tokens drawn from filtered public documents, high-quality educational and code data, newly created synthetic textbook-like material, acquired academic books and Q&A datasets, and supervised chat data.
  • Publicly available training data has cutoff dates of June 2024 or earlier; training occurred from October through November 2024. Microsoft describes multilingual data as a minority of the training mixture, while English is the primary intended language.
  • Post-training included supervised fine-tuning and direct preference optimization. Microsoft does not publish a document-level corpus ledger, complete deduplication proof, or benchmark-contamination audit, so those boundaries remain unavailable.

History and source-reviewed changelog

  1. 2024-12-12 — Phi-4 model and technical report released

    Microsoft published the 14B Phi-4 artifact, model card, MIT license, and technical report centered on data quality and synthetic-data training.

    Milestone source
  2. 2025-01-08 — Pinned Open LLM Leaderboard v2 evaluation

    The benchmark-maintainer contents row recorded microsoft/phi-4 at model SHA 381727a5ee103da6c1b14ecd3d39cd09832cbcf8 with a 30.358128 suite average and a disclosed evaluation date.

    Milestone source
  3. 2025-02-26 — Phi-4 family expanded

    Microsoft announced Phi-4-mini and Phi-4-multimodal as separate artifacts; their capabilities and results do not transfer to the base Phi-4 page.

    Milestone source

Risks and limitations

  • Open-weight results depend on the exact runtime, precision, quantization, and prompt template; reference results do not transfer automatically.
  • The release-specific license and acceptable-use policy must be reviewed before commercial deployment.

Source coverage

ModelRefs verified the exact microsoft/phi-4 artifact, technical report, data summary, MIT license, current Microsoft Foundry capabilities, deployment path, implementation template, and seven source-scoped benchmark records. Microsoft publishes one benchmark-maintainer execution date for the Open LLM Leaderboard v2 row; physical execution dates for the provider-run SimpleEval rows remain undisclosed and are not inferred.

Sources

Continue your research

Use these connected ModelRefs sections to compare alternatives, inspect implementation paths, and review the evidence and governance boundaries relevant to Phi-4 - AI model implementation reference.