Foundation-Models-Framework-Lab

rudrankriyamMIT活跃维护

面向 Apple Foundation Models 框架的实战实验场,帮你在 iOS 和 macOS 上动手搭建、测试并评估端侧大模型应用。

A practical lab for building, testing, and evaluating apps with Apple's Foundation Models framework.

1.3.0发布于 2026-11-07 12:50 UTC1,190star70fork同步于 2026-11-10 11:49 UTC

怎么上手

由 README 提炼,执行前请确认
git clone https://github.com/rudrankriyam/Foundation-Models-Framework-Lab.git
cd Foundation-Models-Framework-Lab
open FoundationLab.xcodeproj
硬件要求按 README 说明

需 Apple Silicon 芯片执行端侧模型,并开启 Apple Intelligence;系统要求 iOS 26.0+、macOS 26.0+ 或 visionOS 26.0+,构建需 Xcode 27.2 或更高。真实模型运行需兼容的物理设备,模拟器仅能验证编译与界面。

支持 Apple Silicon
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

Apple 基础模型框架的原生实验台,用于编写、运行并对比提示词与工具调用

面向 Apple Foundation Models 框架的实战实验场,帮你在 iOS 和 macOS 上动手搭建、测试并评估端侧大模型应用。

核心能力

  • 在 Playground 中编辑提示词、指令与采样参数并流式运行
  • 内置天气、搜索、日历、健康等九个现成工具配方
  • 用 @Generable 与 @Guide 做结构化输出和动态 schema
  • 持久化运行记录,可查看转录、工具调用、耗时与 token 用量
  • macOS 上导入 .fmadapter 对比基座与适配器输出

容易踩的坑

模拟器无法跑真实模型推理,必须用兼容的物理设备;OS 27 新 API 受可用性限制,需 OS 27 运行时才会出现;适配器训练与导出不在 App 内,需另装 Tools/AdapterStudio 的 fmas CLI。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本1.3.0
  1. 1.3.0最新正式版2026-11-07 · 2026-11-07 12:50 UTC

    Foundation Lab 1.3 adds Apple TV and Apple Watch apps, new labs for the Xcode 27.3 Foundation Models APIs, and fixes from a full audit of the codebase.

    Highlights

    • Foundation Lab TV. A standalone tvOS app with prompt, streaming and @Generable runs. On tvOS 27.3 it uses the on-device model. (#234)
    • Foundation Lab Watch. A watchOS companion inside the iOS app. SystemLanguageModel isn't available on watchOS, so it runs on Private Cloud Compute. (#229)
    • New API labs:
      • Data Content: custom data attachments and data entries. (#236)
      • Session State: a guided lab for SessionState and SessionBinding. (#233)
      • Dynamic Profile Builder: shows the dynamic instruction group lifecycle. (#230)
      • Generation Guides: shows how @Guide(key:) maps keys. (#232)
    • Feedback attachments. Runs can attach Foundation Models feedback in run detail. (#231)
    • Wider layouts. Library and Runs show their list beside the detail on wide screens. Playground adapts to iPhone Duo resizing and keeps its inspector open across layout changes. (#220–#225)
    • Confirmation before side effects. Calendar, Reminders and now Contacts mutations wait for in-app approval. Swift export writes the confirmed tools, so copied code also asks before writing. (#212, #241, #245)
    • Voice. Voice mode keeps capturing speech after a pause. Voice runs record their real duration and status, including failed and cancelled runs. (#239, #246)
    • Audit fixes:
      • Health: the last-night sleep window is fixed. (#237)
      • Labs: multilingual demos can be cancelled, Gemini empty responses no longer fail to decode, and Data Content types are declared. (#238)
      • Playground: experiment loads wait for a running run to finish, and persistence errors are hardened. (#243)
      • Localization: Core and Library strings are localized and stale catalog keys are removed. (#227, #240)
    • Runtime. The app uses FoundationModelsKit 4.0.0. (#199–#201, #245)

    Requirements

    • iOS 26.0+, macOS 26.0+ or visionOS 26.0+; tvOS 27.0+ (on-device model on tvOS 27.3); watchOS 27.0+ (Private Cloud Compute)
    • Xcode 27.2 or later. Xcode 27.3-only APIs are behind #if canImport(FoundationModels, _version: 2.2).
    • Apple Silicon and Apple Intelligence for live on-device model execution

    Validation

    • PR CI on Xcode 27.2 for every merged PR, including the new macOS build, strict SwiftLint and the UI test build-for-testing step
    • FoundationLabCore: 55 tests (4 skipped)
    • FoundationModelsKit 4.0.0: 228 tests
    • Voice: a macOS harness fed recorded speech with pauses of 1 s to 40 s through the recognizer. Every word was captured once, in order.
    • TestFlight 1.3.0 build from the release commit

    Full Changelog: https://github.com/rudrankriyam/Foundation-Models-Framework-Lab/compare/1.2.0...1.3.0

  2. 1.2.02026-06-23 · 2026-06-23 10:05 UTC
    查看更新说明

    Foundation Lab 1.2 turns Apple’s newest Foundation Models surfaces from static walkthroughs into runnable, inspectable experiments.

    Highlights

    • Live Spotlight RAG — build an isolated sample index, force a real SpotlightSearchTool retrieval, inspect returned evidence, and keep the grounded answer visibly separate from its sources.
    • Live image input — import an image, run the model, retry safely, and preserve truthful result, cancellation, accessibility-focus, and provider metadata state.
    • Interactive inference controls — compare reasoning levels and tool-calling modes through actual model runs, with a bundled weather fixture for deterministic tool experiments.
    • Session observability — inspect live transcripts, tool trajectories, usage, performance traces, and cancellation state instead of reading static examples.
    • Quieter interface — a distilled Library, Playground, and Runs flow; clearer primary actions; full-width accessible controls; and no beginner/expert taxonomy.
    • Runtime reliability — fixes looping microphone prompts, stale image evidence, superseded Spotlight runs, stopping-state races, and Xcode 27 beta 2 compatibility.
    • Repeatable TestFlight delivery — dedicated distribution signing replaces hosted-runner certificate creation, making archives reproducible without revoking existing team certificates.

    Requirements

    • iOS 26.0+ or macOS 26.0+
    • Xcode 26.6 or Xcode 27 beta 2
    • Apple Silicon and Apple Intelligence for live on-device model execution
    • OS 27 for the newest Spotlight, image-input, reasoning, and tool-mode APIs

    Validation

    • Signed and exported the 1.2.0 iOS archive with Xcode 26.6
    • FoundationLabCore: 52 XCTest + 15 Swift Testing tests
    • FoundationModelsKit and tools: 90 tests
    • AFMServer: 118 tests
    • Strict SwiftLint and workflow validation

    Full Changelog: https://github.com/rudrankriyam/Foundation-Models-Framework-Lab/compare/1.1.0...1.2.0

  3. 1.1.02026-06-22 · 2026-06-22 18:08 UTC
    查看更新说明

    Foundation Lab 1.1 makes the lab genuinely scriptable: the app, reusable packages, and afm CLI now share token accounting, runtime inspection, schema handling, and a secure local model bridge.

    Highlights

    • Adds an OpenAI-compatible local chat-completions server with secure TCP and Unix-socket transports, backpressured server-sent event streaming, structured JSON-schema responses, and capture-only function tools that never execute caller-supplied actions.
    • Adds a signed Foundation Lab Agent Bridge and no-TTY CLI workflow for automation, including prepare, launch, status, model discovery, and chat commands without attempting to reuse Apple's private fm entitlements.
    • Shares provenance-aware input, output, total, context, and session token usage through FoundationModelsKit, using Apple's tokenizer where available and an explicitly labeled fallback on older runtimes.
    • Adds entitlement-aware model availability and Private Cloud Compute quota inspection, with authorization, runtime availability, and failure reasons reported separately.
    • Expands strict schema tooling with reusable JSON-schema conversion, object authoring, duplicate-key and unsupported-keyword rejection, response formats, and deterministic token-accounting inputs.
    • Hardens request pipelining, cancellation, descriptor rotation, bridge readiness, streaming writes, and tool-call ordering, with macOS 26 and 27 compatibility preserved.
    • Renames AppBench to FMFBench, adds agentic scenarios and stronger evidence validation, and keeps Simulator output separate from publishable device evidence.
    • Continues the Foundation Lab runtime cleanup with truthful Health data behavior, safer voice and cancellation lifecycles, resilient persistence, executable OS 27 labs, refreshed localization, and clearer Library / Playground / Runs workflows.

    Validation

    • AFMServer: 118 tests passed with Xcode 26.6 and 120 with Xcode 27.
    • FoundationModelsKit: 90 tests passed with Xcode 26.6 and 51 with Xcode 27.
    • Foundation Lab built successfully for generic macOS and iOS Simulator with both Xcode 26.6 and Xcode 27.
    • Strict SwiftLint passed for the shared runtime, CLI, AFMServer, and FoundationModelsKit.
    • The universal afm artifact, post-merge AFM CLI workflow, Adapter Studio workflow, and FMFBench workflow passed on the release code.
    • The optional TestFlight workflow is currently blocked before build because the hosted runner does not provide its configured Xcode 26.5; no archive or upload was attempted.

    Requirements

    • Xcode 26.6 or Xcode 27
    • iOS 26.0+ or macOS 26.0+
    • Apple Silicon and Apple Intelligence for live on-device model execution
    • OS 27 and managed entitlement availability for OS 27-only or Private Cloud Compute capabilities

    Full Changelog: https://github.com/rudrankriyam/Foundation-Models-Framework-Lab/compare/1.0.0...1.1.0

  4. 1.0.02026-06-20 · 2026-06-20 01:34 UTC
    查看更新说明

    Foundation Lab 1.0 is the first stable release of the experiment workbench for Apple’s Foundation Models framework, designed to help beginners start from working recipes while giving experts a fully configurable environment.

    Highlights

    • Replaces the crowded Home, Lab, and Studio hierarchy with a focused Library / Playground / Runs workflow inspired by Create ML.
    • Adds 34 curated recipes organized from beginner to expert, alongside custom prompts, model runtime, reasoning, generation options, tools, and runnable Swift export.
    • Saves experiments and exact run snapshots, including transcript context, tool calls and results, timing, model configuration, and errors.
    • Adds real Search1, Open-Meteo, MapKit, and Core Location integrations instead of placeholder playground behavior.
    • Makes Xcode 27 examples explicit about what is live, deterministic, app-owned, or reference-only; runtime telemetry now reports real streamed usage and app-measured timing.
    • Adds macOS AppBench Evaluations replay, an image-input resolution probe, and a Gemini video session built through custom LanguageModel execution.
    • Adopts Swift 6 complete concurrency and hardens cancellation, voice/text overlap, audio-session work, persistence recovery, multi-window ownership, and Private Cloud Compute fallback behavior.
    • Localizes the complete primary workflow across all ten supported locales and adds native macOS commands, Settings, and adaptive iPhone/iPad presentation.

    Validation

    • Foundation Lab builds passed for macOS and iOS Simulator with Xcode 27.
    • Strict SwiftLint passed.
    • Root Swift package: 160 tests passed.
    • AppBench Evaluations: 12 tests passed.
    • Adapter Studio: 17 tests passed.
    • Image Input Probe: 13 tests passed.
    • All required GitHub checks passed on the release commit.

    Requirements

    • Xcode 27
    • iOS 26.0+ or macOS 26.0+
    • Apple Intelligence enabled on a compatible Apple Silicon device

    Full Changelog: https://github.com/rudrankriyam/Foundation-Models-Framework-Lab/compare/0.3.0...1.0.0

  5. 0.3.02026-06-13 · 2026-06-13 06:28 UTC
    查看更新说明

    Foundation Models Framework Lab is now the canonical workspace for building, testing, and evaluating apps with Apple’s Foundation Models framework.

    Highlights

    • Consolidates FoundationModelsKit, the afm CLI, AppBench, and Adapter Studio into one maintained repository.
    • Adds Xcode 27 examples for Private Cloud Compute, reasoning levels, image input, dynamic profiles, model routing, tool-calling control, transcript transforms, and evaluations.
    • Introduces the practical AppBench suite with app-shaped workloads, deterministic grading, guardrail and offline trials, device metadata, latency and throughput reporting, and an iPhone device runner.
    • Expands FoundationLabCore into a shared capability layer used by the app, App Intents, and command-line workflows.
    • Adds Foundation Models app-builder and OS 27 updater agent skills with self-contained implementation guidance.
    • Improves Studio, RAG, voice, App Intents, multilingual examples, token accounting, and runtime configuration.
    • Includes tested local FoundationModelsKit utilities and system-integration tools for external Swift package consumers.

    Validation

    • FoundationLabCore: 37 tests
    • FoundationModelsKit: 68 tests
    • AppBench: 21 tests
    • Adapter Studio: 17 tests
    • AFM CLI GitHub Actions: passing

    The TestFlight workflow currently reaches the archive step but is blocked by Apple signing certificate capacity and provisioning, not a source build failure.

    Full Changelog: https://github.com/rudrankriyam/Foundation-Models-Framework-Lab/compare/0.2.0...0.3.0

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Foundation Lab

    Foundation Lab is a native iOS and macOS workbench for learning, testing, and shipping with Apple's Foundation Models framework. It keeps the prompt, configuration, tools, transcript, and run evidence in one place while still providing focused labs for APIs that need a specialized interface.

    The app is designed for two complementary workflows:

    • Open a working recipe, change one thing, and run it immediately.
    • Compose custom prompts and tools, inspect every run, compare adapters, and export reproducible evidence from the app.

    App Structure

    Foundation Lab has three primary destinations:

    DestinationPurpose
    LibraryBrowse 18 editable recipes, 14 guided labs, three workshops, saved experiments, and one workspace.
    PlaygroundEdit prompts and instructions, configure the model and tools, stream responses, use voice input, save experiments, and export Swift.
    RunsInspect persisted run status, configuration, transcript events, tool calls, timing, and token usage.

    Library entries identify how they open:

    • Recipe opens in Playground and can be edited, run, and saved.
    • Guided Lab uses a focused interface for a specific Foundation Models API.
    • Workshop groups related schema, language, or Xcode 27 examples without adding another top-level destination.
    • Workspace opens a dedicated tool such as Adapter Comparison.

    Requirements

    • iOS 26.0+, macOS 26.0+, or visionOS 26.0+
    • watchOS 27.0+ for the Foundation Lab Watch companion, which ships inside the iOS app and runs prompts on Private Cloud Compute
    • tvOS 27.0+ for the Foundation Lab TV app; its Foundation Models features need tvOS 27.3 and an Xcode 27.3 SDK
    • Apple Silicon for on-device model execution
    • Apple Intelligence enabled for live model runs
    • Xcode 27.2 or later

    The app still runs on OS 26. APIs introduced with OS 27 are availability-gated, so the newest labs appear only on an OS 27 runtime.

    Getting Started

    git clone https://github.com/rudrankriyam/Foundation-Models-Framework-Lab.git
    cd Foundation-Models-Framework-Lab
    open FoundationLab.xcodeproj
    

    Build from the command line:

    xcodebuild \
      -project FoundationLab.xcodeproj \
      -scheme 'Foundation Lab' \
      -destination 'generic/platform=macOS' \
      CODE_SIGNING_ALLOWED=NO \
      build
    
    xcodebuild \
      -project FoundationLab.xcodeproj \
      -scheme 'Foundation Lab' \
      -destination 'generic/platform=iOS Simulator' \
      CODE_SIGNING_ALLOWED=NO \
      build
    
    xcodebuild \
      -project FoundationLab.xcodeproj \
      -scheme 'Foundation Lab TV' \
      -destination 'generic/platform=tvOS Simulator' \
      CODE_SIGNING_ALLOWED=NO \
      build
    

    Live model execution requires a compatible physical device. Simulator builds remain useful for compilation and interface validation.

    Capabilities

    Experiments and conversations

    • Streaming multi-turn conversations with context-window management
    • Editable instructions, sampling, response limits, runtime, and reasoning controls
    • Saved experiment configurations and persistent run history
    • Swift export for Playground configurations
    • Speech recognition and synthesis integrated into Playground

    Built-in tools

    Nine ready-made tool recipes use the shared FoundationModelsTools package:

    • Weather through Open-Meteo
    • Keyless Search1 web search
    • Contacts
    • Calendar
    • Reminders
    • Location and place search
    • Authorized HealthKit data
    • Apple Music
    • Web metadata

    Tool recipes open in Playground, where tools can be combined or removed. Tools that can change user data require confirmation through the app-owned workflow.

    Structured output and applied projects

    • @Generable models and @Guide constraints
    • Dynamic schemas, nested objects, unions, forms, and invoice extraction
    • Multilingual sessions and supported-language inspection
    • RAG document indexing and semantic retrieval with LumoKit and VecturaKit
    • A HealthKit dashboard and chat grounded only in authorized Health data

    Xcode 27 labs

    When built with Xcode 27, Foundation Lab also demonstrates:

    • PrivateCloudComputeLanguageModel
    • Shared LanguageModel execution
    • Image attachments and references
    • Explicit tool-calling modes
    • Dynamic profiles and reasoning controls
    • Transcript inspection and history transforms
    • Context-budget visualization
    • Custom model executors, including a video-capable provider bridge

    The image-input probe under Tools/ImageInputProbe can measure the current SDK's practical decoded-buffer boundary.

    Workspaces

    Adapter Comparison

    On macOS, import a .fmadapter package and run the same prompt through fresh base-model and adapter sessions. The workspace shows both streams and diagnostic time-to-first-token and total-duration measurements.

    Training and export remain in the companion fmas CLI:

    python3.11 -m venv .venv-fmas
    source .venv-fmas/bin/activate
    python -m pip install -e Tools/AdapterStudio
    fmas init
    fmas setup
    fmas train-adapter --help
    fmas export --help
    

    See Tools/AdapterStudio for the full workflow.

    Command-Line Interface

    The afm CLI now ships from the standalone rudrankriyam/Foundation-Models-Framework-CLI repository. It uses the public FoundationModelsKit package and keeps CLI releases independent from Foundation Lab app releases.

    brew tap rudrankriyam/tap
    brew install afm
    

    See the CLI repository for source, documentation, release automation, and server-mode implementation.

    Repository Map

    SurfaceLocationPurpose
    Foundation LabFoundation LabNative Library, Playground, Runs, guided labs, and workspaces
    FoundationLabCoreFoundationLabCoreUI-independent requests, results, use cases, providers, and experiment models
    FoundationModelsKitrryam/FoundationModelsKitExternal transcript, context, history, and system-tool package
    AFM CLIrudrankriyam/Foundation-Models-Framework-CLIScriptable Foundation Models workflows
    FoundationModelsBenchrudrankriyam/FoundationModelsBenchExternal quality, safety, tool-use, on-device, and Private Cloud Compute benchmark
    Adapter toolingTools/AdapterStudioAdapter training and export with fmas
    Book playgroundsBookPlaygroundsChapter-oriented #Playground examples

    FoundationModelsBench and the AFM CLI are developed and released from their standalone repositories. Foundation Lab keeps the native app, app runtime, and adapter tooling here.

    Swift Package Products

    FoundationModelsKit and FoundationModelsTools are defined in the external rryam/FoundationModelsKit package. Local package consumers should depend on that package URL directly rather than requesting those products from this repository's root manifest.

    • FoundationModelsKit provides transcript history transforms, provenance-aware token accounting shared by the app and CLI, calibrated estimation, and context-budget utilities.
    • FoundationModelsTools provides calendar, contacts, health, location, music, reminders, weather, web search, and web metadata tools.
    • FoundationLabCore provides the shared capability and experiment runtime.

    Localization and Permissions

    The app ships English, German, Spanish, French, Italian, Japanese, Korean, Portuguese (Brazil), Simplified Chinese, and Traditional Chinese localizations.

    Features request permissions only when needed. Depending on the selected recipe or lab, the app may request microphone, speech recognition, contacts, calendar, reminders, location, HealthKit, or Apple Music access.

    Validation

    swiftlint lint --strict --config .swiftlint.yml
    swift test
    

    On pull requests, CI runs the FoundationLabCore test suite (swift test) and typechecks the book playgrounds via Tools/BookPlaygrounds/typecheck.sh (foundation-lab-pr.yml). A separate adapter-studio.yml workflow lints and builds Foundation Lab for macOS and iOS Simulator when Adapter Studio files change.

    TestFlight

    Join the Foundation Lab beta on TestFlight.

    Pushes to main that affect the app can run the repository-local ASC workflow in .asc/workflow.json through foundation-lab-testflight.yml.

    Agent Skills

    Reusable Foundation Models skills now live in rryam/FoundationModelsKit:

    • foundation-models-app-builder for production Foundation Models patterns
    • foundation-models-os27-updater for Xcode 27 and OS 27 migrations
    npx skills add rryam/FoundationModelsKit \
      --skill foundation-models-app-builder
    
    npx skills add rryam/FoundationModelsKit \
      --skill foundation-models-os27-updater
    

    Contributing

    Contributions are welcome. Please open an issue or pull request with a focused change and include the relevant lint, test, and build results.

    License

    Foundation Lab is available under the MIT License. See LICENSE.