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

Ensure tokenizer sizers with truncation parameters count their overflow encodings #433

Merged
merged 2 commits into from
Oct 25, 2024

Conversation

Jeadie
Copy link
Contributor

@Jeadie Jeadie commented Oct 25, 2024

Bug fix

When determining the size of a chunk that would exceed a tokenizer's TruncationParams (when set, generally via a tokenizer.json's truncation key), it would ignore the Encoding::get_overflowing.

This PR fixes this issue by recursively computing the size of these overflows too.


Note: Not all Tokenizers have truncation, hence passing tests for Tokenizer::from_pretrained("bert-base-cased", None) (link).

  • thenlper/gte-small has truncation parameters, but they are too large to be causing issues in unit testing.

Copy link

codecov bot commented Oct 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.39%. Comparing base (f1f81e7) to head (424f395).
Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #433   +/-   ##
=======================================
  Coverage   99.38%   99.39%           
=======================================
  Files          11       11           
  Lines        1953     1974   +21     
=======================================
+ Hits         1941     1962   +21     
  Misses         12       12           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@benbrandt benbrandt force-pushed the jeadie/24-10-26/overflow branch from 9deb112 to 431041c Compare October 25, 2024 19:01
@benbrandt
Copy link
Owner

Thanks @Jeadie ! There is always more to learn about the tokenizers crate 😅

I'll work on getting this merged and released since I assume this bug is affecting you.

@benbrandt benbrandt merged commit 19f4305 into benbrandt:main Oct 25, 2024
22 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