Skip to content

add custom tokenizer #1396

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

Merged
merged 6 commits into from
Apr 20, 2025
Merged

Conversation

drahnreb
Copy link
Contributor

@drahnreb drahnreb commented Apr 17, 2025

Description

Regardless of selected model, tiktoken was always used to do the tokenization. This PR removes this dependency and adds the ability to replace tiktoken with a custom tokenizer.

Related Issues

None

Changes Made

  • Add tokenizer parameter to replace default tiktoken encoding/decoding.
  • Added Tokenizer and a default TiktokenTokenizer in utils.
  • Kept tiktoken_model_name parameter for backwards compatibility.
  • Updated Readme.
  • Added example for google/gemma based GemmaTokenizer.

Checklist

  • Changes tested locally
  • Code reviewed
  • Documentation updated (if necessary)

@drahnreb drahnreb force-pushed the drahnreb/add-custom-tokenizer branch from 3ff9dee to 968ad00 Compare April 18, 2025 14:16
@drahnreb drahnreb force-pushed the drahnreb/add-custom-tokenizer branch from 968ad00 to de827ab Compare April 18, 2025 14:33
@drahnreb
Copy link
Contributor Author

@danielaskdd Fixed linting and rebased. Please review. Kindly let me know if changes are needed.

@danielaskdd danielaskdd merged commit 48e49fb into HKUDS:main Apr 20, 2025
1 check passed
@danielaskdd
Copy link
Collaborator

Thanks for sharing. There some issues in the PR which I already fix it after merge:

  • tokenizer does not add to global_config for default setting: cd01ec6
  • We use num_fragment instead of summary_max_tokens to determine where LLM summarization is need now: 4ae5246

@drahnreb drahnreb deleted the drahnreb/add-custom-tokenizer branch April 20, 2025 08:33
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.

2 participants