Phi-3 Mini

Microsoft's efficient 3.8B parameter language model — state-of-the-art performance in a compact package, designed for on-device and resource-constrained scenarios.

3.8B params 4K context bf16 MIT license
3.8B
Parameters
4K
Context Length
592K+
Downloads
1.4K+
Likes on HF

Key Features

Efficient Inference

Runs Anywhere

Runs efficiently on CPU, GPU, and even mobile devices. Optimized for bf16 with just ~7.6 GB memory footprint.

Strong Performance

Punches Above Its Weight

Competitive with models 2-3x its size on benchmarks like MMLU, HellaSwag, and GSM8K.

Easy Fine-tuning

Customize It

Full fine-tuning and LoRA/QLoRA support. Compatible with Hugging Face Transformers and TRL.

Multilingual

Global Reach

Trained on multilingual data with strong performance across English, French, German, Spanish, and more.

Chat Optimized

Conversational

Instruction-tuned variant with a custom chat template for conversational use cases.

MIT License

Truly Open

Fully open-source with a permissive MIT license — use it freely in commercial and research projects.

Try It Live

Chat with Phi-3 Mini

Try Phi-3 Mini right now — powered by Hugging Face Chat with serverless inference.

Open HF Chat

Quick Start

# Install
pip install transformers accelerate

# Load and generate
from transformers import AutoModelForCausalLM, AutoTokenizer

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

messages = [{"role": "user", "content": "Explain quantum computing simply."}]
inputs = tokenizer.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True)
outputs = model.generate(**inputs, max_new_tokens=256)
print(tokenizer.decode(outputs[0]))

Use Cases

Code Generation

Write & Debug Code

Write functions, debug code, explain complex algorithms, and generate programming snippets.

Content Creation

Create Content

Draft emails, blog posts, social media content, and creative writing with contextual understanding.

Education

Learn & Teach

Explain concepts, answer questions, and serve as a tutoring assistant across various subjects.

Data Analysis

Analyze & Report

Analyze data, generate reports, summarize documents, and extract insights from text.