To clarify, the above code just returns the final hidden state of each token and not whole sentence embedding.
for sentence embedding you can try sentence-bert.
https://huggingface.co/sentence-transformers
1 Like