<!--
{
  "availability" : [
    "iOS: 14.0.0 - 18.0.0",
    "iPadOS: 14.0.0 - 18.0.0",
    "macCatalyst: 14.0.0 - 18.0.0",
    "macOS: 11.0.0 - 15.0.0",
    "tvOS: 14.0.0 - 18.0.0",
    "visionOS: 1.0.0 - 2.0.0",
    "watchOS: 7.0.0 - 11.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "Accelerate",
  "identifier" : "/documentation/Accelerate/BNNSLayerParametersMultiheadAttention/init(query:key:value:add_zero_attn:key_attn_bias:value_attn_bias:output:dropout:seed:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "s:So37BNNSLayerParametersMultiheadAttentiona5query3key5value13add_zero_attn0f1_J5_bias0g1_j1_K06output7dropout4seedABSo017BNNSMHAProjectionB0a_A2MSbSo21BNNSNDArrayDescriptoraAoMSfs6UInt32Vtcfc"
  },
  "title" : "init(query:key:value:add_zero_attn:key_attn_bias:value_attn_bias:output:dropout:seed:)"
}
-->

# init(query:key:value:add_zero_attn:key_attn_bias:value_attn_bias:output:dropout:seed:)

Returns a new multihead attention layer parameters structure from the specified parameters.

```
init(query: BNNSMHAProjectionParameters, key: BNNSMHAProjectionParameters, value: BNNSMHAProjectionParameters, add_zero_attn: Bool, key_attn_bias: BNNSNDArrayDescriptor, value_attn_bias: BNNSNDArrayDescriptor, output: BNNSMHAProjectionParameters, dropout: Float, seed: UInt32)
```

## Parameters

`query`

A projection parameter structure that describes the query-related input parameters and projection.

`key`

A projection parameter structure that describes the key-related input parameters and projection.

`value`

A projection parameter structure that describes the value-related input parameters and projection.

`add_zero_attn`

A Boolean value that, if true, adds a row of zeroes to the projected *K* and *V* inputs to the calculation.

`key_attn_bias`

A 2D tensor that’s added to the key as part of the attention calculation.

`value_attn_bias`

A 2D tensor that’s added to the value as part of the attention calculation.

`output`

A projection parameter structure that describes the output tensor and associated projection.

`dropout`

The probability that the layer drops out an element.

`seed`

The seed for the dropout layer’s random number generator.

---

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)