Add support for Transformers and TikToken #4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request includes significant updates to the
chonkie
library, focusing on enhancing tokenizer support and improving chunker initialization. The most important changes include adding support for multiple tokenizer backends, updating chunker classes to use a unified initialization method, and adding new tests for these changes.Enhancements to tokenizer support:
src/chonkie/chunker/base.py
: Added support for multiple tokenizer backends (transformers
,tokenizers
,tiktoken
) and methods for encoding text and batches of text.README.md
: Updated the example to include importing and initializing different tokenizers.Updates to chunker classes:
src/chonkie/chunker/semantic.py
: Modified theSemanticChunker
class to use the new unified initialization method and removed redundant tokenizer assignments. [1] [2] [3] [4]src/chonkie/chunker/sentence.py
: Updated theSentenceChunker
class to use the new initialization method and default values for chunk size and overlap. [1] [2] [3] [4]src/chonkie/chunker/token.py
: Refactored theTokenChunker
class to use the new initialization method and encoding functions. [1] [2] [3]src/chonkie/chunker/word.py
: Updated theWordChunker
class to use the new initialization method and encoding functions. [1] [2] [3] [4]Additional changes:
tests/chunker/test_token_chunker.py
: Added new tests for different tokenizer backends and updated existing tests to reflect changes in chunker initialization. [1] [2] [3] [4]pyproject.toml
: Updated development dependencies to includetransformers
andtiktoken
.