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

Enable using kwargs for selecting pad-to-max-length strategy for tokenizer in embeddings #393

Merged
merged 2 commits into from
Oct 16, 2024

Conversation

kcirred
Copy link
Contributor

@kcirred kcirred commented Oct 8, 2024

Allows users to pass tokenizer keyword argument to select the tokenizer settings desired. In this case, enabling for pad_to_max_length.

Copy link
Contributor

@gabe-l-hart gabe-l-hart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! I'm going to defer full review to @gkumbhat, but there's one little formatting NIT I noticed when glancing through it.

caikit_nlp/modules/text_embedding/embedding.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@gkumbhat gkumbhat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution.

Looks like DCO is failing on this PR. Can you do a --signoff and push again?

@kcirred
Copy link
Contributor Author

kcirred commented Oct 8, 2024

@gkumbhat I also wrote a unit test so let me push that as well.

I suspect the def sum_token_count in embeddings.py is doing what is intended. By counting sum(encoding.attention_mask) the 0s will be dropped.

In my test case, I originally wanted to show that the results stays the same but there will be a change to the tokenizer input_ids and attention_mask shape. I will not use input_token_count which comes from sum_token_count as they will come out to be the same despite the change in attention_mask. For now I only test that the change in tokenizer option in our use case does not change the final result.

Copy link
Collaborator

@gkumbhat gkumbhat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Thanks for making updates

Copy link
Collaborator

@gkumbhat gkumbhat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

Copy link
Contributor

@gabe-l-hart gabe-l-hart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@gkumbhat gkumbhat merged commit 0219d50 into caikit:main Oct 16, 2024
5 checks passed
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.

3 participants