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

[Fix] Add fix for #92: Support class.method as a Tokenizer for CustomEmbedding +. minor changes #128

Merged
merged 9 commits into from
Jan 2, 2025

Conversation

bhavnicksm
Copy link
Collaborator

This pull request includes several updates and improvements to the chonkie project, focusing on enhancing tokenizer handling, updating documentation, and adding new test cases. Below are the most important changes:

Enhancements to Tokenizer Handling:

  • src/chonkie/chunker/base.py: Improved the _get_tokenizer_backend, _get_tokenizer_counter, _encode, _encode_batch, _decode, and _decode_batch methods to support callable tokenizer backends. [1] [2] [3] [4] [5] [6]
  • Removed unnecessary handling of function-based tokenizers in the __init__ method.

Documentation Updates:

Test Cases:

  • Added a comprehensive test suite for the CustomEmbeddings class in tests/embeddings/test_custom_embeddings.py.

Code Cleanup:

  • Removed unused imports and reordered imports for better readability in several files. [1] [2] [3] [4] [5]

Workflow Update:

bhavnicksm and others added 9 commits December 31, 2024 22:45
Hyperlink good first issue
- Removed abstractmethod decorators from `embed_batch`, `count_tokens_batch`, and `similarity` methods in the BaseEmbeddings class.
- Updated the `similarity` method to ensure it returns a float.
- Introduced a new CustomEmbeddings class implementing the abstract methods with functionality for embedding, token counting, and similarity calculation.
- Added comprehensive unit tests for the CustomEmbeddings class, covering initialization, embedding single and batch texts, token counting, and similarity calculation.

These changes enhance the flexibility and test coverage of the embeddings functionality.
[FIX]  Support class methods as `token_counter` objects for `CustomEmbeddings` (#92)
@bhavnicksm bhavnicksm merged commit 21d0376 into main Jan 2, 2025
6 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.

2 participants