PhiCookBook / zh-HK
AGENTS.md3.9k starsChanged 9 months agoMITView on GitHub
PhiCookBook 是一個全面的食譜庫,包含了 Microsoft Phi 系列小語言模型(SLMs)的實作範例、教學及文件。此庫展示了包括推論、微調、量化、RAG 實現及多模態應用於不同平台與框架的多種使用案例。 關鍵技術: - 語言: Python、C#/.NET、JavaScript/Node.js - 框架: ONNX Runtime、PyTorch、Transformers、MLX、OpenVINO、Semantic Kernel - 平台: Microsoft Foundry、GitHub Models、Hugging Face、Ollama - 模型類型: Phi-3、Phi-3.5、Phi-4(文字、視覺、多模態、推理變體) 倉庫結構: - /code/ - 工作代碼範例與示範實作 - /md/ - 詳細文件、教學及操作指南 - /translations/ - 多語言翻譯(通過自動化工作流程支持超過50種語言) - /.devcontainer/ - 開發容器設定(含 Python 3.12 與 Ollama) Prerequisites: - Python 3.12 or later - .NET 8.0 SDK (for C# examples) - Node.js 18+ and npm (for JavaScript examples) - 16GB RAM minimum recommended Installation: For Python Examples: Navigate to specific example directories…
- Installs packages
Trending
Quiet since July.thin dataabout the whole repository
Who's talking about microsoft/PhiCookBook
- Azure/co-op-translator“Over translation "Jupyter ノートブック"→"Jupyter Notebook" (en→jp)”GitHub · Jul 1, 2026 · 1 reactions
- Azure/co-op-translator“Markdown bold not handled correctly (en→jp)”GitHub · Feb 2, 2026 · 1 reactions
- Azure/co-op-translator“Incorrect chunking of list items with code placeholders causes broken ``` fences”GitHub · Jan 30, 2026 · 1 reactions
- Azure/co-op-translator“Unclosed code block (en→ja)”GitHub · Dec 18, 2025 · 1 reactions
- microsoft/generative-ai-with-javascript“Link Checker Report”GitHub · Feb 15, 2026
The biggest 5 of 9 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 9
Talked about on GitHub (9 times).
On GitHub · 9
- Jul 1, 2026Over translation "Jupyter ノートブック"→"Jupyter Notebook" (en→jp) — Azure/co-op-translator1 reaction · 10 comments
- Feb 2, 2026Markdown bold not handled correctly (en→jp) — Azure/co-op-translator1 reaction
- Jan 30, 2026Incorrect chunking of list items with code placeholders causes broken ``` fences — Azure/co-op-translator1 reaction · 4 comments
- Dec 18, 2025Unclosed code block (en→ja) — Azure/co-op-translator1 reaction · 1 comment
- Feb 15, 2026Link Checker Report — microsoft/generative-ai-with-javascript0 reactions
4 more on GitHub
- Feb 15, 2026Link Checker Report — microsoft/generative-ai-with-javascript0 reactions
- Jun 14, 2025Mixed-Language Output in Multiple Translations — Azure/co-op-translator0 reactions
- Jun 5, 2025[tiny] Update phi3-vision configs to use oumi trainer — oumi-ai/oumi0 reactions
- May 8, 2025Need to make eval feature on Co-op Translator — Azure/co-op-translator0 reactions
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository55 other files it gives its agents.
- AGENTS.mdAGENTS.md
- translations/ar/AGENTS.mdAGENTS.md
- translations/bg/AGENTS.mdAGENTS.md
- translations/bn/AGENTS.mdAGENTS.md
- translations/cs/AGENTS.mdAGENTS.md
- translations/da/AGENTS.mdAGENTS.md
- translations/de/AGENTS.mdAGENTS.md
- translations/el/AGENTS.mdAGENTS.md
- translations/en/AGENTS.mdAGENTS.md
- translations/es/AGENTS.mdAGENTS.md
- translations/et/AGENTS.mdAGENTS.md
- translations/fa/AGENTS.mdAGENTS.md
- translations/fi/AGENTS.mdAGENTS.md
- translations/fr/AGENTS.mdAGENTS.md
- translations/he/AGENTS.mdAGENTS.md
- translations/hi/AGENTS.mdAGENTS.md
- translations/hr/AGENTS.mdAGENTS.md
- translations/hu/AGENTS.mdAGENTS.md
- translations/id/AGENTS.mdAGENTS.md
- translations/it/AGENTS.mdAGENTS.md
- translations/ja/AGENTS.mdAGENTS.md
- translations/km/AGENTS.mdAGENTS.md
- translations/kn/AGENTS.mdAGENTS.md
- translations/ko/AGENTS.mdAGENTS.md
- translations/lt/AGENTS.mdAGENTS.md
- translations/ml/AGENTS.mdAGENTS.md
- translations/mr/AGENTS.mdAGENTS.md
- translations/ms/AGENTS.mdAGENTS.md
- translations/my/AGENTS.mdAGENTS.md
- translations/ne/AGENTS.mdAGENTS.md
- translations/nl/AGENTS.mdAGENTS.md
- translations/no/AGENTS.mdAGENTS.md
- translations/pa/AGENTS.mdAGENTS.md
- translations/pcm/AGENTS.mdAGENTS.md
- translations/pl/AGENTS.mdAGENTS.md
- translations/pt-BR/AGENTS.mdAGENTS.md
- translations/pt-PT/AGENTS.mdAGENTS.md
- translations/ro/AGENTS.mdAGENTS.md
- translations/ru/AGENTS.mdAGENTS.md
- translations/sk/AGENTS.mdAGENTS.md
- translations/sl/AGENTS.mdAGENTS.md
- translations/sr/AGENTS.mdAGENTS.md
- translations/sv/AGENTS.mdAGENTS.md
- translations/sw/AGENTS.mdAGENTS.md
- translations/ta/AGENTS.mdAGENTS.md
- translations/te/AGENTS.mdAGENTS.md
- translations/th/AGENTS.mdAGENTS.md
- translations/tl/AGENTS.mdAGENTS.md
- translations/tr/AGENTS.mdAGENTS.md
- translations/uk/AGENTS.mdAGENTS.md
- translations/ur/AGENTS.mdAGENTS.md
- translations/vi/AGENTS.mdAGENTS.md
- translations/zh-CN/AGENTS.mdAGENTS.md
- translations/zh-MO/AGENTS.mdAGENTS.md
- translations/zh-TW/AGENTS.mdAGENTS.md
The file
We split this AGENTS.md into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 28
Use the "Open in Dev Containers" badge from README
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md
Project Overview
PhiCookBook 是一個全面的食譜庫,包含了 Microsoft Phi 系列小語言模型(SLMs)的實作範例、教學及文件。此庫展示了包括推論、微調、量化、RAG 實現及多模態應用於不同平台與框架的多種使用案例。
關鍵技術:
- 語言: Python、C#/.NET、JavaScript/Node.js
- 框架: ONNX Runtime、PyTorch、Transformers、MLX、OpenVINO、Semantic Kernel
- 平台: Microsoft Foundry、GitHub Models、Hugging Face、Ollama
- 模型類型: Phi-3、Phi-3.5、Phi-4(文字、視覺、多模態、推理變體)
倉庫結構:
/code/- 工作代碼範例與示範實作/md/- 詳細文件、教學及操作指南/translations/- 多語言翻譯(通過自動化工作流程支持超過50種語言)/.devcontainer/- 開發容器設定(含 Python 3.12 與 Ollama)
Development Environment Setup
Using GitHub Codespaces or Dev Containers (Recommended)
- Open in GitHub Codespaces (fastest):
- Click the "Open in GitHub Codespaces" badge in README
- Container auto-configures with Python 3.12 and Ollama with Phi-3
- Open in VS Code Dev Containers:
- Use the "Open in Dev Containers" badge from README
- Container requires 16GB host memory minimum
Local Setup
Prerequisites:
- Python 3.12 or later
- .NET 8.0 SDK (for C# examples)
- Node.js 18+ and npm (for JavaScript examples)
- 16GB RAM minimum recommended
Installation:
git clone https://github.com/microsoft/PhiCookBook.git
cd PhiCookBookFor Python Examples: Navigate to specific example directories and install dependencies:
cd code/<example-directory>
pip install -r requirements.txt # 如果 requirements.txt 存在For .NET Examples:
cd md/04.HOL/dotnet/src
dotnet restore LabsPhi.sln
dotnet build LabsPhi.slnFor JavaScript/Web Examples:
cd code/08.RAG/rag_webgpu_chat
npm install
npm run dev # 啟動開發伺服器
npm run build # 建立生產版本Repository Organization
Code Examples (/code/)
- 01.Introduce/ - 基本介紹與入門範例
- 03.Finetuning/ 和 04.Finetuning/ - 多種方法的微調範例
- 03.Inference/ - 在不同硬體(AIPC、MLX)上的推論範例
- 06.E2E/ - 端到端應用範例
- 07.Lab/ - 實驗室/實驗性實作
- 08.RAG/ - 檢索增強生成範例
- 09.UpdateSamples/ - 最新更新範例
Documentation (/md/)
- 01.Introduction/ - 介紹指南、環境設置、平台指南
- 02.Application/ - 按應用類型組織的實作範例(文字、代碼、視覺、音頻等)
- 02.QuickStart/ - Microsoft Foundry 和 GitHub Models 快速入門指南
- 03.FineTuning/ - 微調文件及教學
- 04.HOL/ - 實作實驗室(含 .NET 範例)
File Formats
- Jupyter Notebooks (
.ipynb) - 互動式 Python 教學腳本,README 中以 📓 標示 - Python Scripts (
.py) - 獨立執行的 Python 範例 - C# Projects (
.csproj,.sln) - .NET 應用與範例 - JavaScript (
.js,package.json) - 網頁及 Node.js 範例 - Markdown (
.md) - 文件及指南
Working with Examples
Running Jupyter Notebooks
Most examples are provided as Jupyter notebooks:
pip install jupyter notebook
jupyter notebook # 開啟瀏覽器介面
# 導航至所需的 .ipynb 檔案Running Python Scripts
cd code/<example-directory>
pip install -r requirements.txt
python <script-name>.pyRunning .NET Examples
cd md/04.HOL/dotnet/src/<project-name>
dotnet runOr build entire solution:
cd md/04.HOL/dotnet/src
dotnet run --project <project-name>Running JavaScript/Web Examples
cd code/08.RAG/rag_webgpu_chat
npm install
npm run dev # 熱重載開發Testing
此倉庫包含範例代碼與教學,而非傳統含單元測試的軟件專案。驗證通常依據:
<strong>執行範例</strong>- 確保範例無錯誤執行<strong>核對輸出</strong>- 核實模型回應是否恰當<strong>跟隨教程</strong>- 教學步驟正常運作
常見驗證方式:
- 在目標環境中測試範例執行
- 確認依賴安裝正確
- 檢查模型能成功下載/加載
- 確認預期行為符合文檔
Code Style and Conventions
General Guidelines
- 範例需清晰、具有註解且具教學意義
- 遵循語言特定慣例(Python 遵循 PEP 8、C# 遵循 .NET 標準)
- 範例聚焦於展示特定 Phi 模型能力
- 包含解釋關鍵概念與模型參數的註解
Documentation Standards
URL Formatting:
- 使用
[text](../../url)格式無多餘空格 - 相對鏈接使用
./表示當前目錄,../表示父目錄 - 不使用國家特定的本地化網址(避免
/en-us/,/en/)
Images:
- 所有圖片儲存在
/imgs/目錄 - 使用包含英文字母、數字及連字號的描述性名稱
- 範例:
phi-3-architecture.png
Markdown Files:
- 文件中參照實際可運行的
/code/目錄範例 - 文件要與代碼同步更新
- 在 README 中以 📓 表情標記 Jupyter 筆記本鏈接
File Organization
/code/中的代碼範例依主題/功能分類/md/的文件結構與代碼結構相呼應(如適用)- 相關文件(筆記本、腳本、設定)放於子目錄以保持整齊
Pull Request Guidelines
Before Submitting
- Fork 倉庫 到自己的帳戶
- 分 PR 類型:
- Bug 修正放一個 PR
- 文件更新放另一個 PR
- 新範例獨立 PR
- 拼寫錯誤修正可合併
- 處理合併衝突:
- 先更新本地
main分支 - 常與官方同步
- 先更新本地
- 翻譯 PR:
- 必須涵蓋資料夾內所有文件翻譯
- 保持與原語言目錄結構一致
Required Checks
PR 會自動執行 GitHub 工作流程驗證:
<strong>相對路徑驗證</strong>- 內部鏈接必須有效- 在 VS Code 按 Ctrl+點擊測試
- 利用 VS Code 內建路徑建議 (
./或../)
- URL 本地化檢查 - 網址不得包含國家語言代碼
- 移除
/en-us/,/en/或其他語言碼 - 使用通用國際網址
- 移除
<strong>網址有效檢查</strong>- 網址需正確返回 200 狀態- 提交前確認鏈接可訪問
- 部分失敗可能因網絡限制
PR Title Format
[component] Brief descriptionExamples:
[docs] Add Phi-4 inference tutorial[code] Fix ONNX Runtime integration example[translation] Add Japanese translation for intro guides
Common Development Patterns
Working with Phi Models
Model Loading:
- 範例使用 Transformers、ONNX Runtime、MLX、OpenVINO 等不同框架
- 模型通常從 Hugging Face、Azure 或 GitHub Models 下載
- 確認模型與硬體(CPU、GPU、NPU)相容
Inference Patterns:
- 文字生成:大部分範例使用聊天/指令變體
- 視覺:Phi-3-vision 與 Phi-4-multimodal 用於圖像理解
- 音頻:Phi-4-multimodal 支援音頻輸入
- 推理:Phi-4-reasoning 變體用於進階推理任務
Platform-Specific Notes
Microsoft Foundry:
- 需要 Azure 訂閱與 API 關鍵
- 請參閱
/md/02.QuickStart/AzureAIFoundry_QuickStart.md
GitHub Models:
- 免費測試等級可用
- 請參閱
/md/02.QuickStart/GitHubModel_QuickStart.md
Local Inference:
- ONNX Runtime:跨平臺,優化推論
- Ollama:便捷本地模型管理(開發容器已預配置)
- Apple MLX:針對蘋果晶片優化
Troubleshooting
Common Issues
Memory Issues:
- Phi 模型需大量記憶體(特別是視覺/多模態版本)
- 資源受限環境建議使用量化模型
- 請參閱
/md/01.Introduction/04/QuantifyingPhi.md
Dependency Conflicts:
- Python 範例可能對版本有特定要求
- 為每個範例使用虛擬環境
- 檢查個別
requirements.txt
Model Download Failures:
- 大型模型在慢速連線下可能超時
- 建議使用雲端環境(Codespaces、Azure)
- 檢查 Hugging Face 快取:
~/.cache/huggingface/
.NET Project Issues:
- 確保已安裝 .NET 8.0 SDK
- 建構前執行
dotnet restore - 部分專案有專用的 CUDA 配置(Debug_Cuda)
JavaScript/Web Examples:
- 使用 Node.js 18+ 保證相容性
- 如有問題刪除
node_modules並重裝 - 檢查瀏覽器控制檯的 WebGPU 兼容性錯誤
Getting Help
- Discord: 參加 Microsoft Foundry 社群 Discord
- GitHub Issues: 報告錯誤與問題
- GitHub Discussions: 提問與分享知識
Additional Context
Responsible AI
所有 Phi 模型的使用應遵循 Microsoft 的負責任 AI 原則:
- 公平性、可靠性、安全性
- 隱私與安全
- 包容性、透明度、問責制
- 生產應用採用 Azure AI 內容安全
- 請參閱
/md/01.Introduction/01/01.AISafety.md
Translations
- 透過自動化 GitHub Action 支援超過50種語言
- 翻譯檔案存放於
/translations/目錄 - 由協作翻譯工作流程維護
- 請勿手動編輯自動生成的翻譯文件
Contributing
- 遵循
CONTRIBUTING.md中的指南 - 接受貢獻者授權協議(CLA)
- 遵守 Microsoft 開源行為守則
- 務必避免在提交中包含安全資訊和憑證
Multi-Language Support
此倉庫為多語言專案,包含以下語言範例:
- Python - ML/AI 工作流程、Jupyter 筆記本、微調
- C#/.NET - 企業應用、ONNX Runtime 整合
- JavaScript - Web AI、使用 WebGPU 的瀏覽器推論
請選擇最符合您使用場景與部署目標的語言。
<!-- CO-OP TRANSLATOR DISCLAIMER START -->免責聲明:
本文件使用 AI 翻譯服務 Co-op Translator 進行翻譯。雖然我們致力於提供準確的翻譯,但請注意自動翻譯可能包含錯誤或不準確之處。原始文件的母語版本應視為權威來源。對於重要資訊,建議尋求專業人工翻譯。我們不對因使用本翻譯而產生的任何誤解或誤釋承擔責任。
<!-- CO-OP TRANSLATOR DISCLAIMER END -->Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

