-
Notifications
You must be signed in to change notification settings - Fork 67
count prompt tokens #366
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
count prompt tokens #366
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
980dafe
count prompt tokens, use tokenizer if needed
saiatmakuri fcbdca1
merge conflict
saiatmakuri b6ebaa3
docstrings
saiatmakuri b02ac14
fix tests and code cov
saiatmakuri e1e9efa
Merge branch 'main' into saiatmakuri/count-prompt-tokens
saiatmakuri 37be04a
add download files from s3 fn
saiatmakuri c3bcc98
use same helpers and add docstring
saiatmakuri 0d00465
change to namedtuple
saiatmakuri 5dab779
add s3 repo locations
saiatmakuri 1cc7381
fallback read from s3
saiatmakuri 45e3502
refactor tokenizer laod
saiatmakuri bd2bb73
edit tests
saiatmakuri 3e9123a
refactor _SUPPORTED_MODELS_BY_FRAMEWORK
saiatmakuri 1d12b73
updates for tests
saiatmakuri 04e078e
move to utils file
saiatmakuri 58c1fbf
move some fns over
saiatmakuri 0344a97
use lru cache
saiatmakuri 8d4ab8a
move model info
saiatmakuri e53394e
root to opt
saiatmakuri 7842ec1
add log and adjust integration test
saiatmakuri b610e13
Merge branch 'main' into saiatmakuri/count-prompt-tokens
saiatmakuri f5da2f9
refocus logs
saiatmakuri e13d65f
change empty string to optional
saiatmakuri 215f7ff
mock count tokens for unit tests
saiatmakuri ed168c9
change 1 mock
saiatmakuri a057792
add unit tests
saiatmakuri 1c32f0f
config change
saiatmakuri 37d4c21
comments pt 1
saiatmakuri c1d9f06
move internal logic to plugins file
saiatmakuri a4019e1
replace usage of utils file
saiatmakuri 3c1a4f5
rearrange test mock
saiatmakuri 5a672dd
only return prompt tokens count on last token in stream
saiatmakuri 8b3a5e9
fix mock
saiatmakuri 4bb2d15
reorganize imports
saiatmakuri 723c786
inject in external interfaces
saiatmakuri 2f821fb
make changes to tests
saiatmakuri 8001dbe
Merge branch 'main' into saiatmakuri/count-prompt-tokens
saiatmakuri e8ff055
fix tests
saiatmakuri 4922b65
adjust test
saiatmakuri 99d6dfb
oops test
saiatmakuri 6916978
add more tests
saiatmakuri fd94350
Merge branch 'main' into saiatmakuri/count-prompt-tokens
saiatmakuri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
model-engine/model_engine_server/domain/repositories/tokenizer_repository.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from abc import ABC, abstractmethod | ||
|
||
from transformers import AutoTokenizer | ||
|
||
|
||
class TokenizerRepository(ABC): | ||
@abstractmethod | ||
def load_tokenizer(self, model_name: str) -> AutoTokenizer: | ||
""" | ||
Loads a tokenizer from a model name. | ||
|
||
Args: | ||
model_name: The model name to load the tokenizer for. | ||
|
||
Returns: | ||
A tokenizer. | ||
""" | ||
pass |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.