If you want to extract a sentence representation (for alignment) out of the encoder output, you should consider using a pooling layer to obtain the sentence vector: sentence-transformers/Pooling.py at ec76488000f94efdba911356b8924cc46db0c2ee · UKPLab/sentence-transformers · GitHub 9 you can refer to the pooling class by sentence-transformers.