Take a look at the HuggingFace “transformers” repo.

  
      
      GitHub
  
  
    

huggingface/transformers 49

🤗 Transformers: State-of-the-art Natural Language Processing for TensorFlow 2.0 and PyTorch. - huggingface/transformers


  
  
    
    
  
  


This can download the pretrained Bert embeddings of your choice, and gives you a pretty straightforward interface for tokenization and extracting embeddings.
The rough outline of your code will look like this:

image1690×883 199 KB