<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "NaturalLanguage",
  "identifier" : "/documentation/NaturalLanguage/NLEmbedding/vector(for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Natural Language",
      "NaturalLanguage"
    ],
    "preciseIdentifier" : "s:So11NLEmbeddingC15NaturalLanguageE6vector3forSaySdGSgSS_tF"
  },
  "title" : "vector(for:)"
}
-->

# vector(for:)

Requests the vector for the given term.

```
@nonobjc func vector(for string: String) -> [Double]?
```

## Parameters

`string`

The term to find in the word embedding.

## Return Value

A vector represented as an array of doubles if present in the word embedding, otherwise `nil`.

## Discussion> Important: This method isn’t safe to call concurrently on a shared ``doc://com.apple.naturallanguage/documentation/NaturalLanguage/NLEmbedding`` instance. Calling it from multiple threads, queues, or tasks at the same time can corrupt the embedding’s state and crash your app. Serialize calls into a shared instance, or give each thread its own instance.

---

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)