Microsoft Phi Models Intermediate

Microsoft's Phi series has redefined what small language models can achieve. Starting with Phi-1 in 2023, each generation has pushed the boundaries of what is possible with fewer parameters, proving that data quality matters more than model size for many tasks.

The Phi Family

Model Parameters Key Innovation Release
Phi-1 1.3B "Textbooks Are All You Need" - high-quality synthetic data June 2023
Phi-1.5 1.3B Extended to general reasoning beyond code Sept 2023
Phi-2 2.7B Matched models 25x its size on reasoning benchmarks Dec 2023
Phi-3 3.8B / 7B / 14B Multiple sizes, long context (128K), multi-modal variant Apr 2024
Phi-4 14B Synthetic data at scale, reasoning improvements Dec 2024
The Phi Philosophy: Microsoft's core insight is that the quality and composition of training data matters far more than raw volume. By curating "textbook-quality" data and generating synthetic examples that teach reasoning step-by-step, Phi models achieve outsized performance relative to their parameter count.

Data-Centric Training

  1. Textbook-quality filtering

    Rather than training on all available web data, Phi models are trained on carefully filtered data that resembles high-quality textbooks - clear explanations, logical structure, and educational content.

  2. Synthetic data generation

    GPT-4 and other large models generate training examples that demonstrate step-by-step reasoning, correct coding patterns, and structured problem-solving. This "distillation" transfers capabilities from large to small models.

  3. Curriculum learning

    Training data is ordered from simpler to more complex examples, helping the model build foundational understanding before tackling harder problems.

Using Phi Models

from transformers import AutoModelForCausalLM, AutoTokenizer

model_name = "microsoft/Phi-3-mini-4k-instruct"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
    model_name,
    torch_dtype="auto",
    device_map="auto"
)

messages = [
    {"role": "user", "content": "Explain quicksort in simple terms."}
]
inputs = tokenizer.apply_chat_template(
    messages, return_tensors="pt"
).to(model.device)

outputs = model.generate(inputs, max_new_tokens=256)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Licensing: Phi models use the MIT license, making them suitable for both commercial and non-commercial use without restrictions. This is one of the most permissive licenses in the SLM space.

Next: Gemma Models

In the next lesson, you will learn about Google's Gemma family and how it compares to Phi in architecture, training, and performance.

Next: Gemma Models →

Ready to Go Deeper?

Live instructor-led courses from our partners. Affiliate disclosure.