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

Calling tokenizer.encode('toString') errors due to bpe function #17

Open
jihan-yin opened this issue Feb 21, 2023 · 2 comments
Open

Calling tokenizer.encode('toString') errors due to bpe function #17

jihan-yin opened this issue Feb 21, 2023 · 2 comments

Comments

@jihan-yin
Copy link

const tokenizer = new GPT3Tokenizer({ type: 'gpt3' });
tokenizer.encode('toString')

will fail. This is because tokenizer.bpe('toString') returns the javascript function toString() instead of an actual string representing the token.

@jihan-yin
Copy link
Author

This is because tokenizer.cache['toString'] = {function toString()}. Not sure how this is happening

@jihan-yin
Copy link
Author

Currently resolving by adding

// @ts-ignore
tokenizer.cache['toString'] = 'toString';

The bpe still returns the javascript native function instead of token ids though, as tokenizer.encodings['toString'] is set to the function for some reason

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

No branches or pull requests

1 participant