<p>Not sure if you still need it but recently a paper mentioned how to use document embeddings to cluster documents and extract words from each cluster to represent a topic. Here's the link:
<a href="https://arxiv.org/pdf/2008.09470.pdf" rel="nofollow noreferrer">https://arxiv.org/pdf/2008.09470.pdf</a>, <a href="https://github.com/ddangelov/Top2Vec" rel="nofollow noreferrer">https://github.com/ddangelov/Top2Vec</a></p>
<p>Inspired by the above paper, another algorithm for topic modelling using BERT to generate sentence embeddings is mentioned here:
<a href="https://towardsdatascience.com/topic-modeling-with-bert-779f7db187e6" rel="nofollow noreferrer">https://towardsdatascience.com/topic-modeling-with-bert-779f7db187e6</a>, <a href="https://github.com/MaartenGr/BERTopic" rel="nofollow noreferrer">https://github.com/MaartenGr/BERTopic</a></p>
<p>The above two libraries provide an end-to-end solution to extract topics from a corpus. But if you're interested only in generating sentence embeddings, look at Gensim's doc2vec (<a href="https://radimrehurek.com/gensim/models/doc2vec.html" rel="nofollow noreferrer">https://radimrehurek.com/gensim/models/doc2vec.html</a>) or at sentence-transformers (<a href="https://github.com/UKPLab/sentence-transformers" rel="nofollow noreferrer">https://github.com/UKPLab/sentence-transformers</a>) as mentioned in the other answers. If you go with sentence-transformers, it is suggested that you train a model on you're domain specific corpus to get good results.</p>
How to cluster similar sentences using BERT
<p>For ElMo, FastText and Word2Vec, I'm averaging the word embeddings within a sentence and using HDBSCAN/KMeans clustering to group similar sentences.</p>

<p>A good example of the implementation can be seen in this short article: <a href="http://ai.intelligentonlinetools.com/ml/text-clustering-word-embedding-machine-learning/" rel="noreferrer">http://ai.intelligentonlinetools.com/ml/text-clustering-word-embedding-machine-learning/</a></p>

<p>I would like to do the same thing using BERT (using the BERT python package from hugging face), however I am rather unfamiliar with how to extract the raw word/sentence vectors in order to input them into a clustering algorithm. I know that BERT can output sentence representations - so how would I actually extract the raw vectors from a sentence?</p>

<p>Any information would be helpful.</p>