<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreAI",
  "identifier" : "/documentation/CoreAI/AIModel",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Core AI"
    ],
    "preciseIdentifier" : "s:13CoreAIRuntime7AIModelV"
  },
  "title" : "AIModel"
}
-->

# AIModel

A specialized model for running inference on a device.

```
struct AIModel
```

## Overview

An `AIModel` represents a specialized `.aimodel` asset, optimized for the current
device’s hardware. You create one by loading the asset from disk:

```swift
let model = try await AIModel(contentsOf: modelURL)
```

Use [`functionDescriptor(for:)`](/documentation/CoreAI/AIModel/functionDescriptor(for:)) to inspect a function’s inputs and outputs,
then load an [`InferenceFunction`](/documentation/CoreAI/InferenceFunction) to run inference.

> Note: The model instance is lightweight and doesn’t own weights or intermediate
> buffers. Those resources belong to the functions you load from it.

## Topics

### Creating a model

[`init(contentsOf:options:)`](/documentation/CoreAI/AIModel/init(contentsOf:options:))

Creates an [`AIModel`](/documentation/CoreAI/AIModel) from a `.aimodel`or `.aimodelc` file.

[`init(resolvingBookmark:)`](/documentation/CoreAI/AIModel/init(resolvingBookmark:))

Create an `AIModel`  by resolving bookmark data pointing to its specialized asset in a cache

### Loading inference functions

[`loadFunction(named:)`](/documentation/CoreAI/AIModel/loadFunction(named:))

[`functionDescriptor(for:)`](/documentation/CoreAI/AIModel/functionDescriptor(for:))

Returns a descriptor for the specified function.

[`functionNames`](/documentation/CoreAI/AIModel/functionNames)

The names of the inference functions in this model.

### Specializing a model

[`specialize(contentsOf:options:cache:cachePolicy:)`](/documentation/CoreAI/AIModel/specialize(contentsOf:options:cache:cachePolicy:))

Specializes a model for the current device.

### Inspecting a model

[`bookmarkData`](/documentation/CoreAI/AIModel/bookmarkData)

Create a bookmark for this AIModel’s cached specialized asset entry as serialized data.

[`deviceArchitectureName`](/documentation/CoreAI/AIModel/deviceArchitectureName)

The Core AI architecture name of the current device.



---

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)