Screenshot of the macOS app running alongside mactop
A sample Swift (macOS) application demonstrating how to download, load, and run Microsoft’s Phi-4 language model using the MLX Model Manager. The app provides a simple SwiftUI interface for prompting Phi-4 and viewing text completions.
Phi-4 is a small language model developed by Microsoft, focusing on providing concise and domain-specific completions. By integrating MLX Model Manager, this app manages the download, caching, and inference process for the Phi-4 model in a streamlined manner.
- Easy Model Management: Downloads and loads the Phi-4 model via MLX Model Manager.
- Simple SwiftUI Interface: Prompt the model and view generated text completions.
- Progress Indicators: Displays download progress and generation progress.
- Markdown-Enabled Output: Displays model output in Markdown format.
- macOS 14 (Sonoma) or later
- Xcode 14 or later
- An internet connection (for initial model download)
-
Clone this repository (or download the ZIP and unzip locally):
git clone https://github.com/kunal732/mlx-swift-phi4 cd phi4-macos-demo
-
Open the project in Xcode:
open phi4-macos-demo.xcodeproj
-
Resolve Swift Package Dependencies:
Xcode should automatically fetch the MLX Model Manager package from GitHub. -
Build & Run in Xcode:
- Select the macOS scheme (e.g., phi4-macos-demo)
- Press Cmd+R (or click the Play button)
- When you launch the app, it will attempt to download the Phi-4 model automatically if it’s not already on your machine.
- Once the download completes, the Answer Prompt button becomes active.
- Enter any prompt (e.g., “Why is the sky blue?”) in the text field.
- Press Return or click Answer Prompt to generate a completion using Phi-4.
- Observe the progress indicator if the model is still loading or generating text.
This sample app is provided under the MIT License. Microsoft’s Phi-4 model usage may be subject to additional terms. Refer to the Microsoft blog post for details on licensing and usage constraints of Phi-4.
- MLX Model Manager: GitHub Repository
- Phi-4 Introduction: Microsoft TechCommunity Blog
Enjoy experimenting with Phi-4 on macOS! If you encounter issues, open an Issue or submit a Pull Request. Contributions are welcome.