Repository navigation
Pass the loaded model's EOS token to Jinja chat templates - #2665
Merged
LostRuins merged 1 commit intoNov 23, 2026
Merged
Conversation
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.
Fixes #2644.
KoboldCpp passed an empty
eos_tokento Jinja even when the model vocabulary defined one. Templates such as Mistral Instruct v0.3 useeos_tokento close prior assistant turns, so the generated prompt joined the assistant reply directly to the next turn.The native model adapter now reads the loaded GGUF vocabulary's EOS token and exposes its text, including special tokens. Python caches that text at model load and supplies it to both Jinja rendering paths. Older native libraries and model formats that do not expose EOS text keep the existing empty fallback.
Local verification
</s>. The cases cover templates invoked with and without tools.python -m unittest discover -s tests -p 'test_*.py' -vpassed all 11 tests after the fix.make -j20 koboldcpp_defaultpassed and produced a library that exportsget_eos_token_text.--jinja --debugmode 1and a locally generated one-layer Mistral GGUF using the Mistral-7B-Instruct-v0.3 tokenizer and chat template. A user–assistant–user request to/v1/chat/completionsreturned HTTP 200 with 16 prompt tokens and one completion token. The vocabulary log reported EOS token 2 as</s>, and the tokenization log showed[INST] First question[/INST] First answer</s>[INST] Follow-up[/INST]. This checks the chat prompt path with synthetic model weights.git diff --checkpassed.