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

Sort samples by length in TextToEmbeddingModelPipeline #40

Open
avidale opened this issue Sep 17, 2024 · 0 comments
Open

Sort samples by length in TextToEmbeddingModelPipeline #40

avidale opened this issue Sep 17, 2024 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@avidale
Copy link
Contributor

avidale commented Sep 17, 2024

When encoding texts, currently, the pipeline (https://github.com/facebookresearch/SONAR/blob/main/sonar/inference_pipelines/text.py#L169) reads them in the provided order, groups them into batches, and collates each batch by padding each text in the batch to have the same length as the longest text in this batch. This sometimes produces batches where most tokens are just pad tokens, so the computation is wasted for them.

To avoid this waste and speed up the pipeline, we could sort the text by length before batching them.

@avidale avidale added enhancement New feature or request good first issue Good for newcomers labels Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant