{"id":"c92760ee-e31f-4996-8157-664c60fa0a58","shortId":"EDJaHd","kind":"skill","title":"apple-on-device-ai","tagline":"Integrate on-device AI using Foundation Models framework, Core ML, and open-source LLM runtimes on Apple Silicon. Covers Foundation Models (LanguageModelSession, @Generable, @Guide, SystemLanguageModel, structured output, tool calling), Core ML (coremltools, model conversion, qua","description":"# On-Device AI for Apple Platforms\n\nGuide for selecting, deploying, and optimizing on-device ML models. Covers Apple\nFoundation Models, Core ML, MLX Swift, and llama.cpp.\n\n## Contents\n\n- [Framework Selection Router](#framework-selection-router)\n- [Apple Foundation Models Overview](#apple-foundation-models-overview)\n- [Core ML Overview](#core-ml-overview)\n- [MLX Swift Overview](#mlx-swift-overview)\n- [Multi-Backend Architecture](#multi-backend-architecture)\n- [Performance Best Practices](#performance-best-practices)\n- [Common Mistakes](#common-mistakes)\n- [Review Checklist](#review-checklist)\n- [References](#references)\n\n## Framework Selection Router\n\nUse this decision tree to pick the right framework for your use case.\n\n### Apple Foundation Models\n\n**When to use:** Text generation, summarization, entity extraction, structured\noutput, and short dialog on iOS 26+ / macOS 26+ devices with Apple Intelligence\nenabled. Zero setup -- no API keys, no network, no model downloads.\n\n**Best for:**\n- Generating text or structured data with `@Generable` types\n- Summarization, classification, content tagging\n- Tool-augmented generation with the `Tool` protocol\n- Apps that need guaranteed on-device privacy\n\n**Not suited for:** Complex math, code generation, factual accuracy tasks,\nor apps targeting pre-iOS 26 devices.\n\n### Core ML\n\n**When to use:** Deploying custom trained models (vision, NLP, audio) across all\nApple platforms. Converting models from PyTorch, TensorFlow, or scikit-learn\nwith coremltools.\n\n**Best for:**\n- Image classification, object detection, segmentation\n- Custom NLP classifiers, sentiment analysis models\n- Audio/speech models via SoundAnalysis integration\n- Any scenario needing Neural Engine optimization\n- Models requiring quantization, palettization, or pruning\n\n### MLX Swift\n\n**When to use:** Running specific open-source LLMs (Llama, Mistral, Qwen, Gemma)\non Apple Silicon with maximum throughput. Research and prototyping.\n\n**Best for:**\n- Highest sustained token generation on Apple Silicon\n- Running Hugging Face models from `mlx-community`\n- Research requiring automatic differentiation\n- Fine-tuning workflows on Mac\n\n### llama.cpp\n\n**When to use:** Cross-platform LLM inference using GGUF model format. Production\ndeployments needing broad device support.\n\n**Best for:**\n- GGUF quantized models (Q4_K_M, Q5_K_M, Q8_0)\n- Cross-platform apps (iOS + Android + desktop)\n- Maximum compatibility with open-source model ecosystem\n\n### Quick Reference\n\n| Scenario | Framework |\n|---|---|\n| Text generation, zero setup (iOS 26+) | Foundation Models |\n| Structured output from on-device LLM | Foundation Models (`@Generable`) |\n| Image classification, object detection | Core ML |\n| Custom model from PyTorch/TensorFlow | Core ML + coremltools |\n| Running specific open-source LLMs | MLX Swift or llama.cpp |\n| Maximum throughput on Apple Silicon | MLX Swift |\n| Cross-platform LLM inference | llama.cpp |\n| OCR and text recognition | Vision framework |\n| Sentiment analysis, NER, tokenization | Natural Language framework |\n| Training custom classifiers on device | Create ML |\n\n## Apple Foundation Models Overview\n\nOn-device language model optimized for Apple Silicon. Available on devices\nsupporting Apple Intelligence (iOS 26+, macOS 26+).\n\n- Token budget covers input + output; check `contextSize` for the limit\n- Check `supportedLanguages` for supported locales\n- Guardrails always enforced, cannot be disabled\n\n### Availability Checking (Required)\n\nAlways check before using. Never crash on unavailability.\n\n```swift\nimport FoundationModels\n\nswitch SystemLanguageModel.default.availability {\ncase .available:\n    // Proceed with model usage\ncase .unavailable(.appleIntelligenceNotEnabled):\n    // Guide user to enable Apple Intelligence in Settings\ncase .unavailable(.modelNotReady):\n    // Model is downloading; show loading state\ncase .unavailable(.deviceNotEligible):\n    // Device cannot run Apple Intelligence; use fallback\ndefault:\n    // Graceful fallback for any other reason\n}\n```\n\n### Session Management\n\n```swift\n// Basic session\nlet session = LanguageModelSession()\n\n// Session with instructions\nlet session = LanguageModelSession {\n    \"You are a helpful cooking assistant.\"\n}\n\n// Session with tools\nlet session = LanguageModelSession(\n    tools: [weatherTool, recipeTool]\n) {\n    \"You are a helpful assistant with access to tools.\"\n}\n```\n\nKey rules:\n- Sessions are stateful -- multi-turn conversations maintain context automatically\n- One request at a time per session (check `session.isResponding`)\n- Call `session.prewarm()` before user interaction for faster first response\n- Save/restore transcripts: `LanguageModelSession(model: model, tools: [], transcript: savedTranscript)`\n\n### Structured Output with @Generable\n\nThe `@Generable` macro creates compile-time schemas for type-safe output:\n\n```swift\n@Generable\nstruct Recipe {\n    @Guide(description: \"The recipe name\")\n    var name: String\n\n    @Guide(description: \"Cooking steps\", .count(3))\n    var steps: [String]\n\n    @Guide(description: \"Prep time in minutes\", .range(1...120))\n    var prepTime: Int\n}\n\nlet response = try await session.respond(\n    to: \"Suggest a quick pasta recipe\",\n    generating: Recipe.self\n)\nprint(response.content.name)\n```\n\n#### @Guide Constraints\n\n| Constraint | Purpose |\n|---|---|\n| `description:` | Natural language hint for generation |\n| `.anyOf([values])` | Restrict to enumerated string values |\n| `.count(n)` | Fixed array length |\n| `.range(min...max)` | Numeric range |\n| `.minimum(n)` / `.maximum(n)` | One-sided numeric bound |\n| `.minimumCount(n)` / `.maximumCount(n)` | Array length bounds |\n| `.constant(value)` | Always returns this value |\n| `.pattern(regex)` | String format enforcement |\n| `.element(guide)` | Guide applied to each array element |\n\nProperties generate in declaration order. Place foundational data before\ndependent data for better results.\n\n### Streaming Structured Output\n\n```swift\nlet stream = session.streamResponse(\n    to: \"Suggest a recipe\",\n    generating: Recipe.self\n)\nfor try await snapshot in stream {\n    // snapshot.content is Recipe.PartiallyGenerated (all properties optional)\n    if let name = snapshot.content.name { updateNameLabel(name) }\n}\n```\n\n### Tool Calling\n\n```swift\nstruct WeatherTool: Tool {\n    let name = \"weather\"\n    let description = \"Get current weather for a city.\"\n\n    @Generable\n    struct Arguments {\n        @Guide(description: \"The city name\")\n        var city: String\n    }\n\n    func call(arguments: Arguments) async throws -> String {\n        let weather = try await fetchWeather(arguments.city)\n        return weather.description\n    }\n}\n```\n\nRegister tools at session creation. The model invokes them autonomously.\n\n### Error Handling\n\n```swift\ndo {\n    let response = try await session.respond(to: prompt)\n} catch let error as LanguageModelSession.GenerationError {\n    switch error {\n    case .guardrailViolation(let context):\n        // Content triggered safety filters\n    case .exceededContextWindowSize(let context):\n        // Too many tokens; summarize and retry\n    case .concurrentRequests(let context):\n        // Another request is in progress on this session\n    case .unsupportedLanguageOrLocale(let context):\n        // Current locale not supported\n    case .unsupportedGuide(let context):\n        // A @Guide constraint is not supported\n    case .assetsUnavailable(let context):\n        // Model assets not available on device\n    case .refusal(let refusal, _):\n        // Model refused; stream refusal.explanation for details\n    case .rateLimited(let context):\n        // Too many requests; back off and retry\n    case .decodingFailure(let context):\n        // Response could not be decoded into the expected type\n    default: break\n    }\n}\n```\n\n### Generation Options\n\n```swift\nlet options = GenerationOptions(\n    sampling: .random(top: 40),\n    temperature: 0.7,\n    maximumResponseTokens: 512\n)\nlet response = try await session.respond(to: prompt, options: options)\n```\n\nSampling modes: `.greedy`, `.random(top:seed:)`, `.random(probabilityThreshold:seed:)`.\n\n### Prompt Design Rules\n\n1. Be concise -- use `tokenCount(for:)` to monitor the context window budget\n2. Use bracketed placeholders in instructions: `[descriptive example]`\n3. Use \"DO NOT\" in all caps for prohibitions\n4. Provide up to 5 few-shot examples for consistency\n5. Use length qualifiers: \"in a few words\", \"in three sentences\"\n\n### Safety and Guardrails\n\n- Guardrails are always enforced and cannot be disabled\n- Instructions take precedence over user prompts\n- Never include untrusted user content in instructions\n- Handle false positives gracefully\n- Frame tool results as authorized data to prevent model refusals\n\n### Use Cases\n\nFoundation Models supports specialized use cases via `SystemLanguageModel.UseCase`:\n- `.general` -- Default for text generation, summarization, dialog\n- `.contentTagging` -- Optimized for categorization and labeling tasks\n\n### Custom Adapters\n\nLoad fine-tuned adapters for specialized behavior (requires entitlement):\n\n```swift\nlet adapter = try SystemLanguageModel.Adapter(name: \"my-adapter\")\ntry await adapter.compile()\nlet model = SystemLanguageModel(adapter: adapter, guardrails: .default)\nlet session = LanguageModelSession(model: model)\n```\n\n> See [references/foundation-models.md](references/foundation-models.md) for\n> the complete Foundation Models API reference.\n\n## Core ML Overview\n\nApple's framework for deploying trained models. Automatically dispatches to the\noptimal compute unit (CPU, GPU, or Neural Engine).\n\n### Model Formats\n\n| Format | Extension | When to Use |\n|---|---|---|\n| `.mlpackage` | Directory (mlprogram) | All new models (iOS 15+) |\n| `.mlmodel` | Single file (neuralnetwork) | Legacy only (iOS 11-14) |\n| `.mlmodelc` | Compiled | Pre-compiled for faster loading |\n\nAlways use mlprogram (`.mlpackage`) for new work.\n\n### Conversion Pipeline (coremltools)\n\n```python\nimport coremltools as ct\n\n# PyTorch conversion (torch.jit.trace)\nmodel.eval()  # CRITICAL: always call eval() before tracing\ntraced = torch.jit.trace(model, example_input)\nmlmodel = ct.convert(\n    traced,\n    inputs=[ct.TensorType(shape=(1, 3, 224, 224), name=\"image\")],\n    minimum_deployment_target=ct.target.iOS18,\n    convert_to='mlprogram',\n)\nmlmodel.save(\"Model.mlpackage\")\n```\n\n### Optimization Techniques\n\n| Technique | Size Reduction | Accuracy Impact | Best Compute Unit |\n|---|---|---|---|\n| INT8 per-channel | ~4x | Low | CPU/GPU |\n| INT4 per-block | ~8x | Medium | GPU |\n| Palettization 4-bit | ~8x | Low-Medium | Neural Engine |\n| W8A8 (weights+activations) | ~4x | Low | ANE (A17 Pro/M4+) |\n| Pruning 75% | ~4x | Medium | CPU/ANE |\n\n### Swift Integration\n\n```swift\nlet config = MLModelConfiguration()\nconfig.computeUnits = .all\nlet model = try MLModel(contentsOf: modelURL, configuration: config)\n\n// Async prediction (iOS 17+)\nlet output = try await model.prediction(from: input)\n```\n\n### MLTensor (iOS 18+)\n\nSwift type for multidimensional array operations:\n\n```swift\nimport CoreML\n\nlet tensor = MLTensor([1.0, 2.0, 3.0, 4.0])\nlet reshaped = tensor.reshaped(to: [2, 2])\nlet result = tensor.softmax()\n```\n\n> See [references/coreml-conversion.md](references/coreml-conversion.md) for the\n> full conversion pipeline and [references/coreml-optimization.md](references/coreml-optimization.md)\n> for optimization techniques.\n\n## MLX Swift Overview\n\nApple's ML framework for Swift. Highest sustained generation throughput on\nApple Silicon via unified memory architecture.\n\n### Loading and Running LLMs\n\n```swift\nimport MLX\nimport MLXLLM\n\nlet config = ModelConfiguration(id: \"mlx-community/Mistral-7B-Instruct-v0.3-4bit\")\nlet model = try await LLMModelFactory.shared.loadContainer(configuration: config)\n\ntry await model.perform { context in\n    let input = try await context.processor.prepare(\n        input: UserInput(prompt: \"Hello\")\n    )\n    let stream = try generate(\n        input: input,\n        parameters: GenerateParameters(temperature: 0.0),\n        context: context\n    )\n    for await part in stream {\n        print(part.chunk ?? \"\", terminator: \"\")\n    }\n}\n```\n\n### Model Selection by Device\n\n| Device | RAM | Recommended Model | RAM Usage |\n|---|---|---|---|\n| iPhone 12-14 | 4-6 GB | SmolLM2-135M or Qwen 2.5 0.5B | ~0.3 GB |\n| iPhone 15 Pro+ | 8 GB | Gemma 3n E4B 4-bit | ~3.5 GB |\n| Mac 8 GB | 8 GB | Llama 3.2 3B 4-bit | ~3 GB |\n| Mac 16 GB+ | 16 GB+ | Mistral 7B 4-bit | ~6 GB |\n\n### Memory Management\n\n1. Never exceed 60% of total RAM on iOS\n2. Set GPU cache limits: `MLX.GPU.set(cacheLimit: 512 * 1024 * 1024)`\n3. Unload models on app backgrounding\n4. Use \"Increased Memory Limit\" entitlement for larger models\n5. Physical device required (no simulator support for Metal GPU)\n\n> See [references/mlx-swift.md](references/mlx-swift.md) for full MLX Swift\n> patterns and llama.cpp integration.\n\n## Multi-Backend Architecture\n\nWhen an app needs multiple AI backends (e.g., Foundation Models + MLX fallback):\n\n```swift\nfunc respond(to prompt: String) async throws -> String {\n    if SystemLanguageModel.default.isAvailable {\n        return try await foundationModelsRespond(prompt)\n    } else if canLoadMLXModel() {\n        return try await mlxRespond(prompt)\n    } else {\n        throw AIError.noBackendAvailable\n    }\n}\n```\n\nSerialize all model access through a coordinator actor to prevent contention:\n\n```swift\nactor ModelCoordinator {\n    func withExclusiveAccess<T>(_ work: () async throws -> T) async rethrows -> T {\n        try await work()\n    }\n}\n```\n\n## Performance Best Practices\n\n1. Run outside debugger for accurate benchmarks (Xcode: Cmd-Opt-R, uncheck\n   \"Debug Executable\")\n2. Call `session.prewarm()` for Foundation Models before user interaction\n3. Pre-compile Core ML models to `.mlmodelc` for faster loading\n4. Use EnumeratedShapes over RangeDim for Neural Engine optimization\n5. Use 4-bit palettization for best Neural Engine memory/latency gains\n6. Batch Vision framework requests in a single `perform()` call\n7. Use async prediction (iOS 17+) in Swift concurrency contexts\n8. Neural Engine (Core ML) is most energy-efficient for compatible operations\n\n## Common Mistakes\n\n1. **No availability check.** Calling `LanguageModelSession()` without checking\n   `SystemLanguageModel.default.availability` crashes on unsupported devices.\n2. **No fallback UI.** Users on pre-iOS 26 or devices without Apple Intelligence\n   see nothing. Always provide a graceful degradation path.\n3. **Exceeding the context window.** The token budget covers input + output.\n   Monitor usage via `tokenCount(for:)` and summarize when needed.\n4. **Concurrent requests on one session.** `LanguageModelSession` supports one\n   request at a time. Check `session.isResponding` or serialize access.\n5. **Untrusted content in instructions.** User input placed in the instructions\n   parameter bypasses guardrail boundaries. Keep user content in the prompt.\n6. **Forgetting `model.eval()` before Core ML tracing.** PyTorch models must be\n   in eval mode before `torch.jit.trace`. Training-mode artifacts corrupt output.\n7. **Using neuralnetwork format.** Always use `mlprogram` (.mlpackage) for new\n   Core ML models. The legacy neuralnetwork format is deprecated.\n8. **Exceeding 60% RAM on iOS (MLX Swift).** Large models cause OOM kills.\n9. **Running MLX in simulator.** MLX requires Metal GPU -- use physical devices.\n10. **Not unloading models on background.** Unload in `scenePhase == .background`.\n\n## Review Checklist\n\n- [ ] Framework selection matches use case and target OS version\n- [ ] Foundation Models: availability checked before every API call\n- [ ] Foundation Models: graceful fallback when model unavailable\n- [ ] Foundation Models: session prewarm called before user interaction\n- [ ] Foundation Models: @Generable properties in logical generation order\n- [ ] Foundation Models: token budget accounted for (check `contextSize`)\n- [ ] Core ML: model format is mlprogram (.mlpackage) for iOS 15+\n- [ ] Core ML: model.eval() called before tracing/exporting PyTorch models\n- [ ] Core ML: minimum_deployment_target set explicitly\n- [ ] Core ML: model accuracy validated after compression\n- [ ] MLX Swift: model size appropriate for target device RAM\n- [ ] MLX Swift: GPU cache limits set, models unloaded on backgrounding\n- [ ] All model access serialized through coordinator actor\n- [ ] Concurrency: model types and tool implementations are `Sendable`-conformant or `@MainActor`-isolated\n- [ ] Physical device testing performed (not simulator)\n\n## References\n\n- [Foundation Models API](references/foundation-models.md) -- LanguageModelSession, @Generable, tool calling, prompt design\n- [Core ML Conversion](references/coreml-conversion.md) -- Model conversion from PyTorch, TensorFlow, other frameworks\n- [Core ML Optimization](references/coreml-optimization.md) -- Quantization, palettization, pruning, performance tuning\n- [MLX Swift & llama.cpp](references/mlx-swift.md) -- MLX Swift patterns, llama.cpp integration, memory management","tags":["apple","device","swift","ios","skills","dpearson2699","accessibility","agent-skills","ai-coding","claude-code","codex-skills","cursor-skills"],"capabilities":["skill","source-dpearson2699","skill-apple-on-device-ai","topic-accessibility","topic-agent-skills","topic-ai-coding","topic-apple","topic-claude-code","topic-codex-skills","topic-cursor-skills","topic-ios","topic-ios-development","topic-liquid-glass","topic-localization","topic-mapkit"],"categories":["swift-ios-skills"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/dpearson2699/swift-ios-skills/apple-on-device-ai","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add dpearson2699/swift-ios-skills","source_repo":"https://github.com/dpearson2699/swift-ios-skills","install_from":"skills.sh"}},"qualityScore":"0.700","qualityRationale":"deterministic score 0.70 from registry signals: · indexed on github topic:agent-skills · 599 github stars · SKILL.md body (17,013 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-05-18T18:53:39.544Z","embedding":null,"createdAt":"2026-04-18T20:33:39.611Z","updatedAt":"2026-05-18T18:53:39.544Z","lastSeenAt":"2026-05-18T18:53:39.544Z","tsv":"'-14':1217,1483 '-6':1485 '/mistral-7b-instruct-v0.3-4bit':1429 '0':368 '0.0':1460 '0.3':1495 '0.5':1493 '0.7':989 '1':686,1013,1262,1534,1661,1752 '1.0':1366 '10':1913 '1024':1551,1552 '11':1216 '12':1482 '120':687 '135m':1489 '15':1208,1498,1982 '16':1522,1524 '17':1343,1732 '18':1353 '2':1025,1374,1375,1543,1676,1765 '2.0':1367 '2.5':1492 '224':1264,1265 '26':163,165,227,393,482,484,1774 '3':675,1033,1263,1519,1553,1685,1788 '3.0':1368 '3.2':1515 '3.5':1507 '3b':1516 '3n':1503 '4':1042,1303,1484,1505,1517,1528,1559,1697,1708,1808 '4.0':1369 '40':987 '4x':1292,1314,1321 '5':1046,1053,1568,1706,1826 '512':991,1550 '6':1530,1717,1847 '60':1537,1890 '7':1727,1869 '75':1320 '7b':1527 '8':1500,1510,1512,1737,1888 '8x':1299,1305 '9':1901 'a17':1317 'access':600,1635,1825,2026 'account':1969 'accur':1666 'accuraci':219,1283,2001 'across':241 'activ':1313 'actor':1639,1644,2030 'adapt':1127,1132,1140,1146,1153,1154 'adapter.compile':1149 'ai':5,10,46,1598 'aierror.nobackendavailable':1631 'alway':501,509,751,1069,1226,1246,1782,1873 'analysi':267,449 'android':374 'ane':1316 'anoth':906 'anyof':716 'api':174,1170,1940,2052 'app':203,222,372,1557,1595 'appl':2,24,48,62,79,84,145,168,243,302,317,432,462,473,479,535,554,1175,1396,1407,1778 'apple-foundation-models-overview':83 'apple-on-device-ai':1 'appleintelligencenoten':530 'appli':763 'appropri':2009 'architectur':105,109,1412,1592 'argument':832,843,844 'arguments.city':853 'array':726,746,766,1358 'artifact':1866 'asset':937 'assetsunavail':933 'assist':584,598 'async':845,1340,1611,1649,1652,1729 'audio':240 'audio/speech':269 'augment':197 'author':1096 'automat':329,614,1182 'autonom':865 'avail':475,506,523,939,1754,1936 'await':694,797,851,873,995,1148,1347,1433,1438,1445,1464,1618,1626,1656 'b':1494 'back':959 'backend':104,108,1591,1599 'background':1558,1918,1922,2023 'basic':568 'batch':1718 'behavior':1135 'benchmark':1667 'best':111,115,181,256,310,356,1285,1659,1712 'better':780 'bit':1304,1506,1518,1529,1709 'block':1298 'bound':741,748 'boundari':1840 'bracket':1027 'break':977 'broad':353 'budget':486,1024,1795,1968 'bypass':1838 'cach':1546,2017 'cachelimit':1549 'call':36,624,814,842,1247,1677,1726,1756,1941,1953,1986,2057 'canloadmlxmodel':1623 'cannot':503,552,1072 'cap':1039 'case':144,522,528,539,548,884,892,902,914,922,932,942,952,963,1103,1109,1929 'catch':877 'categor':1122 'caus':1898 'channel':1291 'check':490,495,507,510,622,1755,1759,1821,1937,1971 'checklist':123,126,1924 'citi':829,836,839 'classif':192,259,407 'classifi':265,457 'cmd':1670 'cmd-opt-r':1669 'code':216 'common':117,120,1750 'common-mistak':119 'communiti':326,1428 'compat':377,1748 'compil':650,1219,1222,1688 'compile-tim':649 'complet':1167 'complex':214 'compress':2004 'comput':1187,1286 'concis':1015 'concurr':1735,1809,2031 'concurrentrequest':903 'config':1328,1339,1423,1436 'config.computeunits':1330 'configur':1338,1435 'conform':2039 'consist':1052 'constant':749 'constraint':707,708,928 'content':71,193,888,1085,1642,1828,1843 'contentsof':1336 'contenttag':1119 'context':613,887,895,905,917,925,935,955,966,1022,1440,1461,1462,1736,1791 'context.processor.prepare':1446 'contexts':491,1972 'convers':41,611,1233,1242,1385,2062,2065 'convert':245,1273 'cook':583,672 'coordin':1638,2029 'core':15,37,65,88,92,229,410,416,1172,1689,1740,1851,1879,1973,1983,1991,1998,2060,2071 'core-ml-overview':91 'coreml':1362 'coremltool':39,255,418,1235,1238 'corrupt':1867 'could':968 'count':674,723 'cover':26,61,487,1796 'cpu':1189 'cpu/ane':1323 'cpu/gpu':1294 'crash':514,1761 'creat':460,648 'creation':860 'critic':1245 'cross':342,370,437 'cross-platform':341,369,436 'ct':1240 'ct.convert':1257 'ct.target':1271 'ct.tensortype':1260 'current':825,918 'custom':235,263,412,456,1126 'data':187,775,778,1097 'debug':1674 'debugg':1664 'decis':134 'declar':771 'decod':971 'decodingfailur':964 'default':558,976,1113,1156 'degrad':1786 'depend':777 'deploy':53,234,351,1179,1269,1994 'deprec':1887 'descript':663,671,680,710,823,834,1031 'design':1011,2059 'desktop':375 'detail':951 'detect':261,409 'devic':4,9,45,58,166,209,228,354,401,459,468,477,551,941,1474,1475,1570,1764,1776,1912,2012,2044 'devicenotelig':550 'dialog':160,1118 'differenti':330 'directori':1202 'disabl':505,1074 'dispatch':1183 'download':180,544 'e.g':1600 'e4b':1504 'ecosystem':383 'effici':1746 'element':760,767 'els':1621,1629 'enabl':170,534 'energi':1745 'energy-effici':1744 'enforc':502,759,1070 'engin':278,1193,1310,1704,1714,1739 'entiti':154 'entitl':1137,1564 'enumer':720 'enumeratedshap':1699 'error':866,879,883 'eval':1248,1859 'everi':1939 'exampl':1032,1050,1254 'exceed':1536,1789,1889 'exceededcontextwindows':893 'execut':1675 'expect':974 'explicit':1997 'extens':1197 'extract':155 'face':321 'factual':218 'fallback':557,560,1604,1767,1945 'fals':1089 'faster':630,1224,1695 'fetchweath':852 'few-shot':1047 'file':1211 'filter':891 'fine':332,1130 'fine-tun':331,1129 'first':631 'fix':725 'forget':1848 'format':349,758,1195,1196,1872,1885,1976 'foundat':12,27,63,80,85,146,394,403,463,774,1104,1168,1601,1680,1934,1942,1949,1957,1965,2050 'foundationmodel':519 'foundationmodelsrespond':1619 'frame':1092 'framework':14,72,76,129,140,387,447,454,1177,1399,1720,1925,2070 'framework-selection-rout':75 'full':1384,1582 'func':841,1606,1646 'gain':1716 'gb':1486,1496,1501,1508,1511,1513,1520,1523,1525,1531 'gemma':300,1502 'generabl':30,189,405,644,646,659,830,1959,2055 'general':1112 'generat':152,183,198,217,315,389,702,715,769,793,978,1116,1404,1454,1963 'generateparamet':1458 'generationopt':983 'get':824 'gguf':347,358 'gpu':1190,1301,1545,1577,1909,2016 'grace':559,1091,1785,1944 'greedi':1003 'guarante':206 'guardrail':500,1066,1067,1155,1839 'guardrailviol':885 'guid':31,50,531,662,670,679,706,761,762,833,927 'handl':867,1088 'hello':1450 'help':582,597 'highest':312,1402 'hint':713 'hug':320 'id':1425 'imag':258,406,1267 'impact':1284 'implement':2036 'import':518,1237,1361,1418,1420 'includ':1082 'increas':1561 'infer':345,440 'input':488,1255,1259,1350,1443,1447,1455,1456,1797,1832 'instruct':575,1030,1075,1087,1830,1836 'int':690 'int4':1295 'int8':1288 'integr':6,273,1325,1588,2088 'intellig':169,480,536,555,1779 'interact':628,1684,1956 'invok':863 'io':162,226,373,392,481,1207,1215,1342,1352,1542,1731,1773,1893,1981 'ios18':1272 'iphon':1481,1497 'isol':2042 'k':362,365 'keep':1841 'key':175,603 'kill':1900 'label':1124 'languag':453,469,712 'languagemodelsess':29,572,578,590,635,1159,1757,1814,2054 'languagemodelsession.generationerror':881 'larg':1896 'larger':1566 'learn':253 'legaci':1213,1883 'length':727,747,1055 'let':570,576,588,691,786,808,819,822,848,870,878,886,894,904,916,924,934,944,954,965,981,992,1139,1150,1157,1327,1332,1344,1363,1370,1376,1422,1430,1442,1451 'limit':494,1547,1563,2018 'llama':297,1514 'llama.cpp':70,337,428,441,1587,2082,2087 'llm':21,344,402,439 'llmmodelfactory.shared.loadcontainer':1434 'llms':296,424,1416 'load':546,1128,1225,1413,1696 'local':499,919 'logic':1962 'low':1293,1307,1315 'low-medium':1306 'm':363,366 'mac':336,1509,1521 'maco':164,483 'macro':647 'mainactor':2041 'maintain':612 'manag':566,1533,2090 'mani':897,957 'match':1927 'math':215 'max':730 'maximum':305,376,429,735 'maximumcount':744 'maximumresponsetoken':990 'medium':1300,1308,1322 'memori':1411,1532,1562,2089 'memory/latency':1715 'metal':1576,1908 'min':729 'minimum':733,1268,1993 'minimumcount':742 'minut':684 'mistak':118,121,1751 'mistral':298,1526 'ml':16,38,59,66,89,93,230,411,417,461,1173,1398,1690,1741,1852,1880,1974,1984,1992,1999,2061,2072 'mlmodel':1209,1256,1335 'mlmodel.save':1276 'mlmodelc':1218,1693 'mlmodelconfigur':1329 'mlpackag':1201,1229,1876,1979 'mlprogram':1203,1228,1275,1875,1978 'mltensor':1351,1365 'mlx':67,95,99,286,325,425,434,1393,1419,1427,1583,1603,1894,1903,1906,2005,2014,2080,2084 'mlx-commun':324,1426 'mlx-swift-overview':98 'mlx.gpu.set':1548 'mlxllm':1421 'mlxrespond':1627 'mode':1002,1860,1865 'model':13,28,40,60,64,81,86,147,179,237,246,268,270,280,322,348,360,382,395,404,413,464,470,526,542,636,637,862,936,946,1100,1105,1151,1160,1161,1169,1181,1194,1206,1253,1333,1431,1471,1478,1555,1567,1602,1634,1681,1691,1855,1881,1897,1916,1935,1943,1947,1950,1958,1966,1975,1990,2000,2007,2020,2025,2032,2051,2064 'model.eval':1244,1849,1985 'model.mlpackage':1277 'model.perform':1439 'model.prediction':1348 'modelconfigur':1424 'modelcoordin':1645 'modelnotreadi':541 'modelurl':1337 'monitor':1020,1799 'multi':103,107,609,1590 'multi-backend':102,1589 'multi-backend-architectur':106 'multi-turn':608 'multidimension':1357 'multipl':1597 'must':1856 'my-adapt':1144 'n':724,734,736,743,745 'name':666,668,809,812,820,837,1143,1266 'natur':452,711 'need':205,276,352,1596,1807 'ner':450 'network':177 'neural':277,1192,1309,1703,1713,1738 'neuralnetwork':1212,1871,1884 'never':513,1081,1535 'new':1205,1231,1878 'nlp':239,264 'noth':1781 'numer':731,740 'object':260,408 'ocr':442 'on-devic':7,43,56,207,399,466 'one':615,738,1812,1816 'one-sid':737 'oom':1899 'open':19,294,380,422 'open-sourc':18,293,379,421 'oper':1359,1749 'opt':1671 'optim':55,279,471,1120,1186,1278,1391,1705,2073 'option':806,979,982,999,1000 'order':772,1964 'os':1932 'output':34,157,397,489,642,657,784,1345,1798,1868 'outsid':1663 'overview':82,87,90,94,97,101,465,1174,1395 'palett':283,1302,1710,2076 'paramet':1457,1837 'part':1465 'part.chunk':1469 'pasta':700 'path':1787 'pattern':755,1585,2086 'per':620,1290,1297 'per-block':1296 'per-channel':1289 'perform':110,114,1658,1725,2046,2078 'performance-best-practic':113 'physic':1569,1911,2043 'pick':137 'pipelin':1234,1386 'place':773,1833 'placehold':1028 'platform':49,244,343,371,438 'posit':1090 'practic':112,116,1660 'pre':225,1221,1687,1772 'pre-compil':1220,1686 'pre-io':224,1771 'preced':1077 'predict':1341,1730 'prep':681 'preptim':689 'prevent':1099,1641 'prewarm':1952 'print':704,1468 'privaci':210 'pro':1499 'pro/m4':1318 'probabilitythreshold':1008 'proceed':524 'product':350 'progress':910 'prohibit':1041 'prompt':876,998,1010,1080,1449,1609,1620,1628,1846,2058 'properti':768,805,1960 'protocol':202 'prototyp':309 'provid':1043,1783 'prune':285,1319,2077 'purpos':709 'python':1236 'pytorch':248,1241,1854,1989,2067 'pytorch/tensorflow':415 'q4':361 'q5':364 'q8':367 'qua':42 'qualifi':1056 'quantiz':282,359,2075 'quick':384,699 'qwen':299,1491 'r':1672 'ram':1476,1479,1540,1891,2013 'random':985,1004,1007 'rang':685,728,732 'rangedim':1701 'ratelimit':953 'reason':564 'recip':661,665,701,792 'recipe.partiallygenerated':803 'recipe.self':703,794 'recipetool':593 'recognit':445 'recommend':1477 'reduct':1282 'refer':127,128,385,1171,2049 'references/coreml-conversion.md':1380,1381,2063 'references/coreml-optimization.md':1388,1389,2074 'references/foundation-models.md':1163,1164,2053 'references/mlx-swift.md':1579,1580,2083 'refus':943,945,947,1101 'refusal.explanation':949 'regex':756 'regist':856 'request':616,907,958,1721,1810,1817 'requir':281,328,508,1136,1571,1907 'research':307,327 'reshap':1371 'respond':1607 'respons':632,692,871,967,993 'response.content.name':705 'restrict':718 'result':781,1094,1377 'rethrow':1653 'retri':901,962 'return':752,854,1616,1624 'review':122,125,1923 'review-checklist':124 'right':139 'router':74,78,131 'rule':604,1012 'run':291,319,419,553,1415,1662,1902 'runtim':22 'safe':656 'safeti':890,1064 'sampl':984,1001 'save/restore':633 'savedtranscript':640 'scenario':275,386 'scenephas':1921 'schema':652 'scikit':252 'scikit-learn':251 'see':1162,1379,1578,1780 'seed':1006,1009 'segment':262 'select':52,73,77,130,1472,1926 'sendabl':2038 'sentenc':1063 'sentiment':266,448 'serial':1632,1824,2027 'session':565,569,571,573,577,585,589,605,621,859,913,1158,1813,1951 'session.isresponding':623,1822 'session.prewarm':625,1678 'session.respond':695,874,996 'session.streamresponse':788 'set':538,1544,1996,2019 'setup':172,391 'shape':1261 'short':159 'shot':1049 'show':545 'side':739 'silicon':25,303,318,433,474,1408 'simul':1573,1905,2048 'singl':1210,1724 'size':1281,2008 'skill' 'skill-apple-on-device-ai' 'smollm2':1488 'smollm2-135m':1487 'snapshot':798 'snapshot.content':801 'snapshot.content.name':810 'soundanalysi':272 'sourc':20,295,381,423 'source-dpearson2699' 'special':1107,1134 'specif':292,420 'state':547,607 'step':673,677 'stream':782,787,800,948,1452,1467 'string':669,678,721,757,840,847,1610,1613 'struct':660,816,831 'structur':33,156,186,396,641,783 'suggest':697,790 'suit':212 'summar':153,191,899,1117,1805 'support':355,478,498,921,931,1106,1574,1815 'supportedlanguag':496 'sustain':313,1403 'swift':68,96,100,287,426,435,517,567,658,785,815,868,980,1138,1324,1326,1354,1360,1394,1401,1417,1584,1605,1643,1734,1895,2006,2015,2081,2085 'switch':520,882 'systemlanguagemodel':32,1152 'systemlanguagemodel.adapter':1142 'systemlanguagemodel.default.availability':521,1760 'systemlanguagemodel.default.isavailable':1615 'systemlanguagemodel.usecase':1111 'tag':194 'take':1076 'target':223,1270,1931,1995,2011 'task':220,1125 'techniqu':1279,1280,1392 'temperatur':988,1459 'tensor':1364 'tensor.reshaped':1372 'tensor.softmax':1378 'tensorflow':249,2068 'termin':1470 'test':2045 'text':151,184,388,444,1115 'three':1062 'throughput':306,430,1405 'throw':846,1612,1630,1650 'time':619,651,682,1820 'token':314,451,485,898,1794,1967 'tokencount':1017,1802 'tool':35,196,201,587,591,602,638,813,818,857,1093,2035,2056 'tool-aug':195 'top':986,1005 'topic-accessibility' 'topic-agent-skills' 'topic-ai-coding' 'topic-apple' 'topic-claude-code' 'topic-codex-skills' 'topic-cursor-skills' 'topic-ios' 'topic-ios-development' 'topic-liquid-glass' 'topic-localization' 'topic-mapkit' 'torch.jit.trace':1243,1252,1862 'total':1539 'trace':1250,1251,1258,1853 'tracing/exporting':1988 'train':236,455,1180,1864 'training-mod':1863 'transcript':634,639 'tree':135 'tri':693,796,850,872,994,1141,1147,1334,1346,1432,1437,1444,1453,1617,1625,1655 'trigger':889 'tune':333,1131,2079 'turn':610 'type':190,655,975,1355,2033 'type-saf':654 'ui':1768 'unavail':516,529,540,549,1948 'uncheck':1673 'unifi':1410 'unit':1188,1287 'unload':1554,1915,1919,2021 'unsupport':1763 'unsupportedguid':923 'unsupportedlanguageorlocal':915 'untrust':1083,1827 'updatenamelabel':811 'usag':527,1480,1800 'use':11,132,143,150,233,290,340,346,512,556,1016,1026,1034,1054,1102,1108,1200,1227,1560,1698,1707,1728,1870,1874,1910,1928 'user':532,627,1079,1084,1683,1769,1831,1842,1955 'userinput':1448 'valid':2002 'valu':717,722,750,754 'var':667,676,688,838 'version':1933 'via':271,1110,1409,1801 'vision':238,446,1719 'w8a8':1311 'weather':821,826,849 'weather.description':855 'weathertool':592,817 'weight':1312 'window':1023,1792 'withexclusiveaccess':1647 'without':1758,1777 'word':1060 'work':1232,1648,1657 'workflow':334 'xcode':1668 'zero':171,390","prices":[{"id":"252f9f00-7b4c-4a86-bd9c-cf75baac0d86","listingId":"c92760ee-e31f-4996-8157-664c60fa0a58","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"dpearson2699","category":"swift-ios-skills","install_from":"skills.sh"},"createdAt":"2026-04-18T20:33:39.611Z"}],"sources":[{"listingId":"c92760ee-e31f-4996-8157-664c60fa0a58","source":"github","sourceId":"dpearson2699/swift-ios-skills/apple-on-device-ai","sourceUrl":"https://github.com/dpearson2699/swift-ios-skills/tree/main/skills/apple-on-device-ai","isPrimary":false,"firstSeenAt":"2026-04-18T22:00:43.464Z","lastSeenAt":"2026-05-18T18:53:39.544Z"},{"listingId":"c92760ee-e31f-4996-8157-664c60fa0a58","source":"skills_sh","sourceId":"dpearson2699/swift-ios-skills/apple-on-device-ai","sourceUrl":"https://skills.sh/dpearson2699/swift-ios-skills/apple-on-device-ai","isPrimary":true,"firstSeenAt":"2026-04-18T20:33:39.611Z","lastSeenAt":"2026-05-07T22:40:32.626Z"}],"details":{"listingId":"c92760ee-e31f-4996-8157-664c60fa0a58","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"dpearson2699","slug":"apple-on-device-ai","github":{"repo":"dpearson2699/swift-ios-skills","stars":599,"topics":["accessibility","agent-skills","ai-coding","apple","claude-code","codex-skills","cursor-skills","ios","ios-development","liquid-glass","localization","mapkit","networking","storekit","swift","swift-concurrency","swiftdata","swiftui","widgetkit","xcode"],"license":"other","html_url":"https://github.com/dpearson2699/swift-ios-skills","pushed_at":"2026-04-26T21:04:17Z","description":"Agent Skills for iOS 26+, Swift 6.3, SwiftUI, and modern Apple frameworks","skill_md_sha":"3772c52eee5c4d2a07fe857f23e3bdd9085ea428","skill_md_path":"skills/apple-on-device-ai/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/dpearson2699/swift-ios-skills/tree/main/skills/apple-on-device-ai"},"layout":"multi","source":"github","category":"swift-ios-skills","frontmatter":{"name":"apple-on-device-ai","description":"Integrate on-device AI using Foundation Models framework, Core ML, and open-source LLM runtimes on Apple Silicon. Covers Foundation Models (LanguageModelSession, @Generable, @Guide, SystemLanguageModel, structured output, tool calling), Core ML (coremltools, model conversion, quantization, palettization, pruning, Neural Engine, MLTensor), MLX Swift (transformer inference, unified memory), and llama.cpp (GGUF, cross-platform LLM). Use when building tool-calling AI features, working with guided generation schemas, converting models, or running on-device inference."},"skills_sh_url":"https://skills.sh/dpearson2699/swift-ios-skills/apple-on-device-ai"},"updatedAt":"2026-05-18T18:53:39.544Z"}}