A map of strings to vectors, which locates neighboring, similar strings.
- iOS 13.0+Beta
- macOS 10.15+Beta
- tvOS 13.0+Beta
- watchOS 6.0+Beta
- Mac Catalyst 13.0+Beta
- Natural Language
NLEmbedding to find similar strings based on the proximity of their vectors. The vocabulary is the entire set of strings in an embedding. Each string in the vocabulary has a vector, which is an array of doubles, and each double corresponds to a dimension in the embedding. An
NLEmbedding uses these vectors to determine the distance between two strings, or to find the nearest neighbors of a string in the vocabulary. The higher the similarity of any two strings, the smaller the distance is between them.
Natural Language provides built-in word embeddings that you can retrieve by using the
word method. You can also compile your own custom embedding into an efficient, searchable, on-disk representation. Typically, you compile an embedding by using Create ML’s
MLWord and save it as a file for your Xcode project at development time. Alternatively, you can compile an embedding at runtime by using Natural Language’s
Your custom embedding can use any kind of string that’s useful to your app, such as phrases, brand names, serial numbers, and so on. For example, you could make an embedding of movie titles. Each movie title could have a vector that places similar movies close together in the embedding.