Merged
Conversation
…y other models too).
Contributor
|
Oh shit.. is this why this was happening to me? I too observed it in some models and not others and resorted to running in verbose to double check. The BOS being missing made me think verbose wasn't outputting the entire prompt when enabled. When I would manually add the BOS token, often times it would get removed by the code above your PR. |
Owner
|
That's a very important fix, thank you. |
Contributor
|
This breaks everything in some situations (eg. using alfred-40B-1023-GGUF with llamacpp_HF), checkbox on or off, doesn't matter. I'm sure it's something small... |
1 task
Contributor
Author
|
Thanks for reporting @TheLounger ! Based on your error log it seems that there are situations where bos_token_id exists but is None? I added a quick fix here: #6061 |
PoetOnTheRun
pushed a commit
to PoetOnTheRun/text-generation-webui
that referenced
this pull request
Oct 22, 2024
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.
Expected behavior
When the UI checkbox to add bos token is checked, user expects bos token to be added.
Actual behavior
When the UI checkbox to add bos token is checked, some models add bos token, but some models don't add bos token. The (mis)configuration of the tokenizer config file affects whether bos token gets added or not.
Scope
Affects both UI users and API users (in API case tested with API parameter to add bos token rather than UI checkbox).
Affects at least model loaders which use huggingface transformers tokenizer (e.g. ExllamaV2_HF).
I checked various models I had on disk, and about half of Llama 3 models from my disk were affected by this issue. I also tried some Lllama 2 models, none of them were affected.
A few examples of affected models:
I don't know if it makes a difference, but I didn't use the downloader script to download models, I manually downloaded them.
Cause
My understanding is that Meta distributed some misconfigured tokenizer.json files and silently updated them later. Copies of the misconfigured tokenizer.json files are now circulating amongst fine tuners and quantizers.
How are the tokenizer.json files misconfigured? They have the bos token defined in some places, but not in all the places where it's needed. I don't really know what these files are supposed to contain. I looked at one llama 3 tokenizer file which appeared to be working correctly, and I found that it had this definition, which was missing from the misconfigured tokenizer files:
The way bos token is implemented in TGW is that the transformers tokenizer is called with
add_special_tokens=True, so if the bos token is not defined in special_tokens, it won't be added.Do we need a fix in TGW if it's a model issue?
We need a fix in TGW because we have UI checkbox and API parameter that set user expectations.
Also, many models quality is severely degraded in TGW if it's not fixed (even if it's technically somebody else's fault).
How to fix this
After transformers tokenizer encode, we check that the bos token is added and manually add it if it is not.
Checklist: