Add special token modification capability#7166
Merged
ggerganov merged 18 commits intoggml-org:masterfrom May 9, 2024
Merged
Conversation
To be able to fix/amend special tokens in a GGUF let's add two new arguments: * `--special-token <name> <value>` where `<name>` can be bos, eos, prefix, middle, etc. while `<value>` is the token value, f.ex. `"<|fim▁begin|>"` * `--special-token-by-id <name> <id>` where `<id>` is the ID of the token, f.ex. 32006 So, in order to f.ex. add fill-in-middle tokens to a GGUF you would do the following: ```bash python3 gguf-new-metadata.py input.gguf output.gguf --special-token prefix "<|fim▁begin|>" --special-token middle "<|fim▁hole|>" --special-token suffix "<|fim▁end|>" ```
To be able to fix/amend special tokens in a GGUF let's add two new arguments: * `--special-token <name> <value>` where `<name>` can be bos, eos, prefix, middle, etc. while `<value>` is the token value, f.ex. `"<|fim▁begin|>"` * `--special-token-by-id <name> <id>` where `<id>` is the ID of the token, f.ex. 32006 So, in order to f.ex. add fill-in-middle tokens to a GGUF you would do the following: ```bash gguf-new-metadata.py input.gguf output.gguf --special-token prefix "<|fim▁begin|>" --special-token middle "<|fim▁end|>" --special-token suffix "<|fim▁hole|>" ``` (yes, fim_end is the `middle` token, because completion is a `prefix`/`suffix`/`middle` sequence (where `middle` is unfilled)) or ```bash gguf-new-metadata.py input.gguf output.gguf --special-token prefix "<fim_prefix>" --special-token middle "<fim_middle>" --special-token suffix "<fim_suffix>" ``` etc... NB: The tokens have to exist already, trying to add non-existent token name/IDs will be ignored (with a warning), while non-existent values will fail (with an error).
…a.cpp into modify-special-tokens-metadata
Collaborator
Author
|
Messed up merge of #6778 so just a resubmission. |
Collaborator
Author
|
Uhm, not sure what's going on with the failed ios/tvos checks? |
ggerganov
approved these changes
May 9, 2024
Collaborator
Author
|
@ggerganov Ooops, was just making a minor tweak, nothing earthshattering. :) |
This was referenced May 29, 2024
Closed
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.
To be able to fix/amend special tokens in a GGUF let's add two new arguments:
--special-token <name> <value>where<name>can be bos, eos, prefix, middle, etc. while<value>is the token value, f.ex."<|fim▁begin|>"--special-token-by-id <name> <id>where<id>is the ID of the token, f.ex. 32006So, in order to f.ex. add fill-in-middle tokens to a GGUF you would do the following:
(yes, fim_end is the
middletoken, because completion is aprefix/suffix/middlesequence (wheremiddleis unfilled))or
etc...
NB: The tokens have to exist already, trying to add non-existent token name will be ignored (with a warning), while non-existent values will fail (with an error).