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

Add a way to count tokens without encoding the whole text; improve performance; fix bugs #38

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

niieani
Copy link

@niieani niieani commented Apr 15, 2023

  • adds highly performant isWithinTokenLimit to count tokens without encoding the whole text
  • improve overall performance by removing transitive arrays
  • include precomputed bpeRanks
  • add type-checking
  • fix a few minor bugs (thanks to type-checking)
  • add generator versions of both decoder and encoder
  • adds prettier and prettifies the codebase

To test, see fork published as gpt-tokenizer.

niieani added 2 commits April 15, 2023 13:31
- adds highly performant `isWithinTokenLimit` to count tokens without encoding the whole text
- improve overall performance by removing transitive arrays
- include precomputed `bpeRanks`
- add type-checking
- fix a few minor bugs (thanks to type-checking)
- add generator versions of both decoder and encoder
@niieani niieani changed the title feat: add a way to count tokens without encoding the whole text Add a way to count tokens without encoding the whole text; improve performance; fix bugs Apr 15, 2023
requires providing an additional argument with cache if you want to make it shared

fixes #35
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