hchiam / text-similarity-test

Get the similarity between sentences (using TensorFlow.js).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Text Similarity Test (using TensorFlow.js)

version

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).

Powered by a Universal Sentence Encoder TensorFlow.js model (U.S.E.).

If you find this project interesting, you might also like this project that goes beyond just U.S.E.: https://github.com/hchiam/comment-analysis

Try it in your browser

https://codepen.io/hchiam/pen/oNjzQRa

Try it from your own computer

open index.html or yarn start or npm start

You can run useModelToEmbedAllSentences from CLI with node tfjs-stuff.js

Import it into your own project

<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/universal-sentence-encoder"></script>
<script src="https://cdn.jsdelivr.net/gh/hchiam/text-similarity-test@1.1.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

Another example

https://codepen.io/hchiam/pen/abJGGox

https://github.com/hchiam/text-similarity-test/blob/master/summary-test.html

More things I'm testing

(See the coglangtext sub-folder.)

Useful references used

Related repos

https://github.com/hchiam/learning-tensorflow

https://github.com/hchiam/text-similarity-test-microservice

https://github.com/hchiam/learning-annoy

Future/Experimental

https://github.com/hchiam/learning-gpt4all

Text Sentiment Analysis Classification and Scoring (using @tensorflow/tfjs): https://codepen.io/hchiam/full/bGQWdmV

Other repos you might find interesting

https://github.com/hchiam/comment-analysis

https://github.com/hchiam/learning-tfjs-umap

About

Get the similarity between sentences (using TensorFlow.js).

License:MIT License


Languages

Language:JavaScript 57.1%Language:HTML 30.1%Language:Jupyter Notebook 9.1%Language:Python 3.3%Language:CSS 0.4%