<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.1.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Speech",
  "identifier" : "/documentation/Speech/SFCustomLanguageModelData/TemplateInsertableBuilder",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Speech"
    ],
    "preciseIdentifier" : "s:6Speech25SFCustomLanguageModelDataC25TemplateInsertableBuilderV"
  },
  "title" : "SFCustomLanguageModelData.TemplateInsertableBuilder"
}
-->

# SFCustomLanguageModelData.TemplateInsertableBuilder

A custom parameter attribute that constructs custom language model data from closures.

```
@resultBuilder struct TemplateInsertableBuilder
```

## Overview

Phrase counts can be generated manually by providing an exact phrase and weight (e.g. “Play the Albin counter gambit”) or
from templates (e.g. “Move my <piece> to <square>”). Templates themselves can be constructed manually, or using
the result builder DSL. This type supports the latter.

## Topics

### Result builder methods

[`static func buildArray([any TemplateInsertable]) -> any TemplateInsertable`](/documentation/Speech/SFCustomLanguageModelData/TemplateInsertableBuilder/buildArray(_:))

Enables support for `for..in` loops.

[`static func buildBlock(any TemplateInsertable...) -> any TemplateInsertable`](/documentation/Speech/SFCustomLanguageModelData/TemplateInsertableBuilder/buildBlock(_:))

Combines statement blocks into a single product.

[`static func buildEither(first: any TemplateInsertable) -> any TemplateInsertable`](/documentation/Speech/SFCustomLanguageModelData/TemplateInsertableBuilder/buildEither(first:))

Enables support for `if-else` and `switch` constructs.

[`static func buildEither(second: any TemplateInsertable) -> any TemplateInsertable`](/documentation/Speech/SFCustomLanguageModelData/TemplateInsertableBuilder/buildEither(second:))

Enables support for `if-else` and `switch` constructs.

[`static func buildOptional((any TemplateInsertable)?) -> any TemplateInsertable`](/documentation/Speech/SFCustomLanguageModelData/TemplateInsertableBuilder/buildOptional(_:))

Enables support for `if` statements that do not have an `else` clause.



---

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)