---
title: MLModel
framework: coreml
role: symbol
role_heading: Class
path: coreml/mlmodel
---

# MLModel

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

## Declaration

```swift
class MLModel
```

## Mentioned in

Downloading and Compiling a Model on the User’s Device Encrypting a Model in Your App

## Overview

Overview MLModel encapsulates a model’s prediction methods, configuration, and model description. In most cases, you can use Core ML without accessing the 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). If your app needs the MLModel interface, use the wrapper class’s model property. With the MLModel interface, you can: Make a prediction with your app’s custom MLFeatureProvider by calling prediction(from:) or prediction(from:options:). Make multiple predictions with your app’s custom MLBatchProvider by calling predictions(fromBatch:) or predictions(from:options:). Inspect your model’s metadata and MLFeatureDescription instances through modelDescription. If your app downloads and compiles a model on the user’s device, you must use the MLModel class directly to make predictions. See Downloading and Compiling a Model on the User’s Device. important: Use an 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:)](coreml/mlmodel/load(contentsof:configuration:).md)
- [load(_:configuration:completionHandler:)](coreml/mlmodel/load(_:configuration:completionhandler:).md)
- [load(contentsOf:configuration:completionHandler:)](coreml/mlmodel/load(contentsof:configuration:completionhandler:).md)
- [init(contentsOf:)](coreml/mlmodel/init(contentsof:).md)
- [init(contentsOf:configuration:)](coreml/mlmodel/init(contentsof:configuration:).md)
- [init(contentsOfURL:)](coreml/mlmodel/init(contentsofurl:).md)
- [init(contentsOfURL:configuration:)](coreml/mlmodel/init(contentsofurl:configuration:).md)

### Compiling a model

- [compileModel(at:)](coreml/mlmodel/compilemodel(at:).md)
- [compileModel(at:completionHandler:)](coreml/mlmodel/compilemodel(at:completionhandler:).md)

### Making predictions

- [prediction(from:)](coreml/mlmodel/prediction(from:).md)
- [prediction(from:options:)](coreml/mlmodel/prediction(from:options:).md)
- [predictions(fromBatch:)](coreml/mlmodel/predictions(frombatch:).md)
- [predictions(from:options:)](coreml/mlmodel/predictions(from:options:).md)
- [prediction(from:using:)](coreml/mlmodel/prediction(from:using:).md)
- [prediction(from:using:options:)](coreml/mlmodel/prediction(from:using:options:).md)
- [MLPredictionOptions](coreml/mlpredictionoptions.md)

### Making state

- [makeState()](coreml/mlmodel/makestate().md)

### Inspecting a model

- [availableComputeDevices](coreml/mlmodel/availablecomputedevices-6klyt.md)
- [configuration](coreml/mlmodel/configuration.md)
- [modelDescription](coreml/mlmodel/modeldescription.md)
- [MLModelDescription](coreml/mlmodeldescription.md)
- [parameterValue(for:)](coreml/mlmodel/parametervalue(for:).md)
- [MLParameterKey](coreml/mlparameterkey.md)

### Supporting types

- [MLModelConfiguration](coreml/mlmodelconfiguration.md)
- [MLOptimizationHints](coreml/mloptimizationhints-swift.struct.md)
- [MLKey](coreml/mlkey.md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Core ML models

- [Getting a Core ML Model](coreml/getting-a-core-ml-model.md)
- [Updating a Model File to a Model Package](coreml/updating-a-model-file-to-a-model-package.md)
- [Integrating a Core ML Model into Your App](coreml/integrating-a-core-ml-model-into-your-app.md)
- [Model Customization](coreml/model-customization.md)
- [Model Personalization](coreml/model-personalization.md)
