Sentence/document encoding

I have used the text language model and text classifier to great success on my dataset. I was wondering what the steps would be to use my language model to generate an encoding / vector from a document instead of a class prediction? (e.g. like Doc2Vec or BERT sentence encodings

Has anyone tried something like this?