Phi-4 14B

MIT

Microsoft · 14B · كثيف

نموذج مايكروسوفت المتخصّص في الاستدلال. تعرّف على ما إذا كان كرت شاشتك أو جهاز الماك قادرًا على تشغيل Phi-4 14B محليًا — 7.8 جيجابايت كحد أدنى، و13 جيجابايت موصى بها.

كيف تستخدم Phi-4 14B في Transformers

حمّل Phi-4 14B في بايثون عبر مكتبة Transformers من HuggingFace. هذه الأوزان الكاملة غير المكمَّمة، فتحتاج ذاكرة أكبر من ملفات GGUF.

عبر pipeline — الطريقة الأسهل

pip install -U transformers
# Use a pipeline as a high-level helper
from transformers import pipeline

pipe = pipeline("text-generation", model="microsoft/phi-4")
messages = [
    {"role": "user", "content": "Who are you?"},
]
pipe(messages)

تحميل النموذج مباشرة

pip install -U transformers
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained("microsoft/phi-4")
model = AutoModelForCausalLM.from_pretrained("microsoft/phi-4", device_map="auto")
messages = [
    {"role": "user", "content": "Who are you?"},
]
inputs = tokenizer.apply_chat_template(
	messages,
	add_generation_prompt=True,
	tokenize=True,
	return_dict=True,
	return_tensors="pt",
).to(model.device)

outputs = model.generate(**inputs, max_new_tokens=40)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))

التوثيق الرسمي: Transformers

كيف تستخدم Phi-4 14B في llama.cpp

يحمّل llama.cpp ملف Phi-4 14B من HuggingFace مباشرة ويشغّله، إمّا خادمًا متوافقًا مع OpenAI بواجهة ويب أو في الطرفية. اختر مستوى الـ Quantization من القائمة، وتتحدّث الأوامر معه.

ملف GGUF من unsloth/phi-4-GGUF

التثبيت على macOS وLinux

curl -LsSf https://llama.app/install.sh | sh
# Start a local OpenAI-compatible server with a web UI:
llama serve -hf unsloth/phi-4-GGUF:Q4_K_M
# Run inference directly in the terminal:
llama cli -hf unsloth/phi-4-GGUF:Q4_K_M

التثبيت عبر WinGet على Windows

winget install llama.cpp
# Start a local OpenAI-compatible server with a web UI:
llama serve -hf unsloth/phi-4-GGUF:Q4_K_M
# Run inference directly in the terminal:
llama cli -hf unsloth/phi-4-GGUF:Q4_K_M

نسخة جاهزة من صفحة الإصدارات

# Download pre-built binary from:
# https://github.com/ggerganov/llama.cpp/releases
# Start a local OpenAI-compatible server with a web UI:
./llama-server -hf unsloth/phi-4-GGUF:Q4_K_M
# Run inference directly in the terminal:
./llama-cli -hf unsloth/phi-4-GGUF:Q4_K_M

البناء من الكود المصدري

git clone https://github.com/ggerganov/llama.cpp.git
cd llama.cpp
cmake -B build
cmake --build build -j --target llama-server llama-cli
# Start a local OpenAI-compatible server with a web UI:
./build/bin/llama-server -hf unsloth/phi-4-GGUF:Q4_K_M
# Run inference directly in the terminal:
./build/bin/llama-cli -hf unsloth/phi-4-GGUF:Q4_K_M

عبر Docker

docker model run hf.co/unsloth/phi-4-GGUF:Q4_K_M

التوثيق الرسمي: llama.cpp

كيف تستخدم Phi-4 14B في Ollama

ينزّل Ollama النموذج ويفتح محادثة محلية بأمر واحد. اختر مستوى الـ Quantization من القائمة، وتتحدّث الأوامر معه.

ملف GGUF من unsloth/phi-4-GGUF

من مكتبة Ollama الرسمية

ollama run phi4

من ملف GGUF على HuggingFace

ollama run hf.co/unsloth/phi-4-GGUF:Q4_K_M

التوثيق الرسمي: Ollama

كيف تستخدم Phi-4 14B في node-llama-cpp

شغّل Phi-4 14B من Node.js بلا تثبيت مسبق. اختر مستوى الـ Quantization من القائمة، وتتحدّث الأوامر معه.

ملف GGUF من unsloth/phi-4-GGUF

محادثة مع النموذج

npx -y node-llama-cpp chat hf:unsloth/phi-4-GGUF:Q4_K_M

قدّر توافق النموذج مع جهازك

npx -y node-llama-cpp inspect estimate hf:unsloth/phi-4-GGUF:Q4_K_M

التوثيق الرسمي: node-llama-cpp

كيف تستخدم Phi-4 14B في Docker Model Runner

يشغّل Docker Desktop النموذج محليًا ويتيحه عبر واجهة متوافقة مع OpenAI. اختر مستوى الـ Quantization من القائمة، وتتحدّث الأوامر معه.

ملف GGUF من unsloth/phi-4-GGUF

شغّل النموذج

docker model run hf.co/unsloth/phi-4-GGUF:Q4_K_M

التوثيق الرسمي: Docker Model Runner

كيف تستخدم Phi-4 14B في LocalAI

LocalAI خادم محلي متوافق مع OpenAI. استبدل {{GGUF_FILE}} باسم ملف GGUF الذي تريده من المستودع unsloth/phi-4-GGUF.

التثبيت من ملف تنفيذي

curl https://localai.io/install.sh | sh
# Load and run the model:
local-ai run huggingface://unsloth/phi-4-GGUF/{{GGUF_FILE}}

عبر صور Docker

# Pull the image:
docker pull localai/localai:latest-cpu
# Load and run the model:
docker run -p 8080:8080 --name localai -v $PWD/models:/build/models localai/localai:latest-cpu huggingface://unsloth/phi-4-GGUF/{{GGUF_FILE}}

التوثيق الرسمي: LocalAI

كيف تستخدم Phi-4 14B في Lemonade

Lemonade خادم محلي من AMD يعمل على المعالجات وكروت الشاشة. اختر مستوى الـ Quantization من القائمة، وتتحدّث الأوامر معه.

ملف GGUF من unsloth/phi-4-GGUF

نزّل النموذج

# Download Lemonade from https://lemonade-server.ai/
lemonade pull unsloth/phi-4-GGUF:Q4_K_M

شغّل النموذج وحاوره

lemonade run user.phi-4-GGUF-Q4_K_M

اعرض كل النماذج المتاحة

lemonade list

التوثيق الرسمي: Lemonade

أوامر التشغيلHuggingFaceOllamaLM Studio
2024-12سياق 16K

مستويات الـ Quantization

Quantizationالبتاتالذاكرةالجودةالحالة
Q2_K25GBمنخفضة—
Q3_K_M36.8GBمتوسطة—
Q4_K_M47.7GBجيدة—
Q5_K_M59.5GBجيدة—
Q6_K611.3GBممتازة—
Q8_0814.8GBممتازة—
F161629.2GBبلا فقد—

الأرقام تشمل الأوزان وذاكرة KV عند طول سياق 2K توكن. غيّر طول السياق من لوحة جهازك لترى أثره على الذاكرة والسرعة.

التطبيقات

شغّل Phi-4 14B داخل أدوات البرمجة التي تعمل بالذكاء الاصطناعي — يشغّل الأمر خادم Ollama على جهازك، يحمّل النموذج، ثم يفتح الأداة موصولة به.

  • Claude Code

    وكيل البرمجة من Anthropic، يعمل في الطرفية وداخل المحرّر

    ollama launch claude --model phi4
  • OpenCode

    وكيل برمجة مفتوح المصدر يعمل في الطرفية داخل مستودعك

    ollama launch opencode --model phi4
  • Codex

    وكيل البرمجة من OpenAI في سطر الأوامر

    ollama launch codex --model phi4
  • Droid

    وكيل البرمجة من Factory، للمهام الطويلة عبر عدّة ملفات

    ollama launch droid --model phi4
  • Hermes Agent

    وكيل برمجة مفتوح من Nous Research، بذاكرة تمتد عبر الجلسات

    ollama launch hermes --model phi4
  • OpenClaw

    وكيل مفتوح المصدر يشغّل المهام على جهازك بلا خدمة سحابية

    ollama launch openclaw --model phi4

تحتاج Ollama والأداة نفسها مثبَّتين. إن لم تكن الأداة مثبّتة، يرشدك الأمر إلى طريقة تثبيتها. اكتب ollama launch وحده لاختيار الأداة من قائمة.

عن هذا النموذج

الوصف الرسمي كما نشرته الجهة المطوِّرة، بلغته الأصلية.

Phi-4 is a 14B parameter, state-of-the-art open model built upon a blend of synthetic datasets, data from filtered public domain websites, and acquired academic books and Q&A datasets.

Phi-4 benchmark

The model underwent a rigorous enhancement and alignment process, incorporating both supervised fine-tuning and direct preference optimization to ensure precise instruction adherence and robust safety measures.

Context length: 16k tokens

Phi-4 performance eval by Microsoft

Primary use cases

The model is designed to accelerate research on language models, for use as a building block for generative AI powered features. It provides uses for general purpose AI systems and applications (primarily in English) which require:

  1. Memory/compute constrained environments.
  2. Latency bound scenarios.
  3. Reasoning and logic.

Out-of-scope use cases

The models are not specifically designed or evaluated for all downstream purposes, thus:

  1. Developers should consider common limitations of language models as they select use cases, and evaluate and mitigate for accuracy, safety, and fairness before using within a specific downstream use case, particularly for high-risk scenarios.
  2. Developers should be aware of and adhere to applicable laws or regulations (including privacy, trade compliance laws, etc.) that are relevant to their use case, including the model’s focus on English.
  3. Nothing contained in this readme should be interpreted as or deemed a restriction or modification to the license the model is released under.

أسئلة شائعة عن تشغيل Phi-4 14B محليًا

هل أستطيع تشغيل Phi-4 14B على جهازي؟
يحتاج Phi-4 14B إلى 7.8 جيجابايت من الذاكرة كحد أدنى، والموصى به 13 جيجابايت. يكفي أن تفتح هذه الصفحة ليُقيَّم النموذج تلقائيًا أمام كرت شاشتك أو جهاز الماك، ثم تشغّله عبر Ollama أو LM Studio أو llama.cpp.
كم يحتاج Phi-4 14B من الـ VRAM؟
بتكميم Q4_K_M يستهلك Phi-4 14B نحو 7.7 جيجابايت من ذاكرة الكرت. أما المستويات الأعلى فتحتاج ذاكرة أكبر، والأدنى تناسب الكروت المحدودة مقابل تنازل في الجودة.