<!--
{
  "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/NLContextualEmbeddingResult",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Natural Language"
    ],
    "preciseIdentifier" : "c:objc(cs)NLContextualEmbeddingResult"
  },
  "title" : "NLContextualEmbeddingResult"
}
-->

# NLContextualEmbeddingResult

An object that represents the embedding vector result from applying a contextual embedding to a string.

```
class NLContextualEmbeddingResult
```

## Overview

This object returns embeddings at the subword level, meaning a single word may generate multiple vectors, especially for rare or complex terms. If you need
to work with whole-word embeddings or create single representations for entire
text inputs, pool or combine subword vectors.

## Topics

### Inspecting the result

[`language`](/documentation/NaturalLanguage/NLContextualEmbeddingResult/language)

The language that the framework identified or used when processing the input string.

[`sequenceLength`](/documentation/NaturalLanguage/NLContextualEmbeddingResult/sequenceLength)

The number of embedding vectors the request generates.

[`string`](/documentation/NaturalLanguage/NLContextualEmbeddingResult/string)

A copy of the input string used to generate the embedding vectors.

### Enumerating the vectors

[`enumerateTokenVectors(in:using:)`](/documentation/NaturalLanguage/NLContextualEmbeddingResult/enumerateTokenVectors(in:using:))

Iterates over the embedding vectors corresponding to the subword tokens within the specified range of the input string.

[`tokenVector(at:)`](/documentation/NaturalLanguage/NLContextualEmbeddingResult/tokenVector(at:))

Gets a token vector at the index you specify.

[`-  enumerateTokenVectorsInRange:usingBlock:`](/documentation/NaturalLanguage/NLContextualEmbeddingResult/enumerateTokenVectorsInRange:usingBlock:)

Iterates over the embedding vectors corresponding to the subword tokens within the specified range of the input string.

[`-  tokenVectorAtIndex:tokenRange:`](/documentation/NaturalLanguage/NLContextualEmbeddingResult/tokenVectorAtIndex:tokenRange:)

Returns a token vector at the specified character index.

## Relationships

### Conforms To

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`Equatable`](/documentation/Swift/Equatable)

[`Hashable`](/documentation/Swift/Hashable)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`CVarArg`](/documentation/Swift/CVarArg)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

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)