Using Tensorflow Universal Sentence Encoder, I want to be able to find the percentage similarity (based on meaning) between two strings. Here is what I have got working so far:
require('@tensorflow/tfjs-node');
const tf = require('@tensorflow/tfjs')
const use = require('@tensorflow-models/universal-sentence-encoder');
(async() => {
const model = await use.load();
const embeddings = (await model.embed(["how old are you", "what is your age"])).unstack()
tf.losses.cosineDistance(embeddings[0], embeddings[1]).print()
})()
While this is a start, I am unsure how to find the percentage similarity (based on meaning) between two strings from this data.
By percentage similarity based on meaning, you would expect the following two strings to have a high percentage similarity: "what is your age" and "how are you". You would expect the following two strings to have a low percentage similarity based on meaning: "king" and "kind"
I am using Node JS.