Use the Core ML API directly to support custom workflows and advanced use cases.


In most cases, you interact only with your model's dynamically generated interface, which is created by Xcode automatically when you add a model to your Xcode project. You can use Core ML APIs directly in cases where you need to support custom workflows or advanced use cases. As an example, if you need to make predictions while asynchronously collecting input data into a custom structure, you can adopt the MLFeatureProvider protocol.

To use the Core ML APIs directly:

  • Adopt the MLFeatureProvider protocol in a class or structure in your app.

  • Use MLModel methods with your MLFeatureProvider.


Machine Learning Model

class MLModel

An encapsulation of all the details of your machine learning model.

Downloading and Compiling a Model on the User’s Device

Install Core ML models on the user’s device dynamically at runtime.

Making Predictions with a Sequence of Inputs

Integrate a recurrent neural network model to process sequences of inputs.

Model Features

class MLFeatureValue

A feature's value and its type bundled as a read-only instance.

protocol MLFeatureProvider

An interface that represents a collection of values for either a model's input or its output.

class MLDictionaryFeatureProvider

A convenience wrapper for the given dictionary of data.

protocol MLBatchProvider

An interface that represents a collection of feature providers.

class MLArrayBatchProvider

A convenience wrapper for batches of feature providers.

Model Updates

Personalizing a Model with On-Device Updates

Modify an updatable Core ML model by running an update task with labeled data.

class MLUpdateTask

A task that updates a model with additional training data.

class MLTask

An abstract base class for machine learning tasks.


Integrating Custom Layers

Integrate custom neural network layers into your Core ML app.

Creating a Custom Layer

Make your own custom layer for Core ML models.

protocol MLCustomLayer

An interface that defines the behavior of a custom layer in your neural network model.

protocol MLCustomModel

An interface that defines the behavior of a custom model.


struct MLModelError

Information about a Core ML model error.