Platforms to show: All Mac Windows Linux Cross-Platform
NLEmbeddingMBS class New in 26.2
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| class | Natural Language | MBS MacFrameworks Plugin | 26.2 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Use an 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 wordEmbeddingForLanguage: 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 MLWordEmbedding and save it as a file for your Xcode project at development time.
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.
This is an abstract class. You can't create an instance, but you can get one from various plugin functions.
- 5 properties
- property dimension as Integer
- property Handle as Integer
- property Language as String
- property revision as Integer
- property vocabularySize as Integer
- 8 methods
- method Constructor Private
- method containsString(Text as String) as Boolean
- method distanceBetweenString(firstString as String, secondString as String, distanceType as Integer = 0) as double
- method neighborsForString(text as String, maximumCount as Integer, maximumDistance as double = 0.0, distanceType as Integer = 0) as NLEmbeddingNeighborMBS()
- method neighborsForVector(vectorValues() as single, maximumCount as Integer, maximumDistance as double = 0.0, distanceType as Integer = 0) as NLEmbeddingNeighborMBS()
- method neighborStringsForString(text as String, maximumCount as Integer, maximumDistance as double = 0.0, distanceType as Integer = 0) as String()
- method neighborStringsForVector(vectorValues() as single, maximumCount as Integer, maximumDistance as double = 0.0, distanceType as Integer = 0) as String()
- method vectorForString(text as String) as Single()
- 9 shared methods
- shared method available as boolean
- shared method currentRevisionForLanguage(language as String) as Integer
- shared method currentSentenceEmbeddingRevisionForLanguage(language as String) as Integer
- shared method embeddingWithContents(File as FolderItem, byref error as NSErrorMBS) as NLEmbeddingMBS
- shared method embeddingWithContents(Path as String, byref error as NSErrorMBS) as NLEmbeddingMBS
- shared method sentenceEmbeddingForLanguage(language as String, Revision as Integer = -1) as NLEmbeddingMBS
- shared method supportedRevisionsForLanguage(language as String) as NSIndexSetMBS
- shared method supportedSentenceEmbeddingRevisionsForLanguage(language as String) as NSIndexSetMBS
- shared method wordEmbeddingForLanguage(language as String, Revision as Integer = -1) as NLEmbeddingMBS
Constants
| Constant | Value | Description |
|---|---|---|
| NLDistanceTypeCosine | 0 |
The means of calculating a distance between two locations in a text embedding.
The meaning of an distance is directly related to the NLDistanceType you use when you call a method that uses it. For example, if you use the neighborsForString method and use NLDistanceTypeCosine for the distanceType parameter, the method calculates the cosine distance and returns it as an NLDistance. |
This class has no sub classes.
Blog Entries
Release notes
- Version 26.2
- Added NLEmbeddingMBS and NLEmbeddingNeighborMBS classes.
Some related classes:
The items on this page are in the following plugins: MBS MacFrameworks Plugin.
NLContextualEmbeddingResultVectorMBS - NLEmbeddingNeighborMBS