Fun project that checks if you can come up with words that are as dissimilar as possible. (Implementation details at the bottom.)
Play it at https://romanoneg.github.io/WordGame/
Uses tensorflow.js to load tensorflow's Universal-Sentence-Encoder in order to create vector representations of each word (or multiple words) entered in the text boxes.
The library is imported with the following in index.html
:
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/universal-sentence-encoder"></script>
The model is then loaded in script.js
:
use.load().then(loadedModel => {
model = loadedModel;
};
And inference is done with:
// sentences is a vector of strings to be embedded
model.embed(sentences).then(embeddings => {
// calculating scores with embeddings
};
These