Skip to content

Commit

Permalink
Fix GGUFs with no BOS token present, mainly qwen2 models. (oobabooga#…
Browse files Browse the repository at this point in the history
…6119)


---------

Co-authored-by: oobabooga <[email protected]>
  • Loading branch information
2 people authored and PoetOnTheRun committed Oct 22, 2024
1 parent 4f80cca commit 8efb9f8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion modules/models_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ def get_model_metadata(model):
if 'tokenizer.chat_template' in metadata:
template = metadata['tokenizer.chat_template']
eos_token = metadata['tokenizer.ggml.tokens'][metadata['tokenizer.ggml.eos_token_id']]
bos_token = metadata['tokenizer.ggml.tokens'][metadata['tokenizer.ggml.bos_token_id']]
if 'tokenizer.ggml.bos_token_id' in metadata:
bos_token = metadata['tokenizer.ggml.tokens'][metadata['tokenizer.ggml.bos_token_id']]
else:
bos_token = ""

template = template.replace('eos_token', "'{}'".format(eos_token))
template = template.replace('bos_token', "'{}'".format(bos_token))

Expand Down

0 comments on commit 8efb9f8

Please sign in to comment.