TensorFlow.JS is a
Watch the following video (duration: 8 minutes) to learn more about TensorFlow.JS and some of its applications:
Since computers can only work with numbers, computer scientists working in the field of Natural Language Understanding (NLU) and Processing (NLP) are using several techniques to convert words or sentences into numbers.
Word embedding is one of the principal concepts in Natural Language Processing, where words from a vocabulary are converted to vectors of real numbers. These vector numbers have the amazing capacity to reflect the relationship between these words.
The Universal Sentence Encoder (USE) model encodes text into
embeddings (high-dimensional vectors) that can be used for
clustering and other natural language tasks.
To read more about
To find out the
semantic similarity of two sentences, we encode each sentence using the USE model and then compare the two vectors produced by the model by calculating their inner dot product.
TensorFlow provides two methods that we can use to calculate dot product of the two vectors:
tf.matMul( sentenceVector1.arraySync(), sentenceVector2.arraySync(), false, true );
tf.matMul( sentenceVector1, sentenceVector2, false, true );
You can get an idea of how the
tf.matMul operates on these two vectors by checking this Matrix Multiplication Calculator. The second matrix (red one) is the one transposed (rotated vertically) by setting the second argument of
matMul to true.
The Toxicity Classifier model can be used to detect offensive language in a text content.
You can read more about the Toxicity Classifier in the following Medium post:
Here is a live demo of a text editor that can detect offensive language using the Toxicity Classifier. Don’t forget to check the
Enable Toxicity Check checkbox to enable this feature. Here is the source code for the demo.
Watch this video to learn more about the application of dot product to find the similarity of two vectors and how it is applied in the real world