<!--
{
  "availability" : [
    "iOS: 14.0.0 - 17.4.0",
    "iPadOS: 14.0.0 - 17.4.0",
    "macCatalyst: 14.0.0 - 17.4.0",
    "macOS: 11.0.0 - 14.3.0",
    "tvOS: 14.0.0 - 17.4.0"
  ],
  "documentType" : "symbol",
  "framework" : "MLCompute",
  "identifier" : "/documentation/MLCompute/MLCMultiheadAttentionDescriptor",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "ML Compute"
    ],
    "preciseIdentifier" : "c:objc(cs)MLCMultiheadAttentionDescriptor"
  },
  "title" : "MLCMultiheadAttentionDescriptor"
}
-->

# MLCMultiheadAttentionDescriptor

A configuration object you use to create a multi-head attention layer.

```
class MLCMultiheadAttentionDescriptor
```

## Topics

### Creating Multi-Head Attention Descriptors

[`init(modelDimension:headCount:)`](/documentation/MLCompute/MLCMultiheadAttentionDescriptor/init(modelDimension:headCount:))

Creates a multi-head attention descriptor with the model dimension and number of parallel attention heads you specify.

[`init(modelDimension:keyDimension:valueDimension:headCount:dropout:hasBiases:hasAttentionBiases:addsZeroAttention:)`](/documentation/MLCompute/MLCMultiheadAttentionDescriptor/init(modelDimension:keyDimension:valueDimension:headCount:dropout:hasBiases:hasAttentionBiases:addsZeroAttention:))

Creates a multi-head attention descriptor with the dimensions, number of attention heads, dropout rate, and bias and padding options you specify.

### Inspecting Multi-Head Attention Descriptors

[`modelDimension`](/documentation/MLCompute/MLCMultiheadAttentionDescriptor/modelDimension)

The model or embedding dimension.

[`keyDimension`](/documentation/MLCompute/MLCMultiheadAttentionDescriptor/keyDimension)

The total dimension of key space, which must be divisible by the number of heads.

[`valueDimension`](/documentation/MLCompute/MLCMultiheadAttentionDescriptor/valueDimension)

The total dimension of value space, which must be divisible by the number of heads.

[`headCount`](/documentation/MLCompute/MLCMultiheadAttentionDescriptor/headCount)

The number of parallel attention heads.

[`dropout`](/documentation/MLCompute/MLCMultiheadAttentionDescriptor/dropout)

The dropout rate you apply to the output projection weights.

[`hasBiases`](/documentation/MLCompute/MLCMultiheadAttentionDescriptor/hasBiases)

A Boolean that specifies whether you add a bias to query, key, value, and output projections.

[`hasAttentionBiases`](/documentation/MLCompute/MLCMultiheadAttentionDescriptor/hasAttentionBiases)

A Boolean that specifies whether you add an array of biases to key and value, respectively.

[`addsZeroAttention`](/documentation/MLCompute/MLCMultiheadAttentionDescriptor/addsZeroAttention)

A Boolean that specifies whether you add a row of zeros to projected key and value.



---

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)