PhiCookBook / pcm
AGENTS.md3.9k starsChanged 9 months agoMITView on GitHub
PhiCookBook na one complete cookbook repo wey get beta beta practical examples, tutorials, and documentation wey show how to work with Microsoft's Phi family of Small Language Models (SLMs). Dis repo dey show different kain use case like inference, fine-tuning, quantization, RAG implementations, and multimodal applications for different platforms and frameworks. Key Technologies: - Languages: Python, C#/.NET, JavaScript/Node.js - Frameworks: ONNX Runtime, PyTorch, Transformers, MLX, OpenVINO, Semantic Kernel - Platforms: Microsoft Foundry, GitHub Models, Hugging Face, Ollama - Model Types:…
- 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/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-HK/AGENTS.mdAGENTS.md
- translations/zh-MO/AGENTS.mdAGENTS.md
- translations/zh-TW/AGENTS.mdAGENTS.md
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
42 rules. About 1 is common, 31 are distinctive, and 10 are very specific to this project.
≈1
Common · estimate
Many files like this have a rule of this kind.
≈31
Distinctive · estimate
This author's own choices. Worth a look.
10
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
- Distinctive: line 139
Running the examples: - Make sure each example fit run without wahala
- Distinctive: line 140
Verifying outputs: - Check say model responses dey correct
- Distinctive: line 144
Test execution for the example inside the correct environment
- Distinctive: line 145
Verify say all dependencies install well
- Distinctive: line 146
Check say model downloads and loads properly
- Distinctive: line 154
Follow language-specific conventions (PEP 8 for Python, C# standards for .NET)
- Distinctive: line 156
Put comments wey explain key concepts and model-specific parameters
- Very specific: line 161
Use text format without extra spaces
- Very specific: line 163
No country-specific locales inside URLs (no use /en-us/, /en/)
- Very specific: line 166
Keep all images for /imgs/ directory
- Distinctive: line 167
Use descriptive names wey get English characters, numbers, and dashes
- Distinctive: line 172
Keep documentation sabi with code updates
- Distinctive: line 173
Use 📓 emoji to show Jupyter notebook links inside README
- Distinctive: line 179
Keep related files (notebooks, scripts, configs) together inside subdirectories
- Distinctive: line 193
Update your local main branch before you do changes
- Distinctive: line 197
Must get translations for ALL files inside the folder
- Distinctive: line 198
Keep structure same as original language
- Distinctive: line 204
Relative path validation: - All internal links suppose work well
- Distinctive: line 205
Test links local: Ctrl+Click for VS Code
- Very specific: line 206
Use path suggestions from VS Code (./ or ../)
- Very specific: line 209
Remove /en-us/, /en/, or other language codes
- Distinctive: line 210
Use generic international URLs
- Distinctive: line 212
Broken URL check: - All URLs must return 200 status code
- Distinctive: line 213
Verify links dey accessible before you submit
- Distinctive: line 234
Check model compatibility with your hardware (CPU, GPU, NPU)
- Distinctive: line 263
Use quantized models for resource-constrained environments
- Distinctive: line 268
Use virtual environments for each example
- Very specific: line 269
Check individual requirements.txt files
- Distinctive: line 273
Consider using cloud environments (Codespaces, Azure)
- Very specific: line 274
Check Hugging Face cache: ~/.cache/huggingface/
- Distinctive: line 277
Make sure .NET 8.0 SDK dey installed
- Very specific: line 278
Use dotnet restore before you build
- Very specific: line 282
Use Node.js 18+ for compatibility
- Distinctive: line 284
Check browser console for WebGPU compatibility issues
- Distinctive: line 290
GitHub Discussions: Ask questions and share knowledge
- Distinctive: line 296
All Phi model usage suppose follow Microsoft's Responsible AI principles:
- Distinctive: line 300
Use Azure AI Content Safety for production applications
- Distinctive: line 308
No make you edit translated files manually (auto-generated)
- Very specific: line 312
Follow guidelines for CONTRIBUTING.md
- Distinctive: line 314
Follow Microsoft Open Source Code of Conduct
- Common: line 315
Keep security and credentials outside your commits
≈ “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 na one complete cookbook repo wey get beta beta practical examples, tutorials, and documentation wey show how to work with Microsoft's Phi family of Small Language Models (SLMs). Dis repo dey show different kain use case like inference, fine-tuning, quantization, RAG implementations, and multimodal applications for different platforms and frameworks.
Key Technologies:
- Languages: Python, C#/.NET, JavaScript/Node.js
- Frameworks: ONNX Runtime, PyTorch, Transformers, MLX, OpenVINO, Semantic Kernel
- Platforms: Microsoft Foundry, GitHub Models, Hugging Face, Ollama
- Model Types: Phi-3, Phi-3.5, Phi-4 (text, vision, multimodal, reasoning variants)
Repository Structure:
/code/- Working code examples and sample implementations/md/- Detailed documentation, tutorials, and how-to guides/translations/- Multi-language translations (50+ languages via automated workflow)/.devcontainer/- Dev container configuration (Python 3.12 with Ollama)
Development Environment Setup
Using GitHub Codespaces or Dev Containers (Recommended)
- Open for GitHub Codespaces (fastest):
- Click the "Open in GitHub Codespaces" badge inside README
- Container go auto-configure with Python 3.12 and Ollama with Phi-3
- Open for VS Code Dev Containers:
- Use the "Open in Dev Containers" badge from README
- Container need 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: Go inside specific example directories and install dependencies:
cd code/<example-directory>
pip install -r requirements.txt # if requirements.txt de kamFor .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 # Start development server
npm run build # Build for productionRepository Organization
Code Examples (/code/)
- 01.Introduce/ - Basic introductions and getting started samples
- 03.Finetuning/ and 04.Finetuning/ - Fine-tuning examples with different methods
- 03.Inference/ - Inference examples on different hardware (AIPC, MLX)
- 06.E2E/ - End-to-end application samples
- 07.Lab/ - Laboratory/experimental implementations
- 08.RAG/ - Retrieval-Augmented Generation samples
- 09.UpdateSamples/ - Latest updated samples
Documentation (/md/)
- 01.Introduction/ - Intro guides, environment setup, platform guides
- 02.Application/ - Application samples arranged by type (Text, Code, Vision, Audio, etc.)
- 02.QuickStart/ - Quick start guides for Microsoft Foundry and GitHub Models
- 03.FineTuning/ - Fine-tuning documentation and tutorials
- 04.HOL/ - Hands-on labs (includes .NET examples)
File Formats
- Jupyter Notebooks (
.ipynb) - Interactive Python tutorials wey dem mark with 📓 inside README - Python Scripts (
.py) - Standalone Python examples - C# Projects (
.csproj,.sln) - .NET applications and samples - JavaScript (
.js,package.json) - Web-based and Node.js examples - Markdown (
.md) - Documentation and guides
Working with Examples
Running Jupyter Notebooks
Most examples na Jupyter notebooks:
pip install jupyter notebook
jupyter notebook # Opɛn di browser interface
# Go enter di .ipynb file wey you wantRunning 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 complete 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 # Development wit hot reloadTesting
Dis repo get example code and tutorials, no be like normal software project wey get unit tests. Validation dey usually done by:
- Running the examples - Make sure each example fit run without wahala
- Verifying outputs - Check say model responses dey correct
- Following tutorials - Step-by-step guides suppose work as e dey document
Common validation approach:
- Test execution for the example inside the correct environment
- Verify say all dependencies install well
- Check say model downloads and loads properly
- Confirm say expected behavior match the documentation
Code Style and Conventions
General Guidelines
- Examples suppose clear, well-commented, and educational
- Follow language-specific conventions (PEP 8 for Python, C# standards for .NET)
- Make examples dey focus on showing specific Phi model capabilities
- Put comments wey explain key concepts and model-specific parameters
Documentation Standards
URL Formatting:
- Use
[text](../../url)format without extra spaces - Relative links: Use
./for current directory,../for parent - No country-specific locales inside URLs (no use
/en-us/,/en/)
Images:
- Keep all images for
/imgs/directory - Use descriptive names wey get English characters, numbers, and dashes
- Example:
phi-3-architecture.png
Markdown Files:
- Reference actual working examples inside
/code/directory - Keep documentation sabi with code updates
- Use 📓 emoji to show Jupyter notebook links inside README
File Organization
- Code examples inside
/code/arranged by topic/feature - Documentation for
/md/dey mirror code structure if e apply - Keep related files (notebooks, scripts, configs) together inside subdirectories
Pull Request Guidelines
Before Submitting
- Fork the repository go your own account
- Separate PRs by type:
- Bug fixes for one PR
- Documentation updates for another
- New examples for separate PRs
- Typo fixes fit combine
- Handle merge conflicts:
- Update your local
mainbranch before you do changes - Sync with upstream often
- Update your local
- Translation PRs:
- Must get translations for ALL files inside the folder
- Keep structure same as original language
Required Checks
PRs dey automatically run GitHub workflows to check:
- Relative path validation - All internal links suppose work well
- Test links local: Ctrl+Click for VS Code
- Use path suggestions from VS Code (
./or../)
- URL locale check - Web URLs no suppose get country locales
- Remove
/en-us/,/en/, or other language codes - Use generic international URLs
- Remove
- Broken URL check - All URLs must return 200 status code
- Verify links dey accessible before you submit
- Note: Some failure fit be because network restrictions
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:
- Examples dey use different frameworks: Transformers, ONNX Runtime, MLX, OpenVINO
- Models dey mostly download from Hugging Face, Azure, or GitHub Models
- Check model compatibility with your hardware (CPU, GPU, NPU)
Inference Patterns:
- Text generation: Most examples dey use chat/instruct variants
- Vision: Phi-3-vision and Phi-4-multimodal for image understanding
- Audio: Phi-4-multimodal support audio inputs
- Reasoning: Phi-4-reasoning variants for advanced reasoning tasks
Platform-Specific Notes
Microsoft Foundry:
- You need Azure subscription and API keys
- See
/md/02.QuickStart/AzureAIFoundry_QuickStart.md
GitHub Models:
- Get free tier for testing
- See
/md/02.QuickStart/GitHubModel_QuickStart.md
Local Inference:
- ONNX Runtime: Cross-platform, optimized inference
- Ollama: Easy local model management (pre-configured in dev container)
- Apple MLX: Optimized for Apple Silicon
Troubleshooting
Common Issues
Memory Issues:
- Phi models need plenty RAM (especially vision/multimodal variants)
- Use quantized models for resource-constrained environments
- See
/md/01.Introduction/04/QuantifyingPhi.md
Dependency Conflicts:
- Python examples fit get specific version requirements
- Use virtual environments for each example
- Check individual
requirements.txtfiles
Model Download Failures:
- Big models fit timeout on slow connections
- Consider using cloud environments (Codespaces, Azure)
- Check Hugging Face cache:
~/.cache/huggingface/
.NET Project Issues:
- Make sure .NET 8.0 SDK dey installed
- Use
dotnet restorebefore you build - Some projects get CUDA-specific configurations (Debug_Cuda)
JavaScript/Web Examples:
- Use Node.js 18+ for compatibility
- Clear
node_modulesand reinstall if yawa still dey - Check browser console for WebGPU compatibility issues
Getting Help
- Discord: Join the Microsoft Foundry Community Discord
- GitHub Issues: Report bugs and issues inside the repo
- GitHub Discussions: Ask questions and share knowledge
Additional Context
Responsible AI
All Phi model usage suppose follow Microsoft's Responsible AI principles:
- Fairness, reliability, safety
- Privacy and security
- Inclusiveness, transparency, accountability
- Use Azure AI Content Safety for production applications
- See
/md/01.Introduction/01/01.AISafety.md
Translations
- 50+ languages dey supported via automated GitHub Action
- Translations dey for
/translations/directory - Maintained by co-op-translator workflow
- No make you edit translated files manually (auto-generated)
Contributing
- Follow guidelines for
CONTRIBUTING.md - Agree to Contributor License Agreement (CLA)
- Follow Microsoft Open Source Code of Conduct
- Keep security and credentials outside your commits
Multi-Language Support
Dis na polyglot repo with examples for:
- Python - ML/AI workflows, Jupyter notebooks, fine-tuning
- C#/.NET - Enterprise applications, ONNX Runtime integration
- JavaScript - Web-based AI, browser inference with WebGPU
Choose the language wey fit your use case and deployment target well well.
<!-- CO-OP TRANSLATOR DISCLAIMER START -->Disclaimer: Dis document don translate wit AI translation service Co-op Translator. Even though we dey try make am correct, abeg sabi say automated translation fit get errors or mistakes. Di original document wey dey im native language na di correct source. For important info, e better make person wey sabi translate human translation. We no go responsible for any misunderstanding or wrong interpretation wey fit come from dis translation.
<!-- 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.

