FlagEmbedding
FlagEmbedding copied to clipboard
correct return type for encoding
The returning type was only np.ndarray, but it is possible to change the return type to torch.Tensor if we set convert_to_numpy to False. The origin version can lead to wordy and inefficient codes because people don't know that encode() can return Tensor. For example, the code in Tutorial uses encode() as follow:
which has to convert the tensor to np.ndarray and then convert it into Tensor.
This code can be changed into:
embeddings = model.encode([sentence_1, sentence_2, sentence_3], convert_to_numpy=False)
which is more effective.