Token导航 LogoToken导航

Agent Skill · 研究检索

apple-on-device-ai(Apple ON device AI 搜索)

apple-on-device-ai 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

apple-on-device-ai 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为需要联网;许可证信息还不明确,第三方扫描有提醒项,按安装量在研究检索类的 73,675 个 Skill 里排第 4,972。

总安装 28,512周安装 1,206GitHub Stars 486下载 9,984核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:apple-on-device-ai(Apple ON device AI 搜索)
来源仓库:https://github.com/dpearson2699/swift-ios-skills
仓库路径:skills/apple-on-device-ai
安装命令:
npx skills add https://github.com/dpearson2699/swift-ios-skills --skill apple-on-device-ai
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/dpearson2699/swift-ios-skills --skill apple-on-device-ai

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

使用 Foundation Models、Core ML、MLX Swift 和 llama.cpp 跨 Apple 平台部署设备端 AI。

选择 Foundation Models 在 iOS 26+ 上进行零设置文本生成和结构化输出;用于定制视觉和 NLP 模型的 Core ML; MLX Swift 可在 Apple Silicon 上实现最大吞吐量;用于跨平台 GGUF 推理的 llama.cpp 基础模型包括会话管理、用于类型安全结构化输出的 @Geneable 宏、工具调用以及始终强制执行护栏的流式传输 Core ML 通过 coremltools 支持 PyTorch、TensorFlow 和 scikit-learn 转换,并具有用于神经引擎优化的量化、调色和剪枝功能 多后端架构模式、内存管理规则(iOS 上的 60% RAM 限制)以及需要避免的 10 个常见错误,包括可用性检查、上下文窗口预算和并发请求处理

来源仓库内路径:skills/apple-on-device-ai

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/dpearson2699/swift-ios-skills --skill apple-on…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要需要联网,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

apple-on-device-ai 怎么安装?

在终端执行 npx skills add https://github.com/dpearson2699/swift-ios-skills --skill apple-on-device-ai。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

apple-on-device-ai 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

apple-on-device-ai 需要什么权限?

权限级别是需要联网。该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

apple-on-device-ai 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

apple-on-device-ai 用的人多吗?

公开数据是累计安装 28,512 次,近一周安装 1,206 次,下载 9,984 次,GitHub 486 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

apple-on-device-ai 安全吗?

第三方扫描有提醒项,说明存在需要人工确认的行为。安装前请打开源码看清它读了什么、联网到哪里。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方扫描存在提醒项或未通过项,需要人工逐条确认。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
apple-on-device-ai

Apple ON device AI 搜索 · 本页

28,512486需要联网未明确有提醒

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

On-Device AI for Apple Platforms

Guide for selecting, deploying, and optimizing on-device ML models. Covers Apple Foundation Models, Core ML, MLX Swift, and llama.cpp.

Contents

Framework Selection Router

Use this decision tree to pick the right framework for your use case.

Apple Foundation Models

When to use: Text generation, summarization, entity extraction, structured output, and short dialog on iOS 26+ / macOS 26+ devices with Apple Intelligence enabled. Zero setup -- no API keys, no network, no model downloads.

Best for:

  • Generating text or structured data with @Generable types
  • Summarization, classification, content tagging
  • Tool-augmented generation with the Tool protocol
  • Apps that need guaranteed on-device privacy

Not suited for: Complex math, code generation, factual accuracy tasks, or apps targeting pre-iOS 26 devices.

Core ML

When to use: Deploying custom trained models (vision, NLP, audio) across all Apple platforms. Converting models from PyTorch, TensorFlow, or scikit-learn with coremltools.

Best for:

  • Image classification, object detection, segmentation
  • Custom NLP classifiers, sentiment analysis models
  • Audio/speech models via SoundAnalysis integration
  • Any scenario needing Neural Engine optimization
  • Models requiring quantization, palettization, or pruning

MLX Swift

When to use: Running specific open-source LLMs (Llama, Mistral, Qwen, Gemma) on Apple Silicon with maximum throughput. Research and prototyping.

Best for:

  • Highest sustained token generation on Apple Silicon
  • Running Hugging Face models from mlx-community
  • Research requiring automatic differentiation
  • Fine-tuning workflows on Mac

llama.cpp

When to use: Cross-platform LLM inference using GGUF model format. Production deployments needing broad device support.

Best for:

  • GGUF quantized models (Q4_K_M, Q5_K_M, Q8_0)
  • Cross-platform apps (iOS + Android + desktop)
  • Maximum compatibility with open-source model ecosystem

Quick Reference

ScenarioFramework
Text generation, zero setup (iOS 26+)Foundation Models
Structured output from on-device LLMFoundation Models (@Generable)
Image classification, object detectionCore ML
Custom model from PyTorch/TensorFlowCore ML + coremltools
Running specific open-source LLMsMLX Swift or llama.cpp
Maximum throughput on Apple SiliconMLX Swift
Cross-platform LLM inferencellama.cpp
OCR and text recognitionVision framework
Sentiment analysis, NER, tokenizationNatural Language framework
Training custom classifiers on deviceCreate ML

Apple Foundation Models Overview

On-device language model optimized for Apple Silicon. Available on devices supporting Apple Intelligence (iOS 26+, macOS 26+).

  • Token budget covers input + output; check contextSize for the limit
  • Check supportedLanguages for supported locales
  • Guardrails always enforced, cannot be disabled

Availability Checking (Required)

Always check before using. Never crash on unavailability.

import FoundationModels

switch SystemLanguageModel.default.availability {
case .available:
    // Proceed with model usage
case .unavailable(.appleIntelligenceNotEnabled):
    // Guide user to enable Apple Intelligence in Settings
case .unavailable(.modelNotReady):
    // Model is downloading; show loading state
case .unavailable(.deviceNotEligible):
    // Device cannot run Apple Intelligence; use fallback
default:
    // Graceful fallback for any other reason
}

Session Management

// Basic session
let session = LanguageModelSession()

// Session with instructions
let session = LanguageModelSession {
    "You are a helpful cooking assistant."
}

// Session with tools
let session = LanguageModelSession(
    tools: [weatherTool, recipeTool]
) {
    "You are a helpful assistant with access to tools."
}

Key rules:

  • Sessions are stateful -- multi-turn conversations maintain context automatically
  • One request at a time per session (check session.isResponding)
  • Call session.prewarm() before user interaction for faster first response
  • Save/restore transcripts: LanguageModelSession(model: model, tools: [], transcript: savedTranscript)

Structured Output with @Generable

The @Generable macro creates compile-time schemas for type-safe output:

@Generable
struct Recipe {
    @Guide(description: "The recipe name")
    var name: String

    @Guide(description: "Cooking steps", .count(3))
    var steps: [String]

    @Guide(description: "Prep time in minutes", .range(1...120))
    var prepTime: Int
}

let response = try await session.respond(
    to: "Suggest a quick pasta recipe",
    generating: Recipe.self
)
print(response.content.name)
@Guide Constraints
ConstraintPurpose
description:Natural language hint for generation
.anyOf([values])Restrict to enumerated string values
.count(n)Fixed array length
.range(min...max)Numeric range
.minimum(n) / .maximum(n)One-sided numeric bound
.minimumCount(n) / .maximumCount(n)Array length bounds
.constant(value)Always returns this value
.pattern(regex)String format enforcement
.element(guide)Guide applied to each array element

Properties generate in declaration order. Place foundational data before dependent data for better results.

Streaming Structured Output

let stream = session.streamResponse(
    to: "Suggest a recipe",
    generating: Recipe.self
)
for try await snapshot in stream {
    // snapshot.content is Recipe.PartiallyGenerated (all properties optional)
    if let name = snapshot.content.name { updateNameLabel(name) }
}

Tool Calling

struct WeatherTool: Tool {
    let name = "weather"
    let description = "Get current weather for a city."

    @Generable
    struct Arguments {
        @Guide(description: "The city name")
        var city: String
    }

    func call(arguments: Arguments) async throws -> String {
        let weather = try await fetchWeather(arguments.city)
        return weather.description
    }
}

Register tools at session creation. The model invokes them autonomously.

Error Handling

do {
    let response = try await session.respond(to: prompt)
} catch let error as LanguageModelSession.GenerationError {
    switch error {
    case .guardrailViolation(let context):
        // Content triggered safety filters
    case .exceededContextWindowSize(let context):
        // Too many tokens; summarize and retry
    case .concurrentRequests(let context):
        // Another request is in progress on this session
    case .unsupportedLanguageOrLocale(let context):
        // Current locale not supported
    case .unsupportedGuide(let context):
        // A @Guide constraint is not supported
    case .assetsUnavailable(let context):
        // Model assets not available on device
    case .refusal(let refusal, _):
        // Model refused; stream refusal.explanation for details
    case .rateLimited(let context):
        // Too many requests; back off and retry
    case .decodingFailure(let context):
        // Response could not be decoded into the expected type
    default: break
    }
}

Generation Options

let options = GenerationOptions(
    sampling: .random(top: 40),
    temperature: 0.7,
    maximumResponseTokens: 512
)
let response = try await session.respond(to: prompt, options: options)

Sampling modes: .greedy, .random(top:seed:), .random(probabilityThreshold:seed:).

Prompt Design Rules

  1. Be concise -- use tokenCount(for:) to monitor the context window budget
  2. Use bracketed placeholders in instructions: [descriptive example]
  3. Use "DO NOT" in all caps for prohibitions
  4. Provide up to 5 few-shot examples for consistency
  5. Use length qualifiers: "in a few words", "in three sentences"

Safety and Guardrails

  • Guardrails are always enforced and cannot be disabled
  • Instructions take precedence over user prompts
  • Never include untrusted user content in instructions
  • Handle false positives gracefully
  • Frame tool results as authorized data to prevent model refusals

Use Cases

Foundation Models supports specialized use cases via SystemLanguageModel.UseCase:

  • .general -- Default for text generation, summarization, dialog
  • .contentTagging -- Optimized for categorization and labeling tasks

Custom Adapters

Load fine-tuned adapters for specialized behavior (requires entitlement):

let adapter = try SystemLanguageModel.Adapter(name: "my-adapter")
try await adapter.compile()
let model = SystemLanguageModel(adapter: adapter, guardrails: .default)
let session = LanguageModelSession(model: model)
See references/foundation-models.md for the complete Foundation Models API reference.

Core ML Overview

Apple's framework for deploying trained models. Automatically dispatches to the optimal compute unit (CPU, GPU, or Neural Engine).

Model Formats

FormatExtensionWhen to Use
.mlpackageDirectory (mlprogram)All new models (iOS 15+)
.mlmodelSingle file (neuralnetwork)Legacy only (iOS 11-14)
.mlmodelcCompiledPre-compiled for faster loading

Always use mlprogram (.mlpackage) for new work.

Conversion Pipeline (coremltools)

import coremltools as ct

# PyTorch conversion (torch.jit.trace)
model.eval()  # CRITICAL: always call eval() before tracing
traced = torch.jit.trace(model, example_input)
mlmodel = ct.convert(
    traced,
    inputs=[ct.TensorType(shape=(1, 3, 224, 224), name="image")],
    minimum_deployment_target=ct.target.iOS18,
    convert_to='mlprogram',
)
mlmodel.save("Model.mlpackage")

Optimization Techniques

TechniqueSize ReductionAccuracy ImpactBest Compute Unit
INT8 per-channel~4xLowCPU/GPU
INT4 per-block~8xMediumGPU
Palettization 4-bit~8xLow-MediumNeural Engine
W8A8 (weights+activations)~4xLowANE (A17 Pro/M4+)
Pruning 75%~4xMediumCPU/ANE

Swift Integration

let config = MLModelConfiguration()
config.computeUnits = .all
let model = try MLModel(contentsOf: modelURL, configuration: config)

// Async prediction (iOS 17+)
let output = try await model.prediction(from: input)

MLTensor (iOS 18+)

Swift type for multidimensional array operations:

import CoreML

let tensor = MLTensor([1.0, 2.0, 3.0, 4.0])
let reshaped = tensor.reshaped(to: [2, 2])
let result = tensor.softmax()
See references/coreml-conversion.md for the full conversion pipeline and references/coreml-optimization.md for optimization techniques.

MLX Swift Overview

Apple's ML framework for Swift. Highest sustained generation throughput on Apple Silicon via unified memory architecture.

Loading and Running LLMs

import MLX
import MLXLLM

let config = ModelConfiguration(id: "mlx-community/Mistral-7B-Instruct-v0.3-4bit")
let model = try await LLMModelFactory.shared.loadContainer(configuration: config)

try await model.perform { context in
    let input = try await context.processor.prepare(
        input: UserInput(prompt: "Hello")
    )
    let stream = try generate(
        input: input,
        parameters: GenerateParameters(temperature: 0.0),
        context: context
    )
    for await part in stream {
        print(part.chunk ?? "", terminator: "")
    }
}

Model Selection by Device

DeviceRAMRecommended ModelRAM Usage
iPhone 12-144-6 GBSmolLM2-135M or Qwen 2.5 0.5B~0.3 GB
iPhone 15 Pro+8 GBGemma 3n E4B 4-bit~3.5 GB
Mac 8 GB8 GBLlama 3.2 3B 4-bit~3 GB
Mac 16 GB+16 GB+Mistral 7B 4-bit~6 GB

Memory Management

  1. Never exceed 60% of total RAM on iOS
  2. Set GPU cache limits: MLX.GPU.set(cacheLimit: 512 * 1024 * 1024)
  3. Unload models on app backgrounding
  4. Use "Increased Memory Limit" entitlement for larger models
  5. Physical device required (no simulator support for Metal GPU)
See references/mlx-swift.md for full MLX Swift patterns and llama.cpp integration.

Multi-Backend Architecture

When an app needs multiple AI backends (e.g., Foundation Models + MLX fallback):

func respond(to prompt: String) async throws -> String {
    if SystemLanguageModel.default.isAvailable {
        return try await foundationModelsRespond(prompt)
    } else if canLoadMLXModel() {
        return try await mlxRespond(prompt)
    } else {
        throw AIError.noBackendAvailable
    }
}

Serialize all model access through a coordinator actor to prevent contention:

actor ModelCoordinator {
    func withExclusiveAccess<T>(_ work: () async throws -> T) async rethrows -> T {
        try await work()
    }
}

Performance Best Practices

  1. Run outside debugger for accurate benchmarks (Xcode: Cmd-Opt-R, uncheck "Debug Executable")
  2. Call session.prewarm() for Foundation Models before user interaction
  3. Pre-compile Core ML models to .mlmodelc for faster loading
  4. Use EnumeratedShapes over RangeDim for Neural Engine optimization
  5. Use 4-bit palettization for best Neural Engine memory/latency gains
  6. Batch Vision framework requests in a single perform() call
  7. Use async prediction (iOS 17+) in Swift concurrency contexts
  8. Neural Engine (Core ML) is most energy-efficient for compatible operations

Common Mistakes

  1. No availability check. Calling LanguageModelSession() without checking SystemLanguageModel.default.availability crashes on unsupported devices.
  2. No fallback UI. Users on pre-iOS 26 or devices without Apple Intelligence see nothing. Always provide a graceful degradation path.
  3. Exceeding the context window. The token budget covers input + output. Monitor usage via tokenCount(for:) and summarize when needed.
  4. Concurrent requests on one session. LanguageModelSession supports one request at a time. Check session.isResponding or serialize access.
  5. Untrusted content in instructions. User input placed in the instructions parameter bypasses guardrail boundaries. Keep user content in the prompt.
  6. Forgetting model.eval() before Core ML tracing. PyTorch models must be in eval mode before torch.jit.trace. Training-mode artifacts corrupt output.
  7. Using neuralnetwork format. Always use mlprogram (.mlpackage) for new Core ML models. The legacy neuralnetwork format is deprecated.
  8. Exceeding 60% RAM on iOS (MLX Swift). Large models cause OOM kills.
  9. Running MLX in simulator. MLX requires Metal GPU -- use physical devices.
  10. Not unloading models on background. Unload in scenePhase ==.background.

Review Checklist

  • Framework selection matches use case and target OS version
  • Foundation Models: availability checked before every API call
  • Foundation Models: graceful fallback when model unavailable
  • Foundation Models: session prewarm called before user interaction
  • Foundation Models: @Generable properties in logical generation order
  • Foundation Models: token budget accounted for (check contextSize)
  • Core ML: model format is mlprogram (.mlpackage) for iOS 15+
  • Core ML: model.eval() called before tracing/exporting PyTorch models
  • Core ML: minimum_deployment_target set explicitly
  • Core ML: model accuracy validated after compression
  • MLX Swift: model size appropriate for target device RAM
  • MLX Swift: GPU cache limits set, models unloaded on backgrounding
  • All model access serialized through coordinator actor
  • Concurrency: model types and tool implementations are Sendable-conformant or @MainActor-isolated
  • Physical device testing performed (not simulator)

References

平台分布

Codex

39.21%
按下载量换算3,915

Claude

29.25%
按下载量换算2,920

Cursor

18.67%
按下载量换算1,864

Gemini CLI

8.88%
按下载量换算887

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在提醒或未通过项,安装前请自行复核。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills