ggml-org/llama.cpp

Include `eos_token` and `bos_token` from `tokenizer_config.json` for chat templating

Open

#5,040 建立於 2024年1月19日

在 GitHub 查看
 (12 留言) (4 反應) (0 負責人)C++ (18,202 fork)batch import
enhancementhelp wanted

倉庫指標

Star
 (110,169 star)
PR 合併指標
 (平均合併 6天 8小時) (30 天內合併 389 個 PR)

描述

Feature Description

Include (at minimum) eos_token and bos_token keys the huggingface tokenizer_config.json as gguf metadata keys.

Motivation

For chat models these differ from the normal eos and bos tokens and are required to stop the model generating user message tokens.

For example to correctly stop generation of chatml chat models you need to watch for the <|im_end|> token specified in the tokenizer_config.json below.

https://huggingface.co/mlabonne/NeuralBeagle14-7B/blob/main/tokenizer_config.json

however the gguf metadata doesn't include this token

image

using the chat_format alone without the eos_token causes generation to continue incorrectly past the end of the assistant respone.

image

Possible Implementation

I'm not too familiar with the gguf-py package but I think adding these to the SpecialVocab class and updating the _try_load_from_tokenizer_json would be a start. Not sure what the correct gguf key should be for these so as to not create confusion.

貢獻者指南