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

BPETokenizer splits grapheme clusters rather than code points -- crashes in Gemma merges #51

Closed
davidkoski opened this issue Feb 26, 2024 · 2 comments

Comments

@davidkoski
Copy link
Contributor

The BPETokenizer currently has code like this:

            let tuple = item.split(separator: " ").map { String($0) }

That doesn't split some merges correctly, e.g. in Gemma it has ▁ह ै. In swift the split() on String splits on grapheme clusters, not code points. As-is, this will crash on the Gemma merges.

I think you want to use:

String.UnicodeScalarView.split(separator:)

to perform this split on the code points instead.

@pcuenca
Copy link
Member

pcuenca commented Feb 28, 2024

Thanks @davidkoski, I think you are right! I'll fix this issue and then work on #42, it's becoming high priority!

@pcuenca
Copy link
Member

pcuenca commented Feb 29, 2024

Fixed in #52, thanks again for reporting!

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

2 participants