<!--
{
  "availability" : [
    "macOS: 10.15.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CreateML",
  "identifier" : "/documentation/CreateML/MLWordEmbedding/vector(for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Create ML",
      "CreateML"
    ],
    "preciseIdentifier" : "s:8CreateML15MLWordEmbeddingV6vector3forSaySdGSgSS_tF"
  },
  "title" : "vector(for:)"
}
-->

# vector(for:)

Accesses the vector associated with the given string in the vocabulary.

```
func vector(for text: String) -> [Double]?
```

## Parameters

`text`

A string in the vocabulary.

## Return Value

The vector associated with the string if present in the word embedding; otherwise, `nil`.

---

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)