Text Similarity Test (using TensorFlow.js)
It outputs a percent similarity between two sentences.
This tool could possibly be used to check whether a free-form answer closely matches the expected answer in meaning. For best results, you probably should constrain responses to short sentences (i.e. short answer questions only).
https://codepen.io/hchiam/pen/oNjzQRa
open index.html or yarn start or npm start
You can run useModelToEmbedAllSentences from CLI with node tfjs-stuff.js
<script src="https://cdn.jsdelivr.net/gh/hchiam/text-similarity-test@1.0.0/tfjs-stuff.js"></script>var sentence1 = "Hello there!";
var sentence2 = "Hi, nice to see you!";
function callback(similarityScore) {
alert(Math.round(similarityScore * 100 * 100) / 100 + "%");
}
useModel(sentence1, sentence2, callback); // useModel comes from tfjs-stuff.js(See the coglangtext sub-folder.)
- https://github.com/tensorflow/tfjs-models/tree/master/universal-sentence-encoder
- https://towardsdatascience.com/how-to-build-a-textual-similarity-analysis-web-app-aa3139d4fb71
- https://github.com/jinglescode/demos/tree/master/src/app/components/nlp-sentence-encoder
- https://towardsdatascience.com/how-to-measure-distances-in-machine-learning-13a396aa34ce
- https://en.wikipedia.org/wiki/Cosine_similarity