<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "NaturalLanguage",
  "identifier" : "/documentation/NaturalLanguage/NLContextualEmbedding/maximumSequenceLength",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Natural Language"
    ],
    "preciseIdentifier" : "c:objc(cs)NLContextualEmbedding(py)maximumSequenceLength"
  },
  "title" : "maximumSequenceLength"
}
-->

# maximumSequenceLength

The maximum number of tokens in sequence for which the embedding generates vectors.

```
var maximumSequenceLength: Int { get }
```

## Discussion> Note: The model operates on subword tokens rather than whole words. Each token may represent a single character, part of a word, or (less commonly) an entire word. Most words are split into multiple tokens, especially rare or complex terms. As a result, the number of tokens in a sequence is often greater than the number of words.

Inputs longer than the token limit will be truncated, and only the first `maximumSequenceLength`
tokens will be processed to generate embeddings.

`NLContextualEmbedding` works best with text snippets at the sentence or paragraph level.
The model truncates text that exceeds this maximum length and only processes the truncated portion of the input.

---

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)