Skip to content

Conversation

@dream-tentacle
Copy link

@dream-tentacle dream-tentacle commented Sep 23, 2024

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:
image

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant