Platforms to show: All Mac Windows Linux Cross-Platform

Back to NLContextualEmbeddingResultVectorMBS class.

NLContextualEmbeddingResultVectorMBS.Constructor   Private

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Natural Language MBS MacFrameworks Plugin 26.2 ✅ Yes ❌ No ❌ No ✅ Yes All
The private constructor.

NLContextualEmbeddingResultVectorMBS.cosineSimilarity(other as NLContextualEmbeddingResultVectorMBS) as Double

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Natural Language MBS MacFrameworks Plugin 26.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Utility function to calculate the cosine similarity between two vectors.
Example
const lang = "en"
Var n As NLContextualEmbeddingMBS = NLContextualEmbeddingMBS.contextualEmbeddingWithLanguage(lang)

// we make vectors for two similar texts
var e as NSErrorMBS
var r1 as NLContextualEmbeddingResultMBS = n.embeddingResultForString("Hello World", lang, e)
Var r2 As NLContextualEmbeddingResultMBS = n.embeddingResultForString("Hallo World", lang, e)

Var average1 As NLContextualEmbeddingResultVectorMBS = r1.averageToken
Var average2 As NLContextualEmbeddingResultVectorMBS = r2.averageToken

Var compare As Double = average1.cosineSimilarity(average2)

MessageBox compare.ToString // 0.93

Returns 1 if equal or 0 if not.

NLContextualEmbeddingResultVectorMBS.values as Single()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Natural Language MBS MacFrameworks Plugin 26.2 ✅ Yes ❌ No ❌ No ✅ Yes All
The vector as array.

The items on this page are in the following plugins: MBS MacFrameworks Plugin.


The biggest plugin in space...