apple/python-apple-fm-sdk
Python bindings for access to the on-device model at the core of Apple Intelligence through the Foundation Models framework
What it solves
This SDK provides a Pythonic interface to Apple's Foundation Models framework, allowing developers to access the on-device foundation models that power Apple Intelligence on macOS. It simplifies the process of running inference and evaluating model features without needing to write Swift code.
How it works
It acts as Python bindings for the underlying Swift-based Foundation Models framework. Developers can use the SystemLanguageModel to access the ondevice model and LanguageModelSession to manage interactions. The SDK supports asynchronous text generation and "guided generation," where Python decorators (like @fm.generable) and constraints can be used to force the model to output data that fits a specific Python class structure.
Who it’s for
Python developers building for macOS who want to integrate Apple Intelligence's on-device capabilities into their applications or perform quality analysis on model outputs.
Highlights
- On-device inference: Runs models locally on macOS for privacy and speed.
- Guided generation: Uses type-safe responses and structured output schemas to ensure the model returns data in a specific format.
- Real-time streaming: Supports streaming text generation responses.
- Batch inference: Enables the evaluation of app features by running batch processes and analyzing results from Python.
Related
- Project
- Project
- Project
- Project