<!--
{
  "availability" : [
    "iOS: 11.0.0 -",
    "iPadOS: 11.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.13.0 -",
    "tvOS: 11.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 4.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreML",
  "identifier" : "/documentation/CoreML/MLModel",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Core ML"
    ],
    "preciseIdentifier" : "c:objc(cs)MLModel"
  },
  "title" : "MLModel"
}
-->

# MLModel

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

```
class MLModel
```

## Overview

[`MLModel`](/documentation/CoreML/MLModel) encapsulates a model’s prediction methods, configuration, and model description.

In most cases, you can use Core ML without accessing the [`MLModel`](/documentation/CoreML/MLModel) class directly. Instead, use the programmer-friendly wrapper class that Xcode automatically generates when you add a model (see [Integrating a Core ML Model into Your App](/documentation/CoreML/integrating-a-core-ml-model-into-your-app)). If your app needs the [`MLModel`](/documentation/CoreML/MLModel) interface, use the wrapper class’s `model` property.

With the [`MLModel`](/documentation/CoreML/MLModel) interface, you can:

- Make a prediction with your app’s custom [`MLFeatureProvider`](/documentation/CoreML/MLFeatureProvider) by calling [`prediction(from:)`](/documentation/CoreML/MLModel/prediction(from:)-9y2aa) or [`prediction(from:options:)`](/documentation/CoreML/MLModel/prediction(from:options:)-81mr6).
- Make multiple predictions with your app’s custom [`MLBatchProvider`](/documentation/CoreML/MLBatchProvider) by calling [`predictions(fromBatch:)`](/documentation/CoreML/MLModel/predictions(fromBatch:)) or [`predictions(from:options:)`](/documentation/CoreML/MLModel/predictions(from:options:)).
- Inspect your model’s [`metadata`](/documentation/CoreML/MLModelDescription/metadata) and [`MLFeatureDescription`](/documentation/CoreML/MLFeatureDescription) instances through [`modelDescription`](/documentation/CoreML/MLModel/modelDescription).

If your app downloads and compiles a model on the user’s device, you must use the [`MLModel`](/documentation/CoreML/MLModel) class directly to make predictions. See [Downloading and Compiling a Model on the User’s Device](/documentation/CoreML/downloading-and-compiling-a-model-on-the-user-s-device).

> Important:
> Use an ``doc://com.apple.coreml/documentation/CoreML/MLModel`` instance on one thread or one dispatch queue at a time. Do this by either serializing method calls to the model, or by creating a separate model instance for each thread and dispatch queue.

## Topics

### Loading a model

[`load(contentsOf:configuration:)`](/documentation/CoreML/MLModel/load(contentsOf:configuration:))

Construct a model asynchronously from a compiled model asset.

[`load(_:configuration:completionHandler:)`](/documentation/CoreML/MLModel/load(_:configuration:completionHandler:))

Construct a model asynchronously from a compiled model asset.

[`load(contentsOf:configuration:completionHandler:)`](/documentation/CoreML/MLModel/load(contentsOf:configuration:completionHandler:))

Creates a Core ML model instance asynchronously from a compiled model file, a custom configuration, and a completion handler.

[`init(contentsOf:)`](/documentation/CoreML/MLModel/init(contentsOf:))

Creates a Core ML model instance from a compiled model file.

[`init(contentsOf:configuration:)`](/documentation/CoreML/MLModel/init(contentsOf:configuration:))

Creates a Core ML model instance from a compiled model file and a custom configuration.

[`init(contentsOfURL:)`](/documentation/CoreML/MLModel/init(contentsOfURL:))

[`init(contentsOfURL:configuration:)`](/documentation/CoreML/MLModel/init(contentsOfURL:configuration:))

### Loading a model

[`loadContentsOfURL:configuration:completionHandler:`](/documentation/CoreML/MLModel/loadContentsOfURL:configuration:completionHandler:)

Creates a Core ML model instance asynchronously from a compiled model file, a custom configuration, and a completion handler.

### Compiling a model

[`compileModel(at:)`](/documentation/CoreML/MLModel/compileModel(at:))

[`compileModel(at:completionHandler:)`](/documentation/CoreML/MLModel/compileModel(at:completionHandler:))

Compile a model for a device.

### Making predictions

[`prediction(from:)`](/documentation/CoreML/MLModel/prediction(from:))

[`prediction(from:options:)`](/documentation/CoreML/MLModel/prediction(from:options:))

[`predictions(fromBatch:)`](/documentation/CoreML/MLModel/predictions(fromBatch:))

Generates predictions for each input feature provider within the batch provider.

[`predictions(from:options:)`](/documentation/CoreML/MLModel/predictions(from:options:))

Generates a prediction for each input feature provider within the batch provider using the prediction options.

[`prediction(from:using:)`](/documentation/CoreML/MLModel/prediction(from:using:))

[`prediction(from:using:options:)`](/documentation/CoreML/MLModel/prediction(from:using:options:))

[`MLPredictionOptions`](/documentation/CoreML/MLPredictionOptions)

The options available when making a prediction.

### Loading a model

[`predictionFromFeatures:completionHandler:`](/documentation/CoreML/MLModel/predictionFromFeatures:completionHandler:)

Generates a prediction asynchronously from the feature values within the input feature provider.

[`predictionFromFeatures:options:completionHandler:`](/documentation/CoreML/MLModel/predictionFromFeatures:options:completionHandler:)

Generates a prediction asynchronously from the feature values within the input feature provider using the prediction options.

[`predictionFromFeatures:usingState:options:completionHandler:`](/documentation/CoreML/MLModel/predictionFromFeatures:usingState:options:completionHandler:)

Run a stateful prediction asynchronously.

### Making state

[`makeState()`](/documentation/CoreML/MLModel/makeState())

Creates a new state object.

[`newState`](/documentation/CoreML/MLModel/newState)

Creates a new state object.

### Inspecting a model

[`availableComputeDevices`](/documentation/CoreML/MLModel/availableComputeDevices-6klyt)

The list of available compute devices that the model’s prediction methods use.

[`availableComputeDevices`](/documentation/CoreML/MLModel/availableComputeDevices-42uzt)

The list of available compute devices that the model’s prediction can use.

[`configuration`](/documentation/CoreML/MLModel/configuration)

The configuration of the model set during initialization.

[`modelDescription`](/documentation/CoreML/MLModel/modelDescription)

Model information you use at runtime during development, which Xcode also displays in its Core ML model editor view.

[`MLModelDescription`](/documentation/CoreML/MLModelDescription)

Information about a model, primarily the input and output format for each feature the model expects, and optional metadata.

[`parameterValue(for:)`](/documentation/CoreML/MLModel/parameterValue(for:))

Returns a model parameter value for a key.

[`MLParameterKey`](/documentation/CoreML/MLParameterKey)

The keys for the parameter dictionary in a model configuration or a model update context.

### Supporting types

[`MLModelConfiguration`](/documentation/CoreML/MLModelConfiguration)

The settings for creating or updating a machine learning model.

[`MLOptimizationHints`](/documentation/CoreML/MLOptimizationHints-swift.struct)

[`MLKey`](/documentation/CoreML/MLKey)

An abstract base class for machine learning key types.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)