coreml
Core ML
On-device machine-learning inference on Apple platforms — image classification/detection, NLP, audio, and custom models, plus on-device fine-tuning. The deep API reference — model integration, the MLModel API, MLFeatureProvider, async predictions, Vision integration, configuration/optimization, stateful models, encryption, and version compatibility — lives in references/guide.md. This file is the decision and discipline layer: read it first, open the guide for specifics.
Dials
Set these explicitly at the start; they change what "correct" means.
TASK—image(classification/detection/segmentation; drive it through Vision, not rawMLModel) ·text(NLP viaNLModel/Natural Language) ·tabular-or-custom(rawMLModel+MLFeatureProvider). If the task is text generation, stop and usefoundation-modelsinstead.COMPUTE_UNITS—all(default; OS picks CPU/GPU/Neural Engine) ·cpuAndNeuralEngine(NN-heavy models) ·cpuAndGPU·cpuOnly(background/deterministic timing). Set onMLModelConfigurationat load, never per-prediction.LOADING—xcode-bundled(default; drop in.mlpackage/.mlmodel, Xcode compiles + generates the class) ·runtime-download(download.mlmodel,MLModel.compileModel(at:), thenMLModel.load(contentsOf:)— for large or swappable models).
When to use
Building or reviewing any on-device inference path: loading a model, configuring compute units, running predictions (sync or async), wiring a model into Vision for images, encrypting a bundled model, running a stateful generator, or on-device personalization (MLUpdateTask). If the goal is generating or reasoning over text, that's foundation-models, not Core ML.