This code snippet is using TensorFlow2.0, some of the code might not be compatible with earlier versions, make sure
to update TF2.0 before executing the code.
embeddings in machine learning are used to represent text with embedding vectors. TensorFlow hub module
provides several pre trained text-embeddings models to convert sentence into embedding vectors.
In this code we will use pre trained token based embedding "https://tfhub.dev/google/tf2-preview/gnews-swivel-20dim/1"
that is trained on English Google News 130GB corpus, it provides embedding vector output with 20 dimensions.
TensorFlow hub module is required for using pre-trained models, install it with below command.