-
Notifications
You must be signed in to change notification settings - Fork 650
Added JS bindings for tokenizers library #13566
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
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/13566
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New FailureAs of commit 9a8993c with merge base bbc281f ( NEW FAILURE - The following job has failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
@@ -871,6 +871,10 @@ if(EXECUTORCH_BUILD_WASM) | |||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/wasm) | |||
endif() | |||
|
|||
if(EXECUTORCH_BUILD_TOKENIZERS_WASM) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we have too many cmake options lmao.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know you've tested this in the demo repo and the tokenizer unit tests are a bit of a pain to set up because they are a submodule.
|
||
EMSCRIPTEN_BINDINGS(TokenizerModule) { | ||
#define JS_BIND_TOKENIZER(NAME) \ | ||
class_<JsTokenizer<NAME>>(#NAME) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you measure the codesize of this lib. I'm curious how bad it is having to individually bind each template instantiation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
102K js, 1.4M wasm
Changing JsTokenizer to not be a template and only need to bind one class reduces the js to 101K.
Removing everything except SentencePiece leaves it with 99K js, 807K wasm so it seems like most of the codesize comes from including each of the different types of tokenizer.
What are the pros-and-cons between putting here vs https://github.com/meta-pytorch/tokenizers library directly? |
Pros:
Cons:
|
I have strong preference to have all the wasm code colocated right now since its in a more exploratory phase of development. |
Summary
Added JavaScript bindings for the tokenizer library so that we can use them to run LLMs in a web browser.
Test plan
I will add end to end tests later.