Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

correct return type for encoding #1119

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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