Skip to content

Glance of Apple foundation model

Published: at 06:39 PM

At WWDC 2025, Apple introduced the Foundation Models framework, offering a powerful, privacy-first Swift API for harnessing large‑language‑model capabilities. With this, developers can integrate features like text generation, guided structured output, tool calling, multi‑turn conversations, and streaming—all running on-device (or privately in the cloud).


Model Variants


System Requirements


Example Code

import FoundationModels

let systemModel = SystemLanguageModel.default
guard systemModel.isAvailable else {
    switch systemModel.availability {
    case .available:
        break
    case .unavailable(let reason):
        print("Model unavailable: \(reason)")
        return
    }
}

let model = FoundationModel()
let config = FoundationModel.Configuration(
    task: .textGeneration(prompt: "Describe the advantages of Swift."),
    streaming: true
)

let session = try await model.makeSession(configuration: config)
for try await chunk in session.streamResults() {
    print(chunk.text, terminator: "")
}

✅ This covers environment checks, streaming, and proper API usage.


Advanced Features

🔧 Guided (Structured) Generation

Use the @Generable macro with @Guide annotations to constrain the model’s output to typed Swift data structures. This ensures reliable, structured responses via constrained decoding .

🧩 Tool Calling

Define app-specific tools with the Tool protocol. The model can autonomously invoke functions (e.g., fetch POIs or call APIs), then integrate the tool responses into its output .

🧠 Stateful Sessions

LanguageModelSession maintains conversation context across multiple prompts, tracks transcripts, and handles context limits. Supports instructions separate from prompts to improve reliability and security .

⏱ Streaming Snapshots

Instead of token “deltas,” FoundationModels streams structured “snapshots”—partial objects matching your schema—allowing UI updates as content evolves .

🛠 Debugging & Profiling

Use the new FoundationModels Instruments tool to prewarm sessions, optimize schema inclusion, and measure latency for smoother experience .

⚙️ Fine-tuning via Adapters

Advanced users can train small adapters to add task-specific skills to the ~3B model, compatible via Python toolkit .


Pros & Cons

✅ Strengths⚠️ Limitations
Privacy-first: local inference, offline supportRequires newer hardware (A17 Pro, M-series)
Native Swift API; structured output; tool useSmaller scale than GPT‑4—suited to in-app tasks
Session support and streaming snapshotsDebugging and tooling still evolving
Cloud inference is encrypted and freeLanguage support still growing

Summary

Apple’s Foundation Models framework empowers developers to embed intelligent features—like guided structured generation, dynamic tool interactions, and conversational flow—directly into apps, all within a privacy-first, on-device paradigm.