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

How smart_batching_collate works? #1592

Closed
InhyeokYoo opened this issue Jun 12, 2022 · 4 comments
Closed

How smart_batching_collate works? #1592

InhyeokYoo opened this issue Jun 12, 2022 · 4 comments

Comments

@InhyeokYoo
Copy link

InhyeokYoo commented Jun 12, 2022

Hi.

I've read SBERT paper but there's one thing I can not understand.
In section 7 Computational Efficiency in the paper, SBERT uses 'smart batching' for computation efficiency by reducing computational overhead from padding.

For improved computation of sentence embeddings, we implemented a smart batching strategy: Sentences with similar lengths are grouped together and are only padded to the longest element in a mini-batch. This drastically reduces computational overhead from padding tokens.

However, the code doesn't use this sentences with similar lengths information.
It seems to me that the collate function just extract text and label from example, and then tokenize the texts and return.

Could please somebody let me know what am I missing?

@nreimers
Copy link
Member

Sentences are sorted by length in the encode method

@InhyeokYoo
Copy link
Author

InhyeokYoo commented Jun 12, 2022

@nreimers

Does it mean smart_batching_collate actually not the smart batching of the paper?

And one more question: why did you use it in encode method not also fit method?

@nreimers
Copy link
Member

Only in the encode. In the fit we what random shuffle

@InhyeokYoo
Copy link
Author

Thank you. Totally understood.

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

No branches or pull requests

2 participants