Repository navigation
Tokenizer ggcc - #38
Merged
Merged
Conversation
added 3 commits
June 30, 2023 04:47
Bugfixes Switch to GGCC format Bugfixes
cleanup on warnings
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This push addresses a serious difference in the tokenization, the one we used was the sentencepiece llama tokenizer. It is not able to tokenizer for Falcon, almost any long word was broken up (including special words) and international content was almost always complete garbage afterward.
This is a serious issue to model quality, so it had to go.
This is a large change, I've spent 20+ hours first reversing what BPE in GPT-2 regex mode really does, then reimplementing it in C++ without the use of regular expressions and unicode libraries. Could have used regexp but it felt wrong to add such a chunky slowness into it.
The whole task felt like reinventing the wheel while getting punched constantly.
So I made a slim unicode library to work with and identify unicode data, bpe-decoders and -encoders similar to the special GPT2-BPE ones, a lookahead parser that should perform identical to the GPT/Falcon regular expression:
's|'t|'re|'ve|'m|'ll|'d| ?\p{L}+| ?\p{N}+| ?[^\s\p{L}\p{N}]+|\s+(?!\S)|\s+.In addition I created a new magic and file version for Falcon ggllm.cpp called "GGCC" V0, there is no way around that now as the falcon tokenizer requires 65,000 merging sub-token pairs to operate.
The model loader supports two modes:
The json parser I wrote is absolute minimal, it expects the json pretty-print format from HF models.
Updating
By using the updated falcon quantizer you will convert the old model (best to start from 32 bit, 16 bit should be fine too) into a GGCC model (file version 10). You will need the falcon 40b tokenizer.json in the model directory.
https://huggingface.co/tiiuae/falcon-7b/blob/main/tokenizer.json
The new solution will need more tests, I am merging it anyway so this moves ahead.
I was not able to find any differences between this one and the transformers tokenizer, though given the scale of this addition there can be issues remaining, in worst case crashes. I ran the tokenizer on a couple random files and that worked fine.
Test input 1:
Result now (identical to transformers tokenization):
Handling of fine tuned custom special tokens:
Before:
New tokenizer: