Recognize IBM Granite 3.3 FIM tokens. Makes llama-server /infill usable. #12988
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.
The model in question is, freshly released by IBM: https://huggingface.co/ibm-granite/granite-3.3-8b-base
The Granite 3.3's FIM tokens are very similar to Qwen's; it's just that they use underscore instead of a dash. So
<fim_middle>
for example instead of<fim-middle>
.Opening up tokenizer_config.json in ibm-granite/granite-3.3-8b-base shows (https://huggingface.co/ibm-granite/granite-3.3-8b-base/blob/main/tokenizer_config.json)
Tested with granite-3 I converted to
.gguf
s. I noticed the llama.cpp code completion vim extension didn't work with the llama-server, so I checked out if tokens were missing, added them, tested them, filed this PR.I could not find an equivalent for file separator token, but I mapped the 5 tokens I found that had clear llama.cpp equivalents.
Testing:
Checked tokenization (i.e. does llama.cpp tokenize them all to single tokens):
Also saw:

And empirically tried in coding with the extension:
code_example_granite.mp4
(I thought it would offer printf() instead...C++ bias? 😉 ) I love that extension.