Skip to main content

Phi

Phi popularised small language models trained on carefully curated / synthetic “textbook-quality” data — strong capability per parameter, historically strong on code exercises in early Phi releases.

Adapted for this playbook from the 🤗 Transformers documentation by Hugging Face. Official page: https://huggingface.co/docs/transformers/model_doc/phi. Images © Hugging Face (documentation-images) unless noted. This is not a substitute for the upstream docs — verify against the current version.

Covers Hugging Face pages: model_doc/phi

Quick usage​

from transformers import pipeline

pipe = pipeline(task="text-generation", model="microsoft/phi-1.5")
print(pipe("def print_prime(n):\n \"\"\"Print all primes between 1 and n\"\"\"\n", max_new_tokens=80))
from transformers import AutoModelForCausalLM, AutoTokenizer

tok = AutoTokenizer.from_pretrained("microsoft/phi-1")
model = AutoModelForCausalLM.from_pretrained(
"microsoft/phi-1", device_map="auto", attn_implementation="sdpa"
)

Collection example: Phi-1.

Official API​

Phi model doc.

Discussion

Comments​

Share feedback or questions about this page. No account required.

Loading comments…